From 276a9de441339ec9be43d7b1220dd8a37db9fd50 Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Mon, 8 Jan 2024 11:29:12 +0100 Subject: [PATCH 01/67] Add supoprt for custom number of decimals used for fee token --- scripts/ethcommands.ts | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/scripts/ethcommands.ts b/scripts/ethcommands.ts index 3d78233..c648230 100644 --- a/scripts/ethcommands.ts +++ b/scripts/ethcommands.ts @@ -197,6 +197,11 @@ export const createERC20Command = { describe: "account (see general help)", default: "user_l2user", }, + decimals: { + string: true, + describe: "number of decimals for token", + default: "18", + }, }, handler: async (argv: any) => { console.log("create-erc20"); @@ -207,12 +212,23 @@ export const createERC20Command = { argv.provider ); - const contractFactory = new ContractFactory( - ERC20PresetFixedSupplyArtifact.abi, - ERC20PresetFixedSupplyArtifact.bytecode, - deployerWallet - ); - const contract = await contractFactory.deploy("AppTestToken", "APP", ethers.utils.parseEther("1000000000"), namedAccount(argv.mintTo).address); + //// Bytecode below is generated from this simple ERC20 token contract which uses custom number of decimals + // contract TestToken is ERC20 { + // uint8 private immutable _decimals; + // + // constructor(uint8 decimals_, address mintTo) ERC20("testnode", "TN") { + // _decimals = decimals_; + // _mint(mintTo, 1_000_000 * 10 ** uint256(decimals_)); + // } + // + // function decimals() public view virtual override returns (uint8) { + // return _decimals; + // } + // } + const erc20TokenBytecode = "0x60a06040523480156200001157600080fd5b5060405162000d4938038062000d49833981016040819052620000349162000198565b60405180604001604052806008815260200167746573746e6f646560c01b815250604051806040016040528060028152602001612a2760f11b81525081600390816200008191906200028b565b5060046200009082826200028b565b50505060ff82166080819052620000c5908290620000b090600a6200046c565b620000bf90620f424062000481565b620000cd565b5050620004b9565b6001600160a01b038216620001285760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b80600260008282546200013c9190620004a3565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b505050565b60008060408385031215620001ac57600080fd5b825160ff81168114620001be57600080fd5b60208401519092506001600160a01b0381168114620001dc57600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200021257607f821691505b6020821081036200023357634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200019357600081815260208120601f850160051c81016020861015620002625750805b601f850160051c820191505b8181101562000283578281556001016200026e565b505050505050565b81516001600160401b03811115620002a757620002a7620001e7565b620002bf81620002b88454620001fd565b8462000239565b602080601f831160018114620002f75760008415620002de5750858301515b600019600386901b1c1916600185901b17855562000283565b600085815260208120601f198616915b82811015620003285788860151825594840194600190910190840162000307565b5085821015620003475787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b600181815b80851115620003ae57816000190482111562000392576200039262000357565b80851615620003a057918102915b93841c939080029062000372565b509250929050565b600082620003c75750600162000466565b81620003d65750600062000466565b8160018114620003ef5760028114620003fa576200041a565b600191505062000466565b60ff8411156200040e576200040e62000357565b50506001821b62000466565b5060208310610133831016604e8410600b84101617156200043f575081810a62000466565b6200044b83836200036d565b806000190482111562000462576200046262000357565b0290505b92915050565b60006200047a8383620003b6565b9392505050565b60008160001904831182151516156200049e576200049e62000357565b500290565b8082018082111562000466576200046662000357565b608051610874620004d5600039600061011b01526108746000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461014557806370a082311461015857806395d89b4114610181578063a457c2d714610189578063a9059cbb1461019c578063dd62ed3e146101af57600080fd5b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100ef57806323b872dd14610101578063313ce56714610114575b600080fd5b6100b66101c2565b6040516100c391906106be565b60405180910390f35b6100df6100da366004610728565b610254565b60405190151581526020016100c3565b6002545b6040519081526020016100c3565b6100df61010f366004610752565b61026e565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000001681526020016100c3565b6100df610153366004610728565b610292565b6100f361016636600461078e565b6001600160a01b031660009081526020819052604090205490565b6100b66102b4565b6100df610197366004610728565b6102c3565b6100df6101aa366004610728565b610343565b6100f36101bd3660046107b0565b610351565b6060600380546101d1906107e3565b80601f01602080910402602001604051908101604052809291908181526020018280546101fd906107e3565b801561024a5780601f1061021f5761010080835404028352916020019161024a565b820191906000526020600020905b81548152906001019060200180831161022d57829003601f168201915b5050505050905090565b60003361026281858561037c565b60019150505b92915050565b60003361027c8582856104a0565b61028785858561051a565b506001949350505050565b6000336102628185856102a58383610351565b6102af919061081d565b61037c565b6060600480546101d1906107e3565b600033816102d18286610351565b9050838110156103365760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084015b60405180910390fd5b610287828686840361037c565b60003361026281858561051a565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b0383166103de5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161032d565b6001600160a01b03821661043f5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161032d565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60006104ac8484610351565b9050600019811461051457818110156105075760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161032d565b610514848484840361037c565b50505050565b6001600160a01b03831661057e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161032d565b6001600160a01b0382166105e05760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161032d565b6001600160a01b038316600090815260208190526040902054818110156106585760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161032d565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610514565b600060208083528351808285015260005b818110156106eb578581018301518582016040015282016106cf565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b038116811461072357600080fd5b919050565b6000806040838503121561073b57600080fd5b6107448361070c565b946020939093013593505050565b60008060006060848603121561076757600080fd5b6107708461070c565b925061077e6020850161070c565b9150604084013590509250925092565b6000602082840312156107a057600080fd5b6107a98261070c565b9392505050565b600080604083850312156107c357600080fd5b6107cc8361070c565b91506107da6020840161070c565b90509250929050565b600181811c908216806107f757607f821691505b60208210810361081757634e487b7160e01b600052602260045260246000fd5b50919050565b8082018082111561026857634e487b7160e01b600052601160045260246000fdfea2646970667358221220c17385bf7b455298f3c99090105f4b3d07556cb9d4d4e4b5d0698f6fc8faf19264736f6c63430008100033"; + const abi = ["constructor(uint8 decimals_, address mintTo)"]; + const contractFactory = new ContractFactory(abi, erc20TokenBytecode, deployerWallet); + const contract = await contractFactory.deploy(parseInt(argv.decimals), namedAccount(argv.mintTo).address); await contract.deployTransaction.wait(); console.log("Contract deployed at address:", contract.address); From 4f60f8c8ebb9543980683eacd263de0b34b66c7e Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Mon, 8 Jan 2024 11:44:12 +0100 Subject: [PATCH 02/67] Add decimals param to test-node.bash --- test-node.bash | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test-node.bash b/test-node.bash index 7d360e4..d920d60 100755 --- a/test-node.bash +++ b/test-node.bash @@ -35,6 +35,7 @@ dev_build_nitro=false dev_build_blockscout=false l3_custom_fee_token=false l3_token_bridge=false +l3_custom_fee_token_decimals=18 batchposters=1 devprivkey=b6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659 l1chainid=1337 @@ -128,6 +129,19 @@ while [[ $# -gt 0 ]]; do l3_custom_fee_token=true shift ;; + --l3-fee-token-decimals) + if ! $l3_custom_fee_token; then + echo "Error: --l3-fee-token-decimals requires --l3-fee-token to be provided." + exit 1 + fi + l3_custom_fee_token_decimals=$2 + if [[ $l3_custom_fee_token_decimals -lt 0 || $l3_custom_fee_token_decimals -gt 36 ]]; then + echo "l3-fee-token-decimals must be in range [0,36], value: $l3_custom_fee_token_decimals." + exit 1 + fi + shift + shift + ;; --l3-token-bridge) if ! $l3node; then echo "Error: --l3-token-bridge requires --l3node to be provided." @@ -165,6 +179,7 @@ while [[ $# -gt 0 ]]; do echo --pos l1 is a proof-of-stake chain \(using prysm for consensus\) echo --validate heavy computation, validating all blocks in WASM echo --l3-fee-token L3 chain is set up to use custom fee token. Only valid if also '--l3node' is provided + echo --l3-fee-token-decimals Number of decimals to use for custom fee token. Only valid if also '--l3-fee-token' is provided echo --l3-token-bridge Deploy L2-L3 token bridge. Only valid if also '--l3node' is provided echo --batchposters batch posters [0-3] echo --redundantsequencers redundant sequencers [0-3] @@ -383,7 +398,7 @@ if $force_init; then if $l3_custom_fee_token; then echo == Deploying custom fee token - nativeTokenAddress=`docker compose run scripts create-erc20 --deployer user_fee_token_deployer --mintTo user_token_bridge_deployer | tail -n 1 | awk '{ print $NF }'` + nativeTokenAddress=`docker compose run scripts create-erc20 --deployer user_fee_token_deployer --mintTo user_token_bridge_deployer --decimals $l3_custom_fee_token_decimals | tail -n 1 | awk '{ print $NF }'` EXTRA_L3_DEPLOY_FLAG="--nativeTokenAddress $nativeTokenAddress" fi From ddc75cee36cb90cee88cce13dcf3e6aad9dfd55e Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Mon, 8 Jan 2024 15:26:34 +0100 Subject: [PATCH 03/67] Adjust values --- scripts/ethcommands.ts | 8 +++++--- test-node.bash | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/ethcommands.ts b/scripts/ethcommands.ts index c648230..8057ee7 100644 --- a/scripts/ethcommands.ts +++ b/scripts/ethcommands.ts @@ -1,5 +1,5 @@ import { runStress } from "./stress"; -import { ContractFactory, ethers, Wallet } from "ethers"; +import { BigNumber, ContractFactory, ethers, Wallet } from "ethers"; import * as consts from "./consts"; import { namedAccount, namedAddress } from "./accounts"; import * as ERC20PresetFixedSupplyArtifact from "@openzeppelin/contracts/build/contracts/ERC20PresetFixedSupply.json"; @@ -65,7 +65,9 @@ async function bridgeNativeToken(argv: any, parentChainUrl: string, chainUrl: st /// deposit fee token const iface = new ethers.utils.Interface(["function depositERC20(uint256 amount)"]) - argv.data = iface.encodeFunctionData("depositERC20", [ethers.utils.parseEther(argv.amount)]); + const decimals = await nativeTokenContract.decimals() + const depositAmount = BigNumber.from(argv.amount).mul(BigNumber.from('10').pow(decimals)) + argv.data = iface.encodeFunctionData("depositERC20", [depositAmount]); await runStress(argv, sendTransaction); @@ -76,7 +78,7 @@ async function bridgeNativeToken(argv: any, parentChainUrl: string, chainUrl: st const sleep = (ms: number) => new Promise(r => setTimeout(r, ms)); while (true) { const balance = await bridger.getBalance() - if (balance.gte(ethers.utils.parseEther(argv.amount))) { + if (balance.gte(depositAmount)) { return } await sleep(100) diff --git a/test-node.bash b/test-node.bash index d920d60..a23ab48 100755 --- a/test-node.bash +++ b/test-node.bash @@ -423,8 +423,8 @@ if $force_init; then echo == Fund L3 accounts if $l3_custom_fee_token; then docker compose run scripts bridge-native-token-to-l3 --amount 50000 --from user_token_bridge_deployer --wait - docker compose run scripts send-l3 --ethamount 500 --from user_token_bridge_deployer --wait - docker compose run scripts send-l3 --ethamount 500 --from user_token_bridge_deployer --to "key_0x$devprivkey" --wait + docker compose run scripts send-l3 --ethamount 5 --from user_token_bridge_deployer --wait + docker compose run scripts send-l3 --ethamount 5 --from user_token_bridge_deployer --to "key_0x$devprivkey" --wait else docker compose run scripts bridge-to-l3 --ethamount 50000 --wait docker compose run scripts bridge-to-l3 --ethamount 500 --wait --from "key_0x$devprivkey" From 2148cc58254c1cd053c2d38916549fc8840b9b23 Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Wed, 10 Jan 2024 10:28:18 +0100 Subject: [PATCH 04/67] Approve correct amount --- scripts/ethcommands.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/ethcommands.ts b/scripts/ethcommands.ts index 8057ee7..e57e0f5 100644 --- a/scripts/ethcommands.ts +++ b/scripts/ethcommands.ts @@ -58,15 +58,19 @@ async function bridgeNativeToken(argv: any, parentChainUrl: string, chainUrl: st argv.to = "address_" + inboxAddr; - /// approve inbox to use fee token + // get token contract const bridgerParentChain = namedAccount(argv.from, argv.threadId).connect(argv.provider) const nativeTokenContract = new ethers.Contract(token, ERC20.abi, bridgerParentChain) - await nativeTokenContract.approve(inboxAddr, ethers.utils.parseEther(argv.amount)) - /// deposit fee token - const iface = new ethers.utils.Interface(["function depositERC20(uint256 amount)"]) + // scale deposit amount const decimals = await nativeTokenContract.decimals() const depositAmount = BigNumber.from(argv.amount).mul(BigNumber.from('10').pow(decimals)) + + /// approve inbox to use fee token + await nativeTokenContract.approve(inboxAddr, depositAmount) + + /// deposit fee token + const iface = new ethers.utils.Interface(["function depositERC20(uint256 amount)"]) argv.data = iface.encodeFunctionData("depositERC20", [depositAmount]); await runStress(argv, sendTransaction); From 9e3dc84ba8885a29386273fedc85b86351e010ba Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Thu, 8 Feb 2024 13:25:11 +0100 Subject: [PATCH 05/67] Move token deployment to separate function --- scripts/ethcommands.ts | 60 ++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/scripts/ethcommands.ts b/scripts/ethcommands.ts index c2632ec..ef4d3cd 100644 --- a/scripts/ethcommands.ts +++ b/scripts/ethcommands.ts @@ -91,6 +91,34 @@ async function bridgeNativeToken(argv: any, parentChainUrl: string, chainUrl: st } } +async function deployERC20Contract(deployerWallet: Wallet, mintTo: string, decimals: number): Promise { + //// Bytecode below is generated from this simple ERC20 token contract which uses custom number of decimals + // contract TestToken is ERC20 { + // uint8 private immutable _decimals; + // + // constructor(uint8 decimals_, address mintTo) ERC20("testnode", "TN") { + // _decimals = decimals_; + // _mint(mintTo, 1_000_000 * 10 ** uint256(decimals_)); + // } + // + // function decimals() public view virtual override returns (uint8) { + // return _decimals; + // } + // } + const erc20TokenBytecode = "0x60a06040523480156200001157600080fd5b5060405162000d4938038062000d49833981016040819052620000349162000198565b60405180604001604052806008815260200167746573746e6f646560c01b815250604051806040016040528060028152602001612a2760f11b81525081600390816200008191906200028b565b5060046200009082826200028b565b50505060ff82166080819052620000c5908290620000b090600a6200046c565b620000bf90620f424062000481565b620000cd565b5050620004b9565b6001600160a01b038216620001285760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b80600260008282546200013c9190620004a3565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b505050565b60008060408385031215620001ac57600080fd5b825160ff81168114620001be57600080fd5b60208401519092506001600160a01b0381168114620001dc57600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200021257607f821691505b6020821081036200023357634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200019357600081815260208120601f850160051c81016020861015620002625750805b601f850160051c820191505b8181101562000283578281556001016200026e565b505050505050565b81516001600160401b03811115620002a757620002a7620001e7565b620002bf81620002b88454620001fd565b8462000239565b602080601f831160018114620002f75760008415620002de5750858301515b600019600386901b1c1916600185901b17855562000283565b600085815260208120601f198616915b82811015620003285788860151825594840194600190910190840162000307565b5085821015620003475787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b600181815b80851115620003ae57816000190482111562000392576200039262000357565b80851615620003a057918102915b93841c939080029062000372565b509250929050565b600082620003c75750600162000466565b81620003d65750600062000466565b8160018114620003ef5760028114620003fa576200041a565b600191505062000466565b60ff8411156200040e576200040e62000357565b50506001821b62000466565b5060208310610133831016604e8410600b84101617156200043f575081810a62000466565b6200044b83836200036d565b806000190482111562000462576200046262000357565b0290505b92915050565b60006200047a8383620003b6565b9392505050565b60008160001904831182151516156200049e576200049e62000357565b500290565b8082018082111562000466576200046662000357565b608051610874620004d5600039600061011b01526108746000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461014557806370a082311461015857806395d89b4114610181578063a457c2d714610189578063a9059cbb1461019c578063dd62ed3e146101af57600080fd5b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100ef57806323b872dd14610101578063313ce56714610114575b600080fd5b6100b66101c2565b6040516100c391906106be565b60405180910390f35b6100df6100da366004610728565b610254565b60405190151581526020016100c3565b6002545b6040519081526020016100c3565b6100df61010f366004610752565b61026e565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000001681526020016100c3565b6100df610153366004610728565b610292565b6100f361016636600461078e565b6001600160a01b031660009081526020819052604090205490565b6100b66102b4565b6100df610197366004610728565b6102c3565b6100df6101aa366004610728565b610343565b6100f36101bd3660046107b0565b610351565b6060600380546101d1906107e3565b80601f01602080910402602001604051908101604052809291908181526020018280546101fd906107e3565b801561024a5780601f1061021f5761010080835404028352916020019161024a565b820191906000526020600020905b81548152906001019060200180831161022d57829003601f168201915b5050505050905090565b60003361026281858561037c565b60019150505b92915050565b60003361027c8582856104a0565b61028785858561051a565b506001949350505050565b6000336102628185856102a58383610351565b6102af919061081d565b61037c565b6060600480546101d1906107e3565b600033816102d18286610351565b9050838110156103365760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084015b60405180910390fd5b610287828686840361037c565b60003361026281858561051a565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b0383166103de5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161032d565b6001600160a01b03821661043f5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161032d565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60006104ac8484610351565b9050600019811461051457818110156105075760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161032d565b610514848484840361037c565b50505050565b6001600160a01b03831661057e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161032d565b6001600160a01b0382166105e05760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161032d565b6001600160a01b038316600090815260208190526040902054818110156106585760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161032d565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610514565b600060208083528351808285015260005b818110156106eb578581018301518582016040015282016106cf565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b038116811461072357600080fd5b919050565b6000806040838503121561073b57600080fd5b6107448361070c565b946020939093013593505050565b60008060006060848603121561076757600080fd5b6107708461070c565b925061077e6020850161070c565b9150604084013590509250925092565b6000602082840312156107a057600080fd5b6107a98261070c565b9392505050565b600080604083850312156107c357600080fd5b6107cc8361070c565b91506107da6020840161070c565b90509250929050565b600181811c908216806107f757607f821691505b60208210810361081757634e487b7160e01b600052602260045260246000fd5b50919050565b8082018082111561026857634e487b7160e01b600052601160045260246000fdfea2646970667358221220c17385bf7b455298f3c99090105f4b3d07556cb9d4d4e4b5d0698f6fc8faf19264736f6c63430008100033"; + const abi = [ + "constructor(uint8 decimals_, address mintTo)", + "function transfer(address to, uint256 amount) returns (bool)"] + ; + const tokenFactory = new ContractFactory(abi, erc20TokenBytecode, deployerWallet); + const token = await tokenFactory.deploy(decimals, deployerWallet.address); + await token.deployTransaction.wait(); + // transfer half the supply to mintTo + const transferAmount = BigNumber.from("500000").mul(BigNumber.from('10').pow(decimals)) + await (await token.functions.transfer(namedAccount(mintTo).address, transferAmount)).wait(); + + return token; +} export const bridgeFundsCommand = { command: "bridge-funds", @@ -231,15 +259,8 @@ export const createERC20Command = { l1provider ); - const tokenFactory = new ContractFactory( - ERC20PresetFixedSupplyArtifact.abi, - ERC20PresetFixedSupplyArtifact.bytecode, - deployerWallet - ); - const token = await tokenFactory.deploy("AppTestToken", "APP", ethers.utils.parseEther("1000000000"), deployerWallet.address); - await token.deployTransaction.wait(); + const token = await deployERC20Contract(deployerWallet, argv.mintTo, argv.decimals); console.log("Contract deployed at L1 address:", token.address); - await (await token.functions.transfer(namedAccount(argv.mintTo).address, ethers.utils.parseEther("100000000"))).wait(); const l1GatewayRouter = new ethers.Contract(l1l2tokenbridge.l2Network.tokenBridge.l1GatewayRouter, L1GatewayRouter.abi, deployerWallet); await (await token.functions.approve(l1l2tokenbridge.l2Network.tokenBridge.l1ERC20Gateway, ethers.constants.MaxUint256)).wait(); @@ -275,27 +296,8 @@ export const createERC20Command = { ethers.utils.sha256(ethers.utils.toUtf8Bytes(argv.deployer)), argv.provider ); - - //// Bytecode below is generated from this simple ERC20 token contract which uses custom number of decimals - // contract TestToken is ERC20 { - // uint8 private immutable _decimals; - // - // constructor(uint8 decimals_, address mintTo) ERC20("testnode", "TN") { - // _decimals = decimals_; - // _mint(mintTo, 1_000_000 * 10 ** uint256(decimals_)); - // } - // - // function decimals() public view virtual override returns (uint8) { - // return _decimals; - // } - // } - const erc20TokenBytecode = "0x60a06040523480156200001157600080fd5b5060405162000d4938038062000d49833981016040819052620000349162000198565b60405180604001604052806008815260200167746573746e6f646560c01b815250604051806040016040528060028152602001612a2760f11b81525081600390816200008191906200028b565b5060046200009082826200028b565b50505060ff82166080819052620000c5908290620000b090600a6200046c565b620000bf90620f424062000481565b620000cd565b5050620004b9565b6001600160a01b038216620001285760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b80600260008282546200013c9190620004a3565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b505050565b60008060408385031215620001ac57600080fd5b825160ff81168114620001be57600080fd5b60208401519092506001600160a01b0381168114620001dc57600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200021257607f821691505b6020821081036200023357634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200019357600081815260208120601f850160051c81016020861015620002625750805b601f850160051c820191505b8181101562000283578281556001016200026e565b505050505050565b81516001600160401b03811115620002a757620002a7620001e7565b620002bf81620002b88454620001fd565b8462000239565b602080601f831160018114620002f75760008415620002de5750858301515b600019600386901b1c1916600185901b17855562000283565b600085815260208120601f198616915b82811015620003285788860151825594840194600190910190840162000307565b5085821015620003475787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b600181815b80851115620003ae57816000190482111562000392576200039262000357565b80851615620003a057918102915b93841c939080029062000372565b509250929050565b600082620003c75750600162000466565b81620003d65750600062000466565b8160018114620003ef5760028114620003fa576200041a565b600191505062000466565b60ff8411156200040e576200040e62000357565b50506001821b62000466565b5060208310610133831016604e8410600b84101617156200043f575081810a62000466565b6200044b83836200036d565b806000190482111562000462576200046262000357565b0290505b92915050565b60006200047a8383620003b6565b9392505050565b60008160001904831182151516156200049e576200049e62000357565b500290565b8082018082111562000466576200046662000357565b608051610874620004d5600039600061011b01526108746000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461014557806370a082311461015857806395d89b4114610181578063a457c2d714610189578063a9059cbb1461019c578063dd62ed3e146101af57600080fd5b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100ef57806323b872dd14610101578063313ce56714610114575b600080fd5b6100b66101c2565b6040516100c391906106be565b60405180910390f35b6100df6100da366004610728565b610254565b60405190151581526020016100c3565b6002545b6040519081526020016100c3565b6100df61010f366004610752565b61026e565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000001681526020016100c3565b6100df610153366004610728565b610292565b6100f361016636600461078e565b6001600160a01b031660009081526020819052604090205490565b6100b66102b4565b6100df610197366004610728565b6102c3565b6100df6101aa366004610728565b610343565b6100f36101bd3660046107b0565b610351565b6060600380546101d1906107e3565b80601f01602080910402602001604051908101604052809291908181526020018280546101fd906107e3565b801561024a5780601f1061021f5761010080835404028352916020019161024a565b820191906000526020600020905b81548152906001019060200180831161022d57829003601f168201915b5050505050905090565b60003361026281858561037c565b60019150505b92915050565b60003361027c8582856104a0565b61028785858561051a565b506001949350505050565b6000336102628185856102a58383610351565b6102af919061081d565b61037c565b6060600480546101d1906107e3565b600033816102d18286610351565b9050838110156103365760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084015b60405180910390fd5b610287828686840361037c565b60003361026281858561051a565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b0383166103de5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161032d565b6001600160a01b03821661043f5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161032d565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60006104ac8484610351565b9050600019811461051457818110156105075760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161032d565b610514848484840361037c565b50505050565b6001600160a01b03831661057e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161032d565b6001600160a01b0382166105e05760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161032d565b6001600160a01b038316600090815260208190526040902054818110156106585760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161032d565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610514565b600060208083528351808285015260005b818110156106eb578581018301518582016040015282016106cf565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b038116811461072357600080fd5b919050565b6000806040838503121561073b57600080fd5b6107448361070c565b946020939093013593505050565b60008060006060848603121561076757600080fd5b6107708461070c565b925061077e6020850161070c565b9150604084013590509250925092565b6000602082840312156107a057600080fd5b6107a98261070c565b9392505050565b600080604083850312156107c357600080fd5b6107cc8361070c565b91506107da6020840161070c565b90509250929050565b600181811c908216806107f757607f821691505b60208210810361081757634e487b7160e01b600052602260045260246000fd5b50919050565b8082018082111561026857634e487b7160e01b600052601160045260246000fdfea2646970667358221220c17385bf7b455298f3c99090105f4b3d07556cb9d4d4e4b5d0698f6fc8faf19264736f6c63430008100033"; - const abi = ["constructor(uint8 decimals_, address mintTo)"]; - const contractFactory = new ContractFactory(abi, erc20TokenBytecode, deployerWallet); - const contract = await contractFactory.deploy(parseInt(argv.decimals), namedAccount(argv.mintTo).address); - await contract.deployTransaction.wait(); - - console.log("Contract deployed at address:", contract.address); + const token = await deployERC20Contract(deployerWallet, argv.mintTo, argv.decimals); + console.log("Contract deployed at address:", token.address); argv.provider.destroy(); }, From 83476e2ad6f4465e50da7ece08fce0f8afba8f6f Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Fri, 19 Apr 2024 14:03:57 +0200 Subject: [PATCH 06/67] Adjust token amounts --- scripts/ethcommands.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/scripts/ethcommands.ts b/scripts/ethcommands.ts index 4192ece..cf5e43f 100644 --- a/scripts/ethcommands.ts +++ b/scripts/ethcommands.ts @@ -106,11 +106,7 @@ async function deployERC20Contract(deployerWallet: Wallet, mintTo: string, decim // } // } const erc20TokenBytecode = "0x60a06040523480156200001157600080fd5b5060405162000d4938038062000d49833981016040819052620000349162000198565b60405180604001604052806008815260200167746573746e6f646560c01b815250604051806040016040528060028152602001612a2760f11b81525081600390816200008191906200028b565b5060046200009082826200028b565b50505060ff82166080819052620000c5908290620000b090600a6200046c565b620000bf90620f424062000481565b620000cd565b5050620004b9565b6001600160a01b038216620001285760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b80600260008282546200013c9190620004a3565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b505050565b60008060408385031215620001ac57600080fd5b825160ff81168114620001be57600080fd5b60208401519092506001600160a01b0381168114620001dc57600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200021257607f821691505b6020821081036200023357634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200019357600081815260208120601f850160051c81016020861015620002625750805b601f850160051c820191505b8181101562000283578281556001016200026e565b505050505050565b81516001600160401b03811115620002a757620002a7620001e7565b620002bf81620002b88454620001fd565b8462000239565b602080601f831160018114620002f75760008415620002de5750858301515b600019600386901b1c1916600185901b17855562000283565b600085815260208120601f198616915b82811015620003285788860151825594840194600190910190840162000307565b5085821015620003475787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b600181815b80851115620003ae57816000190482111562000392576200039262000357565b80851615620003a057918102915b93841c939080029062000372565b509250929050565b600082620003c75750600162000466565b81620003d65750600062000466565b8160018114620003ef5760028114620003fa576200041a565b600191505062000466565b60ff8411156200040e576200040e62000357565b50506001821b62000466565b5060208310610133831016604e8410600b84101617156200043f575081810a62000466565b6200044b83836200036d565b806000190482111562000462576200046262000357565b0290505b92915050565b60006200047a8383620003b6565b9392505050565b60008160001904831182151516156200049e576200049e62000357565b500290565b8082018082111562000466576200046662000357565b608051610874620004d5600039600061011b01526108746000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461014557806370a082311461015857806395d89b4114610181578063a457c2d714610189578063a9059cbb1461019c578063dd62ed3e146101af57600080fd5b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100ef57806323b872dd14610101578063313ce56714610114575b600080fd5b6100b66101c2565b6040516100c391906106be565b60405180910390f35b6100df6100da366004610728565b610254565b60405190151581526020016100c3565b6002545b6040519081526020016100c3565b6100df61010f366004610752565b61026e565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000001681526020016100c3565b6100df610153366004610728565b610292565b6100f361016636600461078e565b6001600160a01b031660009081526020819052604090205490565b6100b66102b4565b6100df610197366004610728565b6102c3565b6100df6101aa366004610728565b610343565b6100f36101bd3660046107b0565b610351565b6060600380546101d1906107e3565b80601f01602080910402602001604051908101604052809291908181526020018280546101fd906107e3565b801561024a5780601f1061021f5761010080835404028352916020019161024a565b820191906000526020600020905b81548152906001019060200180831161022d57829003601f168201915b5050505050905090565b60003361026281858561037c565b60019150505b92915050565b60003361027c8582856104a0565b61028785858561051a565b506001949350505050565b6000336102628185856102a58383610351565b6102af919061081d565b61037c565b6060600480546101d1906107e3565b600033816102d18286610351565b9050838110156103365760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084015b60405180910390fd5b610287828686840361037c565b60003361026281858561051a565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b0383166103de5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161032d565b6001600160a01b03821661043f5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161032d565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60006104ac8484610351565b9050600019811461051457818110156105075760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161032d565b610514848484840361037c565b50505050565b6001600160a01b03831661057e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161032d565b6001600160a01b0382166105e05760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161032d565b6001600160a01b038316600090815260208190526040902054818110156106585760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161032d565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610514565b600060208083528351808285015260005b818110156106eb578581018301518582016040015282016106cf565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b038116811461072357600080fd5b919050565b6000806040838503121561073b57600080fd5b6107448361070c565b946020939093013593505050565b60008060006060848603121561076757600080fd5b6107708461070c565b925061077e6020850161070c565b9150604084013590509250925092565b6000602082840312156107a057600080fd5b6107a98261070c565b9392505050565b600080604083850312156107c357600080fd5b6107cc8361070c565b91506107da6020840161070c565b90509250929050565b600181811c908216806107f757607f821691505b60208210810361081757634e487b7160e01b600052602260045260246000fd5b50919050565b8082018082111561026857634e487b7160e01b600052601160045260246000fdfea2646970667358221220c17385bf7b455298f3c99090105f4b3d07556cb9d4d4e4b5d0698f6fc8faf19264736f6c63430008100033"; - const abi = [ - "constructor(uint8 decimals_, address mintTo)", - "function transfer(address to, uint256 amount) returns (bool)"] - ; - const tokenFactory = new ContractFactory(abi, erc20TokenBytecode, deployerWallet); + const tokenFactory = new ContractFactory(ERC20.abi, erc20TokenBytecode, deployerWallet); const token = await tokenFactory.deploy(decimals, deployerWallet.address); await token.deployTransaction.wait(); // transfer half the supply to mintTo @@ -264,8 +260,9 @@ export const createERC20Command = { const l1GatewayRouter = new ethers.Contract(l1l2tokenbridge.l2Network.tokenBridge.l1GatewayRouter, L1GatewayRouter.abi, deployerWallet); await (await token.functions.approve(l1l2tokenbridge.l2Network.tokenBridge.l1ERC20Gateway, ethers.constants.MaxUint256)).wait(); + const supply = await token.totalSupply(); await (await l1GatewayRouter.functions.outboundTransfer( - token.address, namedAccount(argv.mintTo).address, ethers.utils.parseEther("100000000"), 100000000, 1000000000, "0x000000000000000000000000000000000000000000000000000fffffffffff0000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000", { + token.address, namedAccount(argv.mintTo).address, supply.div(2), 100000000, 1000000000, "0x000000000000000000000000000000000000000000000000000fffffffffff0000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000", { value: ethers.utils.parseEther("1"), } )).wait(); From cc2ead1fdc8ff4f5df9dc64def0d93298bc8fc39 Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Fri, 19 Apr 2024 15:52:50 +0200 Subject: [PATCH 07/67] Mint all to deployer --- scripts/ethcommands.ts | 37 ++++++++++++++++++------------------- test-node.bash | 5 +++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/scripts/ethcommands.ts b/scripts/ethcommands.ts index cf5e43f..4045b0b 100644 --- a/scripts/ethcommands.ts +++ b/scripts/ethcommands.ts @@ -3,7 +3,6 @@ import { BigNumber, ContractFactory, ethers, Wallet } from "ethers"; import * as consts from "./consts"; import { namedAccount, namedAddress } from "./accounts"; import * as L1GatewayRouter from "@arbitrum/token-bridge-contracts/build/contracts/contracts/tokenbridge/ethereum/gateway/L1GatewayRouter.sol/L1GatewayRouter.json"; -import * as ERC20PresetFixedSupplyArtifact from "@openzeppelin/contracts/build/contracts/ERC20PresetFixedSupply.json"; import * as ERC20 from "@openzeppelin/contracts/build/contracts/ERC20.json"; import * as fs from "fs"; const path = require("path"); @@ -91,29 +90,33 @@ async function bridgeNativeToken(argv: any, parentChainUrl: string, chainUrl: st } } -async function deployERC20Contract(deployerWallet: Wallet, mintTo: string, decimals: number): Promise { +async function deployERC20Contract(deployerWallet: Wallet, decimals: number): Promise { //// Bytecode below is generated from this simple ERC20 token contract which uses custom number of decimals + + // pragma solidity 0.8.16; + // + // import {ERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; + // // contract TestToken is ERC20 { // uint8 private immutable _decimals; // // constructor(uint8 decimals_, address mintTo) ERC20("testnode", "TN") { // _decimals = decimals_; - // _mint(mintTo, 1_000_000 * 10 ** uint256(decimals_)); + // _mint(mintTo, 1_000_000_000); // } // // function decimals() public view virtual override returns (uint8) { // return _decimals; // } // } - const erc20TokenBytecode = "0x60a06040523480156200001157600080fd5b5060405162000d4938038062000d49833981016040819052620000349162000198565b60405180604001604052806008815260200167746573746e6f646560c01b815250604051806040016040528060028152602001612a2760f11b81525081600390816200008191906200028b565b5060046200009082826200028b565b50505060ff82166080819052620000c5908290620000b090600a6200046c565b620000bf90620f424062000481565b620000cd565b5050620004b9565b6001600160a01b038216620001285760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b80600260008282546200013c9190620004a3565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b505050565b60008060408385031215620001ac57600080fd5b825160ff81168114620001be57600080fd5b60208401519092506001600160a01b0381168114620001dc57600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200021257607f821691505b6020821081036200023357634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200019357600081815260208120601f850160051c81016020861015620002625750805b601f850160051c820191505b8181101562000283578281556001016200026e565b505050505050565b81516001600160401b03811115620002a757620002a7620001e7565b620002bf81620002b88454620001fd565b8462000239565b602080601f831160018114620002f75760008415620002de5750858301515b600019600386901b1c1916600185901b17855562000283565b600085815260208120601f198616915b82811015620003285788860151825594840194600190910190840162000307565b5085821015620003475787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b600181815b80851115620003ae57816000190482111562000392576200039262000357565b80851615620003a057918102915b93841c939080029062000372565b509250929050565b600082620003c75750600162000466565b81620003d65750600062000466565b8160018114620003ef5760028114620003fa576200041a565b600191505062000466565b60ff8411156200040e576200040e62000357565b50506001821b62000466565b5060208310610133831016604e8410600b84101617156200043f575081810a62000466565b6200044b83836200036d565b806000190482111562000462576200046262000357565b0290505b92915050565b60006200047a8383620003b6565b9392505050565b60008160001904831182151516156200049e576200049e62000357565b500290565b8082018082111562000466576200046662000357565b608051610874620004d5600039600061011b01526108746000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461014557806370a082311461015857806395d89b4114610181578063a457c2d714610189578063a9059cbb1461019c578063dd62ed3e146101af57600080fd5b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100ef57806323b872dd14610101578063313ce56714610114575b600080fd5b6100b66101c2565b6040516100c391906106be565b60405180910390f35b6100df6100da366004610728565b610254565b60405190151581526020016100c3565b6002545b6040519081526020016100c3565b6100df61010f366004610752565b61026e565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000001681526020016100c3565b6100df610153366004610728565b610292565b6100f361016636600461078e565b6001600160a01b031660009081526020819052604090205490565b6100b66102b4565b6100df610197366004610728565b6102c3565b6100df6101aa366004610728565b610343565b6100f36101bd3660046107b0565b610351565b6060600380546101d1906107e3565b80601f01602080910402602001604051908101604052809291908181526020018280546101fd906107e3565b801561024a5780601f1061021f5761010080835404028352916020019161024a565b820191906000526020600020905b81548152906001019060200180831161022d57829003601f168201915b5050505050905090565b60003361026281858561037c565b60019150505b92915050565b60003361027c8582856104a0565b61028785858561051a565b506001949350505050565b6000336102628185856102a58383610351565b6102af919061081d565b61037c565b6060600480546101d1906107e3565b600033816102d18286610351565b9050838110156103365760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084015b60405180910390fd5b610287828686840361037c565b60003361026281858561051a565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b0383166103de5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161032d565b6001600160a01b03821661043f5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161032d565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60006104ac8484610351565b9050600019811461051457818110156105075760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161032d565b610514848484840361037c565b50505050565b6001600160a01b03831661057e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161032d565b6001600160a01b0382166105e05760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161032d565b6001600160a01b038316600090815260208190526040902054818110156106585760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161032d565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610514565b600060208083528351808285015260005b818110156106eb578581018301518582016040015282016106cf565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b038116811461072357600080fd5b919050565b6000806040838503121561073b57600080fd5b6107448361070c565b946020939093013593505050565b60008060006060848603121561076757600080fd5b6107708461070c565b925061077e6020850161070c565b9150604084013590509250925092565b6000602082840312156107a057600080fd5b6107a98261070c565b9392505050565b600080604083850312156107c357600080fd5b6107cc8361070c565b91506107da6020840161070c565b90509250929050565b600181811c908216806107f757607f821691505b60208210810361081757634e487b7160e01b600052602260045260246000fd5b50919050565b8082018082111561026857634e487b7160e01b600052601160045260246000fdfea2646970667358221220c17385bf7b455298f3c99090105f4b3d07556cb9d4d4e4b5d0698f6fc8faf19264736f6c63430008100033"; - const tokenFactory = new ContractFactory(ERC20.abi, erc20TokenBytecode, deployerWallet); + + const erc20TokenBytecode = "0x60a06040523480156200001157600080fd5b5060405162000bf438038062000bf483398101604081905262000034916200017d565b60405180604001604052806008815260200167746573746e6f646560c01b815250604051806040016040528060028152602001612a2760f11b815250816003908162000081919062000270565b50600462000090828262000270565b50505060ff8216608052620000aa81633b9aca00620000b2565b505062000364565b6001600160a01b0382166200010d5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b80600260008282546200012191906200033c565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b505050565b600080604083850312156200019157600080fd5b825160ff81168114620001a357600080fd5b60208401519092506001600160a01b0381168114620001c157600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600181811c90821680620001f757607f821691505b6020821081036200021857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200017857600081815260208120601f850160051c81016020861015620002475750805b601f850160051c820191505b81811015620002685782815560010162000253565b505050505050565b81516001600160401b038111156200028c576200028c620001cc565b620002a4816200029d8454620001e2565b846200021e565b602080601f831160018114620002dc5760008415620002c35750858301515b600019600386901b1c1916600185901b17855562000268565b600085815260208120601f198616915b828110156200030d57888601518255948401946001909101908401620002ec565b50858210156200032c5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b808201808211156200035e57634e487b7160e01b600052601160045260246000fd5b92915050565b60805161087462000380600039600061011b01526108746000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461014557806370a082311461015857806395d89b4114610181578063a457c2d714610189578063a9059cbb1461019c578063dd62ed3e146101af57600080fd5b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100ef57806323b872dd14610101578063313ce56714610114575b600080fd5b6100b66101c2565b6040516100c391906106be565b60405180910390f35b6100df6100da366004610728565b610254565b60405190151581526020016100c3565b6002545b6040519081526020016100c3565b6100df61010f366004610752565b61026e565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000001681526020016100c3565b6100df610153366004610728565b610292565b6100f361016636600461078e565b6001600160a01b031660009081526020819052604090205490565b6100b66102b4565b6100df610197366004610728565b6102c3565b6100df6101aa366004610728565b610343565b6100f36101bd3660046107b0565b610351565b6060600380546101d1906107e3565b80601f01602080910402602001604051908101604052809291908181526020018280546101fd906107e3565b801561024a5780601f1061021f5761010080835404028352916020019161024a565b820191906000526020600020905b81548152906001019060200180831161022d57829003601f168201915b5050505050905090565b60003361026281858561037c565b60019150505b92915050565b60003361027c8582856104a0565b61028785858561051a565b506001949350505050565b6000336102628185856102a58383610351565b6102af919061081d565b61037c565b6060600480546101d1906107e3565b600033816102d18286610351565b9050838110156103365760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084015b60405180910390fd5b610287828686840361037c565b60003361026281858561051a565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b0383166103de5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161032d565b6001600160a01b03821661043f5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161032d565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60006104ac8484610351565b9050600019811461051457818110156105075760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161032d565b610514848484840361037c565b50505050565b6001600160a01b03831661057e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161032d565b6001600160a01b0382166105e05760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161032d565b6001600160a01b038316600090815260208190526040902054818110156106585760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161032d565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610514565b600060208083528351808285015260005b818110156106eb578581018301518582016040015282016106cf565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b038116811461072357600080fd5b919050565b6000806040838503121561073b57600080fd5b6107448361070c565b946020939093013593505050565b60008060006060848603121561076757600080fd5b6107708461070c565b925061077e6020850161070c565b9150604084013590509250925092565b6000602082840312156107a057600080fd5b6107a98261070c565b9392505050565b600080604083850312156107c357600080fd5b6107cc8361070c565b91506107da6020840161070c565b90509250929050565b600181811c908216806107f757607f821691505b60208210810361081757634e487b7160e01b600052602260045260246000fd5b50919050565b8082018082111561026857634e487b7160e01b600052601160045260246000fdfea2646970667358221220ae10cf6b65bb4070682573aeaa582fd9c484b3a2837f1c899bcbbd7ded6fcddb64736f6c63430008100033"; + const abi = ["constructor(uint8 decimals_, address mintTo)"]; + const tokenFactory = new ContractFactory(abi, erc20TokenBytecode, deployerWallet); const token = await tokenFactory.deploy(decimals, deployerWallet.address); await token.deployTransaction.wait(); - // transfer half the supply to mintTo - const transferAmount = BigNumber.from("500000").mul(BigNumber.from('10').pow(decimals)) - await (await token.functions.transfer(namedAccount(mintTo).address, transferAmount)).wait(); - return token; + return token.address; } export const bridgeFundsCommand = { @@ -222,10 +225,6 @@ export const createERC20Command = { string: true, describe: "account (see general help)" }, - mintTo: { - string: true, - describe: "account (see general help)", - }, bridgeable: { boolean: true, describe: "if true, deploy on L1 and bridge to L2", @@ -255,14 +254,15 @@ export const createERC20Command = { l1provider ); - const token = await deployERC20Contract(deployerWallet, argv.mintTo, argv.decimals); + const tokenAddress = await deployERC20Contract(deployerWallet, argv.decimals); + const token = new ethers.Contract(tokenAddress, ERC20.abi, deployerWallet); console.log("Contract deployed at L1 address:", token.address); const l1GatewayRouter = new ethers.Contract(l1l2tokenbridge.l2Network.tokenBridge.l1GatewayRouter, L1GatewayRouter.abi, deployerWallet); await (await token.functions.approve(l1l2tokenbridge.l2Network.tokenBridge.l1ERC20Gateway, ethers.constants.MaxUint256)).wait(); const supply = await token.totalSupply(); await (await l1GatewayRouter.functions.outboundTransfer( - token.address, namedAccount(argv.mintTo).address, supply.div(2), 100000000, 1000000000, "0x000000000000000000000000000000000000000000000000000fffffffffff0000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000", { + token.address, deployerWallet.address, supply, 100000000, 1000000000, "0x000000000000000000000000000000000000000000000000000fffffffffff0000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000", { value: ethers.utils.parseEther("1"), } )).wait(); @@ -293,8 +293,8 @@ export const createERC20Command = { ethers.utils.sha256(ethers.utils.toUtf8Bytes(argv.deployer)), argv.provider ); - const token = await deployERC20Contract(deployerWallet, argv.mintTo, argv.decimals); - console.log("Contract deployed at address:", token.address); + const tokenAddress = await deployERC20Contract(deployerWallet, argv.decimals); + console.log("Contract deployed at address:", tokenAddress); argv.provider.destroy(); }, @@ -327,8 +327,7 @@ export const transferERC20Command = { argv.provider = new ethers.providers.WebSocketProvider(argv.l2url); const account = namedAccount(argv.from).connect(argv.provider); const tokenContract = new ethers.Contract(argv.token, ERC20.abi, account); - const decimals = await tokenContract.decimals(); - await(await tokenContract.transfer(namedAccount(argv.to).address, ethers.utils.parseUnits(argv.amount, decimals))).wait(); + await(await tokenContract.transfer(namedAccount(argv.to).address, argv.amount)).wait(); argv.provider.destroy(); }, }; diff --git a/test-node.bash b/test-node.bash index 13f1bff..2b3d78a 100755 --- a/test-node.bash +++ b/test-node.bash @@ -411,8 +411,9 @@ if $force_init; then if $l3_custom_fee_token; then echo == Deploying custom fee token - nativeTokenAddress=`docker compose run scripts create-erc20 --deployer user_fee_token_deployer --mintTo user_token_bridge_deployer --bridgeable $tokenbridge --decimals $l3_custom_fee_token_decimals | tail -n 1 | awk '{ print $NF }'` - docker compose run scripts transfer-erc20 --token $nativeTokenAddress --amount 100 --from user_token_bridge_deployer --to l3owner + nativeTokenAddress=`docker compose run scripts create-erc20 --deployer user_fee_token_deployer --bridgeable $tokenbridge --decimals $l3_custom_fee_token_decimals | tail -n 1 | awk '{ print $NF }'` + docker compose run scripts transfer-erc20 --token $nativeTokenAddress --amount 100 --from user_fee_token_deployer --to l3owner + docker compose run scripts transfer-erc20 --token $nativeTokenAddress --amount 100 --from user_fee_token_deployer --to user_token_bridge_deployer EXTRA_L3_DEPLOY_FLAG="-e FEE_TOKEN_ADDRESS=$nativeTokenAddress" fi From 5789086c9e2b4cc0f6a06bbc3531352ce5ed1f26 Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Fri, 19 Apr 2024 17:25:02 +0200 Subject: [PATCH 08/67] Fix amounts --- scripts/ethcommands.ts | 8 +++++--- test-node.bash | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/ethcommands.ts b/scripts/ethcommands.ts index 4045b0b..1f341ed 100644 --- a/scripts/ethcommands.ts +++ b/scripts/ethcommands.ts @@ -102,7 +102,7 @@ async function deployERC20Contract(deployerWallet: Wallet, decimals: number): Pr // // constructor(uint8 decimals_, address mintTo) ERC20("testnode", "TN") { // _decimals = decimals_; - // _mint(mintTo, 1_000_000_000); + // _mint(mintTo, 1_000_000_000 * 10 ** decimals_); // } // // function decimals() public view virtual override returns (uint8) { @@ -110,7 +110,7 @@ async function deployERC20Contract(deployerWallet: Wallet, decimals: number): Pr // } // } - const erc20TokenBytecode = "0x60a06040523480156200001157600080fd5b5060405162000bf438038062000bf483398101604081905262000034916200017d565b60405180604001604052806008815260200167746573746e6f646560c01b815250604051806040016040528060028152602001612a2760f11b815250816003908162000081919062000270565b50600462000090828262000270565b50505060ff8216608052620000aa81633b9aca00620000b2565b505062000364565b6001600160a01b0382166200010d5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b80600260008282546200012191906200033c565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b505050565b600080604083850312156200019157600080fd5b825160ff81168114620001a357600080fd5b60208401519092506001600160a01b0381168114620001c157600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600181811c90821680620001f757607f821691505b6020821081036200021857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200017857600081815260208120601f850160051c81016020861015620002475750805b601f850160051c820191505b81811015620002685782815560010162000253565b505050505050565b81516001600160401b038111156200028c576200028c620001cc565b620002a4816200029d8454620001e2565b846200021e565b602080601f831160018114620002dc5760008415620002c35750858301515b600019600386901b1c1916600185901b17855562000268565b600085815260208120601f198616915b828110156200030d57888601518255948401946001909101908401620002ec565b50858210156200032c5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b808201808211156200035e57634e487b7160e01b600052601160045260246000fd5b92915050565b60805161087462000380600039600061011b01526108746000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461014557806370a082311461015857806395d89b4114610181578063a457c2d714610189578063a9059cbb1461019c578063dd62ed3e146101af57600080fd5b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100ef57806323b872dd14610101578063313ce56714610114575b600080fd5b6100b66101c2565b6040516100c391906106be565b60405180910390f35b6100df6100da366004610728565b610254565b60405190151581526020016100c3565b6002545b6040519081526020016100c3565b6100df61010f366004610752565b61026e565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000001681526020016100c3565b6100df610153366004610728565b610292565b6100f361016636600461078e565b6001600160a01b031660009081526020819052604090205490565b6100b66102b4565b6100df610197366004610728565b6102c3565b6100df6101aa366004610728565b610343565b6100f36101bd3660046107b0565b610351565b6060600380546101d1906107e3565b80601f01602080910402602001604051908101604052809291908181526020018280546101fd906107e3565b801561024a5780601f1061021f5761010080835404028352916020019161024a565b820191906000526020600020905b81548152906001019060200180831161022d57829003601f168201915b5050505050905090565b60003361026281858561037c565b60019150505b92915050565b60003361027c8582856104a0565b61028785858561051a565b506001949350505050565b6000336102628185856102a58383610351565b6102af919061081d565b61037c565b6060600480546101d1906107e3565b600033816102d18286610351565b9050838110156103365760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084015b60405180910390fd5b610287828686840361037c565b60003361026281858561051a565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b0383166103de5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161032d565b6001600160a01b03821661043f5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161032d565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60006104ac8484610351565b9050600019811461051457818110156105075760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161032d565b610514848484840361037c565b50505050565b6001600160a01b03831661057e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161032d565b6001600160a01b0382166105e05760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161032d565b6001600160a01b038316600090815260208190526040902054818110156106585760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161032d565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610514565b600060208083528351808285015260005b818110156106eb578581018301518582016040015282016106cf565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b038116811461072357600080fd5b919050565b6000806040838503121561073b57600080fd5b6107448361070c565b946020939093013593505050565b60008060006060848603121561076757600080fd5b6107708461070c565b925061077e6020850161070c565b9150604084013590509250925092565b6000602082840312156107a057600080fd5b6107a98261070c565b9392505050565b600080604083850312156107c357600080fd5b6107cc8361070c565b91506107da6020840161070c565b90509250929050565b600181811c908216806107f757607f821691505b60208210810361081757634e487b7160e01b600052602260045260246000fd5b50919050565b8082018082111561026857634e487b7160e01b600052601160045260246000fdfea2646970667358221220ae10cf6b65bb4070682573aeaa582fd9c484b3a2837f1c899bcbbd7ded6fcddb64736f6c63430008100033"; + const erc20TokenBytecode = "0x60a06040523480156200001157600080fd5b5060405162000d4938038062000d49833981016040819052620000349162000195565b60405180604001604052806008815260200167746573746e6f646560c01b815250604051806040016040528060028152602001612a2760f11b815250816003908162000081919062000288565b50600462000090828262000288565b50505060ff8216608052620000c281620000ac84600a62000469565b620000bc90633b9aca0062000481565b620000ca565b5050620004b9565b6001600160a01b038216620001255760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b8060026000828254620001399190620004a3565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b505050565b60008060408385031215620001a957600080fd5b825160ff81168114620001bb57600080fd5b60208401519092506001600160a01b0381168114620001d957600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200020f57607f821691505b6020821081036200023057634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200019057600081815260208120601f850160051c810160208610156200025f5750805b601f850160051c820191505b8181101562000280578281556001016200026b565b505050505050565b81516001600160401b03811115620002a457620002a4620001e4565b620002bc81620002b58454620001fa565b8462000236565b602080601f831160018114620002f45760008415620002db5750858301515b600019600386901b1c1916600185901b17855562000280565b600085815260208120601f198616915b82811015620003255788860151825594840194600190910190840162000304565b5085821015620003445787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b600181815b80851115620003ab5781600019048211156200038f576200038f62000354565b808516156200039d57918102915b93841c93908002906200036f565b509250929050565b600082620003c45750600162000463565b81620003d35750600062000463565b8160018114620003ec5760028114620003f75762000417565b600191505062000463565b60ff8411156200040b576200040b62000354565b50506001821b62000463565b5060208310610133831016604e8410600b84101617156200043c575081810a62000463565b6200044883836200036a565b80600019048211156200045f576200045f62000354565b0290505b92915050565b60006200047a60ff841683620003b3565b9392505050565b60008160001904831182151516156200049e576200049e62000354565b500290565b8082018082111562000463576200046362000354565b608051610874620004d5600039600061011b01526108746000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c80633950935111610071578063395093511461014557806370a082311461015857806395d89b4114610181578063a457c2d714610189578063a9059cbb1461019c578063dd62ed3e146101af57600080fd5b806306fdde03146100ae578063095ea7b3146100cc57806318160ddd146100ef57806323b872dd14610101578063313ce56714610114575b600080fd5b6100b66101c2565b6040516100c391906106be565b60405180910390f35b6100df6100da366004610728565b610254565b60405190151581526020016100c3565b6002545b6040519081526020016100c3565b6100df61010f366004610752565b61026e565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000001681526020016100c3565b6100df610153366004610728565b610292565b6100f361016636600461078e565b6001600160a01b031660009081526020819052604090205490565b6100b66102b4565b6100df610197366004610728565b6102c3565b6100df6101aa366004610728565b610343565b6100f36101bd3660046107b0565b610351565b6060600380546101d1906107e3565b80601f01602080910402602001604051908101604052809291908181526020018280546101fd906107e3565b801561024a5780601f1061021f5761010080835404028352916020019161024a565b820191906000526020600020905b81548152906001019060200180831161022d57829003601f168201915b5050505050905090565b60003361026281858561037c565b60019150505b92915050565b60003361027c8582856104a0565b61028785858561051a565b506001949350505050565b6000336102628185856102a58383610351565b6102af919061081d565b61037c565b6060600480546101d1906107e3565b600033816102d18286610351565b9050838110156103365760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084015b60405180910390fd5b610287828686840361037c565b60003361026281858561051a565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6001600160a01b0383166103de5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b606482015260840161032d565b6001600160a01b03821661043f5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b606482015260840161032d565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60006104ac8484610351565b9050600019811461051457818110156105075760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000604482015260640161032d565b610514848484840361037c565b50505050565b6001600160a01b03831661057e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b606482015260840161032d565b6001600160a01b0382166105e05760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b606482015260840161032d565b6001600160a01b038316600090815260208190526040902054818110156106585760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b606482015260840161032d565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3610514565b600060208083528351808285015260005b818110156106eb578581018301518582016040015282016106cf565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b038116811461072357600080fd5b919050565b6000806040838503121561073b57600080fd5b6107448361070c565b946020939093013593505050565b60008060006060848603121561076757600080fd5b6107708461070c565b925061077e6020850161070c565b9150604084013590509250925092565b6000602082840312156107a057600080fd5b6107a98261070c565b9392505050565b600080604083850312156107c357600080fd5b6107cc8361070c565b91506107da6020840161070c565b90509250929050565b600181811c908216806107f757607f821691505b60208210810361081757634e487b7160e01b600052602260045260246000fd5b50919050565b8082018082111561026857634e487b7160e01b600052601160045260246000fdfea2646970667358221220257f3d763bae7b8c0189ed676531d85a1046e0bea68722f67c2616d46f01c02964736f6c63430008100033"; const abi = ["constructor(uint8 decimals_, address mintTo)"]; const tokenFactory = new ContractFactory(abi, erc20TokenBytecode, deployerWallet); const token = await tokenFactory.deploy(decimals, deployerWallet.address); @@ -327,7 +327,9 @@ export const transferERC20Command = { argv.provider = new ethers.providers.WebSocketProvider(argv.l2url); const account = namedAccount(argv.from).connect(argv.provider); const tokenContract = new ethers.Contract(argv.token, ERC20.abi, account); - await(await tokenContract.transfer(namedAccount(argv.to).address, argv.amount)).wait(); + const tokenDecimals = await tokenContract.decimals(); + const amountToTransfer = BigNumber.from(argv.amount).mul(BigNumber.from('10').pow(tokenDecimals)); + await(await tokenContract.transfer(namedAccount(argv.to).address, amountToTransfer)).wait(); argv.provider.destroy(); }, }; diff --git a/test-node.bash b/test-node.bash index 2b3d78a..676f65f 100755 --- a/test-node.bash +++ b/test-node.bash @@ -412,8 +412,8 @@ if $force_init; then if $l3_custom_fee_token; then echo == Deploying custom fee token nativeTokenAddress=`docker compose run scripts create-erc20 --deployer user_fee_token_deployer --bridgeable $tokenbridge --decimals $l3_custom_fee_token_decimals | tail -n 1 | awk '{ print $NF }'` - docker compose run scripts transfer-erc20 --token $nativeTokenAddress --amount 100 --from user_fee_token_deployer --to l3owner - docker compose run scripts transfer-erc20 --token $nativeTokenAddress --amount 100 --from user_fee_token_deployer --to user_token_bridge_deployer + docker compose run scripts transfer-erc20 --token $nativeTokenAddress --amount 10000 --from user_fee_token_deployer --to l3owner + docker compose run scripts transfer-erc20 --token $nativeTokenAddress --amount 10000 --from user_fee_token_deployer --to user_token_bridge_deployer EXTRA_L3_DEPLOY_FLAG="-e FEE_TOKEN_ADDRESS=$nativeTokenAddress" fi @@ -445,7 +445,7 @@ if $force_init; then echo == Fund L3 accounts if $l3_custom_fee_token; then - docker compose run scripts bridge-native-token-to-l3 --amount 50000 --from user_token_bridge_deployer --wait + docker compose run scripts bridge-native-token-to-l3 --amount 5000 --from user_token_bridge_deployer --wait docker compose run scripts send-l3 --ethamount 5 --from user_token_bridge_deployer --wait docker compose run scripts send-l3 --ethamount 5 --from user_token_bridge_deployer --to "key_0x$devprivkey" --wait else From e8e187b4dced1083e34b8109753b40f18589d0f4 Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Wed, 19 Jun 2024 19:04:41 +0200 Subject: [PATCH 09/67] Fix funding the L3 accounts in case of fee token --- scripts/ethcommands.ts | 2 +- test-node.bash | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/ethcommands.ts b/scripts/ethcommands.ts index 1f341ed..d1bc514 100644 --- a/scripts/ethcommands.ts +++ b/scripts/ethcommands.ts @@ -82,7 +82,7 @@ async function bridgeNativeToken(argv: any, parentChainUrl: string, chainUrl: st const sleep = (ms: number) => new Promise(r => setTimeout(r, ms)); while (true) { const balance = await bridger.getBalance() - if (balance.gte(depositAmount)) { + if (balance.gte(0)) { return } await sleep(100) diff --git a/test-node.bash b/test-node.bash index cec7463..04778ec 100755 --- a/test-node.bash +++ b/test-node.bash @@ -463,9 +463,9 @@ if $force_init; then echo == Fund L3 accounts if $l3_custom_fee_token; then - docker compose run scripts bridge-native-token-to-l3 --amount 5000 --from user_token_bridge_deployer --wait - docker compose run scripts send-l3 --ethamount 5 --from user_token_bridge_deployer --wait - docker compose run scripts send-l3 --ethamount 5 --from user_token_bridge_deployer --to "key_0x$devprivkey" --wait + docker compose run scripts bridge-native-token-to-l3 --amount 5000 --from user_fee_token_deployer --wait + docker compose run scripts send-l3 --ethamount 5 --from user_fee_token_deployer --wait + docker compose run scripts send-l3 --ethamount 5 --from user_fee_token_deployer --to "key_0x$devprivkey" --wait else docker compose run scripts bridge-to-l3 --ethamount 50000 --wait docker compose run scripts bridge-to-l3 --ethamount 500 --wait --from "key_0x$devprivkey" From dbf27b6fff9aa1c7bc1096f5e12022c35d3352be Mon Sep 17 00:00:00 2001 From: gzeon Date: Thu, 4 Jul 2024 16:40:49 +0800 Subject: [PATCH 10/67] feat: use node v18 --- rollupcreator/Dockerfile | 2 +- scripts/Dockerfile | 2 +- tokenbridge/Dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rollupcreator/Dockerfile b/rollupcreator/Dockerfile index 17b065a..f6406da 100644 --- a/rollupcreator/Dockerfile +++ b/rollupcreator/Dockerfile @@ -1,4 +1,4 @@ -FROM node:16-bullseye-slim +FROM node:18-bullseye-slim ARG NITRO_CONTRACTS_BRANCH=main RUN apt-get update && \ apt-get install -y git docker.io python3 build-essential curl jq diff --git a/scripts/Dockerfile b/scripts/Dockerfile index c5b7050..ca2c677 100644 --- a/scripts/Dockerfile +++ b/scripts/Dockerfile @@ -1,4 +1,4 @@ -FROM node:16-bullseye-slim +FROM node:18-bullseye-slim WORKDIR /workspace COPY ./package.json ./yarn.lock ./ RUN yarn diff --git a/tokenbridge/Dockerfile b/tokenbridge/Dockerfile index 3d8cbac..dac06fb 100644 --- a/tokenbridge/Dockerfile +++ b/tokenbridge/Dockerfile @@ -1,4 +1,4 @@ -FROM node:16-bullseye-slim +FROM node:18-bullseye-slim ARG TOKEN_BRIDGE_BRANCH=main RUN apt-get update && \ apt-get install -y git docker.io python3 build-essential From 3af86a023224688499c199184993e10221934d6e Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Tue, 9 Jul 2024 14:04:36 +0200 Subject: [PATCH 11/67] Properly check that native bridging was successful --- scripts/ethcommands.ts | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/scripts/ethcommands.ts b/scripts/ethcommands.ts index d1bc514..39254d2 100644 --- a/scripts/ethcommands.ts +++ b/scripts/ethcommands.ts @@ -58,6 +58,11 @@ async function bridgeNativeToken(argv: any, parentChainUrl: string, chainUrl: st argv.to = "address_" + inboxAddr; + // snapshot balance before deposit + const childProvider = new ethers.providers.WebSocketProvider(chainUrl); + const bridger = namedAccount(argv.from, argv.threadId).connect(childProvider) + const bridgerBalanceBefore = await bridger.getBalance() + // get token contract const bridgerParentChain = namedAccount(argv.from, argv.threadId).connect(argv.provider) const nativeTokenContract = new ethers.Contract(token, ERC20.abi, bridgerParentChain) @@ -77,12 +82,25 @@ async function bridgeNativeToken(argv: any, parentChainUrl: string, chainUrl: st argv.provider.destroy(); if (argv.wait) { - const childProvider = new ethers.providers.WebSocketProvider(chainUrl); - const bridger = namedAccount(argv.from, argv.threadId).connect(childProvider) const sleep = (ms: number) => new Promise(r => setTimeout(r, ms)); + + // calculate amount being minted on child chain + let expectedMintedAmount = depositAmount + if(decimals < 18) { + // inflate up to 18 decimals + expectedMintedAmount = depositAmount.mul(BigNumber.from('10').pow(18 - decimals)) + } else if(decimals > 18) { + // deflate down to 18 decimals, rounding up + const quotient = BigNumber.from('10').pow(decimals - 18) + expectedMintedAmount = depositAmount.div(quotient) + if(expectedMintedAmount.mul(quotient).lt(depositAmount)) { + expectedMintedAmount = expectedMintedAmount.add(1) + } + } + while (true) { - const balance = await bridger.getBalance() - if (balance.gte(0)) { + const bridgerBalanceAfter = await bridger.getBalance() + if (bridgerBalanceAfter.sub(bridgerBalanceBefore).eq(expectedMintedAmount)) { return } await sleep(100) From 7123edc4312dea90f26f4199ecf7c6bcc5bf6dc8 Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Tue, 9 Jul 2024 18:54:21 +0200 Subject: [PATCH 12/67] Make funding work for all chain combos --- test-node.bash | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test-node.bash b/test-node.bash index daa6be7..736b504 100755 --- a/test-node.bash +++ b/test-node.bash @@ -470,12 +470,11 @@ if $force_init; then echo == Fund L3 accounts if $l3_custom_fee_token; then docker compose run scripts bridge-native-token-to-l3 --amount 5000 --from user_fee_token_deployer --wait - docker compose run scripts send-l3 --ethamount 5 --from user_fee_token_deployer --wait - docker compose run scripts send-l3 --ethamount 5 --from user_fee_token_deployer --to "key_0x$devprivkey" --wait + docker compose run scripts send-l3 --ethamount 100 --from user_fee_token_deployer --wait else docker compose run scripts bridge-to-l3 --ethamount 50000 --wait fi - docker compose run scripts send-l3 --ethamount 100 --to l3owner --wait + docker compose run scripts send-l3 --ethamount 10 --to l3owner --wait echo == Deploy CacheManager on L3 docker compose run -e CHILD_CHAIN_RPC="http://l3node:3347" -e CHAIN_OWNER_PRIVKEY=$l3ownerkey rollupcreator deploy-cachemanager-testnode From 230d5c4878a127f07f01d83cd78ffd4ae2d3bbe0 Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Tue, 9 Jul 2024 18:56:06 +0200 Subject: [PATCH 13/67] Bump versions --- test-node.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-node.bash b/test-node.bash index 736b504..3ebd6c6 100755 --- a/test-node.bash +++ b/test-node.bash @@ -7,8 +7,8 @@ BLOCKSCOUT_VERSION=offchainlabs/blockscout:v1.0.0-c8db5b1 # This commit matches the v1.2.1 contracts, with additional support for CacheManger deployment. # Once v1.2.2 is released, we can switch to that version. -DEFAULT_NITRO_CONTRACTS_VERSION="867663657b98a66b60ff244e46226e0cb368ab94" -DEFAULT_TOKEN_BRIDGE_VERSION="v1.2.1" +DEFAULT_NITRO_CONTRACTS_VERSION="v2.0.0-beta.1" +DEFAULT_TOKEN_BRIDGE_VERSION="v1.2.2" # Set default versions if not overriden by provided env vars : ${NITRO_CONTRACTS_BRANCH:=$DEFAULT_NITRO_CONTRACTS_VERSION} From ec94da8fd4defce857edd2f399462b5914c4d252 Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Tue, 9 Jul 2024 19:05:28 +0200 Subject: [PATCH 14/67] Remove comment --- test-node.bash | 2 -- 1 file changed, 2 deletions(-) diff --git a/test-node.bash b/test-node.bash index 3ebd6c6..5e041b3 100755 --- a/test-node.bash +++ b/test-node.bash @@ -5,8 +5,6 @@ set -e NITRO_NODE_VERSION=offchainlabs/nitro-node:v3.0.1-cf4b74e-dev BLOCKSCOUT_VERSION=offchainlabs/blockscout:v1.0.0-c8db5b1 -# This commit matches the v1.2.1 contracts, with additional support for CacheManger deployment. -# Once v1.2.2 is released, we can switch to that version. DEFAULT_NITRO_CONTRACTS_VERSION="v2.0.0-beta.1" DEFAULT_TOKEN_BRIDGE_VERSION="v1.2.2" From badbcbea9b43d46e115da4d7c9f2f57c31af8431 Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Wed, 17 Jul 2024 10:13:02 +0200 Subject: [PATCH 15/67] Do not transfer all supply to L2, leave some for L1-L3 bridging test --- scripts/ethcommands.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/ethcommands.ts b/scripts/ethcommands.ts index 39254d2..fcf1dca 100644 --- a/scripts/ethcommands.ts +++ b/scripts/ethcommands.ts @@ -279,8 +279,10 @@ export const createERC20Command = { const l1GatewayRouter = new ethers.Contract(l1l2tokenbridge.l2Network.tokenBridge.l1GatewayRouter, L1GatewayRouter.abi, deployerWallet); await (await token.functions.approve(l1l2tokenbridge.l2Network.tokenBridge.l1ERC20Gateway, ethers.constants.MaxUint256)).wait(); const supply = await token.totalSupply(); + // transfer 90% of supply to l2 + const transferAmount = supply.mul(9).div(10); await (await l1GatewayRouter.functions.outboundTransfer( - token.address, deployerWallet.address, supply, 100000000, 1000000000, "0x000000000000000000000000000000000000000000000000000fffffffffff0000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000", { + token.address, deployerWallet.address, transferAmount, 100000000, 1000000000, "0x000000000000000000000000000000000000000000000000000fffffffffff0000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000", { value: ethers.utils.parseEther("1"), } )).wait(); From 8b531fbb6d18ae2aee31d1f1f5074b4a59429799 Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Thu, 1 Aug 2024 10:46:37 +0200 Subject: [PATCH 16/67] Bump nitro contracts --- test-node.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-node.bash b/test-node.bash index 5e041b3..7479780 100755 --- a/test-node.bash +++ b/test-node.bash @@ -5,7 +5,7 @@ set -e NITRO_NODE_VERSION=offchainlabs/nitro-node:v3.0.1-cf4b74e-dev BLOCKSCOUT_VERSION=offchainlabs/blockscout:v1.0.0-c8db5b1 -DEFAULT_NITRO_CONTRACTS_VERSION="v2.0.0-beta.1" +DEFAULT_NITRO_CONTRACTS_VERSION="v2.1.0" DEFAULT_TOKEN_BRIDGE_VERSION="v1.2.2" # Set default versions if not overriden by provided env vars From 720fbb961869b4b70ebfb6920218944cbd401182 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Wed, 7 Aug 2024 13:19:44 +0200 Subject: [PATCH 17/67] Disable rebuild of dev docker imgs w --build false --- test-node.bash | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/test-node.bash b/test-node.bash index dd112c9..96bb9d2 100755 --- a/test-node.bash +++ b/test-node.bash @@ -38,6 +38,7 @@ fi run=true force_build=false +skip_build=false validate=false detach=false blockscout=false @@ -91,8 +92,19 @@ while [[ $# -gt 0 ]]; do fi ;; --build) - force_build=true shift + if [[ $# -eq 0 || $1 == -* ]]; then + # If no argument after --build, set flag to true + force_build=true + else + while [[ $# -gt 0 && $1 != -* ]]; do + if [[ $1 == "false" ]]; then + force_build=false + skip_build=true + fi + shift + done + fi ;; --validate) simple=false @@ -177,7 +189,7 @@ while [[ $# -gt 0 ]]; do echo $0 script [SCRIPT-ARGS] echo echo OPTIONS: - echo --build rebuild docker images + echo --build rebuild docker images. --build false disables rebuild echo --dev build nitro and blockscout dockers from source instead of pulling them. Disables simple mode echo --init remove all data, rebuild, deploy new rollup echo --pos l1 is a proof-of-stake chain \(using prysm for consensus\) @@ -200,17 +212,17 @@ while [[ $# -gt 0 ]]; do esac done -if $force_init; then +if ! $skip_build && $force_init; then force_build=true fi -if $dev_build_nitro; then +if ! $skip_build && $dev_build_nitro; then if [[ "$(docker images -q nitro-node-dev:latest 2> /dev/null)" == "" ]]; then force_build=true fi fi -if $dev_build_blockscout; then +if ! $skip_build && $dev_build_blockscout; then if [[ "$(docker images -q blockscout:latest 2> /dev/null)" == "" ]]; then force_build=true fi From 8428bc3bd3395a1067ece462c4a9f9e7ed45b228 Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Mon, 12 Aug 2024 11:20:15 +0200 Subject: [PATCH 18/67] Make UpgradeExecutor L3 arbowner --- scripts/consts.ts | 2 ++ scripts/ethcommands.ts | 52 ++++++++++++++++++++++++++++++++++++++++++ scripts/index.ts | 2 ++ test-node.bash | 7 +++++- 4 files changed, 62 insertions(+), 1 deletion(-) diff --git a/scripts/consts.ts b/scripts/consts.ts index ff32226..edfcedd 100644 --- a/scripts/consts.ts +++ b/scripts/consts.ts @@ -5,3 +5,5 @@ export const tokenbridgedatapath = "/tokenbridge-data"; // Not secure. Do not use for production purposes export const l1mnemonic = "indoor dish desk flag debris potato excuse depart ticket judge file exit"; + +export const ARB_OWNER = "0x0000000000000000000000000000000000000070"; \ No newline at end of file diff --git a/scripts/ethcommands.ts b/scripts/ethcommands.ts index fcf1dca..81a7b89 100644 --- a/scripts/ethcommands.ts +++ b/scripts/ethcommands.ts @@ -3,8 +3,10 @@ import { BigNumber, ContractFactory, ethers, Wallet } from "ethers"; import * as consts from "./consts"; import { namedAccount, namedAddress } from "./accounts"; import * as L1GatewayRouter from "@arbitrum/token-bridge-contracts/build/contracts/contracts/tokenbridge/ethereum/gateway/L1GatewayRouter.sol/L1GatewayRouter.json"; +import * as L1AtomicTokenBridgeCreator from "@arbitrum/token-bridge-contracts/build/contracts/contracts/tokenbridge/ethereum/L1AtomicTokenBridgeCreator.sol/L1AtomicTokenBridgeCreator.json"; import * as ERC20 from "@openzeppelin/contracts/build/contracts/ERC20.json"; import * as fs from "fs"; +import { ARB_OWNER } from "./consts"; const path = require("path"); async function sendTransaction(argv: any, threadId: number) { @@ -235,6 +237,56 @@ export const bridgeNativeTokenToL3Command = { }, }; +export const transferL3ChainOwnershipCommand = { + command: "transfer-l3-chain-ownership", + describe: "transfer L3 chain ownership to upgrade executor", + builder: { + creator: { + string: true, + describe: "address of the token bridge creator", + }, + wait: { + boolean: true, + describe: "wait till ownership is transferred", + default: false, + }, + }, + handler: async (argv: any) => { + // get inbox address from config file + const deploydata = JSON.parse( + fs + .readFileSync(path.join(consts.configpath, "l3deployment.json")) + .toString() + ); + const inboxAddr = ethers.utils.hexlify(deploydata.inbox); + + // get L3 upgrade executor address from token bridge creator + const l2provider = new ethers.providers.WebSocketProvider(argv.l2url); + const tokenBridgeCreator = new ethers.Contract(argv.creator, L1AtomicTokenBridgeCreator.abi, l2provider); + const [,,,,,,,l3UpgradeExecutorAddress,] = await tokenBridgeCreator.inboxToL2Deployment(inboxAddr); + + // set TX params + argv.provider = new ethers.providers.WebSocketProvider(argv.l3url); + argv.to = "address_" + ARB_OWNER; + argv.from = "l3owner"; + argv.ethamount = "0"; + + // add L3 UpgradeExecutor to chain owners + const arbOwnerIface = new ethers.utils.Interface([ + "function addChainOwner(address newOwner) external", + "function removeChainOwner(address ownerToRemove) external" + ]) + argv.data = arbOwnerIface.encodeFunctionData("addChainOwner", [l3UpgradeExecutorAddress]); + await runStress(argv, sendTransaction); + + // remove L3 owner from chain owners + argv.data = arbOwnerIface.encodeFunctionData("removeChainOwner", [namedAccount("l3owner").address]); + await runStress(argv, sendTransaction); + + argv.provider.destroy(); + } +}; + export const createERC20Command = { command: "create-erc20", describe: "creates simple ERC20 on L2", diff --git a/scripts/index.ts b/scripts/index.ts index 2fd189f..3c83a3e 100644 --- a/scripts/index.ts +++ b/scripts/index.ts @@ -19,6 +19,7 @@ import { sendL2Command, sendL3Command, sendRPCCommand, + transferL3ChainOwnershipCommand, } from "./ethcommands"; async function main() { @@ -41,6 +42,7 @@ async function main() { .command(sendL2Command) .command(sendL3Command) .command(sendRPCCommand) + .command(transferL3ChainOwnershipCommand) .command(writeConfigCommand) .command(writeGethGenesisCommand) .command(writeL2ChainConfigCommand) diff --git a/test-node.bash b/test-node.bash index 7479780..6c1dd5a 100755 --- a/test-node.bash +++ b/test-node.bash @@ -5,7 +5,7 @@ set -e NITRO_NODE_VERSION=offchainlabs/nitro-node:v3.0.1-cf4b74e-dev BLOCKSCOUT_VERSION=offchainlabs/blockscout:v1.0.0-c8db5b1 -DEFAULT_NITRO_CONTRACTS_VERSION="v2.1.0" +DEFAULT_NITRO_CONTRACTS_VERSION="47989be933f4720a80d39c7da42a97b0cfdf7311" DEFAULT_TOKEN_BRIDGE_VERSION="v1.2.2" # Set default versions if not overriden by provided env vars @@ -462,6 +462,11 @@ if $force_init; then fi docker compose run -e PARENT_WETH_OVERRIDE=$l2Weth -e ROLLUP_OWNER_KEY=$l3ownerkey -e ROLLUP_ADDRESS=$rollupAddress -e PARENT_RPC=http://sequencer:8547 -e PARENT_KEY=$deployer_key -e CHILD_RPC=http://l3node:3347 -e CHILD_KEY=$deployer_key tokenbridge deploy:local:token-bridge docker compose run --entrypoint sh tokenbridge -c "cat network.json && cp network.json l2l3_network.json" + + # set L3 UpgradeExecutor, deployed by token bridge creator in previous step, to be the L3 chain owner. L3owner (EOA) and alias of L2 UpgradeExectuor have the executor role on the L3 UpgradeExecutor + echo == Set L3 UpgradeExecutor to be chain owner + tokenBridgeCreator=`docker compose run --entrypoint sh tokenbridge -c "cat l2l3_network.json" | jq -r '.l1TokenBridgeCreator'` + docker compose run scripts transfer-l3-chain-ownership --creator $tokenBridgeCreator echo fi From 26ffe7d84206856d1baa47c99743eb8188469a2d Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Mon, 12 Aug 2024 12:35:50 +0200 Subject: [PATCH 19/67] Clarify logic around dev builds and rebuilding The concepts of using the dev builds for nitro and blockscout and rebuilding are now split into different variables internally to the test-node.bash script and can be controlled independently. The --dev flag by itself means to use the dev builds and to rebuild them. --no-build-dev-nitro and -no-build-dev-blockscout disable rebuilding the respective dev images. --no-build disables rebuilding the dev images and also rebuilding contracts related images, and the node images. This finer grained control saves time in the development cycle by allowing the user to rebuild only what is needed. An example command line to reinitialize the blockchain, use the dev images, but not rebuild anything except blockscout would be: ./test-node.bash --init --dev --no-build --build-dev-blockscout --blockscout Flags are read from left to right; flags to the right cancel the effects of flags to the left. --- test-node.bash | 147 +++++++++++++++++++++++++++++-------------------- 1 file changed, 87 insertions(+), 60 deletions(-) diff --git a/test-node.bash b/test-node.bash index 96bb9d2..2bdb513 100755 --- a/test-node.bash +++ b/test-node.bash @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -e +set -eu NITRO_NODE_VERSION=offchainlabs/nitro-node:v3.0.1-cf4b74e-dev BLOCKSCOUT_VERSION=offchainlabs/blockscout:v1.0.0-c8db5b1 @@ -37,7 +37,6 @@ else fi run=true -force_build=false skip_build=false validate=false detach=false @@ -46,14 +45,23 @@ tokenbridge=false l3node=false consensusclient=false redundantsequencers=0 -dev_build_nitro=false -dev_build_blockscout=false l3_custom_fee_token=false l3_token_bridge=false batchposters=1 devprivkey=b6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659 l1chainid=1337 simple=true + +# Use the dev versions of nitro/blockscout +dev_nitro=false +dev_blockscout=false + +# Rebuild docker images +build_dev_nitro=false +build_dev_blockscout=false +build_contracts=false +build_node_images=false + while [[ $# -gt 0 ]]; do case $1 in --init) @@ -78,33 +86,60 @@ while [[ $# -gt 0 ]]; do shift if [[ $# -eq 0 || $1 == -* ]]; then # If no argument after --dev, set both flags to true - dev_build_nitro=true - dev_build_blockscout=true + dev_nitro=true + build_dev_nitro=true + dev_blockscout=true + build_dev_blockscout=true else while [[ $# -gt 0 && $1 != -* ]]; do if [[ $1 == "nitro" ]]; then - dev_build_nitro=true + dev_nitro=true + build_dev_nitro=true elif [[ $1 == "blockscout" ]]; then - dev_build_blockscout=true + dev_blockscout=true + build_dev_blockscout=true fi shift done fi ;; --build) + build_dev_nitro=true + build_dev_blockscout=true + build_contracts=true + build_node_images=true + shift + ;; + --no-build) + build_dev_nitro=false + build_dev_blockscout=false + build_contracts=false + build_node_images=false + shift + ;; + --build-dev-nitro) + build_dev_nitro=true + shift + ;; + --no-build-dev-nitro) + build_dev_nitro=false + shift + ;; + --build-dev-blockscout) + build_dev_blockscout=true + shift + ;; + --no-build-dev-blockscout) + build_dev_blockscout=false + shift + ;; + --build-contracts) + build_contracts=true + shift + ;; + --no-build-contracts) + build_contracts=false shift - if [[ $# -eq 0 || $1 == -* ]]; then - # If no argument after --build, set flag to true - force_build=true - else - while [[ $# -gt 0 && $1 != -* ]]; do - if [[ $1 == "false" ]]; then - force_build=false - skip_build=true - fi - shift - done - fi ;; --validate) simple=false @@ -189,7 +224,8 @@ while [[ $# -gt 0 ]]; do echo $0 script [SCRIPT-ARGS] echo echo OPTIONS: - echo --build rebuild docker images. --build false disables rebuild + echo --build rebuild docker images + echo --no-build don\'t rebuild docker images echo --dev build nitro and blockscout dockers from source instead of pulling them. Disables simple mode echo --init remove all data, rebuild, deploy new rollup echo --pos l1 is a proof-of-stake chain \(using prysm for consensus\) @@ -206,28 +242,18 @@ while [[ $# -gt 0 ]]; do echo --no-tokenbridge don\'t build or launch tokenbridge echo --no-run does not launch nodes \(useful with build or init\) echo --no-simple run a full configuration with separate sequencer/batch-poster/validator/relayer + echo --build-dev-nitro rebuild dev nitro docker image + echo --no-build-dev-nitro don\'t rebuild dev nitro docker image + echo --build-dev-blockscout rebuild dev blockscout docker image + echo --no-build-dev-blockscout don\'t rebuild dev blockscout docker image + echo --build-contracts rebuild contracts related docker images + echo --no-build-contracts rebuild contracts related docker images echo echo script runs inside a separate docker. For SCRIPT-ARGS, run $0 script --help exit 0 esac done -if ! $skip_build && $force_init; then - force_build=true -fi - -if ! $skip_build && $dev_build_nitro; then - if [[ "$(docker images -q nitro-node-dev:latest 2> /dev/null)" == "" ]]; then - force_build=true - fi -fi - -if ! $skip_build && $dev_build_blockscout; then - if [[ "$(docker images -q blockscout:latest 2> /dev/null)" == "" ]]; then - force_build=true - fi -fi - NODES="sequencer" INITIAL_SEQ_NODES="sequencer" @@ -267,25 +293,28 @@ fi if $blockscout; then NODES="$NODES blockscout" fi -if $force_build; then - echo == Building.. - if $dev_build_nitro; then - if ! [ -n "${NITRO_SRC+set}" ]; then - NITRO_SRC=`dirname $PWD` - fi - if ! grep ^FROM "${NITRO_SRC}/Dockerfile" | grep nitro-node 2>&1 > /dev/null; then - echo nitro source not found in "$NITRO_SRC" - echo execute from a sub-directory of nitro or use NITRO_SRC environment variable - exit 1 - fi - docker build "$NITRO_SRC" -t nitro-node-dev --target nitro-node-dev + + +if $dev_nitro && $build_dev_nitro; then + echo == Building Nitro + if ! [ -n "${NITRO_SRC+set}" ]; then + NITRO_SRC=`dirname $PWD` fi - if $dev_build_blockscout; then - if $blockscout; then - docker build blockscout -t blockscout -f blockscout/docker/Dockerfile - fi + if ! grep ^FROM "${NITRO_SRC}/Dockerfile" | grep nitro-node 2>&1 > /dev/null; then + echo nitro source not found in "$NITRO_SRC" + echo execute from a sub-directory of nitro or use NITRO_SRC environment variable + exit 1 + fi + docker build "$NITRO_SRC" -t nitro-node-dev --target nitro-node-dev +fi +if $dev_blockscout && $build_dev_blockscout; then + if $blockscout; then + echo == Building Blockscout + docker build blockscout -t blockscout -f blockscout/docker/Dockerfile fi +fi +if $build_contracts; then LOCAL_BUILD_NODES="scripts rollupcreator" if $tokenbridge || $l3_token_bridge; then LOCAL_BUILD_NODES="$LOCAL_BUILD_NODES tokenbridge" @@ -293,25 +322,23 @@ if $force_build; then docker compose build --no-rm $LOCAL_BUILD_NODES fi -if $dev_build_nitro; then +if $dev_nitro; then docker tag nitro-node-dev:latest nitro-node-dev-testnode else docker pull $NITRO_NODE_VERSION docker tag $NITRO_NODE_VERSION nitro-node-dev-testnode fi -if $dev_build_blockscout; then - if $blockscout; then +if $blockscout; then + if $dev_blockscout; then docker tag blockscout:latest blockscout-testnode - fi -else - if $blockscout; then + else docker pull $BLOCKSCOUT_VERSION docker tag $BLOCKSCOUT_VERSION blockscout-testnode fi fi -if $force_build; then +if $build_node_images; then docker compose build --no-rm $NODES scripts fi From 0e22925fbd2c6df9636a78b430629eb553ab5c87 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Mon, 12 Aug 2024 12:45:50 +0200 Subject: [PATCH 20/67] No skip_build --- test-node.bash | 1 - 1 file changed, 1 deletion(-) diff --git a/test-node.bash b/test-node.bash index 2bdb513..c202a47 100755 --- a/test-node.bash +++ b/test-node.bash @@ -37,7 +37,6 @@ else fi run=true -skip_build=false validate=false detach=false blockscout=false From 7ac0d6ee5fddae35454c67d61919689faf17cda5 Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Mon, 12 Aug 2024 13:56:22 +0200 Subject: [PATCH 21/67] Add comment --- test-node.bash | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test-node.bash b/test-node.bash index 6c1dd5a..54ce48e 100755 --- a/test-node.bash +++ b/test-node.bash @@ -5,7 +5,8 @@ set -e NITRO_NODE_VERSION=offchainlabs/nitro-node:v3.0.1-cf4b74e-dev BLOCKSCOUT_VERSION=offchainlabs/blockscout:v1.0.0-c8db5b1 -DEFAULT_NITRO_CONTRACTS_VERSION="47989be933f4720a80d39c7da42a97b0cfdf7311" +# This commit matches v2.1.0 release of nitro-contracts, with additional support to set arb owner through upgrade executor +DEFAULT_NITRO_CONTRACTS_VERSION="99c07a7db2fcce75b751c5a2bd4936e898cda065" DEFAULT_TOKEN_BRIDGE_VERSION="v1.2.2" # Set default versions if not overriden by provided env vars From aae904b31c95c7931e197a57cb873377cdef9ac2 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Tue, 13 Aug 2024 13:52:28 +0200 Subject: [PATCH 22/67] Contracts and node images should rebuild on --init --- test-node.bash | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test-node.bash b/test-node.bash index c202a47..4fa253a 100755 --- a/test-node.bash +++ b/test-node.bash @@ -69,6 +69,8 @@ while [[ $# -gt 0 ]]; do read -p "are you sure? [y/n]" -n 1 response if [[ $response == "y" ]] || [[ $response == "Y" ]]; then force_init=true + build_contracts=true + build_node_images=true echo else exit 0 @@ -78,6 +80,8 @@ while [[ $# -gt 0 ]]; do ;; --init-force) force_init=true + build_contracts=true + build_node_images=true shift ;; --dev) From 4732c5d0278e85e291b9d425b7a6361be1bcae25 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Tue, 13 Aug 2024 16:45:57 +0200 Subject: [PATCH 23/67] Declare variable before use for -u flag --- test-node.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/test-node.bash b/test-node.bash index 4fa253a..81401aa 100755 --- a/test-node.bash +++ b/test-node.bash @@ -461,6 +461,7 @@ if $force_init; then echo l3owneraddress $l3owneraddress docker compose run scripts --l2owner $l3owneraddress write-l3-chain-config + EXTRA_L3_DEPLOY_FLAG="" if $l3_custom_fee_token; then echo == Deploying custom fee token nativeTokenAddress=`docker compose run scripts create-erc20 --deployer user_fee_token_deployer --mintTo user_token_bridge_deployer --bridgeable $tokenbridge | tail -n 1 | awk '{ print $NF }'` From 4c489a79c7bb1c4c648d9fa46b4f2101a8083818 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Wed, 14 Aug 2024 11:44:52 +0200 Subject: [PATCH 24/67] Change contracts to utils, add --force-build-utils --- test-node.bash | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/test-node.bash b/test-node.bash index 81401aa..75f6d30 100755 --- a/test-node.bash +++ b/test-node.bash @@ -58,7 +58,8 @@ dev_blockscout=false # Rebuild docker images build_dev_nitro=false build_dev_blockscout=false -build_contracts=false +build_utils=false +force_build_utils=false build_node_images=false while [[ $# -gt 0 ]]; do @@ -69,7 +70,7 @@ while [[ $# -gt 0 ]]; do read -p "are you sure? [y/n]" -n 1 response if [[ $response == "y" ]] || [[ $response == "Y" ]]; then force_init=true - build_contracts=true + build_utils=true build_node_images=true echo else @@ -80,7 +81,7 @@ while [[ $# -gt 0 ]]; do ;; --init-force) force_init=true - build_contracts=true + build_utils=true build_node_images=true shift ;; @@ -109,14 +110,14 @@ while [[ $# -gt 0 ]]; do --build) build_dev_nitro=true build_dev_blockscout=true - build_contracts=true + build_utils=true build_node_images=true shift ;; --no-build) build_dev_nitro=false build_dev_blockscout=false - build_contracts=false + build_utils=false build_node_images=false shift ;; @@ -136,12 +137,16 @@ while [[ $# -gt 0 ]]; do build_dev_blockscout=false shift ;; - --build-contracts) - build_contracts=true + --build-utils) + build_utils=true shift ;; - --no-build-contracts) - build_contracts=false + --no-build-utils) + build_utils=false + shift + ;; + --force-build-utils) + force_build_utils=true shift ;; --validate) @@ -249,8 +254,9 @@ while [[ $# -gt 0 ]]; do echo --no-build-dev-nitro don\'t rebuild dev nitro docker image echo --build-dev-blockscout rebuild dev blockscout docker image echo --no-build-dev-blockscout don\'t rebuild dev blockscout docker image - echo --build-contracts rebuild contracts related docker images - echo --no-build-contracts rebuild contracts related docker images + echo --build-utils rebuild scripts, rollupcreator, token bridge docker images + echo --no-build-utils don\'t rebuild scripts, rollupcreator, token bridge docker images + echo --force-build-utils force rebuilding utils, useful if NITRO_CONTRACTS_ or TOKEN_BRIDGE_BRANCH changes echo echo script runs inside a separate docker. For SCRIPT-ARGS, run $0 script --help exit 0 @@ -317,12 +323,16 @@ if $dev_blockscout && $build_dev_blockscout; then fi fi -if $build_contracts; then +if $build_utils; then LOCAL_BUILD_NODES="scripts rollupcreator" if $tokenbridge || $l3_token_bridge; then LOCAL_BUILD_NODES="$LOCAL_BUILD_NODES tokenbridge" fi - docker compose build --no-rm $LOCAL_BUILD_NODES + UTILS_NOCACHE="" + if $force_build_utils; then + UTILS_NOCACHE="--no-cache" + fi + docker compose build --no-rm $UTILS_NOCACHE $LOCAL_BUILD_NODES fi if $dev_nitro; then From 7edd38570f7407196df3ce70acfb2494b77be2d8 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Wed, 14 Aug 2024 18:49:50 +0200 Subject: [PATCH 25/67] Upgrade to the consensus-v31 release --- scripts/config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/config.ts b/scripts/config.ts index eefcdd2..6edded2 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -344,7 +344,7 @@ function writeL2ChainConfig(argv: any) { "EnableArbOS": true, "AllowDebugPrecompiles": true, "DataAvailabilityCommittee": false, - "InitialArbOSVersion": 30, + "InitialArbOSVersion": 31, "InitialChainOwner": argv.l2owner, "GenesisBlockNum": 0 } @@ -377,7 +377,7 @@ function writeL3ChainConfig(argv: any) { "EnableArbOS": true, "AllowDebugPrecompiles": true, "DataAvailabilityCommittee": false, - "InitialArbOSVersion": 30, + "InitialArbOSVersion": 31, "InitialChainOwner": argv.l2owner, "GenesisBlockNum": 0 } From 8ec213161a2e5e18252c55b882d6e1270a559170 Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Wed, 14 Aug 2024 21:33:55 +0200 Subject: [PATCH 26/67] Update versions of contracts token-bridge and node These updated versions are needed to work with the consensus-v31 release. --- rollupcreator/Dockerfile | 2 +- test-node.bash | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/rollupcreator/Dockerfile b/rollupcreator/Dockerfile index 17b065a..5706b9c 100644 --- a/rollupcreator/Dockerfile +++ b/rollupcreator/Dockerfile @@ -1,4 +1,4 @@ -FROM node:16-bullseye-slim +FROM node:18.20.3-bullseye-slim ARG NITRO_CONTRACTS_BRANCH=main RUN apt-get update && \ apt-get install -y git docker.io python3 build-essential curl jq diff --git a/test-node.bash b/test-node.bash index dd112c9..645f5f6 100755 --- a/test-node.bash +++ b/test-node.bash @@ -2,13 +2,11 @@ set -e -NITRO_NODE_VERSION=offchainlabs/nitro-node:v3.0.1-cf4b74e-dev -BLOCKSCOUT_VERSION=offchainlabs/blockscout:v1.0.0-c8db5b1 +NITRO_NODE_VERSION=offchainlabs/nitro-node:v3.1.0-7d1d84c-dev +BLOCKSCOUT_VERSION=offchainlabs/blockscout:v1.1.0-0e716c8 -# This commit matches the v1.2.1 contracts, with additional support for CacheManger deployment. -# Once v1.2.2 is released, we can switch to that version. -DEFAULT_NITRO_CONTRACTS_VERSION="867663657b98a66b60ff244e46226e0cb368ab94" -DEFAULT_TOKEN_BRIDGE_VERSION="v1.2.1" +DEFAULT_NITRO_CONTRACTS_VERSION="v2.0.0" +DEFAULT_TOKEN_BRIDGE_VERSION="v1.2.2" # Set default versions if not overriden by provided env vars : ${NITRO_CONTRACTS_BRANCH:=$DEFAULT_NITRO_CONTRACTS_VERSION} From 313853eec643caeba01b45ac4314d0385eae6d2c Mon Sep 17 00:00:00 2001 From: gzeon Date: Thu, 15 Aug 2024 13:47:33 +0800 Subject: [PATCH 27/67] fix: prysm config --- scripts/config.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/config.ts b/scripts/config.ts index eefcdd2..2b1b7f7 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -13,16 +13,25 @@ PRESET_BASE: interop GENESIS_FORK_VERSION: 0x20000089 # Altair -ALTAIR_FORK_EPOCH: 1 +ALTAIR_FORK_EPOCH: 0 ALTAIR_FORK_VERSION: 0x20000090 # Merge -BELLATRIX_FORK_EPOCH: 2 +BELLATRIX_FORK_EPOCH: 0 BELLATRIX_FORK_VERSION: 0x20000091 -TERMINAL_TOTAL_DIFFICULTY: 50 +TERMINAL_TOTAL_DIFFICULTY: 0 + +# Capella +CAPELLA_FORK_EPOCH: 0 +CAPELLA_FORK_VERSION: 0x20000092 +MAX_WITHDRAWALS_PER_PAYLOAD: 16 + +DENEB_FORK_EPOCH: 2 +DENEB_FORK_VERSION: 0x20000093 + # Time parameters -SECONDS_PER_SLOT: 12 +SECONDS_PER_SLOT: 6 SLOTS_PER_EPOCH: 6 # Deposit contract From 75d03ba80ef3a3e8ee5d805b7ebfe33a63f1aa6f Mon Sep 17 00:00:00 2001 From: gzeon Date: Thu, 15 Aug 2024 13:49:46 +0800 Subject: [PATCH 28/67] fix: remove irrelevant changes --- scripts/config.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/config.ts b/scripts/config.ts index 2b1b7f7..469761f 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -13,13 +13,13 @@ PRESET_BASE: interop GENESIS_FORK_VERSION: 0x20000089 # Altair -ALTAIR_FORK_EPOCH: 0 +ALTAIR_FORK_EPOCH: 1 ALTAIR_FORK_VERSION: 0x20000090 # Merge -BELLATRIX_FORK_EPOCH: 0 +BELLATRIX_FORK_EPOCH: 2 BELLATRIX_FORK_VERSION: 0x20000091 -TERMINAL_TOTAL_DIFFICULTY: 0 +TERMINAL_TOTAL_DIFFICULTY: 50 # Capella CAPELLA_FORK_EPOCH: 0 @@ -31,7 +31,7 @@ DENEB_FORK_VERSION: 0x20000093 # Time parameters -SECONDS_PER_SLOT: 6 +SECONDS_PER_SLOT: 12 SLOTS_PER_EPOCH: 6 # Deposit contract From a8e9f82d2b0ce985092427c4b5a11525f4b1db5d Mon Sep 17 00:00:00 2001 From: gzeon Date: Thu, 15 Aug 2024 15:14:07 +0900 Subject: [PATCH 29/67] fix: pos --- docker-compose.yaml | 8 ++------ scripts/config.ts | 4 ++-- test-node.bash | 6 +++--- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 81deb6d..90e88d9 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -93,7 +93,7 @@ services: - generate-genesis - --num-validators=64 - --output-ssz=/consensus/genesis.ssz - - --chain-config-file=/config/prysm.yaml + - --config-name=interop volumes: - "consensus:/consensus" - "config:/config" @@ -108,10 +108,9 @@ services: - --datadir=/consensus/beacondata - --rpc-port=5000 - --min-sync-peers=0 - - --interop-genesis-state=/consensus/genesis.ssz + - --genesis-state=/consensus/genesis.ssz - --interop-eth1data-votes - --bootstrap-node= - - --chain-config-file=/config/prysm.yaml - --rpc-host=0.0.0.0 - --grpc-gateway-host=0.0.0.0 - --chain-id=32382 @@ -121,8 +120,6 @@ services: depends_on: geth: condition: service_started - create_beacon_chain_genesis: - condition: service_completed_successfully ports: - "127.0.0.1:5000:5000" - "127.0.0.1:3500:3500" @@ -140,7 +137,6 @@ services: - --accept-terms-of-use - --interop-num-validators=64 - --interop-start-index=0 - - --chain-config-file=/config/prysm.yaml depends_on: prysm_beacon_chain: condition: service_started diff --git a/scripts/config.ts b/scripts/config.ts index 469761f..d6d44b9 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -13,11 +13,11 @@ PRESET_BASE: interop GENESIS_FORK_VERSION: 0x20000089 # Altair -ALTAIR_FORK_EPOCH: 1 +ALTAIR_FORK_EPOCH: 0 ALTAIR_FORK_VERSION: 0x20000090 # Merge -BELLATRIX_FORK_EPOCH: 2 +BELLATRIX_FORK_EPOCH: 0 BELLATRIX_FORK_VERSION: 0x20000091 TERMINAL_TOTAL_DIFFICULTY: 50 diff --git a/test-node.bash b/test-node.bash index 7479780..e637de5 100755 --- a/test-node.bash +++ b/test-node.bash @@ -339,8 +339,8 @@ if $force_init; then echo == Writing configs docker compose run scripts write-geth-genesis-config - echo == Writing configs - docker compose run scripts write-prysm-config +# echo == Writing configs +# docker compose run scripts write-prysm-config echo == Initializing go-ethereum genesis configuration docker compose run geth init --datadir /datadir/ /config/geth_genesis.json @@ -349,7 +349,7 @@ if $force_init; then docker compose up --wait geth echo == Creating prysm genesis - docker compose up create_beacon_chain_genesis + docker compose run create_beacon_chain_genesis echo == Running prysm docker compose up --wait prysm_beacon_chain From 63b9cbb73cf9d4ebce54cdc77e80655ec3da7524 Mon Sep 17 00:00:00 2001 From: gzeon Date: Thu, 15 Aug 2024 16:36:52 +0900 Subject: [PATCH 30/67] fix: working config --- docker-compose.yaml | 3 +++ scripts/config.ts | 4 ++++ test-node.bash | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 90e88d9..7bc877e 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -94,6 +94,7 @@ services: - --num-validators=64 - --output-ssz=/consensus/genesis.ssz - --config-name=interop + - --chain-config-file=/config/prysm.yaml volumes: - "consensus:/consensus" - "config:/config" @@ -111,6 +112,7 @@ services: - --genesis-state=/consensus/genesis.ssz - --interop-eth1data-votes - --bootstrap-node= + - --chain-config-file=/config/prysm.yaml - --rpc-host=0.0.0.0 - --grpc-gateway-host=0.0.0.0 - --chain-id=32382 @@ -137,6 +139,7 @@ services: - --accept-terms-of-use - --interop-num-validators=64 - --interop-start-index=0 + - --chain-config-file=/config/prysm.yaml depends_on: prysm_beacon_chain: condition: service_started diff --git a/scripts/config.ts b/scripts/config.ts index d6d44b9..67e1b5e 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -26,9 +26,13 @@ CAPELLA_FORK_EPOCH: 0 CAPELLA_FORK_VERSION: 0x20000092 MAX_WITHDRAWALS_PER_PAYLOAD: 16 +# DENEB DENEB_FORK_EPOCH: 2 DENEB_FORK_VERSION: 0x20000093 +# ELECTRA +ELECTRA_FORK_EPOCH: 2 +ELECTRA_FORK_VERSION: 0x20000094 # Time parameters SECONDS_PER_SLOT: 12 diff --git a/test-node.bash b/test-node.bash index e637de5..0719866 100755 --- a/test-node.bash +++ b/test-node.bash @@ -339,8 +339,8 @@ if $force_init; then echo == Writing configs docker compose run scripts write-geth-genesis-config -# echo == Writing configs -# docker compose run scripts write-prysm-config + echo == Writing configs + docker compose run scripts write-prysm-config echo == Initializing go-ethereum genesis configuration docker compose run geth init --datadir /datadir/ /config/geth_genesis.json From b3be70f8798ea2af40c150b1668ff560b5c7b7dc Mon Sep 17 00:00:00 2001 From: gzeon Date: Thu, 15 Aug 2024 16:37:25 +0900 Subject: [PATCH 31/67] chore: reduce slot time to speed up deployment --- scripts/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/config.ts b/scripts/config.ts index 67e1b5e..dbd8845 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -35,7 +35,7 @@ ELECTRA_FORK_EPOCH: 2 ELECTRA_FORK_VERSION: 0x20000094 # Time parameters -SECONDS_PER_SLOT: 12 +SECONDS_PER_SLOT: 2 SLOTS_PER_EPOCH: 6 # Deposit contract From 91f4892fa49f17e001908387e72e8f71cf01342a Mon Sep 17 00:00:00 2001 From: gzeon Date: Thu, 15 Aug 2024 16:48:07 +0900 Subject: [PATCH 32/67] fix: enable electra since genesis --- scripts/config.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/config.ts b/scripts/config.ts index dbd8845..467636d 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -27,15 +27,15 @@ CAPELLA_FORK_VERSION: 0x20000092 MAX_WITHDRAWALS_PER_PAYLOAD: 16 # DENEB -DENEB_FORK_EPOCH: 2 +DENEB_FORK_EPOCH: 0 DENEB_FORK_VERSION: 0x20000093 # ELECTRA -ELECTRA_FORK_EPOCH: 2 +ELECTRA_FORK_EPOCH: 0 ELECTRA_FORK_VERSION: 0x20000094 # Time parameters -SECONDS_PER_SLOT: 2 +SECONDS_PER_SLOT: 12 SLOTS_PER_EPOCH: 6 # Deposit contract From 626db9044c8d96b5e495131daed0ad53ceb864e2 Mon Sep 17 00:00:00 2001 From: gzeon Date: Thu, 15 Aug 2024 17:58:53 +0900 Subject: [PATCH 33/67] fix: use newer geth --- docker-compose.yaml | 6 +----- scripts/config.ts | 10 ++++------ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 7bc877e..73dad66 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -47,7 +47,7 @@ services: - "127.0.0.1:6379:6379" geth: - image: ethereum/client-go:v1.10.23 + image: ethereum/client-go:v1.13.15 ports: - "127.0.0.1:8545:8545" - "127.0.0.1:8551:8551" @@ -77,10 +77,6 @@ services: - --authrpc.jwtsecret=/config/jwt.hex - --nodiscover - --syncmode=full - - --dev - - --dev.period=1 - - --mine - - --miner.etherbase=0x3f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E - --gcmode=archive # Creates a genesis state for the beacon chain using a YAML configuration file and diff --git a/scripts/config.ts b/scripts/config.ts index 467636d..82246d9 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -50,7 +50,6 @@ function writeGethGenesisConfig(argv: any) { "config": { "ChainName": "l1_chain", "chainId": 32382, - "consensus": "clique", "homesteadBlock": 0, "daoForkSupport": true, "eip150Block": 0, @@ -67,11 +66,10 @@ function writeGethGenesisConfig(argv: any) { "terminalBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "arrowGlacierBlock": 0, "grayGlacierBlock": 0, - "clique": { - "period": 5, - "epoch": 30000 - }, - "terminalTotalDifficulty": 50 + "shanghaiTime": 1691701126, + "cancunTime": 1691701198, + "terminalTotalDifficulty": 0, + "terminalTotalDifficultyPassed": true }, "difficulty": "1", "extradata": "0x00000000000000000000000000000000000000000000000000000000000000003f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E0B0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", From 54ea69082bf73fd41c4c46e4f92c656a154dbc6b Mon Sep 17 00:00:00 2001 From: gzeon Date: Fri, 16 Aug 2024 23:33:25 +0900 Subject: [PATCH 34/67] fix: remove --config-name=interop --- docker-compose.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 73dad66..f288fac 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -89,7 +89,6 @@ services: - generate-genesis - --num-validators=64 - --output-ssz=/consensus/genesis.ssz - - --config-name=interop - --chain-config-file=/config/prysm.yaml volumes: - "consensus:/consensus" From d56413c2fecd97b51745138a0c972d5a8a44c8e9 Mon Sep 17 00:00:00 2001 From: gzeon Date: Fri, 16 Aug 2024 23:41:14 +0900 Subject: [PATCH 35/67] fix: disable electra --- scripts/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/config.ts b/scripts/config.ts index 82246d9..64d98b8 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -31,7 +31,7 @@ DENEB_FORK_EPOCH: 0 DENEB_FORK_VERSION: 0x20000093 # ELECTRA -ELECTRA_FORK_EPOCH: 0 +ELECTRA_FORK_EPOCH: 18446744073709551615 ELECTRA_FORK_VERSION: 0x20000094 # Time parameters From b50457a2e06db3008d6299cf419ec6a166c89598 Mon Sep 17 00:00:00 2001 From: gzeon Date: Sat, 17 Aug 2024 00:05:52 +0900 Subject: [PATCH 36/67] fix: use latest geth --- docker-compose.yaml | 3 ++- test-node.bash | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index f288fac..c18a179 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -47,7 +47,7 @@ services: - "127.0.0.1:6379:6379" geth: - image: ethereum/client-go:v1.13.15 + image: ethereum/client-go:latest ports: - "127.0.0.1:8545:8545" - "127.0.0.1:8551:8551" @@ -78,6 +78,7 @@ services: - --nodiscover - --syncmode=full - --gcmode=archive + - --state.scheme=hash # Creates a genesis state for the beacon chain using a YAML configuration file and # a deterministic set of validators diff --git a/test-node.bash b/test-node.bash index 0719866..c828998 100755 --- a/test-node.bash +++ b/test-node.bash @@ -343,7 +343,7 @@ if $force_init; then docker compose run scripts write-prysm-config echo == Initializing go-ethereum genesis configuration - docker compose run geth init --datadir /datadir/ /config/geth_genesis.json + docker compose run geth init --state.scheme hash --datadir /datadir/ /config/geth_genesis.json echo == Starting geth docker compose up --wait geth From d4329bdc213624446ee2450e43b55f9ab341f78c Mon Sep 17 00:00:00 2001 From: gzeon Date: Sat, 17 Aug 2024 00:27:39 +0900 Subject: [PATCH 37/67] fix: add fee recipient --- docker-compose.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yaml b/docker-compose.yaml index c18a179..ab3d1e3 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -115,6 +115,7 @@ services: - --execution-endpoint=http://geth:8551 - --accept-terms-of-use - --jwt-secret=/config/jwt.hex + - --suggested-fee-recipient=0x000000000000000000000000000000000000dead depends_on: geth: condition: service_started From f0d7b1c09e57c0b1c3b36532ddc1b503426f09a9 Mon Sep 17 00:00:00 2001 From: gzeon Date: Sat, 17 Aug 2024 00:59:55 +0900 Subject: [PATCH 38/67] fix: enable deneb --- docker-compose.yaml | 6 +++++- scripts/config.ts | 5 ++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index ab3d1e3..18303bf 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -88,9 +88,13 @@ services: command: - testnet - generate-genesis + - --fork=deneb - --num-validators=64 + - --genesis-time-delay=15 - --output-ssz=/consensus/genesis.ssz - --chain-config-file=/config/prysm.yaml + - --geth-genesis-json-in=/config/geth_genesis.json + - --geth-genesis-json-out=/config/geth_genesis.json volumes: - "consensus:/consensus" - "config:/config" @@ -115,7 +119,7 @@ services: - --execution-endpoint=http://geth:8551 - --accept-terms-of-use - --jwt-secret=/config/jwt.hex - - --suggested-fee-recipient=0x000000000000000000000000000000000000dead + - --suggested-fee-recipient=0x000000000000000000000000000000000000dEaD depends_on: geth: condition: service_started diff --git a/scripts/config.ts b/scripts/config.ts index 64d98b8..ecc3dbf 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -31,7 +31,6 @@ DENEB_FORK_EPOCH: 0 DENEB_FORK_VERSION: 0x20000093 # ELECTRA -ELECTRA_FORK_EPOCH: 18446744073709551615 ELECTRA_FORK_VERSION: 0x20000094 # Time parameters @@ -66,8 +65,8 @@ function writeGethGenesisConfig(argv: any) { "terminalBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "arrowGlacierBlock": 0, "grayGlacierBlock": 0, - "shanghaiTime": 1691701126, - "cancunTime": 1691701198, + "shanghaiTime": 0, + "cancunTime": 1706778826, "terminalTotalDifficulty": 0, "terminalTotalDifficultyPassed": true }, From 17ca06428adf62bd240334918c9d5ba0c972549f Mon Sep 17 00:00:00 2001 From: gzeon Date: Sat, 17 Aug 2024 01:00:32 +0900 Subject: [PATCH 39/67] fix: wait for tx sync --- scripts/ethcommands.ts | 19 +++++++++++++++++++ scripts/index.ts | 2 ++ test-node.bash | 13 ++++++++----- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/scripts/ethcommands.ts b/scripts/ethcommands.ts index fcf1dca..1ba9768 100644 --- a/scripts/ethcommands.ts +++ b/scripts/ethcommands.ts @@ -473,3 +473,22 @@ export const sendRPCCommand = { await rpcProvider.send(argv.method, argv.params) } } + +export const waitForSyncCommand = { + command: "wait-for-sync", + describe: "wait for rpc to sync", + builder: { + url: { string: true, describe: "url to send rpc call", default: "http://sequencer:8547"}, + }, + handler: async (argv: any) => { + const rpcProvider = new ethers.providers.JsonRpcProvider(argv.url) + let syncStatus; + do { + syncStatus = await rpcProvider.send("eth_syncing", []) + if (syncStatus !== false) { + // Wait for a short interval before checking again + await new Promise(resolve => setTimeout(resolve, 5000)) + } + } while (syncStatus !== false) + }, +}; diff --git a/scripts/index.ts b/scripts/index.ts index 2fd189f..e0a1aa4 100644 --- a/scripts/index.ts +++ b/scripts/index.ts @@ -19,6 +19,7 @@ import { sendL2Command, sendL3Command, sendRPCCommand, + waitForSyncCommand, } from "./ethcommands"; async function main() { @@ -51,6 +52,7 @@ async function main() { .command(printPrivateKeyCommand) .command(redisReadCommand) .command(redisInitCommand) + .command(waitForSyncCommand) .strict() .demandCommand(1, "a command must be specified") .epilogue(namedAccountHelpString) diff --git a/test-node.bash b/test-node.bash index c828998..84557e7 100755 --- a/test-node.bash +++ b/test-node.bash @@ -339,8 +339,11 @@ if $force_init; then echo == Writing configs docker compose run scripts write-geth-genesis-config - echo == Writing configs - docker compose run scripts write-prysm-config + echo == Writing configs + docker compose run scripts write-prysm-config + + echo == Creating prysm genesis + docker compose run create_beacon_chain_genesis echo == Initializing go-ethereum genesis configuration docker compose run geth init --state.scheme hash --datadir /datadir/ /config/geth_genesis.json @@ -348,9 +351,6 @@ if $force_init; then echo == Starting geth docker compose up --wait geth - echo == Creating prysm genesis - docker compose run create_beacon_chain_genesis - echo == Running prysm docker compose up --wait prysm_beacon_chain docker compose up --wait prysm_validator @@ -358,6 +358,9 @@ if $force_init; then docker compose up --wait geth fi + echo == Waiting for geth to sync + docker compose run scripts wait-for-sync --url http://geth:8545 + echo == Funding validator, sequencer and l2owner docker compose run scripts send-l1 --ethamount 1000 --to validator --wait docker compose run scripts send-l1 --ethamount 1000 --to sequencer --wait From 66968663f51ff71ba69411614d2ddef05195832b Mon Sep 17 00:00:00 2001 From: gzeon Date: Sat, 17 Aug 2024 01:02:12 +0900 Subject: [PATCH 40/67] fix: format --- scripts/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/config.ts b/scripts/config.ts index ecc3dbf..9735e98 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -65,7 +65,7 @@ function writeGethGenesisConfig(argv: any) { "terminalBlockHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "arrowGlacierBlock": 0, "grayGlacierBlock": 0, - "shanghaiTime": 0, + "shanghaiTime": 0, "cancunTime": 1706778826, "terminalTotalDifficulty": 0, "terminalTotalDifficultyPassed": true From d0c48087ec0792f55d4369fba85006776701f59e Mon Sep 17 00:00:00 2001 From: gzeon Date: Sat, 17 Aug 2024 01:06:47 +0900 Subject: [PATCH 41/67] feat: shorter slot for faster testing --- scripts/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/config.ts b/scripts/config.ts index 9735e98..8ad8382 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -34,7 +34,7 @@ DENEB_FORK_VERSION: 0x20000093 ELECTRA_FORK_VERSION: 0x20000094 # Time parameters -SECONDS_PER_SLOT: 12 +SECONDS_PER_SLOT: 2 SLOTS_PER_EPOCH: 6 # Deposit contract From b577249bc17918a99f88f1ffaa78faf6e361cad7 Mon Sep 17 00:00:00 2001 From: gzeon Date: Sat, 17 Aug 2024 01:17:20 +0900 Subject: [PATCH 42/67] fix: readd dev flags --- docker-compose.yaml | 4 ++++ scripts/config.ts | 2 +- test-node.bash | 22 +++++++++++----------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 18303bf..95a9fd5 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -79,6 +79,10 @@ services: - --syncmode=full - --gcmode=archive - --state.scheme=hash + - --dev + - --dev.period=1 + - --mine + - --miner.etherbase=0x3f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E # Creates a genesis state for the beacon chain using a YAML configuration file and # a deterministic set of validators diff --git a/scripts/config.ts b/scripts/config.ts index 8ad8382..1aef099 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -70,7 +70,7 @@ function writeGethGenesisConfig(argv: any) { "terminalTotalDifficulty": 0, "terminalTotalDifficultyPassed": true }, - "difficulty": "1", + "difficulty": "0", "extradata": "0x00000000000000000000000000000000000000000000000000000000000000003f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E0B0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "nonce": "0x42", "timestamp": "0x0", diff --git a/test-node.bash b/test-node.bash index 84557e7..91b2bef 100755 --- a/test-node.bash +++ b/test-node.bash @@ -335,29 +335,29 @@ if $force_init; then docker compose run --entrypoint sh geth -c "chown -R 1000:1000 /keystore" docker compose run --entrypoint sh geth -c "chown -R 1000:1000 /config" - if $consensusclient; then - echo == Writing configs - docker compose run scripts write-geth-genesis-config + echo == Writing geth configs + docker compose run scripts write-geth-genesis-config - echo == Writing configs + if $consensusclient; then + echo == Writing prysm configs docker compose run scripts write-prysm-config echo == Creating prysm genesis docker compose run create_beacon_chain_genesis + fi - echo == Initializing go-ethereum genesis configuration - docker compose run geth init --state.scheme hash --datadir /datadir/ /config/geth_genesis.json - - echo == Starting geth - docker compose up --wait geth + echo == Initializing go-ethereum genesis configuration + docker compose run geth init --state.scheme hash --datadir /datadir/ /config/geth_genesis.json + if $consensusclient; then echo == Running prysm docker compose up --wait prysm_beacon_chain docker compose up --wait prysm_validator - else - docker compose up --wait geth fi + echo == Starting geth + docker compose up --wait geth + echo == Waiting for geth to sync docker compose run scripts wait-for-sync --url http://geth:8545 From bf63f06996118cd940e95e1d8d91d2b4cf5fc1ef Mon Sep 17 00:00:00 2001 From: gzeon Date: Sat, 17 Aug 2024 01:18:52 +0900 Subject: [PATCH 43/67] fix: readd condition --- docker-compose.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yaml b/docker-compose.yaml index 95a9fd5..f2369ed 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -127,6 +127,8 @@ services: depends_on: geth: condition: service_started + create_beacon_chain_genesis: + condition: service_completed_successfully ports: - "127.0.0.1:5000:5000" - "127.0.0.1:3500:3500" From 41f925d3fb61647dde5332851f2fdd7273cdc681 Mon Sep 17 00:00:00 2001 From: gzeon Date: Sat, 17 Aug 2024 01:29:53 +0900 Subject: [PATCH 44/67] fix: reduce diff --- docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index f2369ed..2597aae 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -77,12 +77,12 @@ services: - --authrpc.jwtsecret=/config/jwt.hex - --nodiscover - --syncmode=full - - --gcmode=archive - --state.scheme=hash - --dev - --dev.period=1 - --mine - --miner.etherbase=0x3f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E + - --gcmode=archive # Creates a genesis state for the beacon chain using a YAML configuration file and # a deterministic set of validators From 9074e6e122911bf2a5d723283bae1fb6ec08829e Mon Sep 17 00:00:00 2001 From: gzeon Date: Sat, 17 Aug 2024 02:08:06 +0900 Subject: [PATCH 45/67] fix: docker compose --- .github/workflows/testnode.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testnode.bash b/.github/workflows/testnode.bash index 0e57e13..41a87ce 100755 --- a/.github/workflows/testnode.bash +++ b/.github/workflows/testnode.bash @@ -44,10 +44,10 @@ while true; do sleep 10 done -docker-compose stop +docker compose stop if [ "$SUCCEEDED" = false ]; then - docker-compose logs + docker compose logs exit 1 fi From f5aca59972b1dfdab4f999edcc634fbcba3b8024 Mon Sep 17 00:00:00 2001 From: gzeon Date: Sat, 17 Aug 2024 02:17:57 +0900 Subject: [PATCH 46/67] ci: test pos --- .github/workflows/ci.yml | 52 +++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a78e451..35dc8f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,36 +2,38 @@ name: CI run-name: CI triggered from @${{ github.actor }} of ${{ github.head_ref }} on: - workflow_dispatch: - merge_group: - pull_request: - push: - branches: - - master - - develop - + workflow_dispatch: + merge_group: + pull_request: + push: + branches: + - master + - develop jobs: build_and_run: runs-on: ubuntu-8 + strategy: + matrix: + pos: [true, false] steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: recursive + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - driver-opts: network=host + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver-opts: network=host - - name: Cache Docker layers - uses: actions/cache@v3 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }} - restore-keys: ${{ runner.os }}-buildx- - - - name: Startup Nitro testnode - run: ${{ github.workspace }}/.github/workflows/testnode.bash + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }} + restore-keys: ${{ runner.os }}-buildx- + + - name: Startup Nitro testnode + run: ${{ github.workspace }}/.github/workflows/testnode.bash ${{ matrix.pos == true && '--pos' || '' }} From 4533a0f95c76a6b068bfa0d7b20b4f9f7864d265 Mon Sep 17 00:00:00 2001 From: gzeon Date: Sat, 17 Aug 2024 03:32:19 +0900 Subject: [PATCH 47/67] ci: fix --- .github/workflows/testnode.bash | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/testnode.bash b/.github/workflows/testnode.bash index 41a87ce..0a080af 100755 --- a/.github/workflows/testnode.bash +++ b/.github/workflows/testnode.bash @@ -5,8 +5,31 @@ # Start the test node and get PID, to terminate it once send-l2 is done. cd ${GITHUB_WORKSPACE} +while [[ $# -gt 0 ]]; do + case $1 in + --pos) + pos=true + shift + ;; + *) + echo "Unknown option $1" + exit 1 + ;; + esac +done + # TODO once develop is merged into nitro-contract's master, remove the NITRO_CONTRACTS_BRANCH env var -./test-node.bash --init-force --l3node --no-simple --detach +if [ "$pos" = true ]; then + echo "Running with --pos" + ./test-node.bash --init-force --l3node --no-simple --detach --pos +else + ./test-node.bash --init-force --l3node --no-simple --detach +fi + +if [ $? -ne 0 ]; then + echo "test-node.bash failed" + exit 1 +fi START=$(date +%s) L2_TRANSACTION_SUCCEEDED=false From 52b69fb6ad716e2bd58fabd7b57d4bbace1a152a Mon Sep 17 00:00:00 2001 From: gzeon Date: Sat, 17 Aug 2024 03:42:53 +0900 Subject: [PATCH 48/67] ci: debug log --- .github/workflows/testnode.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/testnode.bash b/.github/workflows/testnode.bash index 0a080af..1e4140c 100755 --- a/.github/workflows/testnode.bash +++ b/.github/workflows/testnode.bash @@ -28,6 +28,7 @@ fi if [ $? -ne 0 ]; then echo "test-node.bash failed" + docker compose logs --tail=1000 exit 1 fi From ed40ac036bcba5b10640bcf61d8e66589fdd156d Mon Sep 17 00:00:00 2001 From: gzeon Date: Sat, 17 Aug 2024 04:09:57 +0900 Subject: [PATCH 49/67] fix: also use 1337 for pos setup --- docker-compose.yaml | 2 +- scripts/config.ts | 2 +- test-node.bash | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 2597aae..f8facec 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -119,7 +119,7 @@ services: - --chain-config-file=/config/prysm.yaml - --rpc-host=0.0.0.0 - --grpc-gateway-host=0.0.0.0 - - --chain-id=32382 + - --chain-id=1337 - --execution-endpoint=http://geth:8551 - --accept-terms-of-use - --jwt-secret=/config/jwt.hex diff --git a/scripts/config.ts b/scripts/config.ts index 1aef099..73f9520 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -48,7 +48,7 @@ function writeGethGenesisConfig(argv: any) { { "config": { "ChainName": "l1_chain", - "chainId": 32382, + "chainId": 1337, "homesteadBlock": 0, "daoForkSupport": true, "eip150Block": 0, diff --git a/test-node.bash b/test-node.bash index 7a86c54..af683f3 100755 --- a/test-node.bash +++ b/test-node.bash @@ -131,7 +131,7 @@ while [[ $# -gt 0 ]]; do ;; --pos) consensusclient=true - l1chainid=32382 + l1chainid=1337 shift ;; --l3node) From e41e324b9544925b7ed5637cfc2d90df18a4c0e0 Mon Sep 17 00:00:00 2001 From: Chris Buckland Date: Mon, 2 Sep 2024 16:00:49 +0100 Subject: [PATCH 50/67] Test commit --- .github/workflows/testnode.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/testnode.bash b/.github/workflows/testnode.bash index 1e4140c..157d4cc 100755 --- a/.github/workflows/testnode.bash +++ b/.github/workflows/testnode.bash @@ -18,6 +18,7 @@ while [[ $# -gt 0 ]]; do esac done + # TODO once develop is merged into nitro-contract's master, remove the NITRO_CONTRACTS_BRANCH env var if [ "$pos" = true ]; then echo "Running with --pos" From ab44f67a7da6e4606733dca5059f4b4435a9804c Mon Sep 17 00:00:00 2001 From: Chris Buckland Date: Mon, 2 Sep 2024 16:02:21 +0100 Subject: [PATCH 51/67] Test passing all the args through --- .github/workflows/testnode.bash | 40 +++++++++++++++++---------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/.github/workflows/testnode.bash b/.github/workflows/testnode.bash index 157d4cc..b03557a 100755 --- a/.github/workflows/testnode.bash +++ b/.github/workflows/testnode.bash @@ -5,27 +5,29 @@ # Start the test node and get PID, to terminate it once send-l2 is done. cd ${GITHUB_WORKSPACE} -while [[ $# -gt 0 ]]; do - case $1 in - --pos) - pos=true - shift - ;; - *) - echo "Unknown option $1" - exit 1 - ;; - esac -done +# while [[ $# -gt 0 ]]; do +# case $1 in +# --pos) +# pos=true +# shift +# ;; +# *) +# echo "Unknown option $1" +# exit 1 +# ;; +# esac +# done -# TODO once develop is merged into nitro-contract's master, remove the NITRO_CONTRACTS_BRANCH env var -if [ "$pos" = true ]; then - echo "Running with --pos" - ./test-node.bash --init-force --l3node --no-simple --detach --pos -else - ./test-node.bash --init-force --l3node --no-simple --detach -fi +./test-node.bash "$@" + +# # TODO once develop is merged into nitro-contract's master, remove the NITRO_CONTRACTS_BRANCH env var +# if [ "$pos" = true ]; then +# echo "Running with --pos" +# ./test-node.bash --init-force --l3node --no-simple --detach --pos +# else +# ./test-node.bash --init-force --l3node --no-simple --detach +# fi if [ $? -ne 0 ]; then echo "test-node.bash failed" From 21b591328283b7d2854be48026bcd2624bf8016d Mon Sep 17 00:00:00 2001 From: Chris Buckland Date: Mon, 2 Sep 2024 16:08:07 +0100 Subject: [PATCH 52/67] Test tokenbridge and l3node startups --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 35dc8f6..efd1c3b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,8 @@ jobs: strategy: matrix: pos: [true, false] + l3node: [true, false] + tokenbridge: [true, false] steps: - name: Checkout @@ -36,4 +38,4 @@ jobs: restore-keys: ${{ runner.os }}-buildx- - name: Startup Nitro testnode - run: ${{ github.workspace }}/.github/workflows/testnode.bash ${{ matrix.pos == true && '--pos' || '' }} + run: ${{ github.workspace }}/.github/workflows/testnode.bash --init-force ${{ matrix.l3node == true && '--l3node' || '' }} ${{ matrix.tokenbridge == true && '--tokenbridge' || '--no-tokenbridge' }} --no-simple --detach ${{ matrix.pos == true && '--pos' || '' }} From cf7feed0d69263430dece118439dc37187ed6596 Mon Sep 17 00:00:00 2001 From: Chris Buckland Date: Mon, 2 Sep 2024 16:12:05 +0100 Subject: [PATCH 53/67] Changed the runner names --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index efd1c3b..924fdf4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,9 +15,9 @@ jobs: runs-on: ubuntu-8 strategy: matrix: - pos: [true, false] - l3node: [true, false] - tokenbridge: [true, false] + pos: [pos, no-pos] + l3node: [l3node, no-l3node] + tokenbridge: [tokenbridge, no-tokenbridge] steps: - name: Checkout @@ -38,4 +38,4 @@ jobs: restore-keys: ${{ runner.os }}-buildx- - name: Startup Nitro testnode - run: ${{ github.workspace }}/.github/workflows/testnode.bash --init-force ${{ matrix.l3node == true && '--l3node' || '' }} ${{ matrix.tokenbridge == true && '--tokenbridge' || '--no-tokenbridge' }} --no-simple --detach ${{ matrix.pos == true && '--pos' || '' }} + run: ${{ github.workspace }}/.github/workflows/testnode.bash --init-force ${{ matrix.l3node == 'l3node' && '--l3node' || '' }} ${{ matrix.tokenbridge == 'tokenbridge' && '--tokenbridge' || '--no-tokenbridge' }} --no-simple --detach ${{ matrix.pos == 'pos' && '--pos' || '' }} From 432f0eea884e49549f1476ee1b948ab6d38156c5 Mon Sep 17 00:00:00 2001 From: Chris Buckland Date: Mon, 2 Sep 2024 16:12:38 +0100 Subject: [PATCH 54/67] Cleanup in ci bash --- .github/workflows/testnode.bash | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/.github/workflows/testnode.bash b/.github/workflows/testnode.bash index b03557a..33c6b55 100755 --- a/.github/workflows/testnode.bash +++ b/.github/workflows/testnode.bash @@ -5,30 +5,8 @@ # Start the test node and get PID, to terminate it once send-l2 is done. cd ${GITHUB_WORKSPACE} -# while [[ $# -gt 0 ]]; do -# case $1 in -# --pos) -# pos=true -# shift -# ;; -# *) -# echo "Unknown option $1" -# exit 1 -# ;; -# esac -# done - - ./test-node.bash "$@" -# # TODO once develop is merged into nitro-contract's master, remove the NITRO_CONTRACTS_BRANCH env var -# if [ "$pos" = true ]; then -# echo "Running with --pos" -# ./test-node.bash --init-force --l3node --no-simple --detach --pos -# else -# ./test-node.bash --init-force --l3node --no-simple --detach -# fi - if [ $? -ne 0 ]; then echo "test-node.bash failed" docker compose logs --tail=1000 From a809fee5356f71ecd5d496316e59940581dca647 Mon Sep 17 00:00:00 2001 From: Chris Buckland Date: Mon, 2 Sep 2024 16:44:35 +0100 Subject: [PATCH 55/67] Dont test for l3 tx if no l3node --- .github/workflows/testnode.bash | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/testnode.bash b/.github/workflows/testnode.bash index 33c6b55..d89bfd1 100755 --- a/.github/workflows/testnode.bash +++ b/.github/workflows/testnode.bash @@ -13,9 +13,15 @@ if [ $? -ne 0 ]; then exit 1 fi + START=$(date +%s) L2_TRANSACTION_SUCCEEDED=false -L3_TRANSACTION_SUCCEEDED=false +L3_TRANSACTION_SUCCEEDED=true +for arg in "$@"; do + if [ "$arg" = "--l3node" ]; then + L3_TRANSACTION_SUCCEEDED=false + fi +done SUCCEEDED=false while true; do From daaae0de5b62742d8330929a3aabfbdb2f89546c Mon Sep 17 00:00:00 2001 From: Chris Buckland Date: Mon, 2 Sep 2024 16:45:52 +0100 Subject: [PATCH 56/67] Added l3 node comment --- .github/workflows/testnode.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/testnode.bash b/.github/workflows/testnode.bash index d89bfd1..83fdd86 100755 --- a/.github/workflows/testnode.bash +++ b/.github/workflows/testnode.bash @@ -16,6 +16,7 @@ fi START=$(date +%s) L2_TRANSACTION_SUCCEEDED=false +# if we're not running an l3node then we just set l3 to success by default L3_TRANSACTION_SUCCEEDED=true for arg in "$@"; do if [ "$arg" = "--l3node" ]; then From 1d2229674d0e8e951350cd6a47ad90a357dad027 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Tue, 13 Aug 2024 13:51:18 +0200 Subject: [PATCH 57/67] Add --l2-anytrust option to run in AnyTrust mode test-node.bash can now be run with --l2-anytrust which runs the l2 nodes in AnyTrust mode. It creates a committee of 2 daserver with assumed-honest set to 1, requiring successful stores of the batch data to both of them. Nitro nodes sync from a mirror daserver. All dasevers use local file storage for the batch data on their own volumes. BLS keys for the committee are automatically generated and the keyset is activated automatically on the SequencerInbox contract. --- docker-compose.yaml | 51 ++++++++++ scripts/config.ts | 212 ++++++++++++++++++++++++++++++++++++++++- scripts/ethcommands.ts | 40 ++++++++ scripts/index.ts | 8 +- test-node.bash | 63 +++++++++++- 5 files changed, 363 insertions(+), 11 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 81deb6d..c71857f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -361,6 +361,54 @@ services: - "config:/config" - /var/run/docker.sock:/var/run/docker.sock + datool: + image: nitro-node-dev-testnode + entrypoint: /usr/local/bin/datool + volumes: + - "config:/config" + - "das-committee-a-data:/das-committee-a" + - "das-committee-b-data:/das-committee-b" + - "das-mirror-data:/das-mirror" + command: + + das-committee-a: + pid: host # allow debugging + image: nitro-node-dev-testnode + entrypoint: /usr/local/bin/daserver + ports: + - "127.0.0.1:9876:9876" + - "127.0.0.1:9877:9877" + volumes: + - "config:/config" + - "das-committee-a-data:/das" + command: + - --conf.file=/config/l2_das_committee_a.json + + das-committee-b: + pid: host # allow debugging + image: nitro-node-dev-testnode + entrypoint: /usr/local/bin/daserver + ports: + - "127.0.0.1:8876:9876" + - "127.0.0.1:8877:9877" + volumes: + - "config:/config" + - "das-committee-b-data:/das" + command: + - --conf.file=/config/l2_das_committee_b.json + + das-mirror: + pid: host # allow debugging + image: nitro-node-dev-testnode + entrypoint: /usr/local/bin/daserver + ports: + - "127.0.0.1:7877:9877" + volumes: + - "config:/config" + - "das-mirror-data:/das" + command: + - --conf.file=/config/l2_das_mirror.json + volumes: l1data: consensus: @@ -377,3 +425,6 @@ volumes: config: postgres-data: tokenbridge-data: + das-committee-a-data: + das-committee-b-data: + das-mirror-data: diff --git a/scripts/config.ts b/scripts/config.ts index eefcdd2..9c6028c 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -1,5 +1,6 @@ import * as fs from 'fs'; import * as consts from './consts' +import { ethers } from "ethers"; import { namedAccount, namedAddress } from './accounts' const path = require("path"); @@ -153,7 +154,7 @@ function writeGethGenesisConfig(argv: any) { function writeConfigs(argv: any) { const valJwtSecret = path.join(consts.configpath, "val_jwt.hex") const chainInfoFile = path.join(consts.configpath, "l2_chain_info.json") - const baseConfig = { + let baseConfig = { "parent-chain": { "connection": { "url": argv.l1url, @@ -171,7 +172,7 @@ function writeConfigs(argv: any) { "parent-chain-wallet" : { "account": namedAddress("validator"), "password": consts.l1passphrase, - "pathname": consts.l1keystore, + "pathname": consts.l1keystore, }, "disable-challenge": false, "enable": false, @@ -205,7 +206,7 @@ function writeConfigs(argv: any) { "parent-chain-wallet" : { "account": namedAddress("sequencer"), "password": consts.l1passphrase, - "pathname": consts.l1keystore, + "pathname": consts.l1keystore, }, "data-poster": { "redis-signer": { @@ -219,6 +220,17 @@ function writeConfigs(argv: any) { "url": argv.validationNodeUrl, "jwtsecret": valJwtSecret, } + }, + "data-availability": { + "enable": false, + "rpc-aggregator": dasBackendsJsonConfig(argv), + "rest-aggregator": { + "enable": true, + "urls": ["http://das-mirror:9877"], + }, + // TODO Fix das config to not need this redundant config + "parent-chain-node-url": argv.l1url, + "sequencer-inbox-address": "not_set" } }, "execution": { @@ -240,6 +252,12 @@ function writeConfigs(argv: any) { }, } + const deploydata = JSON.parse( + fs + .readFileSync(path.join(consts.configpath, "deployment.json")) + .toString() + ); + baseConfig.node["data-availability"]["sequencer-inbox-address"] = ethers.utils.hexlify(deploydata["sequencer-inbox"]); const baseConfJSON = JSON.stringify(baseConfig) @@ -254,11 +272,20 @@ function writeConfigs(argv: any) { simpleConfig.node["batch-poster"].enable = true simpleConfig.node["batch-poster"]["redis-url"] = "" simpleConfig.execution["sequencer"].enable = true + if (argv.anytrust) { + simpleConfig.node["data-availability"].enable = true + simpleConfig.node["data-availability"]["rpc-aggregator"].enable = true + simpleConfig.node["data-availability"]["rest-aggregator"].enable = true + } fs.writeFileSync(path.join(consts.configpath, "sequencer_config.json"), JSON.stringify(simpleConfig)) } else { let validatorConfig = JSON.parse(baseConfJSON) validatorConfig.node.staker.enable = true validatorConfig.node.staker["use-smart-contract-wallet"] = true + if (argv.anytrust) { + validatorConfig.node["data-availability"].enable = true + validatorConfig.node["data-availability"]["rest-aggregator"].enable = true + } let validconfJSON = JSON.stringify(validatorConfig) fs.writeFileSync(path.join(consts.configpath, "validator_config.json"), validconfJSON) @@ -271,11 +298,20 @@ function writeConfigs(argv: any) { sequencerConfig.node["seq-coordinator"].enable = true sequencerConfig.execution["sequencer"].enable = true sequencerConfig.node["delayed-sequencer"].enable = true + if (argv.anytrust) { + sequencerConfig.node["data-availability"].enable = true + sequencerConfig.node["data-availability"]["rest-aggregator"].enable = true + } fs.writeFileSync(path.join(consts.configpath, "sequencer_config.json"), JSON.stringify(sequencerConfig)) let posterConfig = JSON.parse(baseConfJSON) posterConfig.node["seq-coordinator"].enable = true posterConfig.node["batch-poster"].enable = true + if (argv.anytrust) { + posterConfig.node["data-availability"].enable = true + posterConfig.node["data-availability"]["rpc-aggregator"].enable = true + posterConfig.node["data-availability"]["rest-aggregator"].enable = true + } fs.writeFileSync(path.join(consts.configpath, "poster_config.json"), JSON.stringify(posterConfig)) } @@ -343,7 +379,7 @@ function writeL2ChainConfig(argv: any) { "arbitrum": { "EnableArbOS": true, "AllowDebugPrecompiles": true, - "DataAvailabilityCommittee": false, + "DataAvailabilityCommittee": argv.anytrust, "InitialArbOSVersion": 30, "InitialChainOwner": argv.l2owner, "GenesisBlockNum": 0 @@ -386,6 +422,92 @@ function writeL3ChainConfig(argv: any) { fs.writeFileSync(path.join(consts.configpath, "l3_chain_config.json"), l3ChainConfigJSON) } +function writeL2DASCommitteeConfig(argv: any, sequencerInboxAddr: string) { + const l2DASCommitteeConfig = { + "data-availability": { + "key": { + "key-dir": "/das/keys" + }, + "local-file-storage": { + "data-dir": "/das/data", + "enable": true, + "enable-expiry": true + }, + "sequencer-inbox-address": sequencerInboxAddr, + "parent-chain-node-url": argv.l1url + }, + "enable-rest": true, + "enable-rpc": true, + "log-level": "INFO", + "rest-addr": "0.0.0.0", + "rest-port": "9877", + "rpc-addr": "0.0.0.0", + "rpc-port": "9876" + } + const l2DASCommitteeConfigJSON = JSON.stringify(l2DASCommitteeConfig) + + fs.writeFileSync(path.join(consts.configpath, "l2_das_committee_" + argv.committeeMember + ".json"), l2DASCommitteeConfigJSON) +} + +function writeL2DASMirrorConfig(argv: any, sequencerInboxAddr: string) { + const l2DASMirrorConfig = { + "data-availability": { + "local-file-storage": { + "data-dir": "/das/data", + "enable": true, + "enable-expiry": false + }, + "sequencer-inbox-address": sequencerInboxAddr, + "parent-chain-node-url": argv.l1url, + "rest-aggregator": { + "enable": true, + "sync-to-storage": { + "eager": false, + "ignore-write-errors": false, + "state-dir": "/das/metadata", + "sync-expired-data": true + }, + "urls": ["http://das-committee-a:9877", "http://das-committee-b:9877"], + } + }, + "enable-rest": true, + "enable-rpc": false, + "log-level": "INFO", + "rest-addr": "0.0.0.0", + "rest-port": "9877" + } + const l2DASMirrorConfigJSON = JSON.stringify(l2DASMirrorConfig) + + fs.writeFileSync(path.join(consts.configpath, "l2_das_mirror.json"), l2DASMirrorConfigJSON) +} + +function writeL2DASKeysetConfig(argv: any) { + const l2DASKeysetConfig = { + "keyset": dasBackendsJsonConfig(argv) + } + const l2DASKeysetConfigJSON = JSON.stringify(l2DASKeysetConfig) + + fs.writeFileSync(path.join(consts.configpath, "l2_das_keyset.json"), l2DASKeysetConfigJSON) +} + +function dasBackendsJsonConfig(argv: any) { + const backends = { + "enable": false, + "assumed-honest": 1, + "backends": [ + { + "url": "http://das-committee-a:9876", + "pubkey": argv.dasBlsA + }, + { + "url": "http://das-committee-b:9876", + "pubkey": argv.dasBlsB + } + ] + } + return backends +} + export const writeConfigCommand = { command: "write-config", describe: "writes config files", @@ -395,7 +517,23 @@ export const writeConfigCommand = { describe: "simple config (sequencer is also poster, validator)", default: false, }, - }, + anytrust: { + boolean: true, + describe: "run nodes in anytrust mode", + default: false + }, + dasBlsA: { + string: true, + describe: "DAS committee member A BLS pub key", + default: "" + }, + dasBlsB: { + string: true, + describe: "DAS committee member B BLS pub key", + default: "" + }, + + }, handler: (argv: any) => { writeConfigs(argv) } @@ -420,6 +558,13 @@ export const writeGethGenesisCommand = { export const writeL2ChainConfigCommand = { command: "write-l2-chain-config", describe: "writes l2 chain config file", + builder: { + anytrust: { + boolean: true, + describe: "enable anytrust in chainconfig", + default: false + }, + }, handler: (argv: any) => { writeL2ChainConfig(argv) } @@ -432,3 +577,60 @@ export const writeL3ChainConfigCommand = { writeL3ChainConfig(argv) } } + +export const writeL2DASCommitteeConfigCommand = { + command: "write-l2-das-committee-config", + describe: "writes daserver committee member config file", + builder: { + committeeMember: { + string: true, + describe: "Unique identifier for the das committee member", + default: "not_set" + }, + }, + handler: (argv: any) => { + const deploydata = JSON.parse( + fs + .readFileSync(path.join(consts.configpath, "deployment.json")) + .toString() + ); + const sequencerInboxAddr = ethers.utils.hexlify(deploydata["sequencer-inbox"]); + + writeL2DASCommitteeConfig(argv, sequencerInboxAddr) + } +} + +export const writeL2DASMirrorConfigCommand = { + command: "write-l2-das-mirror-config", + describe: "writes daserver mirror config file", + handler: (argv: any) => { + const deploydata = JSON.parse( + fs + .readFileSync(path.join(consts.configpath, "deployment.json")) + .toString() + ); + const sequencerInboxAddr = ethers.utils.hexlify(deploydata["sequencer-inbox"]); + + writeL2DASMirrorConfig(argv, sequencerInboxAddr) + } +} + +export const writeL2DASKeysetConfigCommand = { + command: "write-l2-das-keyset-config", + describe: "writes DAS keyset config", + builder: { + dasBlsA: { + string: true, + describe: "DAS committee member A BLS pub key", + default: "" + }, + dasBlsB: { + string: true, + describe: "DAS committee member B BLS pub key", + default: "" + }, + }, + handler: (argv: any) => { + writeL2DASKeysetConfig(argv) + } +} diff --git a/scripts/ethcommands.ts b/scripts/ethcommands.ts index 82eeadb..9122e6b 100644 --- a/scripts/ethcommands.ts +++ b/scripts/ethcommands.ts @@ -279,6 +279,25 @@ export const createERC20Command = { }, }; +// Will revert if the keyset is already valid. +async function setValidKeyset(argv: any, upgradeExecutorAddr: string, sequencerInboxAddr: string, keyset: string){ + const innerIface = new ethers.utils.Interface(["function setValidKeyset(bytes)"]) + const innerData = innerIface.encodeFunctionData("setValidKeyset", [keyset]); + + // The Executor contract is the owner of the SequencerInbox so calls must be made + // through it. + const outerIface = new ethers.utils.Interface(["function executeCall(address,bytes)"]) + argv.data = outerIface.encodeFunctionData("executeCall", [sequencerInboxAddr, innerData]); + + argv.from = "l2owner"; + argv.to = "address_" + upgradeExecutorAddr + argv.ethamount = "0" + + await runStress(argv, sendTransaction); + + argv.provider.destroy(); +} + export const transferERC20Command = { command: "transfer-erc20", describe: "transfers ERC20 token", @@ -431,3 +450,24 @@ export const sendRPCCommand = { await rpcProvider.send(argv.method, argv.params) } } + +export const setValidKeysetCommand = { + command: "set-valid-keyset", + describe: "sets the anytrust keyset", + handler: async (argv: any) => { + argv.provider = new ethers.providers.WebSocketProvider(argv.l1url); + const deploydata = JSON.parse( + fs + .readFileSync(path.join(consts.configpath, "deployment.json")) + .toString() + ); + const sequencerInboxAddr = ethers.utils.hexlify(deploydata["sequencer-inbox"]); + const upgradeExecutorAddr = ethers.utils.hexlify(deploydata["upgrade-executor"]); + + const keyset = fs + .readFileSync(path.join(consts.configpath, "l2_das_keyset.hex")) + .toString() + + await setValidKeyset(argv, upgradeExecutorAddr, sequencerInboxAddr, keyset) + } +} diff --git a/scripts/index.ts b/scripts/index.ts index 2fd189f..758d5a5 100644 --- a/scripts/index.ts +++ b/scripts/index.ts @@ -2,7 +2,7 @@ import { hideBin } from "yargs/helpers"; import Yargs from "yargs/yargs"; import { stressOptions } from "./stress"; import { redisReadCommand, redisInitCommand } from "./redis"; -import { writeConfigCommand, writeGethGenesisCommand, writePrysmCommand, writeL2ChainConfigCommand, writeL3ChainConfigCommand } from "./config"; +import { writeConfigCommand, writeGethGenesisCommand, writePrysmCommand, writeL2ChainConfigCommand, writeL3ChainConfigCommand, writeL2DASCommitteeConfigCommand, writeL2DASMirrorConfigCommand, writeL2DASKeysetConfigCommand } from "./config"; import { printAddressCommand, namedAccountHelpString, @@ -19,6 +19,7 @@ import { sendL2Command, sendL3Command, sendRPCCommand, + setValidKeysetCommand, } from "./ethcommands"; async function main() { @@ -30,6 +31,7 @@ async function main() { l3url: { string: true, default: "ws://l3node:3348" }, validationNodeUrl: { string: true, default: "ws://validation_node:8549" }, l2owner: { string: true, default: "0x3f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E" }, + committeeMember: { string: true, default: "not_set" }, }) .options(stressOptions) .command(bridgeFundsCommand) @@ -41,10 +43,14 @@ async function main() { .command(sendL2Command) .command(sendL3Command) .command(sendRPCCommand) + .command(setValidKeysetCommand) .command(writeConfigCommand) .command(writeGethGenesisCommand) .command(writeL2ChainConfigCommand) .command(writeL3ChainConfigCommand) + .command(writeL2DASCommitteeConfigCommand) + .command(writeL2DASMirrorConfigCommand) + .command(writeL2DASKeysetConfigCommand) .command(writePrysmCommand) .command(writeAccountsCommand) .command(printAddressCommand) diff --git a/test-node.bash b/test-node.bash index 75f6d30..a8d7af4 100755 --- a/test-node.bash +++ b/test-node.bash @@ -50,6 +50,7 @@ batchposters=1 devprivkey=b6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659 l1chainid=1337 simple=true +l2anytrust=false # Use the dev versions of nitro/blockscout dev_nitro=false @@ -209,6 +210,10 @@ while [[ $# -gt 0 ]]; do l3_token_bridge=true shift ;; + --l2-anytrust) + l2anytrust=true + shift + ;; --redundantsequencers) simple=false redundantsequencers=$2 @@ -241,6 +246,7 @@ while [[ $# -gt 0 ]]; do echo --l3node deploys an L3 node on top of the L2 echo --l3-fee-token L3 chain is set up to use custom fee token. Only valid if also '--l3node' is provided echo --l3-token-bridge Deploy L2-L3 token bridge. Only valid if also '--l3node' is provided + echo --l2-anytrust run the L2 as an AnyTrust chain echo --batchposters batch posters [0-3] echo --redundantsequencers redundant sequencers [0-3] echo --detach detach from nodes after running them @@ -266,6 +272,13 @@ done NODES="sequencer" INITIAL_SEQ_NODES="sequencer" +#if $l2anytrust; then +# # NODES="$NODES das-committee-a das-committee-b das-mirror" +# NODES="$NODES das-committee-a das-committee-b" +#fi + +#NODES="$NODES sequencer" + if ! $simple; then NODES="$NODES redis" fi @@ -303,7 +316,6 @@ if $blockscout; then NODES="$NODES blockscout" fi - if $dev_nitro && $build_dev_nitro; then echo == Building Nitro if ! [ -n "${NITRO_SRC+set}" ]; then @@ -408,8 +420,13 @@ if $force_init; then l2ownerAddress=`docker compose run scripts print-address --account l2owner | tail -n 1 | tr -d '\r\n'` - echo == Writing l2 chain config - docker compose run scripts --l2owner $l2ownerAddress write-l2-chain-config + if $l2anytrust; then + echo "== Writing l2 chain config (anytrust enabled)" + docker compose run scripts --l2owner $l2ownerAddress write-l2-chain-config --anytrust + else + echo == Writing l2 chain config + docker compose run scripts --l2owner $l2ownerAddress write-l2-chain-config + fi sequenceraddress=`docker compose run scripts print-address --account sequencer | tail -n 1 | tr -d '\r\n'` l2ownerKey=`docker compose run scripts print-private-key --account l2owner | tail -n 1 | tr -d '\r\n'` @@ -419,12 +436,48 @@ if $force_init; then docker compose run -e PARENT_CHAIN_RPC="http://geth:8545" -e DEPLOYER_PRIVKEY=$l2ownerKey -e PARENT_CHAIN_ID=$l1chainid -e CHILD_CHAIN_NAME="arb-dev-test" -e MAX_DATA_SIZE=117964 -e OWNER_ADDRESS=$l2ownerAddress -e WASM_MODULE_ROOT=$wasmroot -e SEQUENCER_ADDRESS=$sequenceraddress -e AUTHORIZE_VALIDATORS=10 -e CHILD_CHAIN_CONFIG_PATH="/config/l2_chain_config.json" -e CHAIN_DEPLOYMENT_INFO="/config/deployment.json" -e CHILD_CHAIN_INFO="/config/deployed_chain_info.json" rollupcreator create-rollup-testnode docker compose run --entrypoint sh rollupcreator -c "jq [.[]] /config/deployed_chain_info.json > /config/l2_chain_info.json" +fi # $force_init + +anytrustNodeConfigLine="" + +# Remaining init may require AnyTrust committee/mirrors to have been started +if $l2anytrust; then + if $force_init; then + echo == Generating AnyTrust Config + docker compose run --user root --entrypoint sh datool -c "mkdir /das-committee-a/keys /das-committee-a/data /das-committee-a/metadata /das-committee-b/keys /das-committee-b/data /das-committee-b/metadata /das-mirror/data /das-mirror/metadata" + docker compose run --user root --entrypoint sh datool -c "chown -R 1000:1000 /das*" + docker compose run datool keygen --dir /das-committee-a/keys + docker compose run datool keygen --dir /das-committee-b/keys + sequencerinbox=`docker compose run --entrypoint sh datool -c "cat /config/l2_chain_info.json | jq -r '.[].rollup.\"sequencer-inbox\"'"` + docker compose run scripts write-l2-das-committee-config --committeeMember a + docker compose run scripts write-l2-das-committee-config --committeeMember b + docker compose run scripts write-l2-das-mirror-config + fi + + das_bls_a=`docker compose run --entrypoint sh datool -c "cat /das-committee-a/keys/das_bls.pub"` + das_bls_b=`docker compose run --entrypoint sh datool -c "cat /das-committee-b/keys/das_bls.pub"` + + docker compose run scripts write-l2-das-keyset-config --dasBlsA $das_bls_a --dasBlsB $das_bls_b + docker compose run --entrypoint sh datool -c "/usr/local/bin/datool dumpkeyset --conf.file /config/l2_das_keyset.json | grep 'Keyset: ' | awk '{ printf \"%s\", \$2 }' > /config/l2_das_keyset.hex" + docker compose run scripts set-valid-keyset + + anytrustNodeConfigLine="--anytrust --dasBlsA $das_bls_a --dasBlsB $das_bls_b" + + if $run; then + echo == Starting AnyTrust committee and mirror + docker compose up --wait das-committee-a das-committee-b das-mirror + # TODO how to make these containers go down since they are now + # run in the background + fi +fi + +if $force_init; then if $simple; then echo == Writing configs - docker compose run scripts write-config --simple + docker compose run scripts write-config --simple $anytrustNodeConfigLine else echo == Writing configs - docker compose run scripts write-config + docker compose run scripts write-config $anytrustNodeConfigLine echo == Initializing redis docker compose up --wait redis From 148b8cb33fb085345d9abdf0ba57d3b67f63499d Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Thu, 5 Sep 2024 16:44:43 -0700 Subject: [PATCH 58/67] Use latest Nitro release v3.1.2 --- test-node.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-node.bash b/test-node.bash index ce73ade..685dea2 100755 --- a/test-node.bash +++ b/test-node.bash @@ -2,7 +2,7 @@ set -eu -NITRO_NODE_VERSION=offchainlabs/nitro-node:v3.1.0-7d1d84c-dev +NITRO_NODE_VERSION=offchainlabs/nitro-node:v3.1.2-309340a-dev BLOCKSCOUT_VERSION=offchainlabs/blockscout:v1.1.0-0e716c8 # This commit matches v2.1.0 release of nitro-contracts, with additional support to set arb owner through upgrade executor From c7b3f6eb25ac231f7656288166f6df6c6b43ce73 Mon Sep 17 00:00:00 2001 From: Chris Buckland Date: Wed, 18 Sep 2024 12:25:28 +0200 Subject: [PATCH 59/67] Added some testing for l3node with custom fee token --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 924fdf4..34126b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: pos: [pos, no-pos] - l3node: [l3node, no-l3node] + l3node: [l3node, l3node6, no-l3node] tokenbridge: [tokenbridge, no-tokenbridge] steps: @@ -38,4 +38,4 @@ jobs: restore-keys: ${{ runner.os }}-buildx- - name: Startup Nitro testnode - run: ${{ github.workspace }}/.github/workflows/testnode.bash --init-force ${{ matrix.l3node == 'l3node' && '--l3node' || '' }} ${{ matrix.tokenbridge == 'tokenbridge' && '--tokenbridge' || '--no-tokenbridge' }} --no-simple --detach ${{ matrix.pos == 'pos' && '--pos' || '' }} + run: ${{ github.workspace }}/.github/workflows/testnode.bash --init-force ${{ (matrix.l3node == 'l3node' && '--l3node') || (matrix.l3node == 'l3node6' && '--l3node --l3-fee-token --l3-token-bridge --l3-fee-token-decimals 6') || '' }} ${{ matrix.tokenbridge == 'tokenbridge' && '--tokenbridge' || '--no-tokenbridge' }} --no-simple --detach ${{ matrix.pos == 'pos' && '--pos' || '' }} From 97200666e5a9301138c4634f062e9a6dcb7acfd9 Mon Sep 17 00:00:00 2001 From: Chris Buckland Date: Wed, 18 Sep 2024 12:28:55 +0200 Subject: [PATCH 60/67] Rename token6 --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34126b3..fd2eb2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: pos: [pos, no-pos] - l3node: [l3node, l3node6, no-l3node] + l3node: [l3node, l3node-token-6, no-l3node] tokenbridge: [tokenbridge, no-tokenbridge] steps: @@ -38,4 +38,4 @@ jobs: restore-keys: ${{ runner.os }}-buildx- - name: Startup Nitro testnode - run: ${{ github.workspace }}/.github/workflows/testnode.bash --init-force ${{ (matrix.l3node == 'l3node' && '--l3node') || (matrix.l3node == 'l3node6' && '--l3node --l3-fee-token --l3-token-bridge --l3-fee-token-decimals 6') || '' }} ${{ matrix.tokenbridge == 'tokenbridge' && '--tokenbridge' || '--no-tokenbridge' }} --no-simple --detach ${{ matrix.pos == 'pos' && '--pos' || '' }} + run: ${{ github.workspace }}/.github/workflows/testnode.bash --init-force ${{ (matrix.l3node == 'l3node' && '--l3node') || (matrix.l3node == 'l3node-token-6' && '--l3node --l3-fee-token --l3-token-bridge --l3-fee-token-decimals 6') || '' }} ${{ matrix.tokenbridge == 'tokenbridge' && '--tokenbridge' || '--no-tokenbridge' }} --no-simple --detach ${{ matrix.pos == 'pos' && '--pos' || '' }} From c09fa7525277510c5354fd649856cd175a744afa Mon Sep 17 00:00:00 2001 From: Chris Buckland Date: Wed, 18 Sep 2024 13:23:44 +0200 Subject: [PATCH 61/67] Set lower transfer amounts --- .github/workflows/testnode.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testnode.bash b/.github/workflows/testnode.bash index 83fdd86..be7e696 100755 --- a/.github/workflows/testnode.bash +++ b/.github/workflows/testnode.bash @@ -27,14 +27,14 @@ SUCCEEDED=false while true; do if [ "$L2_TRANSACTION_SUCCEEDED" = false ]; then - if ${GITHUB_WORKSPACE}/test-node.bash script send-l2 --ethamount 100 --to user_l2user --wait; then + if ${GITHUB_WORKSPACE}/test-node.bash script send-l2 --ethamount 2 --to user_l2user --wait; then echo "Sending l2 transaction succeeded" L2_TRANSACTION_SUCCEEDED=true fi fi if [ "$L3_TRANSACTION_SUCCEEDED" = false ]; then - if ${GITHUB_WORKSPACE}/test-node.bash script send-l3 --ethamount 100 --to user_l3user --wait; then + if ${GITHUB_WORKSPACE}/test-node.bash script send-l3 --ethamount 2 --to user_l3user --wait; then echo "Sending l3 transaction succeeded" L3_TRANSACTION_SUCCEEDED=true fi From 20b5d14a0dd6d3ec1132b86a9522559311f1bb78 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Tue, 24 Sep 2024 15:15:20 -0500 Subject: [PATCH 62/67] Update to nitro v3.2.1 --- blockscout | 2 +- scripts/config.ts | 2 +- test-node.bash | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/blockscout b/blockscout index a978272..cca5c1a 160000 --- a/blockscout +++ b/blockscout @@ -1 +1 @@ -Subproject commit a9782723bcaefdfa44fd353474903b1b457b132d +Subproject commit cca5c1a8442ff8a34c39a957ab7e9e3381af911b diff --git a/scripts/config.ts b/scripts/config.ts index 6edded2..a131fae 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -344,7 +344,7 @@ function writeL2ChainConfig(argv: any) { "EnableArbOS": true, "AllowDebugPrecompiles": true, "DataAvailabilityCommittee": false, - "InitialArbOSVersion": 31, + "InitialArbOSVersion": 32, "InitialChainOwner": argv.l2owner, "GenesisBlockNum": 0 } diff --git a/test-node.bash b/test-node.bash index f18e5d0..0e4b0e4 100755 --- a/test-node.bash +++ b/test-node.bash @@ -2,7 +2,7 @@ set -eu -NITRO_NODE_VERSION=offchainlabs/nitro-node:v3.1.0-7d1d84c-dev +NITRO_NODE_VERSION=offchainlabs/nitro-node:v3.2.1-d81324d BLOCKSCOUT_VERSION=offchainlabs/blockscout:v1.1.0-0e716c8 DEFAULT_NITRO_CONTRACTS_VERSION="v2.0.0" From 72141dd495ad965aa2a23723ea3e755037903ad7 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Tue, 24 Sep 2024 17:28:51 -0500 Subject: [PATCH 63/67] Update blockscout pin to arbitrum branch --- blockscout | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockscout b/blockscout index cca5c1a..60d60cb 160000 --- a/blockscout +++ b/blockscout @@ -1 +1 @@ -Subproject commit cca5c1a8442ff8a34c39a957ab7e9e3381af911b +Subproject commit 60d60cb331b0289d39c7480379a14a86100af37a From fe7af88b2ef3a4c73b312d3eb2ac071e701b704e Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Mon, 30 Sep 2024 11:42:58 +0200 Subject: [PATCH 64/67] Add clabot config --- .clabot | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .clabot diff --git a/.clabot b/.clabot new file mode 100644 index 0000000..55cb5e6 --- /dev/null +++ b/.clabot @@ -0,0 +1,5 @@ +{ + "contributors": "https://api.github.com/repos/OffchainLabs/clabot-config/contents/nitro-contributors.json", + "message": "We require contributors to sign our Contributor License Agreement. In order for us to review and merge your code, please sign the linked documents below to get yourself added. https://na3.docusign.net/Member/PowerFormSigning.aspx?PowerFormId=b15c81cc-b5ea-42a6-9107-3992526f2898&env=na3&acct=6e152afc-6284-44af-a4c1-d8ef291db402&v=2", + "label": "s" +} From 02621d2eaa56ba85d0b55540042cfdfcc100b5a0 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Wed, 2 Oct 2024 18:22:37 +0200 Subject: [PATCH 65/67] Fix PR comments --- docker-compose.yaml | 4 +-- scripts/config.ts | 62 +++++++++++++----------------------------- scripts/ethcommands.ts | 2 +- test-node.bash | 43 +++++++++++------------------ 4 files changed, 38 insertions(+), 73 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index bdf13ae..f595b66 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -388,7 +388,7 @@ services: - "config:/config" - "das-committee-a-data:/das" command: - - --conf.file=/config/l2_das_committee_a.json + - --conf.file=/config/l2_das_committee.json das-committee-b: pid: host # allow debugging @@ -401,7 +401,7 @@ services: - "config:/config" - "das-committee-b-data:/das" command: - - --conf.file=/config/l2_das_committee_b.json + - --conf.file=/config/l2_das_committee.json das-mirror: pid: host # allow debugging diff --git a/scripts/config.ts b/scripts/config.ts index 6f8bfe3..15bc6f7 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -161,6 +161,18 @@ function writeGethGenesisConfig(argv: any) { fs.writeFileSync(path.join(consts.configpath, "val_jwt.hex"), val_jwt) } +type ChainInfo = { + [key: string]: any; +}; + +// Define a function to return ChainInfo +function getChainInfo(): ChainInfo { + const filePath = path.join(consts.configpath, "l2_chain_info.json"); + const fileContents = fs.readFileSync(filePath).toString(); + const chainInfo: ChainInfo = JSON.parse(fileContents); + return chainInfo; +} + function writeConfigs(argv: any) { const valJwtSecret = path.join(consts.configpath, "val_jwt.hex") const chainInfoFile = path.join(consts.configpath, "l2_chain_info.json") @@ -232,7 +244,7 @@ function writeConfigs(argv: any) { } }, "data-availability": { - "enable": false, + "enable": argv.anytrust, "rpc-aggregator": dasBackendsJsonConfig(argv), "rest-aggregator": { "enable": true, @@ -262,12 +274,7 @@ function writeConfigs(argv: any) { }, } - const deploydata = JSON.parse( - fs - .readFileSync(path.join(consts.configpath, "deployment.json")) - .toString() - ); - baseConfig.node["data-availability"]["sequencer-inbox-address"] = ethers.utils.hexlify(deploydata["sequencer-inbox"]); + baseConfig.node["data-availability"]["sequencer-inbox-address"] = ethers.utils.hexlify(getChainInfo()[0]["rollup"]["sequencer-inbox"]); const baseConfJSON = JSON.stringify(baseConfig) @@ -283,19 +290,13 @@ function writeConfigs(argv: any) { simpleConfig.node["batch-poster"]["redis-url"] = "" simpleConfig.execution["sequencer"].enable = true if (argv.anytrust) { - simpleConfig.node["data-availability"].enable = true simpleConfig.node["data-availability"]["rpc-aggregator"].enable = true - simpleConfig.node["data-availability"]["rest-aggregator"].enable = true } fs.writeFileSync(path.join(consts.configpath, "sequencer_config.json"), JSON.stringify(simpleConfig)) } else { let validatorConfig = JSON.parse(baseConfJSON) validatorConfig.node.staker.enable = true validatorConfig.node.staker["use-smart-contract-wallet"] = true - if (argv.anytrust) { - validatorConfig.node["data-availability"].enable = true - validatorConfig.node["data-availability"]["rest-aggregator"].enable = true - } let validconfJSON = JSON.stringify(validatorConfig) fs.writeFileSync(path.join(consts.configpath, "validator_config.json"), validconfJSON) @@ -308,19 +309,13 @@ function writeConfigs(argv: any) { sequencerConfig.node["seq-coordinator"].enable = true sequencerConfig.execution["sequencer"].enable = true sequencerConfig.node["delayed-sequencer"].enable = true - if (argv.anytrust) { - sequencerConfig.node["data-availability"].enable = true - sequencerConfig.node["data-availability"]["rest-aggregator"].enable = true - } fs.writeFileSync(path.join(consts.configpath, "sequencer_config.json"), JSON.stringify(sequencerConfig)) let posterConfig = JSON.parse(baseConfJSON) posterConfig.node["seq-coordinator"].enable = true posterConfig.node["batch-poster"].enable = true if (argv.anytrust) { - posterConfig.node["data-availability"].enable = true posterConfig.node["data-availability"]["rpc-aggregator"].enable = true - posterConfig.node["data-availability"]["rest-aggregator"].enable = true } fs.writeFileSync(path.join(consts.configpath, "poster_config.json"), JSON.stringify(posterConfig)) } @@ -432,7 +427,8 @@ function writeL3ChainConfig(argv: any) { fs.writeFileSync(path.join(consts.configpath, "l3_chain_config.json"), l3ChainConfigJSON) } -function writeL2DASCommitteeConfig(argv: any, sequencerInboxAddr: string) { +function writeL2DASCommitteeConfig(argv: any) { + const sequencerInboxAddr = ethers.utils.hexlify(getChainInfo()[0]["rollup"]["sequencer-inbox"]); const l2DASCommitteeConfig = { "data-availability": { "key": { @@ -456,7 +452,7 @@ function writeL2DASCommitteeConfig(argv: any, sequencerInboxAddr: string) { } const l2DASCommitteeConfigJSON = JSON.stringify(l2DASCommitteeConfig) - fs.writeFileSync(path.join(consts.configpath, "l2_das_committee_" + argv.committeeMember + ".json"), l2DASCommitteeConfigJSON) + fs.writeFileSync(path.join(consts.configpath, "l2_das_committee.json"), l2DASCommitteeConfigJSON) } function writeL2DASMirrorConfig(argv: any, sequencerInboxAddr: string) { @@ -591,22 +587,8 @@ export const writeL3ChainConfigCommand = { export const writeL2DASCommitteeConfigCommand = { command: "write-l2-das-committee-config", describe: "writes daserver committee member config file", - builder: { - committeeMember: { - string: true, - describe: "Unique identifier for the das committee member", - default: "not_set" - }, - }, handler: (argv: any) => { - const deploydata = JSON.parse( - fs - .readFileSync(path.join(consts.configpath, "deployment.json")) - .toString() - ); - const sequencerInboxAddr = ethers.utils.hexlify(deploydata["sequencer-inbox"]); - - writeL2DASCommitteeConfig(argv, sequencerInboxAddr) + writeL2DASCommitteeConfig(argv) } } @@ -614,13 +596,7 @@ export const writeL2DASMirrorConfigCommand = { command: "write-l2-das-mirror-config", describe: "writes daserver mirror config file", handler: (argv: any) => { - const deploydata = JSON.parse( - fs - .readFileSync(path.join(consts.configpath, "deployment.json")) - .toString() - ); - const sequencerInboxAddr = ethers.utils.hexlify(deploydata["sequencer-inbox"]); - + const sequencerInboxAddr = ethers.utils.hexlify(getChainInfo()[0]["rollup"]["sequencer-inbox"]); writeL2DASMirrorConfig(argv, sequencerInboxAddr) } } diff --git a/scripts/ethcommands.ts b/scripts/ethcommands.ts index 3311cf5..06285e7 100644 --- a/scripts/ethcommands.ts +++ b/scripts/ethcommands.ts @@ -386,7 +386,7 @@ async function setValidKeyset(argv: any, upgradeExecutorAddr: string, sequencerI argv.to = "address_" + upgradeExecutorAddr argv.ethamount = "0" - await runStress(argv, sendTransaction); + await sendTransaction(argv, 0); argv.provider.destroy(); } diff --git a/test-node.bash b/test-node.bash index e40f818..9c7204c 100755 --- a/test-node.bash +++ b/test-node.bash @@ -224,9 +224,9 @@ while [[ $# -gt 0 ]]; do shift ;; --l2-anytrust) - l2anytrust=true - shift - ;; + l2anytrust=true + shift + ;; --redundantsequencers) simple=false redundantsequencers=$2 @@ -260,7 +260,7 @@ while [[ $# -gt 0 ]]; do echo --l3-fee-token L3 chain is set up to use custom fee token. Only valid if also '--l3node' is provided echo --l3-fee-token-decimals Number of decimals to use for custom fee token. Only valid if also '--l3-fee-token' is provided echo --l3-token-bridge Deploy L2-L3 token bridge. Only valid if also '--l3node' is provided - echo --l2-anytrust run the L2 as an AnyTrust chain + echo --l2-anytrust run the L2 as an AnyTrust chain echo --batchposters batch posters [0-3] echo --redundantsequencers redundant sequencers [0-3] echo --detach detach from nodes after running them @@ -286,13 +286,6 @@ done NODES="sequencer" INITIAL_SEQ_NODES="sequencer" -#if $l2anytrust; then -# # NODES="$NODES das-committee-a das-committee-b das-mirror" -# NODES="$NODES das-committee-a das-committee-b" -#fi - -#NODES="$NODES sequencer" - if ! $simple; then NODES="$NODES redis" fi @@ -465,27 +458,23 @@ if $l2anytrust; then docker compose run --user root --entrypoint sh datool -c "chown -R 1000:1000 /das*" docker compose run datool keygen --dir /das-committee-a/keys docker compose run datool keygen --dir /das-committee-b/keys - sequencerinbox=`docker compose run --entrypoint sh datool -c "cat /config/l2_chain_info.json | jq -r '.[].rollup.\"sequencer-inbox\"'"` - docker compose run scripts write-l2-das-committee-config --committeeMember a - docker compose run scripts write-l2-das-committee-config --committeeMember b + docker compose run scripts write-l2-das-committee-config docker compose run scripts write-l2-das-mirror-config - fi - das_bls_a=`docker compose run --entrypoint sh datool -c "cat /das-committee-a/keys/das_bls.pub"` - das_bls_b=`docker compose run --entrypoint sh datool -c "cat /das-committee-b/keys/das_bls.pub"` + das_bls_a=`docker compose run --entrypoint sh datool -c "cat /das-committee-a/keys/das_bls.pub"` + das_bls_b=`docker compose run --entrypoint sh datool -c "cat /das-committee-b/keys/das_bls.pub"` - docker compose run scripts write-l2-das-keyset-config --dasBlsA $das_bls_a --dasBlsB $das_bls_b - docker compose run --entrypoint sh datool -c "/usr/local/bin/datool dumpkeyset --conf.file /config/l2_das_keyset.json | grep 'Keyset: ' | awk '{ printf \"%s\", \$2 }' > /config/l2_das_keyset.hex" - docker compose run scripts set-valid-keyset + docker compose run scripts write-l2-das-keyset-config --dasBlsA $das_bls_a --dasBlsB $das_bls_b + docker compose run --entrypoint sh datool -c "/usr/local/bin/datool dumpkeyset --conf.file /config/l2_das_keyset.json | grep 'Keyset: ' | awk '{ printf \"%s\", \$2 }' > /config/l2_das_keyset.hex" + docker compose run scripts set-valid-keyset - anytrustNodeConfigLine="--anytrust --dasBlsA $das_bls_a --dasBlsB $das_bls_b" + anytrustNodeConfigLine="--anytrust --dasBlsA $das_bls_a --dasBlsB $das_bls_b" + fi - if $run; then - echo == Starting AnyTrust committee and mirror - docker compose up --wait das-committee-a das-committee-b das-mirror - # TODO how to make these containers go down since they are now - # run in the background - fi + if $run; then + echo == Starting AnyTrust committee and mirror + docker compose up --wait das-committee-a das-committee-b das-mirror + fi fi if $force_init; then From cebbb192cbc9d3b0b12bd8eb610d7d914817d5c7 Mon Sep 17 00:00:00 2001 From: Ethen Pociask Date: Tue, 14 Jan 2025 04:25:34 +0700 Subject: [PATCH 66/67] chore: Update CI to use eigenda flag --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9605784..c0926b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,12 +12,13 @@ on: jobs: build_and_run: - runs-on: ubuntu-8 + runs-on: ubuntu-latest strategy: matrix: pos: [pos, no-pos] l3node: [l3node, l3node-token-6, no-l3node] tokenbridge: [tokenbridge, no-tokenbridge] + eigenda: [eigenda, no-eigenda] steps: - name: Checkout @@ -40,4 +41,4 @@ jobs: - name: Startup Nitro testnode env: EIGENDA_SIGNER_PRIVATE_KEY: ${{ secrets.EIGENDA_SIGNER_PRIVATE_KEY }} - run: EIGENDA_SIGNER_PRIVATE_KEY=$EIGENDA_SIGNER_PRIVATE_KEY ${{ github.workspace }}/.github/workflows/testnode.bash --init-force ${{ (matrix.l3node == 'l3node' && '--l3node') || (matrix.l3node == 'l3node-token-6' && '--l3node --l3-fee-token --l3-token-bridge --l3-fee-token-decimals 6') || '' }} ${{ matrix.tokenbridge == 'tokenbridge' && '--tokenbridge' || '--no-tokenbridge' }} --no-simple --detach ${{ matrix.pos == 'pos' && '--pos' || '' }} + run: EIGENDA_SIGNER_PRIVATE_KEY=$EIGENDA_SIGNER_PRIVATE_KEY ${{ github.workspace }}/.github/workflows/testnode.bash --init-force ${{ (matrix.l3node == 'l3node' && '--l3node') || (matrix.l3node == 'l3node-token-6' && '--l3node --l3-fee-token --l3-token-bridge --l3-fee-token-decimals 6') || '' }} ${{ matrix.tokenbridge == 'tokenbridge' && '--tokenbridge' || '--no-tokenbridge' }} --no-simple --detach ${{ matrix.pos == 'pos' && '--pos' || '' }} ${{matrix.eigenda == 'eigenda' && '--eigenda' || ''}} From f186aa746c28101c3e908121b7c23336c9deea06 Mon Sep 17 00:00:00 2001 From: Ethen Pociask Date: Wed, 15 Jan 2025 04:01:50 +0700 Subject: [PATCH 67/67] chore: Temporarily disable prysm tests --- .github/workflows/ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0926b3..a40bb97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - pos: [pos, no-pos] + # Temporarily disabling this until a fix is pushed upstream + # pos: [pos, no-pos] l3node: [l3node, l3node-token-6, no-l3node] tokenbridge: [tokenbridge, no-tokenbridge] eigenda: [eigenda, no-eigenda] @@ -41,4 +42,6 @@ jobs: - name: Startup Nitro testnode env: EIGENDA_SIGNER_PRIVATE_KEY: ${{ secrets.EIGENDA_SIGNER_PRIVATE_KEY }} - run: EIGENDA_SIGNER_PRIVATE_KEY=$EIGENDA_SIGNER_PRIVATE_KEY ${{ github.workspace }}/.github/workflows/testnode.bash --init-force ${{ (matrix.l3node == 'l3node' && '--l3node') || (matrix.l3node == 'l3node-token-6' && '--l3node --l3-fee-token --l3-token-bridge --l3-fee-token-decimals 6') || '' }} ${{ matrix.tokenbridge == 'tokenbridge' && '--tokenbridge' || '--no-tokenbridge' }} --no-simple --detach ${{ matrix.pos == 'pos' && '--pos' || '' }} ${{matrix.eigenda == 'eigenda' && '--eigenda' || ''}} + ## add this into run CMD when prysm patch is applied upstream + ## $ {{ matrix.pos == 'pos' && '--pos' || '' }} + run: EIGENDA_SIGNER_PRIVATE_KEY=$EIGENDA_SIGNER_PRIVATE_KEY ${{ github.workspace }}/.github/workflows/testnode.bash --init-force ${{ (matrix.l3node == 'l3node' && '--l3node') || (matrix.l3node == 'l3node-token-6' && '--l3node --l3-fee-token --l3-token-bridge --l3-fee-token-decimals 6') || '' }} ${{ matrix.tokenbridge == 'tokenbridge' && '--tokenbridge' || '--no-tokenbridge' }} --no-simple --detach ${{matrix.eigenda == 'eigenda' && '--eigenda' || ''}}