Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 68 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/RunEVMxRead.s.sol --broadcast --skip-simulation --with-gas-price 0 --legacy --sig "deployAppGateway()"
```

### 1a. **Verify the EVMx Contract**
Expand Down Expand Up @@ -41,14 +41,75 @@ 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.

### 1. **Deploy the EVMx Inbox Tests Script**
Run the following command to deploy the EVMx Inbox tests script:
```bash
forge script script/inbox/RunEVMxInbox.s.sol --broadcast --skip-simulation --with-gas-price 0 --legacy --sig "deployAppGateway()"
```

### 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 <APP_GATEWAY_ADDRESS> 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 <ONCHAIN_ADDRESS> src/inbox/Inbox.sol:Inbox
```

### 5. **Run EVMx Inbox Script**
Finally, run the EVMx Inbox script:
```bash
forge script script/inbox/RunEVMxInbox.s.sol --broadcast --sig "onchainToEVMx()"
```

```bash
forge script script/inbox/RunEVMxInbox.s.sol --broadcast --legacy --with-gas-price 0 --sig "eVMxToOnchain()"
```

```bash
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.

### 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/RunEVMxWrite.s.sol --broadcast --skip-simulation --with-gas-price 0 --legacy --sig "deployAppGateway()"
```

### 1a. **Verify the Contract**
Expand Down Expand Up @@ -83,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
```
26 changes: 23 additions & 3 deletions script/SetupScript.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -30,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));

Expand All @@ -46,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);

Expand All @@ -59,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);
Expand Down Expand Up @@ -99,17 +101,35 @@ 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);
console.log("Set APP_GATEWAY environment variable to:", 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 {
uint256 availableFees = checkDepositedFees(chainId);

if (availableFees > 0) {
executeScriptSpecificLogic();
withdrawAppFees(chainId);
} else {
console.log("NO AVAILABLE FEES - Please deposit fees before running this script");
}
Expand Down
28 changes: 0 additions & 28 deletions script/deployment-mistakes/DeployEVMxDeploymentMistakesApp.s.sol

This file was deleted.

25 changes: 23 additions & 2 deletions script/deployment-mistakes/RunEVMxDeploymentMistakes.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -111,12 +117,27 @@ 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 withdrawAppFees() external {
init();
_withdrawAppFees(arbSepChainId);
}

function deployOnchainContracts() external {
init();
_deployOnchainContracts();
}

function runTests() external {
_run(arbSepChainId);
}
}
28 changes: 0 additions & 28 deletions script/inbox/DeployEVMxInbox.s.sol

This file was deleted.

81 changes: 66 additions & 15 deletions script/inbox/RunEVMxInbox.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,27 @@ 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;
address opSepForwarder;
address arbSepForwarder;
address opSepInboxAddress;
address arbSepInboxAddress;
uint8 step;

function appGateway() internal view override returns (address) {
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);
Expand All @@ -24,21 +34,34 @@ 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(rpcEVMx);
vm.startBroadcast(privateKey);
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);
vm.startBroadcast(privateKey);

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);
vm.startBroadcast(privateKey);

IInbox(opSepInboxAddress).increaseOnGateway(5);
require(inboxAppGateway.valueOnGateway() != 5, "Expected the same value");
inboxAppGateway.updateOnchain(opSepChainId);
require(IInbox(opSepInboxAddress).value() != 5, "Expected the same value");
IInbox(opSepInboxAddress).propagateToAnother(arbSepChainId);
require(IInbox(arbSepInboxAddress).value() != 5, "Expected the same value");
IInbox(opSepInboxAddress).propagateToAnother(arbSepChainId);

vm.stopBroadcast();
console.log("All inbox transactions executed successfully");
vm.stopBroadcast();
console.log("Update on Arbitrum Sepolia from AppGateway executed successfully");
}
}

// Initialize contract references
Expand All @@ -49,15 +72,43 @@ contract RunEVMxInbox is SetupScript {
function executeScriptSpecificLogic() internal override {
init();
getForwarderAddresses();
opSepInboxAddress = inboxAppGateway.getOnChainAddress(inboxAppGateway.inbox(), opSepChainId);
arbSepInboxAddress = inboxAppGateway.getOnChainAddress(inboxAppGateway.inbox(), arbSepChainId);
inboxTransactions();
}

function run() external {
_run(arbSepChainId);
function run() external pure {
console.log(
"Please call one of these external functions: deployAppGateway(), deployOnchainContracts(), onchainToEVMx(), eVMxToOnchain(), or onchainToOnchain()"
);
}

function deployAppGateway() external {
_deployAppGateway();
}

function withdrawAppFees() external {
init();
_withdrawAppFees(arbSepChainId);
}

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);
}
}
Loading
Loading