From c52d5a3ddc41629b0f4e667fc2ed3817af834a8b Mon Sep 17 00:00:00 2001 From: Rookmate <14072042+rookmate@users.noreply.github.com> Date: Mon, 10 Mar 2025 21:13:53 +0400 Subject: [PATCH 01/14] Split inbox interface to separate file --- script/inbox/RunEVMxInbox.s.sol | 3 ++- src/inbox/IInbox.sol | 8 ++++++++ src/inbox/InboxAppGateway.sol | 23 +++-------------------- 3 files changed, 13 insertions(+), 21 deletions(-) create mode 100644 src/inbox/IInbox.sol diff --git a/script/inbox/RunEVMxInbox.s.sol b/script/inbox/RunEVMxInbox.s.sol index c86c94a..9fe2c9a 100644 --- a/script/inbox/RunEVMxInbox.s.sol +++ b/script/inbox/RunEVMxInbox.s.sol @@ -3,7 +3,8 @@ pragma solidity ^0.8.0; import {console} from "forge-std/console.sol"; import {SetupScript} from "../SetupScript.sol"; -import {InboxAppGateway, IInbox} from "../../src/inbox/InboxAppGateway.sol"; +import {InboxAppGateway} from "../../src/inbox/InboxAppGateway.sol"; +import {IInbox} from "../../src/inbox/IInbox.sol"; contract RunEVMxInbox is SetupScript { InboxAppGateway inboxAppGateway; diff --git a/src/inbox/IInbox.sol b/src/inbox/IInbox.sol new file mode 100644 index 0000000..8c2dc7b --- /dev/null +++ b/src/inbox/IInbox.sol @@ -0,0 +1,8 @@ +pragma solidity ^0.8.0; + +interface IInbox { + function value() external returns (uint256); + function increaseOnGateway(uint256 value_) external returns (bytes32); + function propagateToAnother(uint32 targetChain) external returns (bytes32); + function updateFromGateway(uint256 value) external; +} diff --git a/src/inbox/InboxAppGateway.sol b/src/inbox/InboxAppGateway.sol index 62c5627..043640d 100644 --- a/src/inbox/InboxAppGateway.sol +++ b/src/inbox/InboxAppGateway.sol @@ -3,22 +3,7 @@ pragma solidity ^0.8.0; import "socket-protocol/contracts/base/AppGatewayBase.sol"; import "./Inbox.sol"; - -interface IInboxDeployer { - function inbox() external pure returns (bytes32 bytecode); - - function forwarderAddresses(bytes32 contractId_, uint32 chainSlug_) - external - view - returns (address forwarderAddress); -} - -interface IInbox { - function value() external returns (uint256); - function increaseOnGateway(uint256 value_) external returns (bytes32); - function propagateToAnother(uint32 targetChain) external returns (bytes32); - function updateFromGateway(uint256 value) external; -} +import "./IInbox.sol"; contract InboxAppGateway is AppGatewayBase { bytes32 public inbox = _createContractId("inbox"); @@ -43,8 +28,7 @@ contract InboxAppGateway is AppGatewayBase { } function updateOnchain(uint32 targetChain) public { - address inboxForwarderAddress = - IInboxDeployer(deployerAddress).forwarderAddresses(IInboxDeployer(deployerAddress).inbox(), targetChain); + address inboxForwarderAddress = this.forwarderAddresses(this.inbox(), targetChain); IInbox(inboxForwarderAddress).updateFromGateway(valueOnGateway); } @@ -55,8 +39,7 @@ contract InboxAppGateway is AppGatewayBase { valueOnGateway += valueOnchain; } else if (msgType == PROPAGATE_TO_ANOTHER) { (uint256 valueOnchain, uint32 targetChain) = abi.decode(payload, (uint256, uint32)); - address inboxForwarderAddress = - IInboxDeployer(deployerAddress).forwarderAddresses(IInboxDeployer(deployerAddress).inbox(), targetChain); + address inboxForwarderAddress = this.forwarderAddresses(this.inbox(), targetChain); IInbox(inboxForwarderAddress).updateFromGateway(valueOnchain); } else { revert("InboxGateway: invalid message type"); From 8b2719976c894cdf6819216f5eb30fc86245a11e Mon Sep 17 00:00:00 2001 From: Rookmate <14072042+rookmate@users.noreply.github.com> Date: Mon, 10 Mar 2025 21:47:23 +0400 Subject: [PATCH 02/14] Update README --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/README.md b/README.md index 460aef7..3e1b75a 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,49 @@ Finally, run the EVMx Read script: forge script script/read/RunEVMxRead.s.sol --broadcast --skip-simulation --with-gas-price 0 --legacy ``` +# Deployment Steps for EVMx Inbox Tests + +Follow these steps to deploy and run the EVMx Inbox tests. + +### 1. **Deploy the EVMx Inbox Tests Script** +Run the following command to deploy the EVMx Inbox tests script: +```bash +forge script script/inbox/DeployEVMxInboxTests.sol --broadcast --legacy --with-gas-price 0 +``` + +### 1a. **Verify the EVMx Contract** +Verify the `InboxAppGateway` contract on Blockscout: +```bash +forge verify-contract --rpc-url https://rpc-evmx-devnet.socket.tech/ --verifier blockscout --verifier-url https://evmx.cloud.blockscout.com/api src/inbox/InboxAppGateway.sol:InboxAppGateway +``` + +### 2. **Update the `APP_GATEWAY` in `.env`** +Make sure to update the `APP_GATEWAY` address in your `.env` file. + +### 3. **Pay Fees in Arbitrum ETH** +Run the script to pay fees in Arbitrum ETH: +```bash +forge script lib/socket-protocol/script/helpers/PayFeesInArbitrumETH.s.sol --broadcast --skip-simulation +``` + +### 4. **Deploy Onchain Contracts** +Deploy the onchain contracts using the following script: +```bash +forge script script/inbox/RunEVMxInbox.s.sol --broadcast --skip-simulation --with-gas-price 0 --legacy --sig "deployOnchainContracts()" +``` + +### 4a. **Verify the Onchain Contract** +Verify the `InboxMultichain` contract on Arbitrum Sepolia Blockscout: +```bash +forge verify-contract --rpc-url https://rpc.ankr.com/arbitrum_sepolia --verifier-url https://arbitrum-sepolia.blockscout.com/api --verifier blockscout src/inbox/InboxMultichain.sol:InboxMultichain +``` + +### 5. **Run EVMx Inbox Script** +Finally, run the EVMx Inbox script: +```bash +forge script script/inbox/RunEVMxInbox.s.sol --broadcast --skip-simulation --with-gas-price 0 --legacy +``` + # Deployment Steps for EVMx Write Tests Follow these steps to deploy and run the EVMx Write tests. From 8d8229ec6311badf714877ffa932f1fb7e3717a4 Mon Sep 17 00:00:00 2001 From: Rookmate <14072042+rookmate@users.noreply.github.com> Date: Tue, 11 Mar 2025 12:05:07 +0400 Subject: [PATCH 03/14] Rename files for consistency --- README.md | 8 ++++---- .../{DeployEVMxInbox.s.sol => DeployEVMxInboxTests.s.sol} | 0 ...{DeployEVMxReadTests.sol => DeployEVMxReadTests.s.sol} | 0 ...eployEVMxWriteTests.sol => DeployEVMxWriteTests.s.sol} | 0 src/inbox/IInbox.sol | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) rename script/inbox/{DeployEVMxInbox.s.sol => DeployEVMxInboxTests.s.sol} (100%) rename script/read/{DeployEVMxReadTests.sol => DeployEVMxReadTests.s.sol} (100%) rename script/write/{DeployEVMxWriteTests.sol => DeployEVMxWriteTests.s.sol} (100%) diff --git a/README.md b/README.md index 3e1b75a..bebded9 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Follow these steps to deploy and run the EVMx Read tests. ### 1. **Deploy the EVMx Read Tests Script** Run the following command to deploy the EVMx Read tests script: ```bash -forge script script/read/DeployEVMxReadTests.sol --broadcast --legacy --with-gas-price 0 +forge script script/read/DeployEVMxReadTests.s.sol --broadcast --legacy --with-gas-price 0 ``` ### 1a. **Verify the EVMx Contract** @@ -48,7 +48,7 @@ Follow these steps to deploy and run the EVMx Inbox tests. ### 1. **Deploy the EVMx Inbox Tests Script** Run the following command to deploy the EVMx Inbox tests script: ```bash -forge script script/inbox/DeployEVMxInboxTests.sol --broadcast --legacy --with-gas-price 0 +forge script script/inbox/DeployEVMxInboxTests.s.sol --broadcast --legacy --with-gas-price 0 ``` ### 1a. **Verify the EVMx Contract** @@ -75,7 +75,7 @@ forge script script/inbox/RunEVMxInbox.s.sol --broadcast --skip-simulation --wit ### 4a. **Verify the Onchain Contract** Verify the `InboxMultichain` contract on Arbitrum Sepolia Blockscout: ```bash -forge verify-contract --rpc-url https://rpc.ankr.com/arbitrum_sepolia --verifier-url https://arbitrum-sepolia.blockscout.com/api --verifier blockscout src/inbox/InboxMultichain.sol:InboxMultichain +forge verify-contract --rpc-url https://rpc.ankr.com/arbitrum_sepolia --verifier-url https://arbitrum-sepolia.blockscout.com/api --verifier blockscout src/inbox/Inbox.sol:Inbox ``` ### 5. **Run EVMx Inbox Script** @@ -91,7 +91,7 @@ Follow these steps to deploy and run the EVMx Write tests. ### 1. **Deploy the EVMx Write Tests Script** Run the following command to deploy the EVMx Write tests script: ```bash -forge script script/write/DeployEVMxWriteTests.sol --broadcast --legacy --with-gas-price 0 +forge script script/write/DeployEVMxWriteTests.s.sol --broadcast --legacy --with-gas-price 0 ``` ### 1a. **Verify the Contract** diff --git a/script/inbox/DeployEVMxInbox.s.sol b/script/inbox/DeployEVMxInboxTests.s.sol similarity index 100% rename from script/inbox/DeployEVMxInbox.s.sol rename to script/inbox/DeployEVMxInboxTests.s.sol diff --git a/script/read/DeployEVMxReadTests.sol b/script/read/DeployEVMxReadTests.s.sol similarity index 100% rename from script/read/DeployEVMxReadTests.sol rename to script/read/DeployEVMxReadTests.s.sol diff --git a/script/write/DeployEVMxWriteTests.sol b/script/write/DeployEVMxWriteTests.s.sol similarity index 100% rename from script/write/DeployEVMxWriteTests.sol rename to script/write/DeployEVMxWriteTests.s.sol diff --git a/src/inbox/IInbox.sol b/src/inbox/IInbox.sol index 8c2dc7b..90044f6 100644 --- a/src/inbox/IInbox.sol +++ b/src/inbox/IInbox.sol @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.0; interface IInbox { From 3f22da2160877cbbbf99d18ef936db904cd68aa7 Mon Sep 17 00:00:00 2001 From: Rookmate <14072042+rookmate@users.noreply.github.com> Date: Tue, 11 Mar 2025 12:05:41 +0400 Subject: [PATCH 04/14] Add OP Sepolia RPC --- script/SetupScript.sol | 1 + script/inbox/RunEVMxInbox.s.sol | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/script/SetupScript.sol b/script/SetupScript.sol index 656705e..12e3b13 100644 --- a/script/SetupScript.sol +++ b/script/SetupScript.sol @@ -18,6 +18,7 @@ abstract contract SetupScript is Script { // ----- ENVIRONMENT VARIABLES ----- string rpcEVMx = vm.envString("EVMX_RPC"); string rpcArbSepolia = vm.envString("ARBITRUM_SEPOLIA_RPC"); + string rpcOPSepolia = vm.envString("OPTIMISM_SEPOLIA_RPC"); address addressResolver = vm.envAddress("ADDRESS_RESOLVER"); address feesPlugArbSepolia = vm.envAddress("ARBITRUM_FEES_PLUG"); address feesManagerAddress = vm.envAddress("FEES_MANAGER"); diff --git a/script/inbox/RunEVMxInbox.s.sol b/script/inbox/RunEVMxInbox.s.sol index 9fe2c9a..bf5be70 100644 --- a/script/inbox/RunEVMxInbox.s.sol +++ b/script/inbox/RunEVMxInbox.s.sol @@ -28,15 +28,28 @@ contract RunEVMxInbox is SetupScript { address opSepInboxAddress = inboxAppGateway.getOnChainAddress(inboxAppGateway.inbox(), opSepChainId); address arbSepInboxAddress = inboxAppGateway.getOnChainAddress(inboxAppGateway.inbox(), arbSepChainId); + vm.createSelectFork(rpcArbSepolia); + vm.startBroadcast(privateKey); + + IInbox(arbSepInboxAddress).increaseOnGateway(5); + + vm.stopBroadcast(); vm.createSelectFork(rpcEVMx); vm.startBroadcast(privateKey); - IInbox(opSepInboxAddress).increaseOnGateway(5); - require(inboxAppGateway.valueOnGateway() != 5, "Expected the same value"); + // TODO: Wait for event? or wait until read is 5 not sure how to handle this on foundry script + console.log(inboxAppGateway.valueOnGateway()); inboxAppGateway.updateOnchain(opSepChainId); - require(IInbox(opSepInboxAddress).value() != 5, "Expected the same value"); + + vm.stopBroadcast(); + vm.createSelectFork(rpcOPSepolia); + vm.startBroadcast(privateKey); + + // TODO: Wait for event? or wait until read is 5 not sure how to handle this on foundry script + console.log(IInbox(opSepInboxAddress).value()); IInbox(opSepInboxAddress).propagateToAnother(arbSepChainId); - require(IInbox(arbSepInboxAddress).value() != 5, "Expected the same value"); + // TODO: Wait for event? or wait until read is 5 not sure how to handle this on foundry script + console.log(IInbox(arbSepInboxAddress).value()); vm.stopBroadcast(); console.log("All inbox transactions executed successfully"); From 1a08f3d4c07fd9b9721ac9b87cd6b1714e0f76de Mon Sep 17 00:00:00 2001 From: Rookmate <14072042+rookmate@users.noreply.github.com> Date: Tue, 11 Mar 2025 12:06:04 +0400 Subject: [PATCH 05/14] Fix function was not async --- src/inbox/InboxAppGateway.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/inbox/InboxAppGateway.sol b/src/inbox/InboxAppGateway.sol index 043640d..5a99a75 100644 --- a/src/inbox/InboxAppGateway.sol +++ b/src/inbox/InboxAppGateway.sol @@ -27,8 +27,8 @@ contract InboxAppGateway is AppGatewayBase { return; } - function updateOnchain(uint32 targetChain) public { - address inboxForwarderAddress = this.forwarderAddresses(this.inbox(), targetChain); + function updateOnchain(uint32 targetChain) public async { + address inboxForwarderAddress = forwarderAddresses[inbox][targetChain]; IInbox(inboxForwarderAddress).updateFromGateway(valueOnGateway); } @@ -39,7 +39,7 @@ contract InboxAppGateway is AppGatewayBase { valueOnGateway += valueOnchain; } else if (msgType == PROPAGATE_TO_ANOTHER) { (uint256 valueOnchain, uint32 targetChain) = abi.decode(payload, (uint256, uint32)); - address inboxForwarderAddress = this.forwarderAddresses(this.inbox(), targetChain); + address inboxForwarderAddress = forwarderAddresses[inbox][targetChain]; IInbox(inboxForwarderAddress).updateFromGateway(valueOnchain); } else { revert("InboxGateway: invalid message type"); From 3cfa22f1ef924c9cd607604e9861ae1614ecf069 Mon Sep 17 00:00:00 2001 From: Rookmate <14072042+rookmate@users.noreply.github.com> Date: Tue, 11 Mar 2025 13:19:36 +0400 Subject: [PATCH 06/14] Breakdown inbox steps. Foundry does not support multi-chain --- README.md | 10 ++++- script/inbox/RunEVMxInbox.s.sol | 66 +++++++++++++++++++++------------ 2 files changed, 52 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index bebded9..2857433 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,15 @@ Follow these steps to deploy and run the EVMx Write tests. ### 1. **Deploy the EVMx Write Tests Script** Run the following command to deploy the EVMx Write tests script: ```bash -forge script script/write/DeployEVMxWriteTests.s.sol --broadcast --legacy --with-gas-price 0 +forge script script/write/DeployEVMxWriteTests.s.sol --broadcast --sig "onchainToEVMx()" +``` + +```bash +forge script script/write/DeployEVMxWriteTests.s.sol --broadcast --legacy --with-gas-price 0 --sig "eVMxToOnchain()" +``` + +```bash +forge script script/write/DeployEVMxWriteTests.s.sol --broadcast --sig "onchainToOnchain()" ``` ### 1a. **Verify the Contract** diff --git a/script/inbox/RunEVMxInbox.s.sol b/script/inbox/RunEVMxInbox.s.sol index bf5be70..1e8478f 100644 --- a/script/inbox/RunEVMxInbox.s.sol +++ b/script/inbox/RunEVMxInbox.s.sol @@ -10,6 +10,9 @@ contract RunEVMxInbox is SetupScript { InboxAppGateway inboxAppGateway; address opSepForwarder; address arbSepForwarder; + address opSepInboxAddress; + address arbSepInboxAddress; + uint8 step; function appGateway() internal view override returns (address) { return address(inboxAppGateway); @@ -25,39 +28,39 @@ contract RunEVMxInbox is SetupScript { } function inboxTransactions() internal { - address opSepInboxAddress = inboxAppGateway.getOnChainAddress(inboxAppGateway.inbox(), opSepChainId); - address arbSepInboxAddress = inboxAppGateway.getOnChainAddress(inboxAppGateway.inbox(), arbSepChainId); + // TODO: Emit event on each update to easily track and update + if (step == 1) { + vm.createSelectFork(rpcArbSepolia); + vm.startBroadcast(privateKey); - vm.createSelectFork(rpcArbSepolia); - vm.startBroadcast(privateKey); + IInbox(arbSepInboxAddress).increaseOnGateway(5); - IInbox(arbSepInboxAddress).increaseOnGateway(5); + vm.stopBroadcast(); + } else if (step == 2) { + // TODO: Emit event on each update to easily track and update + vm.createSelectFork(rpcEVMx); + vm.startBroadcast(privateKey); - vm.stopBroadcast(); - vm.createSelectFork(rpcEVMx); - vm.startBroadcast(privateKey); - - // TODO: Wait for event? or wait until read is 5 not sure how to handle this on foundry script - console.log(inboxAppGateway.valueOnGateway()); - inboxAppGateway.updateOnchain(opSepChainId); + inboxAppGateway.updateOnchain(opSepChainId); - vm.stopBroadcast(); - vm.createSelectFork(rpcOPSepolia); - vm.startBroadcast(privateKey); + vm.stopBroadcast(); + } else if (step == 3) { + // TODO: Emit event on each update to easily track and update + vm.createSelectFork(rpcOPSepolia); + vm.startBroadcast(privateKey); - // TODO: Wait for event? or wait until read is 5 not sure how to handle this on foundry script - console.log(IInbox(opSepInboxAddress).value()); - IInbox(opSepInboxAddress).propagateToAnother(arbSepChainId); - // TODO: Wait for event? or wait until read is 5 not sure how to handle this on foundry script - console.log(IInbox(arbSepInboxAddress).value()); + IInbox(opSepInboxAddress).propagateToAnother(arbSepChainId); - vm.stopBroadcast(); + vm.stopBroadcast(); + } console.log("All inbox transactions executed successfully"); } // Initialize contract references function init() internal { inboxAppGateway = InboxAppGateway(appGatewayAddress); + opSepInboxAddress = inboxAppGateway.getOnChainAddress(inboxAppGateway.inbox(), opSepChainId); + arbSepInboxAddress = inboxAppGateway.getOnChainAddress(inboxAppGateway.inbox(), arbSepChainId); } function executeScriptSpecificLogic() internal override { @@ -66,12 +69,29 @@ contract RunEVMxInbox is SetupScript { inboxTransactions(); } - function run() external { - _run(arbSepChainId); + function run() external pure { + console.log( + "Please call one of these external functions: onchainToEVMx(), eVMxToOnchain(), or onchainToOnchain()" + ); } function deployOnchainContracts() external { init(); _deployOnchainContracts(); } + + function onchainToEVMx() external { + step = 1; + _run(arbSepChainId); + } + + function eVMxToOnchain() external { + step = 2; + _run(arbSepChainId); + } + + function onchainToOnchain() external { + step = 3; + _run(arbSepChainId); + } } From f14e5e8423f3eddf76d1de53e62dbc2b693cb9a2 Mon Sep 17 00:00:00 2001 From: Rookmate <14072042+rookmate@users.noreply.github.com> Date: Tue, 11 Mar 2025 13:27:16 +0400 Subject: [PATCH 07/14] Fix README --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2857433..384ecc1 100644 --- a/README.md +++ b/README.md @@ -81,16 +81,6 @@ forge verify-contract --rpc-url https://rpc.ankr.com/arbitrum_sepolia --verifier ### 5. **Run EVMx Inbox Script** Finally, run the EVMx Inbox script: ```bash -forge script script/inbox/RunEVMxInbox.s.sol --broadcast --skip-simulation --with-gas-price 0 --legacy -``` - -# Deployment Steps for EVMx Write Tests - -Follow these steps to deploy and run the EVMx Write tests. - -### 1. **Deploy the EVMx Write Tests Script** -Run the following command to deploy the EVMx Write tests script: -```bash forge script script/write/DeployEVMxWriteTests.s.sol --broadcast --sig "onchainToEVMx()" ``` @@ -102,6 +92,16 @@ forge script script/write/DeployEVMxWriteTests.s.sol --broadcast --legacy --with forge script script/write/DeployEVMxWriteTests.s.sol --broadcast --sig "onchainToOnchain()" ``` +# Deployment Steps for EVMx Write Tests + +Follow these steps to deploy and run the EVMx Write tests. + +### 1. **Deploy the EVMx Write Tests Script** +Run the following command to deploy the EVMx Write tests script: +```bash +forge script script/write/DeployEVMxWriteTests.s.sol --broadcast --legacy --with-gas-price 0 --sig "onchainToEVMx()" +``` + ### 1a. **Verify the Contract** Verify the `WriteAppGateway` contract on Blockscout: ```bash From d65ce5f758757642a5c96b53662a6f92080288e3 Mon Sep 17 00:00:00 2001 From: Rookmate <14072042+rookmate@users.noreply.github.com> Date: Tue, 11 Mar 2025 15:40:07 +0400 Subject: [PATCH 08/14] Add deploy AppGateway from same script --- README.md | 6 +++--- script/SetupScript.sol | 19 +++++++++++++++++ script/inbox/DeployEVMxInboxTests.s.sol | 28 ------------------------- script/inbox/RunEVMxInbox.s.sol | 13 +++++++++++- 4 files changed, 34 insertions(+), 32 deletions(-) delete mode 100644 script/inbox/DeployEVMxInboxTests.s.sol diff --git a/README.md b/README.md index 384ecc1..d5a4dcb 100644 --- a/README.md +++ b/README.md @@ -81,15 +81,15 @@ forge verify-contract --rpc-url https://rpc.ankr.com/arbitrum_sepolia --verifier ### 5. **Run EVMx Inbox Script** Finally, run the EVMx Inbox script: ```bash -forge script script/write/DeployEVMxWriteTests.s.sol --broadcast --sig "onchainToEVMx()" +forge script script/inbox/RunEVMxInbox.s.sol --broadcast --sig "onchainToEVMx()" ``` ```bash -forge script script/write/DeployEVMxWriteTests.s.sol --broadcast --legacy --with-gas-price 0 --sig "eVMxToOnchain()" +forge script script/inbox/RunEVMxInbox.s.sol --broadcast --legacy --with-gas-price 0 --sig "eVMxToOnchain()" ``` ```bash -forge script script/write/DeployEVMxWriteTests.s.sol --broadcast --sig "onchainToOnchain()" +forge script script/inbox/RunEVMxInbox.s.sol --broadcast --sig "onchainToOnchain()" ``` # Deployment Steps for EVMx Write Tests diff --git a/script/SetupScript.sol b/script/SetupScript.sol index 12e3b13..ba99dfe 100644 --- a/script/SetupScript.sol +++ b/script/SetupScript.sol @@ -31,6 +31,7 @@ abstract contract SetupScript is Script { uint32[2] chainIds = [opSepChainId, arbSepChainId]; Fees fees = Fees({feePoolChain: arbSepChainId, feePoolToken: ETH_ADDRESS, amount: 0.001 ether}); + Fees deployFees = Fees({feePoolChain: arbSepChainId, feePoolToken: ETH_ADDRESS, amount: 0.0005 ether}); FeesManager feesManager = FeesManager(payable(feesManagerAddress)); FeesPlug feesPlug = FeesPlug(payable(feesPlugArbSepolia)); @@ -100,9 +101,27 @@ abstract contract SetupScript is Script { console.log("Contracts deployed"); } + // Deploy new AppGateway on EVMx + function _deployAppGateway() internal virtual returns (address newAppGateway) { + vm.createSelectFork(rpcEVMx); + vm.startBroadcast(privateKey); + + newAppGateway = deployAppGatewayContract(); + + vm.stopBroadcast(); + + console.log("New AppGateway deployed at:", newAppGateway); + console.log("See AppGateway on EVMx: https://evmx.cloud.blockscout.com/address/%s", newAppGateway); + + return newAppGateway; + } + // Abstract functions to be implemented by child contracts function appGateway() internal view virtual returns (address); + // Function to be overridden by child contracts to deploy specific AppGateway implementation + function deployAppGatewayContract() internal virtual returns (address); + // Standard flow // Each implementation script will call these functions function _run(uint32 chainId) internal { diff --git a/script/inbox/DeployEVMxInboxTests.s.sol b/script/inbox/DeployEVMxInboxTests.s.sol deleted file mode 100644 index 88c7a4b..0000000 --- a/script/inbox/DeployEVMxInboxTests.s.sol +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {Script} from "forge-std/Script.sol"; -import {console} from "forge-std/console.sol"; -import {Fees} from "socket-protocol/contracts/protocol/utils/common/Structs.sol"; -import {ETH_ADDRESS} from "socket-protocol/contracts/protocol/utils/common/Constants.sol"; - -import {InboxAppGateway} from "../../src/inbox/InboxAppGateway.sol"; - -contract DeployEVMxContracts is Script { - function run() external { - address addressResolver = vm.envAddress("ADDRESS_RESOLVER"); - string memory rpc = vm.envString("EVMX_RPC"); - vm.createSelectFork(rpc); - - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(deployerPrivateKey); - - Fees memory fees = Fees({feePoolChain: 421614, feePoolToken: ETH_ADDRESS, amount: 0.0005 ether}); - - InboxAppGateway appGateway = new InboxAppGateway(addressResolver, fees); - - console.log("Contracts deployed:"); - console.log("AppGateway:", address(appGateway)); - console.log("See AppGateway on EVMx: https://evmx.cloud.blockscout.com/address/%s", address(appGateway)); - } -} diff --git a/script/inbox/RunEVMxInbox.s.sol b/script/inbox/RunEVMxInbox.s.sol index 1e8478f..9154066 100644 --- a/script/inbox/RunEVMxInbox.s.sol +++ b/script/inbox/RunEVMxInbox.s.sol @@ -18,6 +18,12 @@ contract RunEVMxInbox is SetupScript { return address(inboxAppGateway); } + function deployAppGatewayContract() internal override returns (address) { + // Deploy InboxAppGateway + InboxAppGateway newGateway = new InboxAppGateway(addressResolver, deployFees); + return address(newGateway); + } + function getForwarderAddresses() internal { vm.createSelectFork(rpcEVMx); opSepForwarder = inboxAppGateway.forwarderAddresses(inboxAppGateway.inbox(), opSepChainId); @@ -71,10 +77,15 @@ contract RunEVMxInbox is SetupScript { function run() external pure { console.log( - "Please call one of these external functions: onchainToEVMx(), eVMxToOnchain(), or onchainToOnchain()" + "Please call one of these external functions: deployAppGateway(), deployOnchainContracts(), onchainToEVMx(), eVMxToOnchain(), or onchainToOnchain()" ); } + function deployAppGateway() external { + address newGateway = _deployAppGateway(); + console.log("AppGateway deployed. Set APP_GATEWAY environment variable to:", newGateway); + } + function deployOnchainContracts() external { init(); _deployOnchainContracts(); From 36fa512c01ae852ec1837758ce56187ee17f4f05 Mon Sep 17 00:00:00 2001 From: Rookmate <14072042+rookmate@users.noreply.github.com> Date: Tue, 11 Mar 2025 15:41:23 +0400 Subject: [PATCH 09/14] Add initialize set to enable Plug to send EVMx requests --- src/inbox/InboxAppGateway.sol | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/inbox/InboxAppGateway.sol b/src/inbox/InboxAppGateway.sol index 5a99a75..8fe02fe 100644 --- a/src/inbox/InboxAppGateway.sol +++ b/src/inbox/InboxAppGateway.sol @@ -23,8 +23,8 @@ contract InboxAppGateway is AppGatewayBase { _deploy(inbox, chainSlug_, IsPlug.YES); } - function initialize(uint32) public pure override { - return; + function initialize(uint32 chainSlug_) public override { + setValidPlug(chainSlug_, inbox, true); } function updateOnchain(uint32 targetChain) public async { @@ -50,6 +50,16 @@ contract InboxAppGateway is AppGatewayBase { fees = fees_; } + /// @notice Sets the validity of an on-chain contract (plug) to authorize it to send information to a specific AppGateway + /// @param chainSlug_ The unique identifier of the chain where the contract resides + /// @param contractId The bytes32 identifier of the contract to be validated + /// @param isValid Boolean flag indicating whether the contract is authorized (true) or not (false) + /// @dev This function retrieves the onchain address using the contractId and chainSlug, then calls the watcher precompile to update the plug's validity status + function setValidPlug(uint32 chainSlug_, bytes32 contractId, bool isValid) public { + address onchainAddress = getOnChainAddress(contractId, chainSlug_); + watcherPrecompile__().setIsValidPlug(chainSlug_, onchainAddress, isValid); + } + function withdrawFeeTokens(uint32 chainSlug_, address token_, uint256 amount_, address receiver_) external { _withdrawFeeTokens(chainSlug_, token_, amount_, receiver_); } From 816b39ee4ac73da9044b4bced5444e8a72c4ff2a Mon Sep 17 00:00:00 2001 From: Rookmate <14072042+rookmate@users.noreply.github.com> Date: Tue, 11 Mar 2025 15:48:24 +0400 Subject: [PATCH 10/14] Update scripts to use new SetupScript --- README.md | 6 ++-- script/SetupScript.sol | 1 + .../DeployEVMxDeploymentMistakesApp.s.sol | 28 ------------------- .../RunEVMxDeploymentMistakes.s.sol | 20 +++++++++++-- script/inbox/RunEVMxInbox.s.sol | 3 +- script/read/DeployEVMxReadTests.s.sol | 28 ------------------- script/read/RunEVMxRead.s.sol | 20 +++++++++++-- script/write/DeployEVMxWriteTests.s.sol | 28 ------------------- script/write/RunEVMxWrite.s.sol | 20 +++++++++++-- 9 files changed, 59 insertions(+), 95 deletions(-) delete mode 100644 script/deployment-mistakes/DeployEVMxDeploymentMistakesApp.s.sol delete mode 100644 script/read/DeployEVMxReadTests.s.sol delete mode 100644 script/write/DeployEVMxWriteTests.s.sol diff --git a/README.md b/README.md index d5a4dcb..787be82 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Follow these steps to deploy and run the EVMx Read tests. ### 1. **Deploy the EVMx Read Tests Script** Run the following command to deploy the EVMx Read tests script: ```bash -forge script script/read/DeployEVMxReadTests.s.sol --broadcast --legacy --with-gas-price 0 +forge script script/read/RunEVMxRead.s.sol --broadcast --skip-simulation --with-gas-price 0 --legacy --sig "deployAppGateway()" ``` ### 1a. **Verify the EVMx Contract** @@ -48,7 +48,7 @@ Follow these steps to deploy and run the EVMx Inbox tests. ### 1. **Deploy the EVMx Inbox Tests Script** Run the following command to deploy the EVMx Inbox tests script: ```bash -forge script script/inbox/DeployEVMxInboxTests.s.sol --broadcast --legacy --with-gas-price 0 +forge script script/inbox/RunEVMxInbox.s.sol --broadcast --skip-simulation --with-gas-price 0 --legacy --sig "deployAppGateway()" ``` ### 1a. **Verify the EVMx Contract** @@ -99,7 +99,7 @@ Follow these steps to deploy and run the EVMx Write tests. ### 1. **Deploy the EVMx Write Tests Script** Run the following command to deploy the EVMx Write tests script: ```bash -forge script script/write/DeployEVMxWriteTests.s.sol --broadcast --legacy --with-gas-price 0 --sig "onchainToEVMx()" +forge script script/write/RunEVMxWrite.s.sol --broadcast --skip-simulation --with-gas-price 0 --legacy --sig "deployAppGateway()" ``` ### 1a. **Verify the Contract** diff --git a/script/SetupScript.sol b/script/SetupScript.sol index ba99dfe..1d8caec 100644 --- a/script/SetupScript.sol +++ b/script/SetupScript.sol @@ -112,6 +112,7 @@ abstract contract SetupScript is Script { console.log("New AppGateway deployed at:", newAppGateway); console.log("See AppGateway on EVMx: https://evmx.cloud.blockscout.com/address/%s", newAppGateway); + console.log("Set APP_GATEWAY environment variable to:", newAppGateway); return newAppGateway; } diff --git a/script/deployment-mistakes/DeployEVMxDeploymentMistakesApp.s.sol b/script/deployment-mistakes/DeployEVMxDeploymentMistakesApp.s.sol deleted file mode 100644 index 309abed..0000000 --- a/script/deployment-mistakes/DeployEVMxDeploymentMistakesApp.s.sol +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {Script} from "forge-std/Script.sol"; -import {console} from "forge-std/console.sol"; -import {Fees} from "socket-protocol/contracts/protocol/utils/common/Structs.sol"; -import {ETH_ADDRESS} from "socket-protocol/contracts/protocol/utils/common/Constants.sol"; - -import {DeploymentMistakesAppGateway} from "../../src/deployment-mistakes/DeploymentMistakesAppGateway.sol"; - -contract DeployEVMxContracts is Script { - function run() external { - address addressResolver = vm.envAddress("ADDRESS_RESOLVER"); - string memory rpc = vm.envString("EVMX_RPC"); - vm.createSelectFork(rpc); - - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(deployerPrivateKey); - - Fees memory fees = Fees({feePoolChain: 421614, feePoolToken: ETH_ADDRESS, amount: 0.0005 ether}); - - DeploymentMistakesAppGateway appGateway = new DeploymentMistakesAppGateway(addressResolver, fees); - - console.log("Contracts deployed:"); - console.log("DeploymentMistakesAppGateway:", address(appGateway)); - console.log("See AppGateway on EVMx: https://evmx.cloud.blockscout.com/address/%s", address(appGateway)); - } -} diff --git a/script/deployment-mistakes/RunEVMxDeploymentMistakes.s.sol b/script/deployment-mistakes/RunEVMxDeploymentMistakes.s.sol index 12e8584..c707ae1 100644 --- a/script/deployment-mistakes/RunEVMxDeploymentMistakes.s.sol +++ b/script/deployment-mistakes/RunEVMxDeploymentMistakes.s.sol @@ -26,6 +26,12 @@ contract RunEVMxDeploymentMistakes is SetupScript { return address(mistakesAppGateway); } + function deployAppGatewayContract() internal override returns (address) { + // Deploy DeploymentMistakesAppGateway + DeploymentMistakesAppGateway newGateway = new DeploymentMistakesAppGateway(addressResolver, deployFees); + return address(newGateway); + } + function getForwarderAddresses() internal { vm.createSelectFork(rpcEVMx); @@ -111,12 +117,22 @@ contract RunEVMxDeploymentMistakes is SetupScript { validateMistakes(); } - function run() external { - _run(arbSepChainId); + function run() external pure { + console.log( + "Please call one of these external functions: deployAppGateway(), deployOnchainContracts(), or runTests()" + ); + } + + function deployAppGateway() external { + _deployAppGateway(); } function deployOnchainContracts() external { init(); _deployOnchainContracts(); } + + function runTests() external { + _run(arbSepChainId); + } } diff --git a/script/inbox/RunEVMxInbox.s.sol b/script/inbox/RunEVMxInbox.s.sol index 9154066..967a2df 100644 --- a/script/inbox/RunEVMxInbox.s.sol +++ b/script/inbox/RunEVMxInbox.s.sol @@ -82,8 +82,7 @@ contract RunEVMxInbox is SetupScript { } function deployAppGateway() external { - address newGateway = _deployAppGateway(); - console.log("AppGateway deployed. Set APP_GATEWAY environment variable to:", newGateway); + _deployAppGateway(); } function deployOnchainContracts() external { diff --git a/script/read/DeployEVMxReadTests.s.sol b/script/read/DeployEVMxReadTests.s.sol deleted file mode 100644 index 763c6be..0000000 --- a/script/read/DeployEVMxReadTests.s.sol +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {Script} from "forge-std/Script.sol"; -import {console} from "forge-std/console.sol"; -import {Fees} from "socket-protocol/contracts/protocol/utils/common/Structs.sol"; -import {ETH_ADDRESS} from "socket-protocol/contracts/protocol/utils/common/Constants.sol"; - -import {ReadAppGateway} from "../../src/read/ReadAppGateway.sol"; - -contract DeployEVMxContracts is Script { - function run() external { - address addressResolver = vm.envAddress("ADDRESS_RESOLVER"); - string memory rpc = vm.envString("EVMX_RPC"); - vm.createSelectFork(rpc); - - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(deployerPrivateKey); - - Fees memory fees = Fees({feePoolChain: 421614, feePoolToken: ETH_ADDRESS, amount: 0.0005 ether}); - - ReadAppGateway appGateway = new ReadAppGateway(addressResolver, fees); - - console.log("Contracts deployed:"); - console.log("AppGateway:", address(appGateway)); - console.log("See AppGateway on EVMx: https://evmx.cloud.blockscout.com/address/%s", address(appGateway)); - } -} diff --git a/script/read/RunEVMxRead.s.sol b/script/read/RunEVMxRead.s.sol index b5aa387..9e52a78 100644 --- a/script/read/RunEVMxRead.s.sol +++ b/script/read/RunEVMxRead.s.sol @@ -14,6 +14,12 @@ contract RunEVMxRead is SetupScript { return address(readAppGateway); } + function deployAppGatewayContract() internal override returns (address) { + // Deploy ReadAppGateway + ReadAppGateway newGateway = new ReadAppGateway(addressResolver, deployFees); + return address(newGateway); + } + function getForwarderAddresses() internal { vm.createSelectFork(rpcEVMx); opSepForwarder = readAppGateway.forwarderAddresses(readAppGateway.multichain(), opSepChainId); @@ -68,12 +74,22 @@ contract RunEVMxRead is SetupScript { runAllTriggers(); } - function run() external { - _run(arbSepChainId); + function run() external pure { + console.log( + "Please call one of these external functions: deployAppGateway(), deployOnchainContracts(), or runTriggers()" + ); + } + + function deployAppGateway() external { + _deployAppGateway(); } function deployOnchainContracts() external { init(); _deployOnchainContracts(); } + + function runTriggers() external { + _run(arbSepChainId); + } } diff --git a/script/write/DeployEVMxWriteTests.s.sol b/script/write/DeployEVMxWriteTests.s.sol deleted file mode 100644 index 44f65fe..0000000 --- a/script/write/DeployEVMxWriteTests.s.sol +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {Script} from "forge-std/Script.sol"; -import {console} from "forge-std/console.sol"; -import {Fees} from "socket-protocol/contracts/protocol/utils/common/Structs.sol"; -import {ETH_ADDRESS} from "socket-protocol/contracts/protocol/utils/common/Constants.sol"; - -import {WriteAppGateway} from "../../src/write/WriteAppGateway.sol"; - -contract DeployEVMxContracts is Script { - function run() external { - address addressResolver = vm.envAddress("ADDRESS_RESOLVER"); - string memory rpc = vm.envString("EVMX_RPC"); - vm.createSelectFork(rpc); - - uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); - vm.startBroadcast(deployerPrivateKey); - - Fees memory fees = Fees({feePoolChain: 421614, feePoolToken: ETH_ADDRESS, amount: 0.0005 ether}); - - WriteAppGateway appGateway = new WriteAppGateway(addressResolver, fees); - - console.log("Contracts deployed:"); - console.log("AppGateway:", address(appGateway)); - console.log("See AppGateway on EVMx: https://evmx.cloud.blockscout.com/address/%s", address(appGateway)); - } -} diff --git a/script/write/RunEVMxWrite.s.sol b/script/write/RunEVMxWrite.s.sol index 5bc82fd..64dfecf 100644 --- a/script/write/RunEVMxWrite.s.sol +++ b/script/write/RunEVMxWrite.s.sol @@ -14,6 +14,12 @@ contract RunEVMxWrite is SetupScript { return address(writeAppGateway); } + function deployAppGatewayContract() internal override returns (address) { + // Deploy WriteAppGateway + WriteAppGateway newGateway = new WriteAppGateway(addressResolver, deployFees); + return address(newGateway); + } + function getForwarderAddresses() internal { vm.createSelectFork(rpcEVMx); opSepForwarder = writeAppGateway.forwarderAddresses(writeAppGateway.multichain(), opSepChainId); @@ -62,12 +68,22 @@ contract RunEVMxWrite is SetupScript { checkResults(); } - function run() external { - _run(arbSepChainId); + function run() external pure { + console.log( + "Please call one of these external functions: deployAppGateway(), deployOnchainContracts(), or runTriggers()" + ); + } + + function deployAppGateway() external { + _deployAppGateway(); } function deployOnchainContracts() external { init(); _deployOnchainContracts(); } + + function runTriggers() external { + _run(arbSepChainId); + } } From 09bf85868a03835e78bfb820fe0fa6a1d4bdbb78 Mon Sep 17 00:00:00 2001 From: Rookmate <14072042+rookmate@users.noreply.github.com> Date: Tue, 11 Mar 2025 16:07:01 +0400 Subject: [PATCH 11/14] Fix inbox script would not deploy --- script/inbox/RunEVMxInbox.s.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/inbox/RunEVMxInbox.s.sol b/script/inbox/RunEVMxInbox.s.sol index 967a2df..cd1d43a 100644 --- a/script/inbox/RunEVMxInbox.s.sol +++ b/script/inbox/RunEVMxInbox.s.sol @@ -65,13 +65,13 @@ contract RunEVMxInbox is SetupScript { // Initialize contract references function init() internal { inboxAppGateway = InboxAppGateway(appGatewayAddress); - opSepInboxAddress = inboxAppGateway.getOnChainAddress(inboxAppGateway.inbox(), opSepChainId); - arbSepInboxAddress = inboxAppGateway.getOnChainAddress(inboxAppGateway.inbox(), arbSepChainId); } function executeScriptSpecificLogic() internal override { init(); getForwarderAddresses(); + opSepInboxAddress = inboxAppGateway.getOnChainAddress(inboxAppGateway.inbox(), opSepChainId); + arbSepInboxAddress = inboxAppGateway.getOnChainAddress(inboxAppGateway.inbox(), arbSepChainId); inboxTransactions(); } From 76834070265bfe2d90957b7812c0da027c7d2030 Mon Sep 17 00:00:00 2001 From: Rookmate <14072042+rookmate@users.noreply.github.com> Date: Tue, 11 Mar 2025 18:56:22 +0400 Subject: [PATCH 12/14] Add async to callFromChain on InboxAppGateway --- src/inbox/InboxAppGateway.sol | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/inbox/InboxAppGateway.sol b/src/inbox/InboxAppGateway.sol index 8fe02fe..0865461 100644 --- a/src/inbox/InboxAppGateway.sol +++ b/src/inbox/InboxAppGateway.sol @@ -32,7 +32,12 @@ contract InboxAppGateway is AppGatewayBase { IInbox(inboxForwarderAddress).updateFromGateway(valueOnGateway); } - function callFromChain(uint32, address, bytes calldata payload_, bytes32) external override onlyWatcherPrecompile { + function callFromChain(uint32, address, bytes calldata payload_, bytes32) + external + override + async + onlyWatcherPrecompile + { (uint32 msgType, bytes memory payload) = abi.decode(payload_, (uint32, bytes)); if (msgType == INCREASE_ON_GATEWAY) { uint256 valueOnchain = abi.decode(payload, (uint256)); From 45b79e8217926bfb0f4aa7faf638b0c8572dcf17 Mon Sep 17 00:00:00 2001 From: Rookmate <14072042+rookmate@users.noreply.github.com> Date: Tue, 11 Mar 2025 19:11:30 +0400 Subject: [PATCH 13/14] Split withdraw to separate external function --- README.md | 15 +++++++++++++++ script/SetupScript.sol | 5 ++--- .../RunEVMxDeploymentMistakes.s.sol | 5 +++++ script/inbox/RunEVMxInbox.s.sol | 5 +++++ script/read/RunEVMxRead.s.sol | 5 +++++ script/write/RunEVMxWrite.s.sol | 5 +++++ 6 files changed, 37 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 787be82..fe856d7 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ Finally, run the EVMx Read script: forge script script/read/RunEVMxRead.s.sol --broadcast --skip-simulation --with-gas-price 0 --legacy ``` +### 6. Withdraw funds +```bash +forge script script/inbox/RunEVMxRead.s.sol --broadcast --sig "withdrawAppFees()" --legacy --with-gas-price 0 +``` + # Deployment Steps for EVMx Inbox Tests Follow these steps to deploy and run the EVMx Inbox tests. @@ -92,6 +97,11 @@ forge script script/inbox/RunEVMxInbox.s.sol --broadcast --legacy --with-gas-pri forge script script/inbox/RunEVMxInbox.s.sol --broadcast --sig "onchainToOnchain()" ``` +### 6. Withdraw funds +```bash +forge script script/inbox/RunEVMxInbox.s.sol --broadcast --sig "withdrawAppFees()" --legacy --with-gas-price 0 +``` + # Deployment Steps for EVMx Write Tests Follow these steps to deploy and run the EVMx Write tests. @@ -134,3 +144,8 @@ Finally, run the EVMx Write script: ```bash forge script script/write/RunEVMxWrite.s.sol --broadcast --skip-simulation --with-gas-price 0 --legacy ``` + +### 6. Withdraw funds +```bash +forge script script/inbox/RunEVMxWrite.s.sol --broadcast --sig "withdrawAppFees()" --legacy --with-gas-price 0 +``` diff --git a/script/SetupScript.sol b/script/SetupScript.sol index 1d8caec..40657e4 100644 --- a/script/SetupScript.sol +++ b/script/SetupScript.sol @@ -48,7 +48,7 @@ abstract contract SetupScript is Script { console.log("Available fees:", availableFees); } - function withdrawAppFees(uint32 chainId) internal { + function _withdrawAppFees(uint32 chainId) internal { // EVMX Check available fees vm.createSelectFork(rpcEVMx); @@ -61,7 +61,7 @@ abstract contract SetupScript is Script { // Gas price from Arbitrum uint256 arbitrumGasPrice = block.basefee + 0.1 gwei; // With buffer - uint256 gasLimit = 5_000_000; // Estimate + uint256 gasLimit = 4_000_000; // Estimate uint256 estimatedGasCost = gasLimit * arbitrumGasPrice; console.log("Arbitrum gas price (wei):", arbitrumGasPrice); @@ -130,7 +130,6 @@ abstract contract SetupScript is Script { if (availableFees > 0) { executeScriptSpecificLogic(); - withdrawAppFees(chainId); } else { console.log("NO AVAILABLE FEES - Please deposit fees before running this script"); } diff --git a/script/deployment-mistakes/RunEVMxDeploymentMistakes.s.sol b/script/deployment-mistakes/RunEVMxDeploymentMistakes.s.sol index c707ae1..17d79bd 100644 --- a/script/deployment-mistakes/RunEVMxDeploymentMistakes.s.sol +++ b/script/deployment-mistakes/RunEVMxDeploymentMistakes.s.sol @@ -127,6 +127,11 @@ contract RunEVMxDeploymentMistakes is SetupScript { _deployAppGateway(); } + function withdrawAppFees() external { + init(); + _withdrawAppFees(arbSepChainId); + } + function deployOnchainContracts() external { init(); _deployOnchainContracts(); diff --git a/script/inbox/RunEVMxInbox.s.sol b/script/inbox/RunEVMxInbox.s.sol index cd1d43a..918e471 100644 --- a/script/inbox/RunEVMxInbox.s.sol +++ b/script/inbox/RunEVMxInbox.s.sol @@ -85,6 +85,11 @@ contract RunEVMxInbox is SetupScript { _deployAppGateway(); } + function withdrawAppFees() external { + init(); + _withdrawAppFees(arbSepChainId); + } + function deployOnchainContracts() external { init(); _deployOnchainContracts(); diff --git a/script/read/RunEVMxRead.s.sol b/script/read/RunEVMxRead.s.sol index 9e52a78..8ce6889 100644 --- a/script/read/RunEVMxRead.s.sol +++ b/script/read/RunEVMxRead.s.sol @@ -84,6 +84,11 @@ contract RunEVMxRead is SetupScript { _deployAppGateway(); } + function withdrawAppFees() external { + init(); + _withdrawAppFees(arbSepChainId); + } + function deployOnchainContracts() external { init(); _deployOnchainContracts(); diff --git a/script/write/RunEVMxWrite.s.sol b/script/write/RunEVMxWrite.s.sol index 64dfecf..2f2c848 100644 --- a/script/write/RunEVMxWrite.s.sol +++ b/script/write/RunEVMxWrite.s.sol @@ -78,6 +78,11 @@ contract RunEVMxWrite is SetupScript { _deployAppGateway(); } + function withdrawAppFees() external { + init(); + _withdrawAppFees(arbSepChainId); + } + function deployOnchainContracts() external { init(); _deployOnchainContracts(); From 27eb1d3b9fb81b4a0b50d6fe95125f655a8282ec Mon Sep 17 00:00:00 2001 From: Rookmate <14072042+rookmate@users.noreply.github.com> Date: Tue, 11 Mar 2025 19:41:07 +0400 Subject: [PATCH 14/14] Update logging --- script/inbox/RunEVMxInbox.s.sol | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/script/inbox/RunEVMxInbox.s.sol b/script/inbox/RunEVMxInbox.s.sol index 918e471..7262376 100644 --- a/script/inbox/RunEVMxInbox.s.sol +++ b/script/inbox/RunEVMxInbox.s.sol @@ -42,6 +42,7 @@ contract RunEVMxInbox is SetupScript { IInbox(arbSepInboxAddress).increaseOnGateway(5); vm.stopBroadcast(); + console.log("Increase on AppGateway executed successfully"); } else if (step == 2) { // TODO: Emit event on each update to easily track and update vm.createSelectFork(rpcEVMx); @@ -50,6 +51,7 @@ contract RunEVMxInbox is SetupScript { inboxAppGateway.updateOnchain(opSepChainId); vm.stopBroadcast(); + console.log("Update on Optimism Sepolia from AppGateway executed successfully"); } else if (step == 3) { // TODO: Emit event on each update to easily track and update vm.createSelectFork(rpcOPSepolia); @@ -58,8 +60,8 @@ contract RunEVMxInbox is SetupScript { IInbox(opSepInboxAddress).propagateToAnother(arbSepChainId); vm.stopBroadcast(); + console.log("Update on Arbitrum Sepolia from AppGateway executed successfully"); } - console.log("All inbox transactions executed successfully"); } // Initialize contract references