diff --git a/contracts/protocol/AddressResolver.sol b/contracts/evmx/AddressResolver.sol similarity index 99% rename from contracts/protocol/AddressResolver.sol rename to contracts/evmx/AddressResolver.sol index e6d0a401..35e9dca9 100644 --- a/contracts/protocol/AddressResolver.sol +++ b/contracts/evmx/AddressResolver.sol @@ -5,7 +5,7 @@ import {Ownable} from "solady/auth/Ownable.sol"; import {LibClone} from "solady/utils/LibClone.sol"; import {UpgradeableBeacon} from "solady/utils/UpgradeableBeacon.sol"; import {Initializable} from "solady/utils/Initializable.sol"; -import "../interfaces/IAddressResolver.sol"; +import "./interfaces/IAddressResolver.sol"; import {Forwarder} from "./Forwarder.sol"; import {AsyncPromise} from "./AsyncPromise.sol"; diff --git a/contracts/protocol/utils/AddressResolverUtil.sol b/contracts/evmx/AddressResolverUtil.sol similarity index 93% rename from contracts/protocol/utils/AddressResolverUtil.sol rename to contracts/evmx/AddressResolverUtil.sol index 21f24611..7e08fcc0 100644 --- a/contracts/protocol/utils/AddressResolverUtil.sol +++ b/contracts/evmx/AddressResolverUtil.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import "../../interfaces/IAddressResolver.sol"; -import "../../interfaces/IMiddleware.sol"; -import "../../interfaces/IWatcherPrecompile.sol"; -import "../../interfaces/IWatcherPrecompileConfig.sol"; -import "../../interfaces/IWatcherPrecompileLimits.sol"; -import "../../interfaces/IFeesManager.sol"; +import "./interfaces/IAddressResolver.sol"; +import "./interfaces/IMiddleware.sol"; +import "./interfaces/IWatcherPrecompile.sol"; +import "./interfaces/IWatcherPrecompileConfig.sol"; +import "./interfaces/IWatcherPrecompileLimits.sol"; +import "./interfaces/IFeesManager.sol"; /// @title AddressResolverUtil /// @notice Utility contract for resolving system contract addresses diff --git a/contracts/protocol/AsyncPromise.sol b/contracts/evmx/AsyncPromise.sol similarity index 94% rename from contracts/protocol/AsyncPromise.sol rename to contracts/evmx/AsyncPromise.sol index 261c9d56..0f8f48ae 100644 --- a/contracts/protocol/AsyncPromise.sol +++ b/contracts/evmx/AsyncPromise.sol @@ -1,13 +1,13 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import {AddressResolverUtil} from "./utils/AddressResolverUtil.sol"; -import {IPromise} from "../interfaces/IPromise.sol"; -import {IAppGateway} from "../interfaces/IAppGateway.sol"; import {Initializable} from "solady/utils/Initializable.sol"; -import {AsyncPromiseState} from "./utils/common/Structs.sol"; -import {MAX_COPY_BYTES} from "./utils/common/Constants.sol"; import {LibCall} from "solady/utils/LibCall.sol"; +import {IPromise} from "./interfaces/IPromise.sol"; +import {IAppGateway} from "./interfaces/IAppGateway.sol"; +import {AddressResolverUtil} from "./AddressResolverUtil.sol"; +import {AsyncPromiseState} from "../utils/common/Structs.sol"; +import {MAX_COPY_BYTES} from "../utils/common/Constants.sol"; abstract contract AsyncPromiseStorage is IPromise { // slots [0-49] reserved for gap diff --git a/contracts/protocol/Forwarder.sol b/contracts/evmx/Forwarder.sol similarity index 93% rename from contracts/protocol/Forwarder.sol rename to contracts/evmx/Forwarder.sol index 17bb2b6d..f6d214c2 100644 --- a/contracts/protocol/Forwarder.sol +++ b/contracts/evmx/Forwarder.sol @@ -1,13 +1,13 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import "../interfaces/IAddressResolver.sol"; -import "../interfaces/IMiddleware.sol"; -import "../interfaces/IAppGateway.sol"; -import "../interfaces/IPromise.sol"; -import "../interfaces/IForwarder.sol"; -import {AddressResolverUtil} from "./utils/AddressResolverUtil.sol"; -import {AsyncModifierNotUsed, NoAsyncPromiseFound, PromiseCallerMismatch, RequestCountMismatch, DeliveryHelperNotSet} from "./utils/common/Errors.sol"; +import "./interfaces/IAddressResolver.sol"; +import "./interfaces/IMiddleware.sol"; +import "./interfaces/IAppGateway.sol"; +import "./interfaces/IPromise.sol"; +import "./interfaces/IForwarder.sol"; +import {AddressResolverUtil} from "./AddressResolverUtil.sol"; +import {AsyncModifierNotUsed, NoAsyncPromiseFound, PromiseCallerMismatch, RequestCountMismatch, DeliveryHelperNotSet} from "../utils/common/Errors.sol"; import "solady/utils/Initializable.sol"; /// @title Forwarder Storage diff --git a/contracts/base/AppGatewayBase.sol b/contracts/evmx/base/AppGatewayBase.sol similarity index 99% rename from contracts/base/AppGatewayBase.sol rename to contracts/evmx/base/AppGatewayBase.sol index f1a936f4..1c8af3a6 100644 --- a/contracts/base/AppGatewayBase.sol +++ b/contracts/evmx/base/AppGatewayBase.sol @@ -1,14 +1,14 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import "../protocol/utils/AddressResolverUtil.sol"; +import "../AddressResolverUtil.sol"; import "../interfaces/IAppGateway.sol"; import "../interfaces/IForwarder.sol"; import "../interfaces/IMiddleware.sol"; import "../interfaces/IPromise.sol"; -import {InvalidPromise, FeesNotSet, AsyncModifierNotUsed} from "../protocol/utils/common/Errors.sol"; -import {FAST} from "../protocol/utils/common/Constants.sol"; +import {InvalidPromise, FeesNotSet, AsyncModifierNotUsed} from "../../utils/common/Errors.sol"; +import {FAST} from "../../utils/common/Constants.sol"; /// @title AppGatewayBase /// @notice Abstract contract for the app gateway diff --git a/contracts/base/ProxyFactory.sol b/contracts/evmx/helpers/ProxyFactory.sol similarity index 100% rename from contracts/base/ProxyFactory.sol rename to contracts/evmx/helpers/ProxyFactory.sol diff --git a/contracts/helpers/TestUSDC.sol b/contracts/evmx/helpers/TestUSDC.sol similarity index 100% rename from contracts/helpers/TestUSDC.sol rename to contracts/evmx/helpers/TestUSDC.sol diff --git a/contracts/interfaces/IAddressResolver.sol b/contracts/evmx/interfaces/IAddressResolver.sol similarity index 100% rename from contracts/interfaces/IAddressResolver.sol rename to contracts/evmx/interfaces/IAddressResolver.sol diff --git a/contracts/interfaces/IAppGateway.sol b/contracts/evmx/interfaces/IAppGateway.sol similarity index 93% rename from contracts/interfaces/IAppGateway.sol rename to contracts/evmx/interfaces/IAppGateway.sol index 886ebec7..7036cd43 100644 --- a/contracts/interfaces/IAppGateway.sol +++ b/contracts/evmx/interfaces/IAppGateway.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import {Read, Parallel, QueuePayloadParams, OverrideParams, CallType, WriteFinality, PayloadParams} from "../protocol/utils/common/Structs.sol"; +import {Read, Parallel, QueuePayloadParams, OverrideParams, WriteFinality, PayloadParams} from "../../utils/common/Structs.sol"; /// @title IAppGateway /// @notice Interface for the app gateway diff --git a/contracts/interfaces/IAuctionManager.sol b/contracts/evmx/interfaces/IAuctionManager.sol similarity index 92% rename from contracts/interfaces/IAuctionManager.sol rename to contracts/evmx/interfaces/IAuctionManager.sol index a67f0200..c741c8e9 100644 --- a/contracts/interfaces/IAuctionManager.sol +++ b/contracts/evmx/interfaces/IAuctionManager.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import {Bid, RequestMetadata, RequestParams} from "../protocol/utils/common/Structs.sol"; +import {Bid, RequestMetadata, RequestParams} from "../../utils/common/Structs.sol"; interface IAuctionManager { /// @notice Bids for an auction diff --git a/contracts/interfaces/IContractFactoryPlug.sol b/contracts/evmx/interfaces/IContractFactoryPlug.sol similarity index 94% rename from contracts/interfaces/IContractFactoryPlug.sol rename to contracts/evmx/interfaces/IContractFactoryPlug.sol index 7a020a6a..4fa5f0fe 100644 --- a/contracts/interfaces/IContractFactoryPlug.sol +++ b/contracts/evmx/interfaces/IContractFactoryPlug.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import {IsPlug} from "../protocol/utils/common/Structs.sol"; +import {IsPlug} from "../../utils/common/Structs.sol"; /// @title IContractFactory /// @notice Interface for contract factory functionality diff --git a/contracts/interfaces/IFeesManager.sol b/contracts/evmx/interfaces/IFeesManager.sol similarity index 96% rename from contracts/interfaces/IFeesManager.sol rename to contracts/evmx/interfaces/IFeesManager.sol index 02701602..d7afdbaf 100644 --- a/contracts/interfaces/IFeesManager.sol +++ b/contracts/evmx/interfaces/IFeesManager.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import {Bid, QueuePayloadParams, PayloadSubmitParams, AppGatewayWhitelistParams} from "../protocol/utils/common/Structs.sol"; +import {Bid, QueuePayloadParams, PayloadSubmitParams, AppGatewayWhitelistParams} from "../../utils/common/Structs.sol"; interface IFeesManager { function blockCredits( diff --git a/contracts/interfaces/IFeesPlug.sol b/contracts/evmx/interfaces/IFeesPlug.sol similarity index 100% rename from contracts/interfaces/IFeesPlug.sol rename to contracts/evmx/interfaces/IFeesPlug.sol diff --git a/contracts/interfaces/IForwarder.sol b/contracts/evmx/interfaces/IForwarder.sol similarity index 100% rename from contracts/interfaces/IForwarder.sol rename to contracts/evmx/interfaces/IForwarder.sol diff --git a/contracts/interfaces/IMiddleware.sol b/contracts/evmx/interfaces/IMiddleware.sol similarity index 98% rename from contracts/interfaces/IMiddleware.sol rename to contracts/evmx/interfaces/IMiddleware.sol index 6bbd5a3d..3fc7d2e2 100644 --- a/contracts/interfaces/IMiddleware.sol +++ b/contracts/evmx/interfaces/IMiddleware.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import {PayloadSubmitParams, QueuePayloadParams, Bid, WriteFinality, BatchParams, CallType, Parallel, IsPlug, RequestMetadata} from "../protocol/utils/common/Structs.sol"; +import {PayloadSubmitParams, QueuePayloadParams, Bid, WriteFinality, BatchParams, CallType, Parallel, IsPlug, RequestMetadata} from "../../utils/common/Structs.sol"; /// @title IMiddleware /// @notice Interface for the Middleware contract diff --git a/contracts/interfaces/IPromise.sol b/contracts/evmx/interfaces/IPromise.sol similarity index 100% rename from contracts/interfaces/IPromise.sol rename to contracts/evmx/interfaces/IPromise.sol diff --git a/contracts/interfaces/IWatcherPrecompile.sol b/contracts/evmx/interfaces/IWatcherPrecompile.sol similarity index 98% rename from contracts/interfaces/IWatcherPrecompile.sol rename to contracts/evmx/interfaces/IWatcherPrecompile.sol index 0262a220..1dd0dabb 100644 --- a/contracts/interfaces/IWatcherPrecompile.sol +++ b/contracts/evmx/interfaces/IWatcherPrecompile.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import {DigestParams, ResolvedPromises, PayloadParams, TriggerParams, PayloadSubmitParams, Bid, RequestParams, RequestMetadata} from "../protocol/utils/common/Structs.sol"; +import {DigestParams, ResolvedPromises, PayloadParams, TriggerParams, PayloadSubmitParams, RequestParams} from "../../utils/common/Structs.sol"; import {IWatcherPrecompileLimits} from "./IWatcherPrecompileLimits.sol"; import {IWatcherPrecompileConfig} from "./IWatcherPrecompileConfig.sol"; diff --git a/contracts/interfaces/IWatcherPrecompileConfig.sol b/contracts/evmx/interfaces/IWatcherPrecompileConfig.sol similarity index 96% rename from contracts/interfaces/IWatcherPrecompileConfig.sol rename to contracts/evmx/interfaces/IWatcherPrecompileConfig.sol index 3cf44e00..fcfc4026 100644 --- a/contracts/interfaces/IWatcherPrecompileConfig.sol +++ b/contracts/evmx/interfaces/IWatcherPrecompileConfig.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import {AppGatewayConfig, PlugConfig} from "../protocol/utils/common/Structs.sol"; +import {AppGatewayConfig, PlugConfig} from "../../utils/common/Structs.sol"; /// @title IWatcherPrecompileConfig /// @notice Interface for the Watcher Precompile system that handles payload verification and execution @@ -59,4 +59,5 @@ interface IWatcherPrecompileConfig { uint256 signatureNonce_, bytes calldata signature_ ) external; + } diff --git a/contracts/evmx/interfaces/IWatcherPrecompileLimits.sol b/contracts/evmx/interfaces/IWatcherPrecompileLimits.sol new file mode 100644 index 00000000..d71447b0 --- /dev/null +++ b/contracts/evmx/interfaces/IWatcherPrecompileLimits.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-3.0-only +pragma solidity ^0.8.21; + +import {LimitParams, UpdateLimitParams} from "../../utils/common/Structs.sol"; + +/// @title IWatcherPrecompileLimits +/// @notice Interface for the Watcher Precompile system that handles payload verification and execution +/// @dev Defines core functionality for payload processing and promise resolution +interface IWatcherPrecompileLimits { + function getTotalFeesRequired( + uint256 queryCount_, + uint256 finalizeCount_, + uint256 scheduleCount_, + uint256 callbackCount_ + ) external view returns (uint256); + + function queryFees() external view returns (uint256); + + function finalizeFees() external view returns (uint256); + + function timeoutFees() external view returns (uint256); + + function callBackFees() external view returns (uint256); +} diff --git a/contracts/protocol/payload-delivery/AuctionManager.sol b/contracts/evmx/payload-delivery/AuctionManager.sol similarity index 95% rename from contracts/protocol/payload-delivery/AuctionManager.sol rename to contracts/evmx/payload-delivery/AuctionManager.sol index 40f1d38d..bf625c8b 100644 --- a/contracts/protocol/payload-delivery/AuctionManager.sol +++ b/contracts/evmx/payload-delivery/AuctionManager.sol @@ -3,13 +3,13 @@ pragma solidity ^0.8.21; import {ECDSA} from "solady/utils/ECDSA.sol"; import "solady/utils/Initializable.sol"; -import "../utils/AccessControl.sol"; -import "../../interfaces/IAuctionManager.sol"; -import {IMiddleware} from "../../interfaces/IMiddleware.sol"; -import {IFeesManager} from "../../interfaces/IFeesManager.sol"; -import {AddressResolverUtil} from "../utils/AddressResolverUtil.sol"; -import {AuctionClosed, AuctionAlreadyStarted, BidExceedsMaxFees, LowerBidAlreadyExists, InvalidTransmitter} from "../utils/common/Errors.sol"; -import {TRANSMITTER_ROLE} from "../utils/common/AccessRoles.sol"; +import "../interfaces/IAuctionManager.sol"; +import {IMiddleware} from "../interfaces/IMiddleware.sol"; +import {IFeesManager} from "../interfaces/IFeesManager.sol"; +import "../../utils/AccessControl.sol"; +import {AddressResolverUtil} from "../AddressResolverUtil.sol"; +import {AuctionClosed, AuctionAlreadyStarted, BidExceedsMaxFees, LowerBidAlreadyExists, InvalidTransmitter} from "../../utils/common/Errors.sol"; +import {TRANSMITTER_ROLE} from "../../utils/common/AccessRoles.sol"; /// @title AuctionManagerStorage /// @notice Storage for the AuctionManager contract diff --git a/contracts/protocol/payload-delivery/ContractFactoryPlug.sol b/contracts/evmx/payload-delivery/ContractFactoryPlug.sol similarity index 91% rename from contracts/protocol/payload-delivery/ContractFactoryPlug.sol rename to contracts/evmx/payload-delivery/ContractFactoryPlug.sol index 24518bd6..c3691374 100644 --- a/contracts/protocol/payload-delivery/ContractFactoryPlug.sol +++ b/contracts/evmx/payload-delivery/ContractFactoryPlug.sol @@ -1,14 +1,14 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import "../utils/AccessControl.sol"; -import {RESCUE_ROLE} from "../utils/common/AccessRoles.sol"; -import "../utils/RescueFundsLib.sol"; -import {NotSocket} from "../utils/common/Errors.sol"; -import "../../base/PlugBase.sol"; -import "../../interfaces/IContractFactoryPlug.sol"; import {LibCall} from "solady/utils/LibCall.sol"; -import {MAX_COPY_BYTES} from "../utils/common/Constants.sol"; +import "../../utils/AccessControl.sol"; +import {RESCUE_ROLE} from "../../utils/common/AccessRoles.sol"; +import "../../utils/RescueFundsLib.sol"; +import {NotSocket} from "../../utils/common/Errors.sol"; +import {MAX_COPY_BYTES} from "../../utils/common/Constants.sol"; +import "../interfaces/IContractFactoryPlug.sol"; +import "../../protocol/base/PlugBase.sol"; /// @title ContractFactory /// @notice Abstract contract for deploying contracts diff --git a/contracts/protocol/payload-delivery/FeesManager.sol b/contracts/evmx/payload-delivery/FeesManager.sol similarity index 98% rename from contracts/protocol/payload-delivery/FeesManager.sol rename to contracts/evmx/payload-delivery/FeesManager.sol index 22a6f70b..7f5e5e61 100644 --- a/contracts/protocol/payload-delivery/FeesManager.sol +++ b/contracts/evmx/payload-delivery/FeesManager.sol @@ -4,11 +4,11 @@ pragma solidity ^0.8.21; import {Ownable} from "solady/auth/Ownable.sol"; import "solady/utils/Initializable.sol"; import "solady/utils/ECDSA.sol"; -import {IFeesPlug} from "../../interfaces/IFeesPlug.sol"; -import "../../interfaces/IFeesManager.sol"; -import {AddressResolverUtil} from "../utils/AddressResolverUtil.sol"; -import {NotAuctionManager, InvalidWatcherSignature, NonceUsed} from "../utils/common/Errors.sol"; -import {Bid, CallType, Parallel, WriteFinality, QueuePayloadParams, IsPlug, PayloadSubmitParams, RequestMetadata, UserCredits} from "../utils/common/Structs.sol"; +import {IFeesPlug} from "../interfaces/IFeesPlug.sol"; +import "../interfaces/IFeesManager.sol"; +import {AddressResolverUtil} from "../AddressResolverUtil.sol"; +import {NotAuctionManager, InvalidWatcherSignature, NonceUsed} from "../../utils/common/Errors.sol"; +import {Bid, CallType, Parallel, WriteFinality, QueuePayloadParams, IsPlug, PayloadSubmitParams, RequestMetadata, UserCredits} from "../../utils/common/Structs.sol"; abstract contract FeesManagerStorage is IFeesManager { // slots [0-49] reserved for gap diff --git a/contracts/protocol/payload-delivery/FeesPlug.sol b/contracts/evmx/payload-delivery/FeesPlug.sol similarity index 93% rename from contracts/protocol/payload-delivery/FeesPlug.sol rename to contracts/evmx/payload-delivery/FeesPlug.sol index 4935afa9..8d7fa8a8 100644 --- a/contracts/protocol/payload-delivery/FeesPlug.sol +++ b/contracts/evmx/payload-delivery/FeesPlug.sol @@ -3,13 +3,13 @@ pragma solidity ^0.8.21; import "solady/utils/SafeTransferLib.sol"; import "solady/tokens/ERC20.sol"; -import "../../base/PlugBase.sol"; -import "../utils/AccessControl.sol"; -import {RESCUE_ROLE} from "../utils/common/AccessRoles.sol"; -import {IFeesPlug} from "../../interfaces/IFeesPlug.sol"; -import "../utils/RescueFundsLib.sol"; -import {ETH_ADDRESS} from "../utils/common/Constants.sol"; -import {InvalidTokenAddress, FeesAlreadyPaid} from "../utils/common/Errors.sol"; +import "../../protocol/base/PlugBase.sol"; +import "../../utils/AccessControl.sol"; +import {RESCUE_ROLE} from "../../utils/common/AccessRoles.sol"; +import {IFeesPlug} from "../interfaces/IFeesPlug.sol"; +import "../../utils/RescueFundsLib.sol"; +import {ETH_ADDRESS} from "../../utils/common/Constants.sol"; +import {InvalidTokenAddress, FeesAlreadyPaid} from "../../utils/common/Errors.sol"; /// @title FeesManager /// @notice Contract for managing fees on a network @@ -125,6 +125,7 @@ contract FeesPlug is IFeesPlug, PlugBase, AccessControl { ) external onlyOwner { _connectSocket(appGatewayId_, socket_, switchboard_); } + /** * @notice Rescues funds from the contract if they are locked by mistake. This contract does not * theoretically need this function but it is added for safety. diff --git a/contracts/protocol/payload-delivery/app-gateway/DeliveryHelper.sol b/contracts/evmx/payload-delivery/app-gateway/DeliveryHelper.sol similarity index 100% rename from contracts/protocol/payload-delivery/app-gateway/DeliveryHelper.sol rename to contracts/evmx/payload-delivery/app-gateway/DeliveryHelper.sol diff --git a/contracts/protocol/payload-delivery/app-gateway/DeliveryHelperStorage.sol b/contracts/evmx/payload-delivery/app-gateway/DeliveryHelperStorage.sol similarity index 70% rename from contracts/protocol/payload-delivery/app-gateway/DeliveryHelperStorage.sol rename to contracts/evmx/payload-delivery/app-gateway/DeliveryHelperStorage.sol index 73c89be1..f6fbcc15 100644 --- a/contracts/protocol/payload-delivery/app-gateway/DeliveryHelperStorage.sol +++ b/contracts/evmx/payload-delivery/app-gateway/DeliveryHelperStorage.sol @@ -1,15 +1,15 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import "../../../interfaces/IMiddleware.sol"; -import {IAddressResolver} from "../../../interfaces/IAddressResolver.sol"; -import {IContractFactoryPlug} from "../../../interfaces/IContractFactoryPlug.sol"; -import {IAppGateway} from "../../../interfaces/IAppGateway.sol"; -import {IAuctionManager} from "../../../interfaces/IAuctionManager.sol"; -import {IFeesManager} from "../../../interfaces/IFeesManager.sol"; - -import {NotAuctionManager, InvalidTransmitter, InvalidIndex} from "../../utils/common/Errors.sol"; -import {DEPLOY, PAYLOAD_SIZE_LIMIT, REQUEST_PAYLOAD_COUNT_LIMIT} from "../../utils/common/Constants.sol"; +import "../../interfaces/IMiddleware.sol"; +import {IAddressResolver} from "../../interfaces/IAddressResolver.sol"; +import {IContractFactoryPlug} from "../../interfaces/IContractFactoryPlug.sol"; +import {IAppGateway} from "../../interfaces/IAppGateway.sol"; +import {IAuctionManager} from "../../interfaces/IAuctionManager.sol"; +import {IFeesManager} from "../../interfaces/IFeesManager.sol"; + +import {NotAuctionManager, InvalidTransmitter, InvalidIndex} from "../../../utils/common/Errors.sol"; +import {DEPLOY, PAYLOAD_SIZE_LIMIT, REQUEST_PAYLOAD_COUNT_LIMIT} from "../../../utils/common/Constants.sol"; /// @title DeliveryHelperStorage /// @notice Storage contract for DeliveryHelper diff --git a/contracts/protocol/payload-delivery/app-gateway/DeliveryUtils.sol b/contracts/evmx/payload-delivery/app-gateway/DeliveryUtils.sol similarity index 97% rename from contracts/protocol/payload-delivery/app-gateway/DeliveryUtils.sol rename to contracts/evmx/payload-delivery/app-gateway/DeliveryUtils.sol index 38fcecc9..14dc88bb 100644 --- a/contracts/protocol/payload-delivery/app-gateway/DeliveryUtils.sol +++ b/contracts/evmx/payload-delivery/app-gateway/DeliveryUtils.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.21; import "solady/utils/Initializable.sol"; import {Ownable} from "solady/auth/Ownable.sol"; -import {AddressResolverUtil} from "../../utils/AddressResolverUtil.sol"; +import {AddressResolverUtil} from "../../AddressResolverUtil.sol"; import "./DeliveryHelperStorage.sol"; /// @notice Abstract contract for managing asynchronous payloads diff --git a/contracts/protocol/payload-delivery/app-gateway/FeesHelpers.sol b/contracts/evmx/payload-delivery/app-gateway/FeesHelpers.sol similarity index 100% rename from contracts/protocol/payload-delivery/app-gateway/FeesHelpers.sol rename to contracts/evmx/payload-delivery/app-gateway/FeesHelpers.sol diff --git a/contracts/protocol/payload-delivery/app-gateway/RequestQueue.sol b/contracts/evmx/payload-delivery/app-gateway/RequestQueue.sol similarity index 100% rename from contracts/protocol/payload-delivery/app-gateway/RequestQueue.sol rename to contracts/evmx/payload-delivery/app-gateway/RequestQueue.sol diff --git a/contracts/protocol/watcherPrecompile/PayloadHeaderDecoder.sol b/contracts/evmx/watcherPrecompile/PayloadHeaderDecoder.sol similarity index 98% rename from contracts/protocol/watcherPrecompile/PayloadHeaderDecoder.sol rename to contracts/evmx/watcherPrecompile/PayloadHeaderDecoder.sol index a7f17356..22879a1c 100644 --- a/contracts/protocol/watcherPrecompile/PayloadHeaderDecoder.sol +++ b/contracts/evmx/watcherPrecompile/PayloadHeaderDecoder.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import {CallType, Parallel, WriteFinality} from "../utils/common/Structs.sol"; +import {CallType, Parallel, WriteFinality} from "../../utils/common/Structs.sol"; library PayloadHeaderDecoder { // Corrected mapping (most significant bits on the left): diff --git a/contracts/protocol/watcherPrecompile/WatcherPrecompileConfig.sol b/contracts/evmx/watcherPrecompile/WatcherPrecompileConfig.sol similarity index 97% rename from contracts/protocol/watcherPrecompile/WatcherPrecompileConfig.sol rename to contracts/evmx/watcherPrecompile/WatcherPrecompileConfig.sol index 81083086..b0a3984f 100644 --- a/contracts/protocol/watcherPrecompile/WatcherPrecompileConfig.sol +++ b/contracts/evmx/watcherPrecompile/WatcherPrecompileConfig.sol @@ -4,9 +4,9 @@ pragma solidity ^0.8.21; import "solady/utils/Initializable.sol"; import {ECDSA} from "solady/utils/ECDSA.sol"; import {Ownable} from "solady/auth/Ownable.sol"; -import "../../interfaces/IWatcherPrecompileConfig.sol"; -import {AddressResolverUtil} from "../utils/AddressResolverUtil.sol"; -import {InvalidWatcherSignature, NonceUsed} from "../utils/common/Errors.sol"; +import "../interfaces/IWatcherPrecompileConfig.sol"; +import {AddressResolverUtil} from "../AddressResolverUtil.sol"; +import {InvalidWatcherSignature, NonceUsed} from "../../utils/common/Errors.sol"; import "./core/WatcherIdUtils.sol"; /// @title WatcherPrecompileConfig diff --git a/contracts/evmx/watcherPrecompile/WatcherPrecompileLimits.sol b/contracts/evmx/watcherPrecompile/WatcherPrecompileLimits.sol new file mode 100644 index 00000000..850feb16 --- /dev/null +++ b/contracts/evmx/watcherPrecompile/WatcherPrecompileLimits.sol @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-3.0-only +pragma solidity ^0.8.21; + +import "solady/utils/Initializable.sol"; +import {Ownable} from "solady/auth/Ownable.sol"; +import {AddressResolverUtil} from "../AddressResolverUtil.sol"; +import "../interfaces/IWatcherPrecompileLimits.sol"; +import {SCHEDULE, QUERY, FINALIZE, CALLBACK} from "../../utils/common/Constants.sol"; + +/// @title WatcherPrecompileLimits +/// @notice Contract for managing watcher precompile limits +contract WatcherPrecompileLimits is + IWatcherPrecompileLimits, + Initializable, + Ownable, + AddressResolverUtil +{ + // slots 0-49 (50) reserved for gauge + // slots 50-100 (51) reserved for addr resolver util + + // slots [101-150]: gap for future storage variables + uint256[50] _gap_before; + + // slot 157: fees + uint256 public queryFees; + uint256 public finalizeFees; + uint256 public timeoutFees; + uint256 public callBackFees; + + /// @notice Emitted when the query fees are set + event QueryFeesSet(uint256 queryFees); + /// @notice Emitted when the finalize fees are set + event FinalizeFeesSet(uint256 finalizeFees); + /// @notice Emitted when the timeout fees are set + event TimeoutFeesSet(uint256 timeoutFees); + /// @notice Emitted when the call back fees are set + event CallBackFeesSet(uint256 callBackFees); + + error WatcherFeesNotSet(bytes32 limitType); + + /// @notice Initial initialization (version 1) + function initialize(address owner_, address addressResolver_, uint256) public reinitializer(1) { + _setAddressResolver(addressResolver_); + _initializeOwner(owner_); + } + + function setQueryFees(uint256 queryFees_) external onlyOwner { + queryFees = queryFees_; + emit QueryFeesSet(queryFees_); + } + + function setFinalizeFees(uint256 finalizeFees_) external onlyOwner { + finalizeFees = finalizeFees_; + emit FinalizeFeesSet(finalizeFees_); + } + + function setTimeoutFees(uint256 timeoutFees_) external onlyOwner { + timeoutFees = timeoutFees_; + emit TimeoutFeesSet(timeoutFees_); + } + + function setCallBackFees(uint256 callBackFees_) external onlyOwner { + callBackFees = callBackFees_; + emit CallBackFeesSet(callBackFees_); + } + + function getTotalFeesRequired( + uint256 queryCount_, + uint256 finalizeCount_, + uint256 scheduleCount_, + uint256 callbackCount_ + ) external view returns (uint256) { + uint256 totalFees = 0; + totalFees += callbackCount_ * callBackFees; + totalFees += queryCount_ * queryFees; + totalFees += finalizeCount_ * finalizeFees; + totalFees += scheduleCount_ * timeoutFees; + + return totalFees; + } +} diff --git a/contracts/protocol/watcherPrecompile/core/RequestHandler.sol b/contracts/evmx/watcherPrecompile/core/RequestHandler.sol similarity index 100% rename from contracts/protocol/watcherPrecompile/core/RequestHandler.sol rename to contracts/evmx/watcherPrecompile/core/RequestHandler.sol diff --git a/contracts/protocol/watcherPrecompile/core/WatcherIdUtils.sol b/contracts/evmx/watcherPrecompile/core/WatcherIdUtils.sol similarity index 100% rename from contracts/protocol/watcherPrecompile/core/WatcherIdUtils.sol rename to contracts/evmx/watcherPrecompile/core/WatcherIdUtils.sol diff --git a/contracts/protocol/watcherPrecompile/core/WatcherPrecompile.sol b/contracts/evmx/watcherPrecompile/core/WatcherPrecompile.sol similarity index 100% rename from contracts/protocol/watcherPrecompile/core/WatcherPrecompile.sol rename to contracts/evmx/watcherPrecompile/core/WatcherPrecompile.sol diff --git a/contracts/protocol/watcherPrecompile/core/WatcherPrecompileCore.sol b/contracts/evmx/watcherPrecompile/core/WatcherPrecompileCore.sol similarity index 98% rename from contracts/protocol/watcherPrecompile/core/WatcherPrecompileCore.sol rename to contracts/evmx/watcherPrecompile/core/WatcherPrecompileCore.sol index 85fc60f7..9da6d736 100644 --- a/contracts/protocol/watcherPrecompile/core/WatcherPrecompileCore.sol +++ b/contracts/evmx/watcherPrecompile/core/WatcherPrecompileCore.sol @@ -1,14 +1,14 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import "./WatcherPrecompileStorage.sol"; import {ECDSA} from "solady/utils/ECDSA.sol"; import {Ownable} from "solady/auth/Ownable.sol"; import "solady/utils/Initializable.sol"; -import {AddressResolverUtil} from "../../utils/AddressResolverUtil.sol"; -import {IFeesManager} from "../../../interfaces/IFeesManager.sol"; +import {AddressResolverUtil} from "../../AddressResolverUtil.sol"; +import {IFeesManager} from "../../interfaces/IFeesManager.sol"; import "./WatcherIdUtils.sol"; +import "./WatcherPrecompileStorage.sol"; /// @title WatcherPrecompileCore /// @notice Core functionality for the WatcherPrecompile system diff --git a/contracts/protocol/watcherPrecompile/core/WatcherPrecompileStorage.sol b/contracts/evmx/watcherPrecompile/core/WatcherPrecompileStorage.sol similarity index 88% rename from contracts/protocol/watcherPrecompile/core/WatcherPrecompileStorage.sol rename to contracts/evmx/watcherPrecompile/core/WatcherPrecompileStorage.sol index d90706f9..2ef880e3 100644 --- a/contracts/protocol/watcherPrecompile/core/WatcherPrecompileStorage.sol +++ b/contracts/evmx/watcherPrecompile/core/WatcherPrecompileStorage.sol @@ -1,15 +1,14 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import "../../../interfaces/IWatcherPrecompile.sol"; -import {IAppGateway} from "../../../interfaces/IAppGateway.sol"; -import {IPromise} from "../../../interfaces/IPromise.sol"; import "../PayloadHeaderDecoder.sol"; - -import {IMiddleware} from "../../../interfaces/IMiddleware.sol"; -import {QUERY, FINALIZE, SCHEDULE, MAX_COPY_BYTES} from "../../utils/common/Constants.sol"; -import {InvalidCallerTriggered, TimeoutDelayTooLarge, TimeoutAlreadyResolved, InvalidInboxCaller, ResolvingTimeoutTooEarly, CallFailed, AppGatewayAlreadyCalled, InvalidWatcherSignature, NonceUsed, RequestAlreadyExecuted} from "../../utils/common/Errors.sol"; -import {ResolvedPromises, AppGatewayConfig, LimitParams, WriteFinality, UpdateLimitParams, PlugConfig, DigestParams, TimeoutRequest, QueuePayloadParams, PayloadParams, RequestParams} from "../../utils/common/Structs.sol"; +import "../../interfaces/IWatcherPrecompile.sol"; +import {IAppGateway} from "../../interfaces/IAppGateway.sol"; +import {IPromise} from "../../interfaces/IPromise.sol"; +import {IMiddleware} from "../../interfaces/IMiddleware.sol"; +import {QUERY, FINALIZE, SCHEDULE, MAX_COPY_BYTES} from "../../../utils/common/Constants.sol"; +import {InvalidCallerTriggered, TimeoutDelayTooLarge, TimeoutAlreadyResolved, InvalidInboxCaller, ResolvingTimeoutTooEarly, CallFailed, AppGatewayAlreadyCalled, InvalidWatcherSignature, NonceUsed, RequestAlreadyExecuted} from "../../../utils/common/Errors.sol"; +import {ResolvedPromises, AppGatewayConfig, LimitParams, WriteFinality, UpdateLimitParams, PlugConfig, DigestParams, TimeoutRequest, QueuePayloadParams, PayloadParams, RequestParams, RequestMetadata} from "../../../utils/common/Structs.sol"; /// @title WatcherPrecompileStorage /// @notice Storage contract for the WatcherPrecompile system diff --git a/contracts/interfaces/IWatcherPrecompileLimits.sol b/contracts/interfaces/IWatcherPrecompileLimits.sol deleted file mode 100644 index 02899a72..00000000 --- a/contracts/interfaces/IWatcherPrecompileLimits.sol +++ /dev/null @@ -1,68 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-only -pragma solidity ^0.8.21; - -import {LimitParams, UpdateLimitParams} from "../protocol/utils/common/Structs.sol"; - -/// @title IWatcherPrecompileLimits -/// @notice Interface for the Watcher Precompile system that handles payload verification and execution -/// @dev Defines core functionality for payload processing and promise resolution -interface IWatcherPrecompileLimits { - /// @notice Get the current limit for a specific app gateway and limit type - /// @param limitType_ The type of limit to query - /// @param appGateway_ The app gateway address - /// @return The current limit value - function getCurrentLimit( - bytes32 limitType_, - address appGateway_ - ) external view returns (uint256); - - /// @notice Get the limit parameters for a specific app gateway and limit type - /// @param limitType_ The type of limit to query - /// @param appGateway_ The app gateway address - /// @return The limit parameters - function getLimitParams( - bytes32 limitType_, - address appGateway_ - ) external view returns (LimitParams memory); - - /// @notice Update limit parameters for multiple app gateways - /// @param updates_ Array of limit parameter updates - function updateLimitParams(UpdateLimitParams[] calldata updates_) external; - - /// @notice Set the default limit value - /// @param defaultLimit_ The new default limit value - function setDefaultLimitAndRatePerSecond(uint256 defaultLimit_) external; - - /// @notice Number of decimals used in limit calculations - function limitDecimals() external view returns (uint256); - - /// @notice Default limit value for any app gateway - function defaultLimit() external view returns (uint256); - - /// @notice Rate at which limit replenishes per second - function defaultRatePerSecond() external view returns (uint256); - - /// @notice Consumes a limit for an app gateway - /// @param appGateway_ The app gateway address - /// @param limitType_ The type of limit to consume - /// @param consumeLimit_ The amount of limit to consume - function consumeLimit(address appGateway_, bytes32 limitType_, uint256 consumeLimit_) external; - - function getTotalFeesRequired( - uint256 queryCount_, - uint256 finalizeCount_, - uint256 scheduleCount_, - uint256 callbackCount_ - ) external view returns (uint256); - - function queryFees() external view returns (uint256); - function finalizeFees() external view returns (uint256); - function timeoutFees() external view returns (uint256); - function callBackFees() external view returns (uint256); - - /// @notice Emitted when limit parameters are updated - event LimitParamsUpdated(UpdateLimitParams[] updates); - - /// @notice Emitted when an app gateway is activated with default limits - event AppGatewayActivated(address indexed appGateway, uint256 maxLimit, uint256 ratePerSecond); -} diff --git a/contracts/protocol/socket/Socket.sol b/contracts/protocol/Socket.sol similarity index 100% rename from contracts/protocol/socket/Socket.sol rename to contracts/protocol/Socket.sol diff --git a/contracts/protocol/socket/SocketBatcher.sol b/contracts/protocol/SocketBatcher.sol similarity index 90% rename from contracts/protocol/socket/SocketBatcher.sol rename to contracts/protocol/SocketBatcher.sol index d996a722..e8313f08 100644 --- a/contracts/protocol/socket/SocketBatcher.sol +++ b/contracts/protocol/SocketBatcher.sol @@ -2,11 +2,11 @@ pragma solidity ^0.8.21; import "solady/auth/Ownable.sol"; -import "../../interfaces/ISocket.sol"; -import "../../interfaces/ISwitchboard.sol"; +import "./interfaces/ISocket.sol"; +import "./interfaces/ISocketBatcher.sol"; +import "./interfaces/ISwitchboard.sol"; import "../utils/RescueFundsLib.sol"; -import {ExecuteParams, TransmissionParams} from "../../protocol/utils/common/Structs.sol"; -import "../../interfaces/ISocketBatcher.sol"; +import {ExecuteParams, TransmissionParams} from "../utils/common/Structs.sol"; /** * @title SocketBatcher diff --git a/contracts/protocol/socket/SocketConfig.sol b/contracts/protocol/SocketConfig.sol similarity index 96% rename from contracts/protocol/socket/SocketConfig.sol rename to contracts/protocol/SocketConfig.sol index 96aebd12..e3fb0194 100644 --- a/contracts/protocol/socket/SocketConfig.sol +++ b/contracts/protocol/SocketConfig.sol @@ -1,15 +1,14 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import "../../interfaces/ISocket.sol"; -import "../../interfaces/ISwitchboard.sol"; -import {IPlug} from "../../interfaces/IPlug.sol"; - +import "./interfaces/ISocket.sol"; +import "./interfaces/ISwitchboard.sol"; +import {IPlug} from "./interfaces/IPlug.sol"; +import "./interfaces/ISocketFeeManager.sol"; import "../utils/AccessControl.sol"; import {GOVERNANCE_ROLE, RESCUE_ROLE, SWITCHBOARD_DISABLER_ROLE} from "../utils/common/AccessRoles.sol"; import {CallType, PlugConfig, SwitchboardStatus, ExecutionStatus} from "../utils/common/Structs.sol"; import {PlugNotFound, InvalidAppGateway, InvalidTransmitter} from "../utils/common/Errors.sol"; -import "../../interfaces/ISocketFeeManager.sol"; import {MAX_COPY_BYTES} from "../utils/common/Constants.sol"; /** diff --git a/contracts/protocol/socket/SocketFeeManager.sol b/contracts/protocol/SocketFeeManager.sol similarity index 94% rename from contracts/protocol/socket/SocketFeeManager.sol rename to contracts/protocol/SocketFeeManager.sol index 1bfb66f4..3e3bfa8e 100644 --- a/contracts/protocol/socket/SocketFeeManager.sol +++ b/contracts/protocol/SocketFeeManager.sol @@ -3,8 +3,8 @@ pragma solidity ^0.8.21; import "../utils/AccessControl.sol"; import {GOVERNANCE_ROLE, RESCUE_ROLE} from "../utils/common/AccessRoles.sol"; -import {ExecuteParams, TransmissionParams} from "../../protocol/utils/common/Structs.sol"; -import "../../interfaces/ISocketFeeManager.sol"; +import {ExecuteParams, TransmissionParams} from "../utils/common/Structs.sol"; +import "./interfaces/ISocketFeeManager.sol"; import "../utils/RescueFundsLib.sol"; /** diff --git a/contracts/protocol/socket/SocketUtils.sol b/contracts/protocol/SocketUtils.sol similarity index 100% rename from contracts/protocol/socket/SocketUtils.sol rename to contracts/protocol/SocketUtils.sol diff --git a/contracts/base/PlugBase.sol b/contracts/protocol/base/PlugBase.sol similarity index 97% rename from contracts/base/PlugBase.sol rename to contracts/protocol/base/PlugBase.sol index 1ef146bc..21d22417 100644 --- a/contracts/base/PlugBase.sol +++ b/contracts/protocol/base/PlugBase.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.21; import {ISocket} from "../interfaces/ISocket.sol"; import {IPlug} from "../interfaces/IPlug.sol"; -import {NotSocket} from "../protocol/utils/common/Errors.sol"; +import {NotSocket} from "../../utils/common/Errors.sol"; /// @title PlugBase /// @notice Abstract contract for plugs diff --git a/contracts/interfaces/IPlug.sol b/contracts/protocol/interfaces/IPlug.sol similarity index 100% rename from contracts/interfaces/IPlug.sol rename to contracts/protocol/interfaces/IPlug.sol diff --git a/contracts/interfaces/ISocket.sol b/contracts/protocol/interfaces/ISocket.sol similarity index 96% rename from contracts/interfaces/ISocket.sol rename to contracts/protocol/interfaces/ISocket.sol index dc5b999e..80a8a25a 100644 --- a/contracts/interfaces/ISocket.sol +++ b/contracts/protocol/interfaces/ISocket.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import {ExecuteParams, TransmissionParams} from "../protocol/utils/common/Structs.sol"; +import {ExecuteParams, TransmissionParams} from "../../utils/common/Structs.sol"; /** * @title ISocket diff --git a/contracts/interfaces/ISocketBatcher.sol b/contracts/protocol/interfaces/ISocketBatcher.sol similarity index 92% rename from contracts/interfaces/ISocketBatcher.sol rename to contracts/protocol/interfaces/ISocketBatcher.sol index b8cb2270..dfd146ac 100644 --- a/contracts/interfaces/ISocketBatcher.sol +++ b/contracts/protocol/interfaces/ISocketBatcher.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import {ExecuteParams} from "../protocol/utils/common/Structs.sol"; +import {ExecuteParams} from "../../utils/common/Structs.sol"; /** * @title ISocketBatcher diff --git a/contracts/interfaces/ISocketFeeManager.sol b/contracts/protocol/interfaces/ISocketFeeManager.sol similarity index 91% rename from contracts/interfaces/ISocketFeeManager.sol rename to contracts/protocol/interfaces/ISocketFeeManager.sol index 1d7958c0..b1029300 100644 --- a/contracts/interfaces/ISocketFeeManager.sol +++ b/contracts/protocol/interfaces/ISocketFeeManager.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import {ExecuteParams, TransmissionParams} from "../protocol/utils/common/Structs.sol"; +import {ExecuteParams, TransmissionParams} from "../../utils/common/Structs.sol"; interface ISocketFeeManager { /** diff --git a/contracts/interfaces/ISwitchboard.sol b/contracts/protocol/interfaces/ISwitchboard.sol similarity index 100% rename from contracts/interfaces/ISwitchboard.sol rename to contracts/protocol/interfaces/ISwitchboard.sol diff --git a/contracts/protocol/socket/switchboard/FastSwitchboard.sol b/contracts/protocol/switchboard/FastSwitchboard.sol similarity index 100% rename from contracts/protocol/socket/switchboard/FastSwitchboard.sol rename to contracts/protocol/switchboard/FastSwitchboard.sol diff --git a/contracts/protocol/socket/switchboard/SwitchboardBase.sol b/contracts/protocol/switchboard/SwitchboardBase.sol similarity index 96% rename from contracts/protocol/socket/switchboard/SwitchboardBase.sol rename to contracts/protocol/switchboard/SwitchboardBase.sol index 0c99eaac..99e3a607 100644 --- a/contracts/protocol/socket/switchboard/SwitchboardBase.sol +++ b/contracts/protocol/switchboard/SwitchboardBase.sol @@ -2,8 +2,8 @@ pragma solidity ^0.8.21; import {ECDSA} from "solady/utils/ECDSA.sol"; -import "../../../interfaces/ISwitchboard.sol"; -import "../../../interfaces/ISocket.sol"; +import "../interfaces/ISwitchboard.sol"; +import "../interfaces/ISocket.sol"; import "../../utils/AccessControl.sol"; import "../../utils/RescueFundsLib.sol"; import {RESCUE_ROLE} from "../../utils/common/AccessRoles.sol"; diff --git a/contracts/protocol/utils/Gauge.sol b/contracts/protocol/utils/Gauge.sol deleted file mode 100644 index fa2aba78..00000000 --- a/contracts/protocol/utils/Gauge.sol +++ /dev/null @@ -1,47 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-only -pragma solidity ^0.8.21; -import {LimitParams} from "../utils/common/Structs.sol"; -import {LimitReached} from "../utils/common/Errors.sol"; - -abstract contract Gauge { - // slot 0-49: gap for future storage variables - uint256[50] _gap_gauge; - - function _getCurrentLimit(LimitParams storage params_) internal view returns (uint256 _limit) { - uint256 timeElapsed = block.timestamp - params_.lastUpdateTimestamp; - uint256 limitIncrease = timeElapsed * params_.ratePerSecond; - - if (limitIncrease + params_.lastUpdateLimit > params_.maxLimit) { - _limit = params_.maxLimit; - } else { - _limit = limitIncrease + params_.lastUpdateLimit; - } - } - - function _consumePartLimit( - uint256 amount_, - LimitParams storage params_ - ) internal returns (uint256 consumedAmount, uint256 pendingAmount) { - uint256 currentLimit = _getCurrentLimit(params_); - params_.lastUpdateTimestamp = block.timestamp; - if (currentLimit >= amount_) { - params_.lastUpdateLimit = currentLimit - amount_; - consumedAmount = amount_; - pendingAmount = 0; - } else { - params_.lastUpdateLimit = 0; - consumedAmount = currentLimit; - pendingAmount = amount_ - currentLimit; - } - } - - function _consumeFullLimit(uint256 amount_, LimitParams storage params_) internal { - uint256 currentLimit = _getCurrentLimit(params_); - if (currentLimit >= amount_) { - params_.lastUpdateTimestamp = block.timestamp; - params_.lastUpdateLimit = currentLimit - amount_; - } else { - revert LimitReached(); - } - } -} diff --git a/contracts/protocol/watcherPrecompile/WatcherPrecompileLimits.sol b/contracts/protocol/watcherPrecompile/WatcherPrecompileLimits.sol deleted file mode 100644 index 2c01968e..00000000 --- a/contracts/protocol/watcherPrecompile/WatcherPrecompileLimits.sol +++ /dev/null @@ -1,210 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-only -pragma solidity ^0.8.21; - -import "solady/utils/Initializable.sol"; -import {Ownable} from "solady/auth/Ownable.sol"; -import {Gauge} from "../utils/Gauge.sol"; -import {AddressResolverUtil} from "../utils/AddressResolverUtil.sol"; -import "../../interfaces/IWatcherPrecompileLimits.sol"; -import {SCHEDULE, QUERY, FINALIZE, CALLBACK} from "../utils/common/Constants.sol"; - -/// @title WatcherPrecompileLimits -/// @notice Contract for managing watcher precompile limits -contract WatcherPrecompileLimits is - IWatcherPrecompileLimits, - Initializable, - Ownable, - Gauge, - AddressResolverUtil -{ - // slots 0-49 (50) reserved for gauge - // slots 50-100 (51) reserved for addr resolver util - - // slots [101-150]: gap for future storage variables - uint256[50] _gap_before; - - // slot 151: limitDecimals - /// @notice Number of decimals used in limit calculations - uint256 public limitDecimals; - - // slot 152: defaultLimit - /// @notice Default limit value for any app gateway - uint256 public defaultLimit; - - // slot 153: defaultRatePerSecond - /// @notice Rate at which limit replenishes per second - uint256 public defaultRatePerSecond; - - // slot 154: _limitParams - // appGateway => limitType => receivingLimitParams - mapping(address => mapping(bytes32 => LimitParams)) internal _limitParams; - - // slot 155: _activeAppGateways - // Mapping to track active app gateways - mapping(address => bool) internal _activeAppGateways; - - // slot 157: fees - uint256 public queryFees; - uint256 public finalizeFees; - uint256 public timeoutFees; - uint256 public callBackFees; - - /// @notice Emitted when the default limit and rate per second are set - event DefaultLimitAndRatePerSecondSet(uint256 defaultLimit, uint256 defaultRatePerSecond); - /// @notice Emitted when the query fees are set - event QueryFeesSet(uint256 queryFees); - /// @notice Emitted when the finalize fees are set - event FinalizeFeesSet(uint256 finalizeFees); - /// @notice Emitted when the timeout fees are set - event TimeoutFeesSet(uint256 timeoutFees); - /// @notice Emitted when the call back fees are set - event CallBackFeesSet(uint256 callBackFees); - - error WatcherFeesNotSet(bytes32 limitType); - - /// @notice Initial initialization (version 1) - function initialize( - address owner_, - address addressResolver_, - uint256 defaultLimit_ - ) public reinitializer(1) { - _setAddressResolver(addressResolver_); - _initializeOwner(owner_); - limitDecimals = 18; - - // limit per day - defaultLimit = defaultLimit_ * 10 ** limitDecimals; - // limit per second - defaultRatePerSecond = defaultLimit / (24 * 60 * 60); - } - - /** - * @notice Get the current limit for a specific app gateway and limit type - * @param limitType_ The type of limit to query - * @param appGateway_ The app gateway address - * @return The current limit value - */ - function getCurrentLimit( - bytes32 limitType_, - address appGateway_ - ) external view returns (uint256) { - return _getCurrentLimit(_limitParams[appGateway_][limitType_]); - } - - /** - * @notice Get the limit parameters for a specific app gateway and limit type - * @param limitType_ The type of limit to query - * @param appGateway_ The app gateway address - * @return The limit parameters - */ - function getLimitParams( - bytes32 limitType_, - address appGateway_ - ) external view returns (LimitParams memory) { - return _limitParams[appGateway_][limitType_]; - } - - /** - * @notice Update limit parameters for multiple app gateways - * @param updates_ Array of limit parameter updates - */ - function updateLimitParams(UpdateLimitParams[] calldata updates_) external onlyOwner { - _updateLimitParams(updates_); - } - - /** - * @notice Internal function to update limit parameters - * @param updates_ Array of limit parameter updates - */ - function _updateLimitParams(UpdateLimitParams[] calldata updates_) internal { - for (uint256 i = 0; i < updates_.length; i++) { - _consumePartLimit(0, _limitParams[updates_[i].appGateway][updates_[i].limitType]); - _limitParams[updates_[i].appGateway][updates_[i].limitType].maxLimit = updates_[i] - .maxLimit; - _limitParams[updates_[i].appGateway][updates_[i].limitType].ratePerSecond = updates_[i] - .ratePerSecond; - } - - emit LimitParamsUpdated(updates_); - } - - /** - * @notice Internal function to consume limit based on caller - * @param appGateway_ The app gateway address - * @param limitType_ The type of limit to consume - * @param consumeLimit_ The amount of limit to consume - */ - function consumeLimit( - address appGateway_, - bytes32 limitType_, - uint256 consumeLimit_ - ) external override onlyWatcherPrecompile { - LimitParams storage limitParams = _limitParams[appGateway_][limitType_]; - - // Initialize limit if not active, give default limit and rate per second - if (!_activeAppGateways[appGateway_]) { - LimitParams memory limitParam = LimitParams({ - maxLimit: defaultLimit, - ratePerSecond: defaultRatePerSecond, - lastUpdateTimestamp: block.timestamp, - lastUpdateLimit: defaultLimit - }); - - _limitParams[appGateway_][QUERY] = limitParam; - _limitParams[appGateway_][FINALIZE] = limitParam; - _limitParams[appGateway_][SCHEDULE] = limitParam; - - _activeAppGateways[appGateway_] = true; - emit AppGatewayActivated(appGateway_, defaultLimit, defaultRatePerSecond); - } - - // Update the limit - _consumeFullLimit(consumeLimit_ * 10 ** limitDecimals, limitParams); - } - - /** - * @notice Set the default limit value - * @param defaultLimit_ The new default limit value - */ - function setDefaultLimitAndRatePerSecond(uint256 defaultLimit_) external onlyOwner { - defaultLimit = defaultLimit_; - defaultRatePerSecond = defaultLimit / (24 * 60 * 60); - - emit DefaultLimitAndRatePerSecondSet(defaultLimit, defaultRatePerSecond); - } - - function setQueryFees(uint256 queryFees_) external onlyOwner { - queryFees = queryFees_; - emit QueryFeesSet(queryFees_); - } - - function setFinalizeFees(uint256 finalizeFees_) external onlyOwner { - finalizeFees = finalizeFees_; - emit FinalizeFeesSet(finalizeFees_); - } - - function setTimeoutFees(uint256 timeoutFees_) external onlyOwner { - timeoutFees = timeoutFees_; - emit TimeoutFeesSet(timeoutFees_); - } - - function setCallBackFees(uint256 callBackFees_) external onlyOwner { - callBackFees = callBackFees_; - emit CallBackFeesSet(callBackFees_); - } - - function getTotalFeesRequired( - uint256 queryCount_, - uint256 finalizeCount_, - uint256 scheduleCount_, - uint256 callbackCount_ - ) external view returns (uint256) { - uint256 totalFees = 0; - totalFees += callbackCount_ * callBackFees; - totalFees += queryCount_ * queryFees; - totalFees += finalizeCount_ * finalizeFees; - totalFees += scheduleCount_ * timeoutFees; - - return totalFees; - } -} diff --git a/contracts/protocol/utils/AccessControl.sol b/contracts/utils/AccessControl.sol similarity index 100% rename from contracts/protocol/utils/AccessControl.sol rename to contracts/utils/AccessControl.sol diff --git a/contracts/protocol/utils/RescueFundsLib.sol b/contracts/utils/RescueFundsLib.sol similarity index 100% rename from contracts/protocol/utils/RescueFundsLib.sol rename to contracts/utils/RescueFundsLib.sol diff --git a/contracts/protocol/utils/common/AccessRoles.sol b/contracts/utils/common/AccessRoles.sol similarity index 100% rename from contracts/protocol/utils/common/AccessRoles.sol rename to contracts/utils/common/AccessRoles.sol diff --git a/contracts/protocol/utils/common/Constants.sol b/contracts/utils/common/Constants.sol similarity index 100% rename from contracts/protocol/utils/common/Constants.sol rename to contracts/utils/common/Constants.sol diff --git a/contracts/protocol/utils/common/Errors.sol b/contracts/utils/common/Errors.sol similarity index 100% rename from contracts/protocol/utils/common/Errors.sol rename to contracts/utils/common/Errors.sol diff --git a/contracts/protocol/utils/common/Structs.sol b/contracts/utils/common/Structs.sol similarity index 100% rename from contracts/protocol/utils/common/Structs.sol rename to contracts/utils/common/Structs.sol diff --git a/script/admin/RescueFunds.s.sol b/script/admin/RescueFunds.s.sol index dbd5a3dd..d1268058 100644 --- a/script/admin/RescueFunds.s.sol +++ b/script/admin/RescueFunds.s.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.19; import {Script} from "forge-std/Script.sol"; import {console} from "forge-std/console.sol"; -import {FeesPlug} from "../../contracts/protocol/payload-delivery/FeesPlug.sol"; +import {FeesPlug} from "../../contracts/evmx/payload-delivery/FeesPlug.sol"; contract RescueFundsScript is Script { address constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; diff --git a/script/admin/UpdateAppEVMxLimits.s.sol b/script/admin/UpdateAppEVMxLimits.s.sol deleted file mode 100644 index 4d23d16c..00000000 --- a/script/admin/UpdateAppEVMxLimits.s.sol +++ /dev/null @@ -1,53 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-only -pragma solidity ^0.8.21; - -import "forge-std/Script.sol"; -import {WatcherPrecompile} from "../../contracts/protocol/watcherPrecompile/core/WatcherPrecompile.sol"; -import {UpdateLimitParams} from "../../contracts/protocol/utils/common/Structs.sol"; -import {SCHEDULE, QUERY, FINALIZE} from "../../contracts/protocol/utils/common/Constants.sol"; - -contract UpdateLimitsScript is Script { - function run() external { - string memory rpc = vm.envString("EVMX_RPC"); - vm.createSelectFork(rpc); - - // Load private key from env - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - - // Start broadcast with private key - vm.startBroadcast(deployerPrivateKey); - address watcherPrecompile = vm.envAddress("WATCHER_PRECOMPILE"); - address appGateway = vm.envAddress("APP_GATEWAY"); - - console.log("WatcherPrecompile address:", watcherPrecompile); - console.log("AppGateway address:", appGateway); - WatcherPrecompile watcherContract = WatcherPrecompile(watcherPrecompile); - - // Create update params array - UpdateLimitParams[] memory updates = new UpdateLimitParams[](3); - - // Example update - modify these values as needed - updates[0] = UpdateLimitParams({ - limitType: SCHEDULE, // Example limit type - appGateway: appGateway, // Replace with actual app gateway address - maxLimit: 10000000000, // Maximum limit - ratePerSecond: 10000000000 // Rate per second - }); - updates[1] = UpdateLimitParams({ - limitType: QUERY, // Example limit type - appGateway: appGateway, // Replace with actual app gateway address - maxLimit: 10000000000, // Maximum limit - ratePerSecond: 10000000000 // Rate per second - }); - updates[2] = UpdateLimitParams({ - limitType: FINALIZE, // Example limit type - appGateway: appGateway, // Replace with actual app gateway address - maxLimit: 10000000000, // Maximum limit - ratePerSecond: 10000000000 // Rate per second - }); - // // Update the limits - watcherContract.watcherPrecompileLimits__().updateLimitParams(updates); - - vm.stopBroadcast(); - } -} diff --git a/script/counter/DeployEVMxCounterApp.s.sol b/script/counter/DeployEVMxCounterApp.s.sol index 42c09af7..79c916c8 100644 --- a/script/counter/DeployEVMxCounterApp.s.sol +++ b/script/counter/DeployEVMxCounterApp.s.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.21; import {Script} from "forge-std/Script.sol"; import {console} from "forge-std/console.sol"; import {CounterAppGateway} from "../../test/apps/app-gateways/counter/CounterAppGateway.sol"; -import {ETH_ADDRESS} from "../../contracts/protocol/utils/common/Constants.sol"; +import {ETH_ADDRESS} from "../../contracts/utils/common/Constants.sol"; // source .env && forge script script/counter/deployEVMxCounterApp.s.sol --broadcast --skip-simulation --legacy --gas-price 0 contract CounterDeploy is Script { diff --git a/script/counter/DeployOnchainCounters.s.sol b/script/counter/DeployOnchainCounters.s.sol index 531e2b95..3edb7b78 100644 --- a/script/counter/DeployOnchainCounters.s.sol +++ b/script/counter/DeployOnchainCounters.s.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.21; import {Script} from "forge-std/Script.sol"; import {console} from "forge-std/console.sol"; -import {ETH_ADDRESS} from "../../contracts/protocol/utils/common/Constants.sol"; +import {ETH_ADDRESS} from "../../contracts/utils/common/Constants.sol"; import {CounterAppGateway} from "../../test/apps/app-gateways/counter/CounterAppGateway.sol"; // source .env && forge script script/counter/DeployCounterOnchain.s.sol --broadcast --skip-simulation --legacy --gas-price 0 diff --git a/script/counter/SetFees.s.sol b/script/counter/SetFees.s.sol index 3f87f4ac..b365f64b 100644 --- a/script/counter/SetFees.s.sol +++ b/script/counter/SetFees.s.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.21; import {Script} from "forge-std/Script.sol"; import {console} from "forge-std/console.sol"; -import {ETH_ADDRESS} from "../../contracts/protocol/utils/common/Constants.sol"; +import {ETH_ADDRESS} from "../../contracts/utils/common/Constants.sol"; import {CounterAppGateway} from "../../test/apps/app-gateways/counter/CounterAppGateway.sol"; // source .env && forge script script/counter/DeployCounterOnchain.s.sol --broadcast --skip-simulation --legacy --gas-price 0 diff --git a/script/counter/WithdrawFeesArbitrumFeesPlug.s.sol b/script/counter/WithdrawFeesArbitrumFeesPlug.s.sol index ecd8b2b6..57ad117e 100644 --- a/script/counter/WithdrawFeesArbitrumFeesPlug.s.sol +++ b/script/counter/WithdrawFeesArbitrumFeesPlug.s.sol @@ -3,8 +3,8 @@ pragma solidity ^0.8.21; import {Script} from "forge-std/Script.sol"; import {console} from "forge-std/console.sol"; -import {FeesManager} from "../../contracts/protocol/payload-delivery/FeesManager.sol"; -import {ETH_ADDRESS} from "../../contracts/protocol/utils/common/Constants.sol"; +import {FeesManager} from "../../contracts/evmx/payload-delivery/FeesManager.sol"; +import {ETH_ADDRESS} from "../../contracts/utils/common/Constants.sol"; import {CounterAppGateway} from "../../test/apps/app-gateways/counter/CounterAppGateway.sol"; // @notice This script is used to withdraw fees from EVMX to Arbitrum Sepolia diff --git a/script/helpers/AppGatewayFeeBalance.s.sol b/script/helpers/AppGatewayFeeBalance.s.sol index 8e80861f..2911c527 100644 --- a/script/helpers/AppGatewayFeeBalance.s.sol +++ b/script/helpers/AppGatewayFeeBalance.s.sol @@ -3,8 +3,8 @@ pragma solidity ^0.8.21; import {Script} from "forge-std/Script.sol"; import {console} from "forge-std/console.sol"; -import {FeesManager} from "../../contracts/protocol/payload-delivery/FeesManager.sol"; -import {ETH_ADDRESS} from "../../contracts/protocol/utils/common/Constants.sol"; +import {FeesManager} from "../../contracts/evmx/payload-delivery/FeesManager.sol"; +import {ETH_ADDRESS} from "../../contracts/utils/common/Constants.sol"; contract CheckDepositedFees is Script { function run() external { diff --git a/script/helpers/CheckAppEVMxLimits.s.sol b/script/helpers/CheckAppEVMxLimits.s.sol deleted file mode 100644 index d31c2cdc..00000000 --- a/script/helpers/CheckAppEVMxLimits.s.sol +++ /dev/null @@ -1,66 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-only -pragma solidity ^0.8.21; - -import "forge-std/Script.sol"; -import {WatcherPrecompile} from "../../contracts/protocol/watcherPrecompile/core/WatcherPrecompile.sol"; -import {LimitParams} from "../../contracts/protocol/utils/common/Structs.sol"; -import {SCHEDULE, QUERY, FINALIZE} from "../../contracts/protocol/utils/common/Constants.sol"; - -contract CheckLimitsScript is Script { - function run() external { - string memory rpc = vm.envString("EVMX_RPC"); - vm.createSelectFork(rpc); - - address watcherPrecompile = vm.envAddress("WATCHER_PRECOMPILE"); - address appGateway = vm.envAddress("APP_GATEWAY"); - - console.log("WatcherPrecompile address:", watcherPrecompile); - console.log("AppGateway address:", appGateway); - WatcherPrecompile watcherContract = WatcherPrecompile(watcherPrecompile); - - LimitParams memory scheduleLimit = watcherContract - .watcherPrecompileLimits__() - .getLimitParams(SCHEDULE, appGateway); - LimitParams memory queryLimit = watcherContract.watcherPrecompileLimits__().getLimitParams( - QUERY, - appGateway - ); - LimitParams memory finalizeLimit = watcherContract - .watcherPrecompileLimits__() - .getLimitParams(FINALIZE, appGateway); - - uint256 scheduleCurrentLimit = watcherContract.watcherPrecompileLimits__().getCurrentLimit( - SCHEDULE, - appGateway - ); - uint256 queryCurrentLimit = watcherContract.watcherPrecompileLimits__().getCurrentLimit( - QUERY, - appGateway - ); - uint256 finalizeCurrentLimit = watcherContract.watcherPrecompileLimits__().getCurrentLimit( - FINALIZE, - appGateway - ); - - console.log("Schedule max limit:"); - console.log(scheduleLimit.maxLimit); - console.log("Schedule rate per second:"); - console.log(scheduleLimit.ratePerSecond); - console.log("Schedule current limit:"); - console.log(scheduleCurrentLimit); - - console.log("Query max limit:"); - console.log(queryLimit.maxLimit); - console.log("Query rate per second:"); - console.log(queryLimit.ratePerSecond); - console.log("Query current limit:"); - console.log(queryCurrentLimit); - - console.log("Finalize max limit:"); - console.log(finalizeLimit.maxLimit); - console.log("Finalize rate per second:"); - console.log(finalizeLimit.ratePerSecond); - console.log("Finalize current limit:"); - console.log(finalizeCurrentLimit); - } -} diff --git a/script/helpers/PayFeesInArbitrumETH.s.sol b/script/helpers/PayFeesInArbitrumETH.s.sol index 0940009a..b7d5b887 100644 --- a/script/helpers/PayFeesInArbitrumETH.s.sol +++ b/script/helpers/PayFeesInArbitrumETH.s.sol @@ -3,8 +3,8 @@ pragma solidity ^0.8.21; import {Script} from "forge-std/Script.sol"; import {console} from "forge-std/console.sol"; -import {FeesPlug} from "../../contracts/protocol/payload-delivery/FeesPlug.sol"; -import {ETH_ADDRESS} from "../../contracts/protocol/utils/common/Constants.sol"; +import {FeesPlug} from "../../contracts/evmx/payload-delivery/FeesPlug.sol"; +import {ETH_ADDRESS} from "../../contracts/utils/common/Constants.sol"; // source .env && forge script script/helpers/PayFeesInArbitrumETH.s.sol --broadcast --skip-simulation contract DepositFees is Script { diff --git a/script/helpers/PayFeesInArbitrumTestUSDC.s.sol b/script/helpers/PayFeesInArbitrumTestUSDC.s.sol index c7fe8111..daf9b08e 100644 --- a/script/helpers/PayFeesInArbitrumTestUSDC.s.sol +++ b/script/helpers/PayFeesInArbitrumTestUSDC.s.sol @@ -3,9 +3,9 @@ pragma solidity ^0.8.21; import {Script} from "forge-std/Script.sol"; import {console} from "forge-std/console.sol"; -import {FeesPlug} from "../../contracts/protocol/payload-delivery/FeesPlug.sol"; -import {ETH_ADDRESS} from "../../contracts/protocol/utils/common/Constants.sol"; -import {TestUSDC} from "../../contracts/helpers/TestUSDC.sol"; +import {FeesPlug} from "../../contracts/evmx/payload-delivery/FeesPlug.sol"; +import {ETH_ADDRESS} from "../../contracts/utils/common/Constants.sol"; +import {TestUSDC} from "../../contracts/evmx/helpers/TestUSDC.sol"; // source .env && forge script script/helpers/PayFeesInArbitrumETH.s.sol --broadcast --skip-simulation contract DepositFees is Script { function run() external { diff --git a/test/DeliveryHelper.t.sol b/test/DeliveryHelper.t.sol index 85d4b42b..a14321b7 100644 --- a/test/DeliveryHelper.t.sol +++ b/test/DeliveryHelper.t.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import "../contracts/protocol/payload-delivery/app-gateway/DeliveryHelper.sol"; -import "../contracts/protocol/payload-delivery/FeesManager.sol"; -import "../contracts/protocol/payload-delivery/AuctionManager.sol"; +import "../contracts/evmx/payload-delivery/app-gateway/DeliveryHelper.sol"; +import "../contracts/evmx/payload-delivery/FeesManager.sol"; +import "../contracts/evmx/payload-delivery/AuctionManager.sol"; -import "../contracts/protocol/Forwarder.sol"; -import "../contracts/interfaces/IAppGateway.sol"; +import "../contracts/evmx/Forwarder.sol"; +import "../contracts/evmx/interfaces/IAppGateway.sol"; import "./SetupTest.t.sol"; diff --git a/test/Migration.t.sol b/test/Migration.t.sol index 0dd023c5..fa7b05cb 100644 --- a/test/Migration.t.sol +++ b/test/Migration.t.sol @@ -2,12 +2,12 @@ pragma solidity ^0.8.21; import "./SetupTest.t.sol"; -import "../contracts/protocol/AddressResolver.sol"; -import "../contracts/protocol/watcherPrecompile/core/WatcherPrecompile.sol"; -import "../contracts/protocol/watcherPrecompile/WatcherPrecompileLimits.sol"; -import "../contracts/protocol/watcherPrecompile/WatcherPrecompileConfig.sol"; -import "../contracts/protocol/Forwarder.sol"; -import "../contracts/protocol/AsyncPromise.sol"; +import "../contracts/evmx/AddressResolver.sol"; +import "../contracts/evmx/watcherPrecompile/core/WatcherPrecompile.sol"; +import "../contracts/evmx/watcherPrecompile/WatcherPrecompileLimits.sol"; +import "../contracts/evmx/watcherPrecompile/WatcherPrecompileConfig.sol"; +import "../contracts/evmx/Forwarder.sol"; +import "../contracts/evmx/AsyncPromise.sol"; import "./mock/MockWatcherPrecompileImpl.sol"; contract MigrationTest is SetupTest { @@ -131,11 +131,6 @@ contract MigrationTest is SetupTest { address(addressResolver), "AddressResolver should be preserved" ); - assertEq( - watcherPrecompileLimits.defaultLimit(), - defaultLimit * 10 ** 18, - "DefaultLimit should be preserved" - ); } function testWatcherPrecompileConfigUpgrade() public { diff --git a/test/SetupTest.t.sol b/test/SetupTest.t.sol index 4735ab79..8153cd27 100644 --- a/test/SetupTest.t.sol +++ b/test/SetupTest.t.sol @@ -2,24 +2,24 @@ pragma solidity ^0.8.21; import "forge-std/Test.sol"; -import "../contracts/protocol/utils/common/Structs.sol"; -import "../contracts/protocol/utils/common/Errors.sol"; -import "../contracts/protocol/utils/common/Constants.sol"; -import "../contracts/protocol/watcherPrecompile/core/WatcherPrecompile.sol"; -import "../contracts/protocol/watcherPrecompile/WatcherPrecompileConfig.sol"; -import "../contracts/protocol/watcherPrecompile/WatcherPrecompileLimits.sol"; -import "../contracts/protocol/watcherPrecompile/PayloadHeaderDecoder.sol"; -import "../contracts/interfaces/IForwarder.sol"; -import "../contracts/protocol/utils/common/AccessRoles.sol"; -import {Socket} from "../contracts/protocol/socket/Socket.sol"; -import "../contracts/protocol/socket/switchboard/FastSwitchboard.sol"; -import "../contracts/protocol/socket/SocketBatcher.sol"; -import "../contracts/protocol/AddressResolver.sol"; -import {ContractFactoryPlug} from "../contracts/protocol/payload-delivery/ContractFactoryPlug.sol"; -import {FeesPlug} from "../contracts/protocol/payload-delivery/FeesPlug.sol"; -import {SocketFeeManager} from "../contracts/protocol/socket/SocketFeeManager.sol"; -import {ETH_ADDRESS} from "../contracts/protocol/utils/common/Constants.sol"; -import {ResolvedPromises, OnChainFees} from "../contracts/protocol/utils/common/Structs.sol"; +import "../contracts/utils/common/Structs.sol"; +import "../contracts/utils/common/Errors.sol"; +import "../contracts/utils/common/Constants.sol"; +import "../contracts/evmx/watcherPrecompile/core/WatcherPrecompile.sol"; +import "../contracts/evmx/watcherPrecompile/WatcherPrecompileConfig.sol"; +import "../contracts/evmx/watcherPrecompile/WatcherPrecompileLimits.sol"; +import "../contracts/evmx/watcherPrecompile/PayloadHeaderDecoder.sol"; +import "../contracts/evmx/interfaces/IForwarder.sol"; +import "../contracts/utils/common/AccessRoles.sol"; +import {Socket} from "../contracts/protocol/Socket.sol"; +import "../contracts/protocol/switchboard/FastSwitchboard.sol"; +import "../contracts/protocol/SocketBatcher.sol"; +import "../contracts/evmx/AddressResolver.sol"; +import {ContractFactoryPlug} from "../contracts/evmx/payload-delivery/ContractFactoryPlug.sol"; +import {FeesPlug} from "../contracts/evmx/payload-delivery/FeesPlug.sol"; +import {SocketFeeManager} from "../contracts/protocol/SocketFeeManager.sol"; +import {ETH_ADDRESS} from "../contracts/utils/common/Constants.sol"; +import {ResolvedPromises, OnChainFees} from "../contracts/utils/common/Structs.sol"; import "solady/utils/ERC1967Factory.sol"; import "./apps/app-gateways/USDC.sol"; diff --git a/test/SocketFeeManager.t.sol b/test/SocketFeeManager.t.sol index e57dc809..e81132ca 100644 --- a/test/SocketFeeManager.t.sol +++ b/test/SocketFeeManager.t.sol @@ -4,10 +4,10 @@ pragma solidity ^0.8.0; import {CounterAppGateway} from "./apps/app-gateways/counter/CounterAppGateway.sol"; import {Counter} from "./apps/app-gateways/counter/Counter.sol"; import "./SetupTest.t.sol"; -import {SocketFeeManager} from "../contracts/protocol/socket/SocketFeeManager.sol"; +import {SocketFeeManager} from "../contracts/protocol/SocketFeeManager.sol"; import {MockFastSwitchboard} from "./mock/MockFastSwitchboard.sol"; -import {ExecuteParams, TransmissionParams, CallType, WriteFinality} from "../contracts/protocol/utils/common/Structs.sol"; -import {GOVERNANCE_ROLE, RESCUE_ROLE} from "../contracts/protocol/utils/common/AccessRoles.sol"; +import {ExecuteParams, TransmissionParams, CallType} from "../contracts/utils/common/Structs.sol"; +import {GOVERNANCE_ROLE, RESCUE_ROLE} from "../contracts/utils/common/AccessRoles.sol"; import {Test} from "forge-std/Test.sol"; contract SocketFeeManagerTest is SetupTest { diff --git a/test/apps/SuperToken.t.sol b/test/apps/SuperToken.t.sol index bd5c88ab..9a5a4897 100644 --- a/test/apps/SuperToken.t.sol +++ b/test/apps/SuperToken.t.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.21; import {SuperTokenAppGateway} from "./app-gateways/super-token/SuperTokenAppGateway.sol"; import {SuperToken} from "./app-gateways/super-token/SuperToken.sol"; import "../DeliveryHelper.t.sol"; -import {QUERY, FINALIZE, SCHEDULE} from "../../contracts/protocol/utils/common/Constants.sol"; +import {QUERY, FINALIZE, SCHEDULE} from "../../contracts/utils/common/Constants.sol"; /** * @title SuperToken Test diff --git a/test/apps/app-gateways/counter/Counter.sol b/test/apps/app-gateways/counter/Counter.sol index 214bab43..4a089f1e 100644 --- a/test/apps/app-gateways/counter/Counter.sol +++ b/test/apps/app-gateways/counter/Counter.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.21; import "solady/auth/Ownable.sol"; -import "../../../../contracts/base/PlugBase.sol"; +import "../../../../contracts/protocol/base/PlugBase.sol"; interface ICounterAppGateway { function increase(uint256 value_) external returns (bytes32); diff --git a/test/apps/app-gateways/counter/CounterAppGateway.sol b/test/apps/app-gateways/counter/CounterAppGateway.sol index f5bca934..eecc2c79 100644 --- a/test/apps/app-gateways/counter/CounterAppGateway.sol +++ b/test/apps/app-gateways/counter/CounterAppGateway.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import "../../../../contracts/base/AppGatewayBase.sol"; -import "../../../../contracts/interfaces/IForwarder.sol"; -import "../../../../contracts/interfaces/IPromise.sol"; +import "../../../../contracts/evmx/base/AppGatewayBase.sol"; +import "../../../../contracts/evmx/interfaces/IForwarder.sol"; +import "../../../../contracts/evmx/interfaces/IPromise.sol"; import "./Counter.sol"; import "./ICounter.sol"; diff --git a/test/apps/app-gateways/super-token/SuperToken.sol b/test/apps/app-gateways/super-token/SuperToken.sol index f1bf0247..e62fdd92 100644 --- a/test/apps/app-gateways/super-token/SuperToken.sol +++ b/test/apps/app-gateways/super-token/SuperToken.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.21; import "solady/tokens/ERC20.sol"; import {Ownable} from "solady/auth/Ownable.sol"; -import "../../../../contracts/base/PlugBase.sol"; +import "../../../../contracts/protocol/base/PlugBase.sol"; /** * @title SuperToken diff --git a/test/apps/app-gateways/super-token/SuperTokenAppGateway.sol b/test/apps/app-gateways/super-token/SuperTokenAppGateway.sol index fbaf6f15..aa88756f 100644 --- a/test/apps/app-gateways/super-token/SuperTokenAppGateway.sol +++ b/test/apps/app-gateways/super-token/SuperTokenAppGateway.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.21; import "solady/auth/Ownable.sol"; -import "../../../../contracts/base/AppGatewayBase.sol"; +import "../../../../contracts/evmx/base/AppGatewayBase.sol"; import "./ISuperToken.sol"; import "./SuperToken.sol"; diff --git a/test/mock/MockFastSwitchboard.sol b/test/mock/MockFastSwitchboard.sol index 3341fab8..e516fe3d 100644 --- a/test/mock/MockFastSwitchboard.sol +++ b/test/mock/MockFastSwitchboard.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import "../../contracts/interfaces/ISwitchboard.sol"; -import "../../contracts/interfaces/ISocket.sol"; +import "../../contracts/protocol/interfaces/ISwitchboard.sol"; +import "../../contracts/protocol/interfaces/ISocket.sol"; + contract MockFastSwitchboard is ISwitchboard { address public owner; ISocket public immutable socket__; diff --git a/test/mock/MockSocket.sol b/test/mock/MockSocket.sol index 7f460c2c..027d3c27 100644 --- a/test/mock/MockSocket.sol +++ b/test/mock/MockSocket.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import {InvalidAppGateway} from "../../contracts/protocol/utils/common/Errors.sol"; -import "../../contracts/interfaces/ISwitchboard.sol"; -import "../../contracts/interfaces/ISocket.sol"; +import {InvalidAppGateway} from "../../contracts/utils/common/Errors.sol"; +import "../../contracts/protocol/interfaces/ISwitchboard.sol"; +import "../../contracts/protocol/interfaces/ISocket.sol"; /** * @title SocketDst diff --git a/test/mock/MockWatcherPrecompile.sol b/test/mock/MockWatcherPrecompile.sol index 3cd1681c..ee89876b 100644 --- a/test/mock/MockWatcherPrecompile.sol +++ b/test/mock/MockWatcherPrecompile.sol @@ -1,13 +1,13 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import "../../contracts/interfaces/IAppGateway.sol"; -import "../../contracts/interfaces/IWatcherPrecompile.sol"; -import "../../contracts/interfaces/IPromise.sol"; +import "../../contracts/evmx/interfaces/IAppGateway.sol"; +import "../../contracts/evmx/interfaces/IWatcherPrecompile.sol"; +import "../../contracts/evmx/interfaces/IPromise.sol"; -import {TimeoutRequest, TriggerParams, PlugConfig, ResolvedPromises, AppGatewayConfig} from "../../contracts/protocol/utils/common/Structs.sol"; -import {QUERY, FINALIZE, SCHEDULE} from "../../contracts/protocol/utils/common/Constants.sol"; -import {TimeoutDelayTooLarge, TimeoutAlreadyResolved, ResolvingTimeoutTooEarly, CallFailed, AppGatewayAlreadyCalled} from "../../contracts/protocol/utils/common/Errors.sol"; +import {TimeoutRequest, TriggerParams, PlugConfig, ResolvedPromises, AppGatewayConfig} from "../../contracts/utils/common/Structs.sol"; +import {QUERY, FINALIZE, SCHEDULE} from "../../contracts/utils/common/Constants.sol"; +import {TimeoutDelayTooLarge, TimeoutAlreadyResolved, ResolvingTimeoutTooEarly, CallFailed, AppGatewayAlreadyCalled} from "../../contracts/utils/common/Errors.sol"; import "solady/utils/ERC1967Factory.sol"; /// @title WatcherPrecompile diff --git a/test/mock/MockWatcherPrecompileImpl.sol b/test/mock/MockWatcherPrecompileImpl.sol index 86f49e22..59cbfb87 100644 --- a/test/mock/MockWatcherPrecompileImpl.sol +++ b/test/mock/MockWatcherPrecompileImpl.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.21; -import "../../contracts/protocol/watcherPrecompile/core/WatcherPrecompile.sol"; +import "../../contracts/evmx/watcherPrecompile/core/WatcherPrecompile.sol"; contract MockWatcherPrecompileImpl is WatcherPrecompile { // Mock function to test reinitialization with version 2