From a5867f9463751bd8cd7852b849732bdf17ea293e Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Mon, 17 Feb 2025 16:46:43 +0400 Subject: [PATCH 1/7] feat: implement overloaded override setters --- contracts/apps/counter/CounterAppGateway.sol | 6 +- .../ParallelCounterAppGateway.sol | 3 +- .../ParallelCounterDeployer.sol | 3 +- .../SuperTokenLockableAppGateway.sol | 4 +- contracts/base/AppGatewayBase.sol | 85 +++++++++++++++---- contracts/interfaces/IAppGateway.sol | 2 + 6 files changed, 75 insertions(+), 28 deletions(-) diff --git a/contracts/apps/counter/CounterAppGateway.sol b/contracts/apps/counter/CounterAppGateway.sol index ffeb3100..76c73726 100644 --- a/contracts/apps/counter/CounterAppGateway.sol +++ b/contracts/apps/counter/CounterAppGateway.sol @@ -32,15 +32,13 @@ contract CounterAppGateway is AppGatewayBase { function readCounters(address[] memory instances_) public async { // the increase function is called on given list of instances // this - _readCallOn(); - _setIsCallSequential(false); + _setOverrides(true); for (uint256 i = 0; i < instances_.length; i++) { uint32 chainSlug = IForwarder(instances_[i]).getChainSlug(); ICounter(instances_[i]).getCounter(); IPromise(instances_[i]).then(this.setCounterValues.selector, abi.encode(chainSlug)); } - _readCallOff(); - _setIsCallSequential(true); + _setOverrides(false); ICounter(instances_[0]).increase(); } diff --git a/contracts/apps/parallel-counter/ParallelCounterAppGateway.sol b/contracts/apps/parallel-counter/ParallelCounterAppGateway.sol index 1f42d779..6fd2d703 100644 --- a/contracts/apps/parallel-counter/ParallelCounterAppGateway.sol +++ b/contracts/apps/parallel-counter/ParallelCounterAppGateway.sol @@ -12,8 +12,7 @@ contract ParallelCounterAppGateway is AppGatewayBase { Fees memory fees_ ) AppGatewayBase(addressResolver_, auctionManager_) { addressResolver__.setContractsToGateways(deployerContract_); - _setFees(fees_); - _setIsCallSequential(false); + _setOverrides(false, true, 1000000, fees_); } function incrementCounters(address[] memory instances_) public async { diff --git a/contracts/apps/parallel-counter/ParallelCounterDeployer.sol b/contracts/apps/parallel-counter/ParallelCounterDeployer.sol index eeca0663..d5506213 100644 --- a/contracts/apps/parallel-counter/ParallelCounterDeployer.sol +++ b/contracts/apps/parallel-counter/ParallelCounterDeployer.sol @@ -17,8 +17,7 @@ contract ParallelCounterDeployer is AppDeployerBase, OwnableTwoStep { ) AppDeployerBase(addressResolver_, auctionManager_, sbType_) { creationCodeWithArgs[counter1] = abi.encodePacked(type(Counter).creationCode); creationCodeWithArgs[counter2] = abi.encodePacked(type(Counter).creationCode); - _setFees(fees_); - _setIsCallSequential(false); + _setOverrides(false, false, 1000000, fees_); _claimOwner(msg.sender); } diff --git a/contracts/apps/super-token-lockable/SuperTokenLockableAppGateway.sol b/contracts/apps/super-token-lockable/SuperTokenLockableAppGateway.sol index 133541be..339f0c23 100644 --- a/contracts/apps/super-token-lockable/SuperTokenLockableAppGateway.sol +++ b/contracts/apps/super-token-lockable/SuperTokenLockableAppGateway.sol @@ -49,12 +49,12 @@ contract SuperTokenLockableAppGateway is AppGatewayBase, OwnableTwoStep { asyncId_ = _getCurrentAsyncId(); ISuperToken(order.srcToken).lockTokens(order.user, order.srcAmount); - _readCallOn(); + _setOverrides(true); // goes to forwarder and deploys promise and stores it ISuperToken(order.srcToken).balanceOf(order.user); IPromise(order.srcToken).then(this.checkBalance.selector, abi.encode(order, asyncId_)); - _readCallOff(); + _setOverrides(false); ISuperToken(order.dstToken).mint(order.user, order.srcAmount); ISuperToken(order.srcToken).burn(order.user, order.srcAmount); diff --git a/contracts/base/AppGatewayBase.sol b/contracts/base/AppGatewayBase.sol index 85b3f6ee..b47f0470 100644 --- a/contracts/base/AppGatewayBase.sol +++ b/contracts/base/AppGatewayBase.sol @@ -14,6 +14,8 @@ import {InvalidPromise, FeesNotSet} from "../common/Errors.sol"; abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin { bool public override isReadCall; bool public override isCallSequential; + uint256 public override gasLimit; + address public auctionManager; bytes public onCompleteData; bytes32 public sbType; @@ -47,10 +49,63 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin isCallSequential = true; } - function _setIsCallSequential(bool isCallSequential_) internal { + //////////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////// OVERRIDE HELPERS /////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////// + + /// @notice Sets multiple overrides in one call + /// @param isReadCall_ The read call flag + /// @param fees_ The fees configuration + /// @param gasLimit_ The gas limit + /// @param isCallSequential_ The sequential call flag + function _setOverrides( + bool isReadCall_, + bool isCallSequential_, + uint256 gasLimit_, + Fees memory fees_ + ) internal { + isReadCall = isReadCall_; + isCallSequential = isCallSequential_; + gasLimit = gasLimit_; + _setFees(fees_); + } + + /// @notice Sets isReadCall, fees and gasLimit overrides + /// @param isReadCall_ The read call flag + /// @param isCallSequential_ The sequential call flag + /// @param gasLimit_ The gas limit + function _setOverrides(bool isReadCall_, bool isCallSequential_, uint256 gasLimit_) internal { + isReadCall = isReadCall_; + isCallSequential = isCallSequential_; + gasLimit = gasLimit_; + } + + /// @notice Sets isReadCall and isCallSequential overrides + /// @param isReadCall_ The read call flag + /// @param isCallSequential_ The sequential call flag + function _setOverrides(bool isReadCall_, bool isCallSequential_) internal { + isReadCall = isReadCall_; isCallSequential = isCallSequential_; } + /// @notice Sets isReadCall and gasLimit overrides + /// @param isReadCall_ The read call flag + function _setOverrides(bool isReadCall_) internal { + isReadCall = isReadCall_; + } + + /// @notice Sets gasLimit overrides + /// @param gasLimit_ The gas limit + function _setOverrides(uint256 gasLimit_) internal { + gasLimit = gasLimit_; + } + + /// @notice Sets fees overrides + /// @param fees_ The fees configuration + function _setOverrides(Fees memory fees_) internal { + _setFees(fees_); + } + /// @notice Creates a contract ID /// @param contractName_ The contract name /// @return bytes32 The contract ID @@ -64,16 +119,6 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin auctionManager = auctionManager_; } - /// @notice Sets the read call flag - function _readCallOn() internal { - isReadCall = true; - } - - /// @notice Turns off the read call flag - function _readCallOff() internal { - isReadCall = false; - } - /// @notice Marks the promises as valid function _markValidPromises() internal { address[] memory promises = addressResolver__.getPromises(); @@ -96,16 +141,10 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin /// @notice increases the transaction fees /// @param asyncId_ The async ID - function increaseFees(bytes32 asyncId_, uint256 newMaxFees_) internal { + function _increaseFees(bytes32 asyncId_, uint256 newMaxFees_) internal { deliveryHelper().increaseFees(asyncId_, newMaxFees_); } - /// @notice hook to handle the revert in callbacks or onchain executions - /// @dev can be overridden by the app gateway to add custom logic - /// @param asyncId_ The async ID - /// @param payloadId_ The payload ID - function handleRevert(bytes32 asyncId_, bytes32 payloadId_) external override onlyPromises {} - /// @notice Withdraws fee tokens /// @param chainSlug_ The chain slug /// @param token_ The token address @@ -120,6 +159,10 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin deliveryHelper().withdrawTo(chainSlug_, token_, amount_, receiver_, auctionManager, fees); } + //////////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////// OVERRIDE HOOKS ///////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////// + /// @notice Callback in pd promise to be called after all contracts are deployed /// @param asyncId_ The async ID /// @param payloadBatch_ The payload batch @@ -134,4 +177,10 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin bytes calldata payload_, bytes32 params_ ) external virtual onlyWatcherPrecompile {} + + /// @notice hook to handle the revert in callbacks or onchain executions + /// @dev can be overridden by the app gateway to add custom logic + /// @param asyncId_ The async ID + /// @param payloadId_ The payload ID + function handleRevert(bytes32 asyncId_, bytes32 payloadId_) external override onlyPromises {} } diff --git a/contracts/interfaces/IAppGateway.sol b/contracts/interfaces/IAppGateway.sol index e4c6fcd0..8cf706e2 100644 --- a/contracts/interfaces/IAppGateway.sol +++ b/contracts/interfaces/IAppGateway.sol @@ -8,6 +8,8 @@ interface IAppGateway { function isCallSequential() external view returns (bool); + function gasLimit() external view returns (uint256); + function onBatchComplete(bytes32 asyncId_, PayloadBatch memory payloadBatch_) external; function callFromInbox( From 683d58ddbcb954f14e1c46ac2039676606c8dfc1 Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Mon, 17 Feb 2025 16:46:59 +0400 Subject: [PATCH 2/7] fix: lint --- hardhat-scripts/deploy/1.deploy.ts | 1 - .../deploy/migration/migrate-proxies.ts | 46 +++++++++++++------ 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/hardhat-scripts/deploy/1.deploy.ts b/hardhat-scripts/deploy/1.deploy.ts index dcff8d4e..e2ed176f 100644 --- a/hardhat-scripts/deploy/1.deploy.ts +++ b/hardhat-scripts/deploy/1.deploy.ts @@ -352,7 +352,6 @@ async function initializeSigVerifier( } } - async function updateContractSettings( contract: Contract, getterMethod: string, diff --git a/hardhat-scripts/deploy/migration/migrate-proxies.ts b/hardhat-scripts/deploy/migration/migrate-proxies.ts index 9370036b..7a44eca4 100644 --- a/hardhat-scripts/deploy/migration/migrate-proxies.ts +++ b/hardhat-scripts/deploy/migration/migrate-proxies.ts @@ -53,7 +53,6 @@ async function main() { providerInstance ); - // Get the proxy factory let proxyFactory = await ethers.getContractAt( "ERC1967Factory", @@ -97,7 +96,8 @@ async function main() { console.log("version variable not found"); } - if (contractName === "AddressResolver") await verifyBeaconImplementation(contract, signer); + if (contractName === "AddressResolver") + await verifyBeaconImplementation(contract, signer); if ( currentImplAddress.toLowerCase() === newImplementation.toLowerCase() @@ -110,10 +110,9 @@ async function main() { console.log("Upgrading proxy..."); const initializeFn = contract.interface.getFunction("initialize"); - const initData = contract.interface.encodeFunctionData( - initializeFn, - [VERSION] - ); + const initData = contract.interface.encodeFunctionData(initializeFn, [ + VERSION, + ]); const tx = await proxyFactory.upgradeAndCall( PROXY_ADDRESS, @@ -153,29 +152,46 @@ async function main() { async function verifyBeaconImplementation(contract: Contract, signer: Wallet) { console.log("Verifying beacon implementations..."); const forwarderBeaconAddress = await contract.forwarderBeacon(); - const forwarderImplementationAddress = await contract.forwarderImplementation(); + const forwarderImplementationAddress = + await contract.forwarderImplementation(); const asyncPromiseBeaconAddress = await contract.asyncPromiseBeacon(); - const asyncPromiseImplementationAddress = await contract.asyncPromiseImplementation(); + const asyncPromiseImplementationAddress = + await contract.asyncPromiseImplementation(); const upgradeableBeaconAbi = [ "function implementation() view returns (address)", ]; - const forwarderBeacon = new ethers.Contract(forwarderBeaconAddress, upgradeableBeaconAbi); - const asyncPromiseBeacon = new ethers.Contract(asyncPromiseBeaconAddress, upgradeableBeaconAbi); + const forwarderBeacon = new ethers.Contract( + forwarderBeaconAddress, + upgradeableBeaconAbi + ); + const asyncPromiseBeacon = new ethers.Contract( + asyncPromiseBeaconAddress, + upgradeableBeaconAbi + ); // Verify forwarder beacon implementation - const forwarderBeaconImplementation = await forwarderBeacon.connect(signer).implementation(); - if (forwarderBeaconImplementation.toLowerCase() !== forwarderImplementationAddress.toLowerCase()) { + const forwarderBeaconImplementation = await forwarderBeacon + .connect(signer) + .implementation(); + if ( + forwarderBeaconImplementation.toLowerCase() !== + forwarderImplementationAddress.toLowerCase() + ) { throw new Error("Forwarder beacon implementation mismatch"); } // Verify async promise beacon implementation - const asyncPromiseBeaconImplementation = await asyncPromiseBeacon.connect(signer).implementation(); - if (asyncPromiseBeaconImplementation.toLowerCase() !== asyncPromiseImplementationAddress.toLowerCase()) { + const asyncPromiseBeaconImplementation = await asyncPromiseBeacon + .connect(signer) + .implementation(); + if ( + asyncPromiseBeaconImplementation.toLowerCase() !== + asyncPromiseImplementationAddress.toLowerCase() + ) { throw new Error("Async promise beacon implementation mismatch"); } - } // We recommend this pattern to be able to use async/await everywhere // and properly handle errors. From c209fdb943d80d9267e360c0abfe7b964996d7b4 Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Mon, 17 Feb 2025 16:49:51 +0400 Subject: [PATCH 3/7] fix: remove separate fees setter --- .../counter-inbox/CounterInboxAppGateway.sol | 2 +- contracts/apps/counter/CounterAppGateway.sol | 6 +- contracts/apps/counter/CounterDeployer.sol | 2 +- contracts/apps/cron/CronAppGateway.sol | 2 +- .../SuperTokenLockableAppGateway.sol | 2 +- .../SuperTokenLockableDeployer.sol | 2 +- .../apps/super-token/SuperTokenAppGateway.sol | 2 +- .../apps/super-token/SuperTokenDeployer.sol | 2 +- contracts/base/AppGatewayBase.sol | 64 ++++++++++--------- contracts/utils/FeesPlugin.sol | 9 --- 10 files changed, 44 insertions(+), 49 deletions(-) diff --git a/contracts/apps/counter-inbox/CounterInboxAppGateway.sol b/contracts/apps/counter-inbox/CounterInboxAppGateway.sol index 9193eadb..d759a543 100644 --- a/contracts/apps/counter-inbox/CounterInboxAppGateway.sol +++ b/contracts/apps/counter-inbox/CounterInboxAppGateway.sol @@ -14,7 +14,7 @@ contract CounterInboxAppGateway is AppGatewayBase { Fees memory fees_ ) AppGatewayBase(addressResolver_, auctionManager_) { watcherPrecompile__().setIsValidInboxCaller(chainSlug_, address(counterInbox_), true); - _setFees(fees_); + _setOverrides(fees_); } function callFromInbox( diff --git a/contracts/apps/counter/CounterAppGateway.sol b/contracts/apps/counter/CounterAppGateway.sol index 76c73726..68d98b25 100644 --- a/contracts/apps/counter/CounterAppGateway.sol +++ b/contracts/apps/counter/CounterAppGateway.sol @@ -18,7 +18,7 @@ contract CounterAppGateway is AppGatewayBase { Fees memory fees_ ) AppGatewayBase(addressResolver_, auctionManager_) { addressResolver__.setContractsToGateways(deployerContract_); - _setFees(fees_); + _setOverrides(fees_); } function incrementCounters(address[] memory instances_) public async { @@ -32,13 +32,13 @@ contract CounterAppGateway is AppGatewayBase { function readCounters(address[] memory instances_) public async { // the increase function is called on given list of instances // this - _setOverrides(true); + _setOverrides(false, true); for (uint256 i = 0; i < instances_.length; i++) { uint32 chainSlug = IForwarder(instances_[i]).getChainSlug(); ICounter(instances_[i]).getCounter(); IPromise(instances_[i]).then(this.setCounterValues.selector, abi.encode(chainSlug)); } - _setOverrides(false); + _setOverrides(false, false); ICounter(instances_[0]).increase(); } diff --git a/contracts/apps/counter/CounterDeployer.sol b/contracts/apps/counter/CounterDeployer.sol index 18bef28a..a546c48f 100644 --- a/contracts/apps/counter/CounterDeployer.sol +++ b/contracts/apps/counter/CounterDeployer.sol @@ -15,7 +15,7 @@ contract CounterDeployer is AppDeployerBase, OwnableTwoStep { Fees memory fees_ ) AppDeployerBase(addressResolver_, auctionManager_, sbType_) { creationCodeWithArgs[counter] = abi.encodePacked(type(Counter).creationCode); - _setFees(fees_); + _setOverrides(fees_); _claimOwner(msg.sender); } diff --git a/contracts/apps/cron/CronAppGateway.sol b/contracts/apps/cron/CronAppGateway.sol index 2a649e5c..9b50abf5 100644 --- a/contracts/apps/cron/CronAppGateway.sol +++ b/contracts/apps/cron/CronAppGateway.sol @@ -13,7 +13,7 @@ contract CronAppGateway is AppGatewayBase { Fees memory fees_ ) AppGatewayBase(addressResolver_, auctionManager_) { addressResolver__.setContractsToGateways(deployerContract_); - _setFees(fees_); + _setOverrides(fees_); } function setTimeout(uint256 delayInSeconds_) public { diff --git a/contracts/apps/super-token-lockable/SuperTokenLockableAppGateway.sol b/contracts/apps/super-token-lockable/SuperTokenLockableAppGateway.sol index 339f0c23..ce282d4c 100644 --- a/contracts/apps/super-token-lockable/SuperTokenLockableAppGateway.sol +++ b/contracts/apps/super-token-lockable/SuperTokenLockableAppGateway.sol @@ -25,7 +25,7 @@ contract SuperTokenLockableAppGateway is AppGatewayBase, OwnableTwoStep { Fees memory fees_ ) AppGatewayBase(addressResolver_, auctionManager_) { addressResolver__.setContractsToGateways(deployerContract_); - _setFees(fees_); + _setOverrides(fees_); _claimOwner(msg.sender); } diff --git a/contracts/apps/super-token-lockable/SuperTokenLockableDeployer.sol b/contracts/apps/super-token-lockable/SuperTokenLockableDeployer.sol index d9bd242e..fd8dfad5 100644 --- a/contracts/apps/super-token-lockable/SuperTokenLockableDeployer.sol +++ b/contracts/apps/super-token-lockable/SuperTokenLockableDeployer.sol @@ -44,7 +44,7 @@ contract SuperTokenLockableDeployer is AppDeployerBase, OwnableTwoStep { abi.encode(params._burnLimit, params._mintLimit) ); - _setFees(fees_); + _setOverrides(fees_); _claimOwner(owner_); } diff --git a/contracts/apps/super-token/SuperTokenAppGateway.sol b/contracts/apps/super-token/SuperTokenAppGateway.sol index fa5f5e14..f51fef59 100644 --- a/contracts/apps/super-token/SuperTokenAppGateway.sol +++ b/contracts/apps/super-token/SuperTokenAppGateway.sol @@ -27,7 +27,7 @@ contract SuperTokenAppGateway is AppGatewayBase, OwnableTwoStep { // sets the fees data like max fees, chain and token for all transfers // they can be updated for each transfer as well - _setFees(fees_); + _setOverrides(fees_); _claimOwner(msg.sender); } diff --git a/contracts/apps/super-token/SuperTokenDeployer.sol b/contracts/apps/super-token/SuperTokenDeployer.sol index 0e814dcd..9dc3a2f4 100644 --- a/contracts/apps/super-token/SuperTokenDeployer.sol +++ b/contracts/apps/super-token/SuperTokenDeployer.sol @@ -34,7 +34,7 @@ contract SuperTokenDeployer is AppDeployerBase, OwnableTwoStep { params_.initialSupply_ ) ); - _setFees(fees_); + _setOverrides(fees_); } function deployContracts(uint32 chainSlug_) external async { diff --git a/contracts/base/AppGatewayBase.sol b/contracts/base/AppGatewayBase.sol index b47f0470..d88a7ff8 100644 --- a/contracts/base/AppGatewayBase.sol +++ b/contracts/base/AppGatewayBase.sol @@ -49,8 +49,35 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin isCallSequential = true; } + /// @notice Creates a contract ID + /// @param contractName_ The contract name + /// @return bytes32 The contract ID + function _createContractId(string memory contractName_) internal pure returns (bytes32) { + return keccak256(abi.encode(contractName_)); + } + + /// @notice Gets the current async ID + /// @return bytes32 The current async ID + function _getCurrentAsyncId() internal view returns (bytes32) { + return deliveryHelper().getCurrentAsyncId(); + } + + /// @notice Sets the auction manager + /// @param auctionManager_ The auction manager + function _setAuctionManager(address auctionManager_) internal { + auctionManager = auctionManager_; + } + + /// @notice Marks the promises as valid + function _markValidPromises() internal { + address[] memory promises = addressResolver__.getPromises(); + for (uint256 i = 0; i < promises.length; i++) { + isValidPromise[promises[i]] = true; + } + } + //////////////////////////////////////////////////////////////////////////////////////////////// - ///////////////////////////////// OVERRIDE HELPERS /////////////////////////////////////////////////// + ///////////////////////////////// TX OVERRIDE HELPERS /////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// /// @notice Sets multiple overrides in one call @@ -67,7 +94,7 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin isReadCall = isReadCall_; isCallSequential = isCallSequential_; gasLimit = gasLimit_; - _setFees(fees_); + fees = fees_; } /// @notice Sets isReadCall, fees and gasLimit overrides @@ -103,35 +130,12 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin /// @notice Sets fees overrides /// @param fees_ The fees configuration function _setOverrides(Fees memory fees_) internal { - _setFees(fees_); + fees = fees_; } - /// @notice Creates a contract ID - /// @param contractName_ The contract name - /// @return bytes32 The contract ID - function _createContractId(string memory contractName_) internal pure returns (bytes32) { - return keccak256(abi.encode(contractName_)); - } - - /// @notice Sets the auction manager - /// @param auctionManager_ The auction manager - function _setAuctionManager(address auctionManager_) internal { - auctionManager = auctionManager_; - } - - /// @notice Marks the promises as valid - function _markValidPromises() internal { - address[] memory promises = addressResolver__.getPromises(); - for (uint256 i = 0; i < promises.length; i++) { - isValidPromise[promises[i]] = true; - } - } - - /// @notice Gets the current async ID - /// @return bytes32 The current async ID - function _getCurrentAsyncId() internal view returns (bytes32) { - return deliveryHelper().getCurrentAsyncId(); - } + //////////////////////////////////////////////////////////////////////////////////////////////// + ///////////////////////////////// ASYNC BATCH HELPERS ///////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////// /// @notice Reverts the transaction /// @param asyncId_ The async ID @@ -160,7 +164,7 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin } //////////////////////////////////////////////////////////////////////////////////////////////// - ///////////////////////////////// OVERRIDE HOOKS ///////////////////////////////////////////////// + ///////////////////////////////// HOOKS ///////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////// /// @notice Callback in pd promise to be called after all contracts are deployed diff --git a/contracts/utils/FeesPlugin.sol b/contracts/utils/FeesPlugin.sol index 943187ac..90c34f8f 100644 --- a/contracts/utils/FeesPlugin.sol +++ b/contracts/utils/FeesPlugin.sol @@ -11,15 +11,6 @@ abstract contract FeesPlugin { /// @dev Contains fee parameters like rates, limits, and recipient addresses Fees public fees; - /// @notice Updates the fee configuration - /// @param fees_ New fee configuration to be set - /// @dev Internal function to be called by inheriting contracts - /// @dev Should be protected with appropriate access control in implementing contracts - function _setFees(Fees memory fees_) internal { - // Update the fee configuration with new parameters - fees = fees_; - } - /// @notice Retrieves the current fee configuration /// @return Current fee configuration struct /// @dev Public view function accessible to any caller From ae32660ce60a7aab5da39f8f3a96541770a35b48 Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Mon, 17 Feb 2025 20:36:27 +0400 Subject: [PATCH 4/7] feat: enum instead of bools in override for readability --- contracts/apps/counter/CounterAppGateway.sol | 4 +- .../ParallelCounterAppGateway.sol | 2 +- .../ParallelCounterDeployer.sol | 2 +- .../SuperTokenLockableAppGateway.sol | 4 +- contracts/base/AppGatewayBase.sol | 44 ++++++++++++++----- 5 files changed, 38 insertions(+), 18 deletions(-) diff --git a/contracts/apps/counter/CounterAppGateway.sol b/contracts/apps/counter/CounterAppGateway.sol index 68d98b25..0a588432 100644 --- a/contracts/apps/counter/CounterAppGateway.sol +++ b/contracts/apps/counter/CounterAppGateway.sol @@ -32,13 +32,13 @@ contract CounterAppGateway is AppGatewayBase { function readCounters(address[] memory instances_) public async { // the increase function is called on given list of instances // this - _setOverrides(false, true); + _setOverrides(Sequential.TRUE); for (uint256 i = 0; i < instances_.length; i++) { uint32 chainSlug = IForwarder(instances_[i]).getChainSlug(); ICounter(instances_[i]).getCounter(); IPromise(instances_[i]).then(this.setCounterValues.selector, abi.encode(chainSlug)); } - _setOverrides(false, false); + _setOverrides(Sequential.FALSE); ICounter(instances_[0]).increase(); } diff --git a/contracts/apps/parallel-counter/ParallelCounterAppGateway.sol b/contracts/apps/parallel-counter/ParallelCounterAppGateway.sol index 6fd2d703..54dfda68 100644 --- a/contracts/apps/parallel-counter/ParallelCounterAppGateway.sol +++ b/contracts/apps/parallel-counter/ParallelCounterAppGateway.sol @@ -12,7 +12,7 @@ contract ParallelCounterAppGateway is AppGatewayBase { Fees memory fees_ ) AppGatewayBase(addressResolver_, auctionManager_) { addressResolver__.setContractsToGateways(deployerContract_); - _setOverrides(false, true, 1000000, fees_); + _setOverrides(Read.OFF, Sequential.TRUE, 1000000, fees_); } function incrementCounters(address[] memory instances_) public async { diff --git a/contracts/apps/parallel-counter/ParallelCounterDeployer.sol b/contracts/apps/parallel-counter/ParallelCounterDeployer.sol index d5506213..cb7e7762 100644 --- a/contracts/apps/parallel-counter/ParallelCounterDeployer.sol +++ b/contracts/apps/parallel-counter/ParallelCounterDeployer.sol @@ -17,7 +17,7 @@ contract ParallelCounterDeployer is AppDeployerBase, OwnableTwoStep { ) AppDeployerBase(addressResolver_, auctionManager_, sbType_) { creationCodeWithArgs[counter1] = abi.encodePacked(type(Counter).creationCode); creationCodeWithArgs[counter2] = abi.encodePacked(type(Counter).creationCode); - _setOverrides(false, false, 1000000, fees_); + _setOverrides(Read.OFF, Sequential.FALSE, 1000000, fees_); _claimOwner(msg.sender); } diff --git a/contracts/apps/super-token-lockable/SuperTokenLockableAppGateway.sol b/contracts/apps/super-token-lockable/SuperTokenLockableAppGateway.sol index ce282d4c..acd2c2e3 100644 --- a/contracts/apps/super-token-lockable/SuperTokenLockableAppGateway.sol +++ b/contracts/apps/super-token-lockable/SuperTokenLockableAppGateway.sol @@ -49,12 +49,12 @@ contract SuperTokenLockableAppGateway is AppGatewayBase, OwnableTwoStep { asyncId_ = _getCurrentAsyncId(); ISuperToken(order.srcToken).lockTokens(order.user, order.srcAmount); - _setOverrides(true); + _setOverrides(Read.ON); // goes to forwarder and deploys promise and stores it ISuperToken(order.srcToken).balanceOf(order.user); IPromise(order.srcToken).then(this.checkBalance.selector, abi.encode(order, asyncId_)); - _setOverrides(false); + _setOverrides(Read.OFF); ISuperToken(order.dstToken).mint(order.user, order.srcAmount); ISuperToken(order.srcToken).burn(order.user, order.srcAmount); diff --git a/contracts/base/AppGatewayBase.sol b/contracts/base/AppGatewayBase.sol index d88a7ff8..e276a2e1 100644 --- a/contracts/base/AppGatewayBase.sol +++ b/contracts/base/AppGatewayBase.sol @@ -20,6 +20,16 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin bytes public onCompleteData; bytes32 public sbType; + enum Read { + ON, + OFF + } + + enum Sequential { + TRUE, + FALSE + } + mapping(address => bool) public isValidPromise; /// @notice Modifier to treat functions async @@ -86,13 +96,13 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin /// @param gasLimit_ The gas limit /// @param isCallSequential_ The sequential call flag function _setOverrides( - bool isReadCall_, - bool isCallSequential_, + Read isReadCall_, + Sequential isCallSequential_, uint256 gasLimit_, Fees memory fees_ ) internal { - isReadCall = isReadCall_; - isCallSequential = isCallSequential_; + isReadCall = isReadCall_ == Read.ON; + isCallSequential = isCallSequential_ == Sequential.TRUE; gasLimit = gasLimit_; fees = fees_; } @@ -101,24 +111,34 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin /// @param isReadCall_ The read call flag /// @param isCallSequential_ The sequential call flag /// @param gasLimit_ The gas limit - function _setOverrides(bool isReadCall_, bool isCallSequential_, uint256 gasLimit_) internal { - isReadCall = isReadCall_; - isCallSequential = isCallSequential_; + function _setOverrides( + Read isReadCall_, + Sequential isCallSequential_, + uint256 gasLimit_ + ) internal { + isReadCall = isReadCall_ == Read.ON; + isCallSequential = isCallSequential_ == Sequential.TRUE; gasLimit = gasLimit_; } /// @notice Sets isReadCall and isCallSequential overrides /// @param isReadCall_ The read call flag /// @param isCallSequential_ The sequential call flag - function _setOverrides(bool isReadCall_, bool isCallSequential_) internal { - isReadCall = isReadCall_; - isCallSequential = isCallSequential_; + function _setOverrides(Read isReadCall_, Sequential isCallSequential_) internal { + isReadCall = isReadCall_ == Read.ON; + isCallSequential = isCallSequential_ == Sequential.TRUE; + } + + /// @notice Sets isReadCall and gasLimit overrides + /// @param isCallSequential_ The sequential call flag + function _setOverrides(Sequential isCallSequential_) internal { + isCallSequential = isCallSequential_ == Sequential.TRUE; } /// @notice Sets isReadCall and gasLimit overrides /// @param isReadCall_ The read call flag - function _setOverrides(bool isReadCall_) internal { - isReadCall = isReadCall_; + function _setOverrides(Read isReadCall_) internal { + isReadCall = isReadCall_ == Read.ON; } /// @notice Sets gasLimit overrides From 4501448e236b25a3c6340ec39a3a50864e31f074 Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Tue, 18 Feb 2025 18:02:59 +0400 Subject: [PATCH 5/7] fix: rename --- contracts/Forwarder.sol | 8 +-- contracts/apps/counter/CounterAppGateway.sol | 3 +- .../ParallelCounterAppGateway.sol | 2 +- .../ParallelCounterDeployer.sol | 2 +- .../app-gateway/BatchAsync.sol | 2 +- .../app-gateway/DeliveryHelper.sol | 4 +- .../app-gateway/FeesManager.sol | 4 +- .../app-gateway/QueueAsync.sol | 8 +-- contracts/base/AppDeployerBase.sol | 7 +-- contracts/base/AppGatewayBase.sol | 59 +++++++------------ contracts/common/Structs.sol | 14 ++++- contracts/interfaces/IAppGateway.sol | 6 +- contracts/interfaces/IDeliveryHelper.sol | 4 +- script/mock/FinalizeAndExecution.s.sol | 4 +- test/DeliveryHelper.t.sol | 2 +- 15 files changed, 61 insertions(+), 68 deletions(-) diff --git a/contracts/Forwarder.sol b/contracts/Forwarder.sol index 43e4656e..e0d0d86c 100644 --- a/contracts/Forwarder.sol +++ b/contracts/Forwarder.sol @@ -81,16 +81,16 @@ contract Forwarder is IForwarder, Initializable { ); // Determine if the call is a read or write operation. - bool isReadCall = IAppGateway(msg.sender).isReadCall(); - bool isCallSequential = IAppGateway(msg.sender).isCallSequential(); + Read isReadCall = IAppGateway(msg.sender).isReadCall(); + Parallel isParallelCall = IAppGateway(msg.sender).isParallelCall(); // Queue the call in the auction house. IDeliveryHelper(deliveryHelper).queue( - isCallSequential, + isParallelCall, chainSlug, onChainAddress, latestAsyncPromise, - isReadCall ? CallType.READ : CallType.WRITE, + isReadCall == Read.ON ? CallType.READ : CallType.WRITE, msg.data ); } diff --git a/contracts/apps/counter/CounterAppGateway.sol b/contracts/apps/counter/CounterAppGateway.sol index 0a588432..f0998e58 100644 --- a/contracts/apps/counter/CounterAppGateway.sol +++ b/contracts/apps/counter/CounterAppGateway.sol @@ -32,13 +32,12 @@ contract CounterAppGateway is AppGatewayBase { function readCounters(address[] memory instances_) public async { // the increase function is called on given list of instances // this - _setOverrides(Sequential.TRUE); for (uint256 i = 0; i < instances_.length; i++) { uint32 chainSlug = IForwarder(instances_[i]).getChainSlug(); ICounter(instances_[i]).getCounter(); IPromise(instances_[i]).then(this.setCounterValues.selector, abi.encode(chainSlug)); } - _setOverrides(Sequential.FALSE); + _setOverrides(Parallel.ON); ICounter(instances_[0]).increase(); } diff --git a/contracts/apps/parallel-counter/ParallelCounterAppGateway.sol b/contracts/apps/parallel-counter/ParallelCounterAppGateway.sol index 54dfda68..bdd1d3ea 100644 --- a/contracts/apps/parallel-counter/ParallelCounterAppGateway.sol +++ b/contracts/apps/parallel-counter/ParallelCounterAppGateway.sol @@ -12,7 +12,7 @@ contract ParallelCounterAppGateway is AppGatewayBase { Fees memory fees_ ) AppGatewayBase(addressResolver_, auctionManager_) { addressResolver__.setContractsToGateways(deployerContract_); - _setOverrides(Read.OFF, Sequential.TRUE, 1000000, fees_); + _setOverrides(Read.OFF, Parallel.OFF, 1000000, fees_); } function incrementCounters(address[] memory instances_) public async { diff --git a/contracts/apps/parallel-counter/ParallelCounterDeployer.sol b/contracts/apps/parallel-counter/ParallelCounterDeployer.sol index cb7e7762..e83e27bf 100644 --- a/contracts/apps/parallel-counter/ParallelCounterDeployer.sol +++ b/contracts/apps/parallel-counter/ParallelCounterDeployer.sol @@ -17,7 +17,7 @@ contract ParallelCounterDeployer is AppDeployerBase, OwnableTwoStep { ) AppDeployerBase(addressResolver_, auctionManager_, sbType_) { creationCodeWithArgs[counter1] = abi.encodePacked(type(Counter).creationCode); creationCodeWithArgs[counter2] = abi.encodePacked(type(Counter).creationCode); - _setOverrides(Read.OFF, Sequential.FALSE, 1000000, fees_); + _setOverrides(Read.OFF, Parallel.ON, 1000000, fees_); _claimOwner(msg.sender); } diff --git a/contracts/apps/payload-delivery/app-gateway/BatchAsync.sol b/contracts/apps/payload-delivery/app-gateway/BatchAsync.sol index 4cd0529d..2d432184 100644 --- a/contracts/apps/payload-delivery/app-gateway/BatchAsync.sol +++ b/contracts/apps/payload-delivery/app-gateway/BatchAsync.sol @@ -133,7 +133,7 @@ abstract contract BatchAsync is QueueAsync { while ( readEndIndex < payloadDetails_.length && payloadDetails_[readEndIndex].callType == CallType.READ && - !payloadDetails_[readEndIndex].isSequential + payloadDetails_[readEndIndex].isParallel == Parallel.ON ) { readEndIndex++; } diff --git a/contracts/apps/payload-delivery/app-gateway/DeliveryHelper.sol b/contracts/apps/payload-delivery/app-gateway/DeliveryHelper.sol index a8151dca..6c83d7e4 100644 --- a/contracts/apps/payload-delivery/app-gateway/DeliveryHelper.sol +++ b/contracts/apps/payload-delivery/app-gateway/DeliveryHelper.sol @@ -121,7 +121,7 @@ contract DeliveryHelper is BatchAsync, OwnableTwoStep, Initializable { IPromise(batchPromise).then(this.callback.selector, abi.encode(asyncId_)); // Handle batch processing based on type - if (!payloads[currentIndex].isSequential) { + if (payloads[currentIndex].isParallel == Parallel.ON) { _processParallelCalls(asyncId_, payloadBatch_, payloads, currentIndex, batchPromise); } else { _processSequentialCall( @@ -181,7 +181,7 @@ contract DeliveryHelper is BatchAsync, OwnableTwoStep, Initializable { if (startIndex_ >= payloads_.length) revert InvalidIndex(); uint256 endIndex = startIndex_; - while (endIndex + 1 < payloads_.length && !payloads_[endIndex + 1].isSequential) { + while (endIndex + 1 < payloads_.length && payloads_[endIndex + 1].isParallel == Parallel.ON) { endIndex++; } diff --git a/contracts/apps/payload-delivery/app-gateway/FeesManager.sol b/contracts/apps/payload-delivery/app-gateway/FeesManager.sol index 46037e00..d0aca1e2 100644 --- a/contracts/apps/payload-delivery/app-gateway/FeesManager.sol +++ b/contracts/apps/payload-delivery/app-gateway/FeesManager.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.0; import {OwnableTwoStep} from "../../../utils/OwnableTwoStep.sol"; import {SignatureVerifier} from "../../../socket/utils/SignatureVerifier.sol"; import {AddressResolverUtil} from "../../../utils/AddressResolverUtil.sol"; -import {Bid, Fees, PayloadDetails, CallType, FinalizeParams, PayloadBatch} from "../../../common/Structs.sol"; +import {Bid, Fees, PayloadDetails, CallType, FinalizeParams, PayloadBatch, Parallel} from "../../../common/Structs.sol"; import {IDeliveryHelper} from "../../../interfaces/IDeliveryHelper.sol"; import {FORWARD_CALL, DISTRIBUTE_FEE, DEPLOY, WITHDRAW} from "../../../common/Constants.sol"; import {IFeesPlug} from "../../../interfaces/IFeesPlug.sol"; @@ -299,7 +299,7 @@ contract FeesManager is IFeesManager, AddressResolverUtil, OwnableTwoStep, Initi callType: callType_, executionGasLimit: 1000000, next: new address[](2), - isSequential: true + isParallel: Parallel.OFF }); } diff --git a/contracts/apps/payload-delivery/app-gateway/QueueAsync.sol b/contracts/apps/payload-delivery/app-gateway/QueueAsync.sol index 9bfa2890..0b3d222c 100644 --- a/contracts/apps/payload-delivery/app-gateway/QueueAsync.sol +++ b/contracts/apps/payload-delivery/app-gateway/QueueAsync.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.21; import {AddressResolverUtil} from "../../../utils/AddressResolverUtil.sol"; -import {CallParams, Fees, PayloadDetails, CallType, Bid, PayloadBatch} from "../../../common/Structs.sol"; +import {CallParams, Fees, PayloadDetails, CallType, Bid, PayloadBatch, Parallel} from "../../../common/Structs.sol"; import {NotAuctionManager, InvalidPromise, InvalidIndex} from "../../../common/Errors.sol"; import {AsyncPromise} from "../../../AsyncPromise.sol"; import {IPromise} from "../../../interfaces/IPromise.sol"; @@ -66,7 +66,7 @@ abstract contract QueueAsync is AddressResolverUtil, IDeliveryHelper { /// @param callType_ The call type /// @param payload_ The payload function queue( - bool isSequential_, + Parallel isParallel_, uint32 chainSlug_, address target_, address asyncPromise_, @@ -82,7 +82,7 @@ abstract contract QueueAsync is AddressResolverUtil, IDeliveryHelper { target: target_, payload: payload_, gasLimit: 10000000, - isSequential: isSequential_ + isParallel: isParallel_ }) ); } @@ -148,7 +148,7 @@ abstract contract QueueAsync is AddressResolverUtil, IDeliveryHelper { callType: params_.callType, executionGasLimit: params_.gasLimit == 0 ? 1_000_000 : params_.gasLimit, next: next, - isSequential: params_.isSequential + isParallel: params_.isParallel }); } diff --git a/contracts/base/AppDeployerBase.sol b/contracts/base/AppDeployerBase.sol index ce88c123..14753fd8 100644 --- a/contracts/base/AppDeployerBase.sol +++ b/contracts/base/AppDeployerBase.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.21; import {DeployParams, Fees, CallType, PayloadBatch} from "../common/Structs.sol"; -import {AppGatewayBase} from "./AppGatewayBase.sol"; +import "./AppGatewayBase.sol"; import {IForwarder} from "../interfaces/IForwarder.sol"; import {IPromise} from "../interfaces/IPromise.sol"; import {IAppDeployer} from "../interfaces/IAppDeployer.sol"; @@ -32,7 +32,7 @@ abstract contract AppDeployerBase is AppGatewayBase, IAppDeployer { onCompleteData = abi.encode(chainSlug_); IDeliveryHelper(deliveryHelper()).queue( - isCallSequential, + isParallelCall, chainSlug_, address(0), asyncPromise, @@ -68,8 +68,7 @@ abstract contract AppDeployerBase is AppGatewayBase, IAppDeployer { return address(0); } - onChainAddress = IForwarder(forwarderAddresses[contractId_][chainSlug_]) - .getOnChainAddress(); + onChainAddress = IForwarder(forwarderAddresses[contractId_][chainSlug_]).getOnChainAddress(); } /// @notice Callback in pd promise to be called after all contracts are deployed diff --git a/contracts/base/AppGatewayBase.sol b/contracts/base/AppGatewayBase.sol index e276a2e1..6091f765 100644 --- a/contracts/base/AppGatewayBase.sol +++ b/contracts/base/AppGatewayBase.sol @@ -5,31 +5,21 @@ import "../utils/AddressResolverUtil.sol"; import "../interfaces/IDeliveryHelper.sol"; import "../interfaces/IAppGateway.sol"; import "../interfaces/IPromise.sol"; -import {Fees} from "../common/Structs.sol"; +import {Fees, Read, Parallel} from "../common/Structs.sol"; import {FeesPlugin} from "../utils/FeesPlugin.sol"; import {InvalidPromise, FeesNotSet} from "../common/Errors.sol"; /// @title AppGatewayBase /// @notice Abstract contract for the app gateway abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin { - bool public override isReadCall; - bool public override isCallSequential; + Read public override isReadCall; + Parallel public override isParallelCall; uint256 public override gasLimit; address public auctionManager; bytes public onCompleteData; bytes32 public sbType; - enum Read { - ON, - OFF - } - - enum Sequential { - TRUE, - FALSE - } - mapping(address => bool) public isValidPromise; /// @notice Modifier to treat functions async @@ -56,7 +46,6 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin constructor(address addressResolver_, address auctionManager_) { _setAddressResolver(addressResolver_); auctionManager = auctionManager_; - isCallSequential = true; } /// @notice Creates a contract ID @@ -94,51 +83,47 @@ abstract contract AppGatewayBase is AddressResolverUtil, IAppGateway, FeesPlugin /// @param isReadCall_ The read call flag /// @param fees_ The fees configuration /// @param gasLimit_ The gas limit - /// @param isCallSequential_ The sequential call flag + /// @param isParallelCall_ The sequential call flag function _setOverrides( Read isReadCall_, - Sequential isCallSequential_, + Parallel isParallelCall_, uint256 gasLimit_, Fees memory fees_ ) internal { - isReadCall = isReadCall_ == Read.ON; - isCallSequential = isCallSequential_ == Sequential.TRUE; + isReadCall = isReadCall_; + isParallelCall = isParallelCall_; gasLimit = gasLimit_; fees = fees_; } /// @notice Sets isReadCall, fees and gasLimit overrides /// @param isReadCall_ The read call flag - /// @param isCallSequential_ The sequential call flag + /// @param isParallelCall_ The sequential call flag /// @param gasLimit_ The gas limit - function _setOverrides( - Read isReadCall_, - Sequential isCallSequential_, - uint256 gasLimit_ - ) internal { - isReadCall = isReadCall_ == Read.ON; - isCallSequential = isCallSequential_ == Sequential.TRUE; + function _setOverrides(Read isReadCall_, Parallel isParallelCall_, uint256 gasLimit_) internal { + isReadCall = isReadCall_; + isParallelCall = isParallelCall_; gasLimit = gasLimit_; } - /// @notice Sets isReadCall and isCallSequential overrides + /// @notice Sets isReadCall and isParallelCall overrides /// @param isReadCall_ The read call flag - /// @param isCallSequential_ The sequential call flag - function _setOverrides(Read isReadCall_, Sequential isCallSequential_) internal { - isReadCall = isReadCall_ == Read.ON; - isCallSequential = isCallSequential_ == Sequential.TRUE; + /// @param isParallelCall_ The sequential call flag + function _setOverrides(Read isReadCall_, Parallel isParallelCall_) internal { + isReadCall = isReadCall_; + isParallelCall = isParallelCall_; } - /// @notice Sets isReadCall and gasLimit overrides - /// @param isCallSequential_ The sequential call flag - function _setOverrides(Sequential isCallSequential_) internal { - isCallSequential = isCallSequential_ == Sequential.TRUE; + /// @notice Sets isParallelCall overrides + /// @param isParallelCall_ The sequential call flag + function _setOverrides(Parallel isParallelCall_) internal { + isParallelCall = isParallelCall_; } - /// @notice Sets isReadCall and gasLimit overrides + /// @notice Sets isReadCall overrides /// @param isReadCall_ The read call flag function _setOverrides(Read isReadCall_) internal { - isReadCall = isReadCall_ == Read.ON; + isReadCall = isReadCall_; } /// @notice Sets gasLimit overrides diff --git a/contracts/common/Structs.sol b/contracts/common/Structs.sol index f32318b6..cfb05a6b 100644 --- a/contracts/common/Structs.sol +++ b/contracts/common/Structs.sol @@ -8,6 +8,16 @@ enum CallType { WITHDRAW } +enum Read { + OFF, + ON +} + +enum Parallel { + OFF, + ON +} + struct AppGatewayConfig { address plug; address appGateway; @@ -47,7 +57,7 @@ struct CallParams { address target; uint32 chainSlug; CallType callType; - bool isSequential; + Parallel isParallel; uint256 gasLimit; bytes payload; } @@ -104,7 +114,7 @@ struct PayloadDetails { address appGateway; address target; uint32 chainSlug; - bool isSequential; + Parallel isParallel; CallType callType; uint256 executionGasLimit; bytes payload; diff --git a/contracts/interfaces/IAppGateway.sol b/contracts/interfaces/IAppGateway.sol index 8cf706e2..ef83f275 100644 --- a/contracts/interfaces/IAppGateway.sol +++ b/contracts/interfaces/IAppGateway.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: Unlicense pragma solidity ^0.8.21; -import {PayloadBatch} from "../common/Structs.sol"; +import {PayloadBatch, Read, Parallel} from "../common/Structs.sol"; interface IAppGateway { - function isReadCall() external view returns (bool); + function isReadCall() external view returns (Read); - function isCallSequential() external view returns (bool); + function isParallelCall() external view returns (Parallel); function gasLimit() external view returns (uint256); diff --git a/contracts/interfaces/IDeliveryHelper.sol b/contracts/interfaces/IDeliveryHelper.sol index 15830cd3..2d9c8c29 100644 --- a/contracts/interfaces/IDeliveryHelper.sol +++ b/contracts/interfaces/IDeliveryHelper.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.3; -import {PayloadDetails, Bid, Fees, DeployParams, CallType, PayloadBatch} from "../common/Structs.sol"; +import {PayloadDetails, Bid, Fees, DeployParams, CallType, PayloadBatch, Parallel} from "../common/Structs.sol"; interface IDeliveryHelper { event BidPlaced( @@ -20,7 +20,7 @@ interface IDeliveryHelper { function clearQueue() external; function queue( - bool isSequential_, + Parallel isParallel_, uint32 chainSlug_, address target_, address asyncPromise_, diff --git a/script/mock/FinalizeAndExecution.s.sol b/script/mock/FinalizeAndExecution.s.sol index 042daadc..e77210d0 100644 --- a/script/mock/FinalizeAndExecution.s.sol +++ b/script/mock/FinalizeAndExecution.s.sol @@ -5,7 +5,7 @@ import {Script} from "forge-std/Script.sol"; import {console} from "forge-std/console.sol"; import {MockWatcherPrecompile} from "../../contracts/mock/MockWatcherPrecompile.sol"; import {MockSocket} from "../../contracts/mock/MockSocket.sol"; -import {CallType, FinalizeParams, PayloadDetails} from "../../contracts/common/Structs.sol"; +import {CallType, FinalizeParams, PayloadDetails, Parallel} from "../../contracts/common/Structs.sol"; contract InboxTest is Script { function run() external { string memory arbRpc = vm.envString("ARBITRUM_SEPOLIA_RPC"); @@ -29,7 +29,7 @@ contract InboxTest is Script { callType: CallType.WRITE, executionGasLimit: 1000000, next: new address[](0), - isSequential: true + isParallel: Parallel.OFF }); FinalizeParams memory finalizeParams = FinalizeParams({ payloadDetails: payloadDetails, diff --git a/test/DeliveryHelper.t.sol b/test/DeliveryHelper.t.sol index e3ba294b..22b9cba2 100644 --- a/test/DeliveryHelper.t.sol +++ b/test/DeliveryHelper.t.sol @@ -456,7 +456,7 @@ contract DeliveryHelperTest is SetupTest { callType: callType_, executionGasLimit: executionGasLimit_, next: next_, - isSequential: false + isParallel: Parallel.ON }); } From 3104d25a3fb216805ea6be5d62f980fc01a84ecd Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Tue, 18 Feb 2025 18:11:22 +0400 Subject: [PATCH 6/7] merge master --- .../apps/payload-delivery/app-gateway/DeliveryHelper.sol | 4 +++- contracts/base/AppDeployerBase.sol | 3 ++- lib/forge-std | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/contracts/apps/payload-delivery/app-gateway/DeliveryHelper.sol b/contracts/apps/payload-delivery/app-gateway/DeliveryHelper.sol index 6c83d7e4..c6c1c5b2 100644 --- a/contracts/apps/payload-delivery/app-gateway/DeliveryHelper.sol +++ b/contracts/apps/payload-delivery/app-gateway/DeliveryHelper.sol @@ -181,7 +181,9 @@ contract DeliveryHelper is BatchAsync, OwnableTwoStep, Initializable { if (startIndex_ >= payloads_.length) revert InvalidIndex(); uint256 endIndex = startIndex_; - while (endIndex + 1 < payloads_.length && payloads_[endIndex + 1].isParallel == Parallel.ON) { + while ( + endIndex + 1 < payloads_.length && payloads_[endIndex + 1].isParallel == Parallel.ON + ) { endIndex++; } diff --git a/contracts/base/AppDeployerBase.sol b/contracts/base/AppDeployerBase.sol index 14753fd8..9c85bebf 100644 --- a/contracts/base/AppDeployerBase.sol +++ b/contracts/base/AppDeployerBase.sol @@ -68,7 +68,8 @@ abstract contract AppDeployerBase is AppGatewayBase, IAppDeployer { return address(0); } - onChainAddress = IForwarder(forwarderAddresses[contractId_][chainSlug_]).getOnChainAddress(); + onChainAddress = IForwarder(forwarderAddresses[contractId_][chainSlug_]) + .getOnChainAddress(); } /// @notice Callback in pd promise to be called after all contracts are deployed diff --git a/lib/forge-std b/lib/forge-std index 1eea5bae..bf909b22 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit 1eea5bae12ae557d589f9f0f0edae2faa47cb262 +Subproject commit bf909b22fa55e244796dfa920c9639fdffa1c545 From e59253a4756a6ccab88fd314028596906b5daa97 Mon Sep 17 00:00:00 2001 From: Ameesha Agrawal Date: Tue, 18 Feb 2025 18:15:15 +0400 Subject: [PATCH 7/7] Merge branch 'staging' into overrides --- contracts/interfaces/IFeesManager.sol | 2 +- lib/solady | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/interfaces/IFeesManager.sol b/contracts/interfaces/IFeesManager.sol index 4e135fec..e686c2b7 100644 --- a/contracts/interfaces/IFeesManager.sol +++ b/contracts/interfaces/IFeesManager.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.3; import {Fees, Bid, PayloadDetails} from "../common/Structs.sol"; interface IFeesManager { - function blockFees(address appGateway_, Fees memory fees_, bytes32 asyncId_) external; + function blockFees(address appGateway_, Fees memory fees_, Bid memory winningBid_, bytes32 asyncId_) external; function updateTransmitterFees( Bid memory winningBid_, diff --git a/lib/solady b/lib/solady index 6c2d0da6..8583a6e3 160000 --- a/lib/solady +++ b/lib/solady @@ -1 +1 @@ -Subproject commit 6c2d0da6397e3c016aabc3f298de1b92c6ce7405 +Subproject commit 8583a6e386b897f3db142a541f86d5953eccd835