diff --git a/README.md b/README.md index 45665ca..e833655 100644 --- a/README.md +++ b/README.md @@ -102,21 +102,39 @@ For help and further scripts, see: ## Named accounts +Here is a list of address that are used in the testnode setup, avoid using them before the deployment finishes or you might end up with some nonce race. + ```bash -./test-node.bash script print-address --account sequencer +./test-node.bash script print-address --account +./test-node.bash script print-private-key --account ``` + ``` sequencer: 0xe2148eE53c0755215Df69b2616E552154EdC584f validator: 0x6A568afe0f82d34759347bb36F14A6bB171d2CBe l2owner: 0x5E1497dD1f08C87b2d8FE23e9AAB6c1De833D927 l3owner: 0x863c904166E801527125D8672442D736194A3362 l3sequencer: 0x3E6134aAD4C4d422FF2A4391Dc315c4DDf98D1a5 -user_l1user: 0x058E6C774025ade66153C65672219191c72c7095 +user_l1traffic: 0xa2db25762CFdF7bAF602F3Bcf2ec534937725f00 +user_l1traffic_b: 0xacC305CaCB4605Aa1975001e24D25F7A5d11dC61 +user_l2traffic: 0x7641C76365faC5090d315410358073D4ba199c57 +user_l2traffic_b: 0x0d25ca3B2c4b8e8c9fe4104Fbd6D37B9563FdaE4 user_token_bridge_deployer: 0x3EaCb30f025630857aDffac9B2366F953eFE4F98 user_fee_token_deployer: 0x2AC5278D230f88B481bBE4A94751d7188ef48Ca2 ``` -While not a named account, 0x3f1eae7d46d88f08fc2f8ed27fcb2ab183eb2d0e is funded on all test chains. +While not a named account, 0x3f1eae7d46d88f08fc2f8ed27fcb2ab183eb2d0e is funded on all test chains and is used to fund other accounts. + +The following account is funded on all L1, L2, and L3 and can be used for testing without risk of nonce race from testnode setup: +``` +user_user: 0xC3Aa24dA923c30BD0738111c458ec68A8FdC2dfD +``` + +## Deployment status + +- L2 and L3 are deployed when their respective RPC are avaliable (port 8545 and 3347) +- L2 token bridge is deployed if `docker-compose run --entrypoint sh tokenbridge -c "cat l1l2_network.json"` returns a valid json. +- L3 token bridge is deployed if `docker-compose run --entrypoint sh tokenbridge -c "cat l2l3_network.json"` returns a valid json. ## Contact diff --git a/scripts/config.ts b/scripts/config.ts index 23ecff4..7ff223b 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -378,7 +378,7 @@ function writeL3ChainConfig(argv: any) { "AllowDebugPrecompiles": true, "DataAvailabilityCommittee": false, "InitialArbOSVersion": 11, - "InitialChainOwner": "0x0000000000000000000000000000000000000000", + "InitialChainOwner": argv.l3owner, "GenesisBlockNum": 0 } } diff --git a/scripts/consts.ts b/scripts/consts.ts index ff32226..06f40f9 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"; diff --git a/scripts/ethcommands.ts b/scripts/ethcommands.ts index 00fdbb1..a4f5e13 100644 --- a/scripts/ethcommands.ts +++ b/scripts/ethcommands.ts @@ -3,9 +3,11 @@ import { 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 ERC20PresetFixedSupplyArtifact from "@openzeppelin/contracts/build/contracts/ERC20PresetFixedSupply.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) { @@ -184,6 +186,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", @@ -279,7 +331,6 @@ export const createERC20Command = { }, }; - export const sendL1Command = { command: "send-l1", describe: "sends funds between l1 accounts", diff --git a/scripts/index.ts b/scripts/index.ts index 9f25c6e..a1b4722 100644 --- a/scripts/index.ts +++ b/scripts/index.ts @@ -18,6 +18,7 @@ import { sendL2Command, sendL3Command, sendRPCCommand, + transferL3ChainOwnershipCommand } from "./ethcommands"; async function main() { @@ -28,7 +29,8 @@ async function main() { l2url: { string: true, default: "ws://sequencer:8548" }, l3url: { string: true, default: "ws://l3node:3348" }, validationNodeUrl: { string: true, default: "ws://validation_node:8549" }, - l2owner: { string: true, default: "0x3f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E" }, + l2owner: { string: true, default: "0x0000000000000000000000000000000000000000" }, + l3owner: { string: true, default: "0x0000000000000000000000000000000000000000" }, }) .options(stressOptions) .command(bridgeFundsCommand) @@ -39,6 +41,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 a48c61f..48825d3 100755 --- a/test-node.bash +++ b/test-node.bash @@ -326,21 +326,25 @@ if $force_init; then docker compose up --wait geth fi - echo == Funding validator, sequencer and l2owner + echo == Funding user on L1 + docker compose run scripts send-l1 --ethamount 100 --to user_user --wait + + echo == Funding validator, sequencer, l2owner and token bridge deployer docker compose run scripts send-l1 --ethamount 1000 --to validator --wait docker compose run scripts send-l1 --ethamount 1000 --to sequencer --wait docker compose run scripts send-l1 --ethamount 1000 --to l2owner --wait + docker compose run scripts send-l1 --ethamount 1000 --to user_token_bridge_deployer --wait echo == create l1 traffic - docker compose run scripts send-l1 --ethamount 1000 --to user_l1user --wait - docker compose run scripts send-l1 --ethamount 0.0001 --from user_l1user --to user_l1user_b --wait --delay 500 --times 1000000 > /dev/null & - - echo == Writing l2 chain config - docker compose run scripts write-l2-chain-config + docker compose run scripts send-l1 --ethamount 1000 --to user_l1traffic --wait + docker compose run scripts send-l1 --ethamount 0.0001 --from user_l1traffic --to user_l1traffic_b --wait --delay 500 --times 1000000 > /dev/null & sequenceraddress=`docker compose run scripts print-address --account sequencer | tail -n 1 | tr -d '\r\n'` 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 write-l2-chain-config --l2owner $l2ownerAddress + docker compose run --entrypoint /usr/local/bin/deploy sequencer --l1conn ws://geth:8546 --l1keystore /home/user/l1keystore --sequencerAddress $sequenceraddress --ownerAddress $l2ownerAddress --l1DeployAccount $l2ownerAddress --l1deployment /config/deployment.json --authorizevalidators 10 --wasmrootpath /home/user/target/machines --l1chainid=$l1chainid --l2chainconfig /config/l2_chain_config.json --l2chainname arb-dev-test --l2chaininfo /config/deployed_chain_info.json docker compose run --entrypoint sh sequencer -c "jq [.[]] /config/deployed_chain_info.json > /config/l2_chain_info.json" @@ -361,23 +365,26 @@ if $force_init; then docker compose run scripts bridge-funds --ethamount 100000 --wait docker compose run scripts bridge-funds --ethamount 1000 --wait --from "key_0x$devprivkey" + echo == Funding user on L2 + docker compose run scripts send-l2 --ethamount 100 --to user_user --wait + if $tokenbridge; then echo == Deploying L1-L2 token bridge sleep 10 # no idea why this sleep is needed but without it the deploy fails randomly rollupAddress=`docker compose run --entrypoint sh poster -c "jq -r '.[0].rollup.rollup' /config/deployed_chain_info.json | tail -n 1 | tr -d '\r\n'"` l2ownerKey=`docker compose run scripts print-private-key --account l2owner | tail -n 1 | tr -d '\r\n'` - docker compose run -e ROLLUP_OWNER_KEY=$l2ownerKey -e ROLLUP_ADDRESS=$rollupAddress -e PARENT_KEY=$devprivkey -e PARENT_RPC=http://geth:8545 -e CHILD_KEY=$devprivkey -e CHILD_RPC=http://sequencer:8547 tokenbridge deploy:local:token-bridge + l2_token_bridge_deployer_key=`docker compose run scripts print-private-key --account user_token_bridge_deployer | tail -n 1 | tr -d '\r\n'` + docker compose run -e ROLLUP_OWNER_KEY=$l2ownerKey -e ROLLUP_ADDRESS=$rollupAddress -e PARENT_KEY=$l2_token_bridge_deployer_key -e PARENT_RPC=http://geth:8545 -e CHILD_KEY=$l2_token_bridge_deployer_key -e CHILD_RPC=http://sequencer:8547 tokenbridge deploy:local:token-bridge docker compose run --entrypoint sh tokenbridge -c "cat network.json && cp network.json l1l2_network.json && cp network.json localNetwork.json" echo fi if $l3node; then - echo == Funding l3 users + echo == Funding l3 owner and sequencer docker compose run scripts send-l2 --ethamount 1000 --to l3owner --wait docker compose run scripts send-l2 --ethamount 1000 --to l3sequencer --wait echo == Funding l2 deployers - docker compose run scripts send-l1 --ethamount 100 --to user_token_bridge_deployer --wait docker compose run scripts send-l2 --ethamount 100 --to user_token_bridge_deployer --wait echo == Funding token deployer @@ -385,11 +392,12 @@ if $force_init; then docker compose run scripts send-l2 --ethamount 100 --to user_fee_token_deployer --wait echo == create l2 traffic - docker compose run scripts send-l2 --ethamount 100 --to user_traffic_generator --wait - docker compose run scripts send-l2 --ethamount 0.0001 --from user_traffic_generator --to user_fee_token_deployer --wait --delay 500 --times 1000000 > /dev/null & + docker compose run scripts send-l2 --ethamount 100 --to user_l2traffic --wait + docker compose run scripts send-l2 --ethamount 0.0001 --from user_l2traffic --to user_l2traffic_b --wait --delay 500 --times 1000000 > /dev/null & + l3owneraddress=`docker compose run scripts print-address --account l3owner | tail -n 1 | tr -d '\r\n'` echo == Writing l3 chain config - docker compose run scripts write-l3-chain-config + docker compose run scripts write-l3-chain-config --l3owner $l3owneraddress if $l3_custom_fee_token; then echo == Deploying custom fee token @@ -398,7 +406,6 @@ if $force_init; then fi echo == Deploying L3 - l3owneraddress=`docker compose run scripts print-address --account l3owner | tail -n 1 | tr -d '\r\n'` l3ownerkey=`docker compose run scripts print-private-key --account l3owner | tail -n 1 | tr -d '\r\n'` l3sequenceraddress=`docker compose run scripts print-address --account l3sequencer | tail -n 1 | tr -d '\r\n'` docker compose run --entrypoint /usr/local/bin/deploy sequencer --l1conn ws://sequencer:8548 --l1keystore /home/user/l1keystore --sequencerAddress $l3sequenceraddress --ownerAddress $l3owneraddress --l1DeployAccount $l3owneraddress --l1deployment /config/l3deployment.json --authorizevalidators 10 --wasmrootpath /home/user/target/machines --l1chainid=412346 --l2chainconfig /config/l3_chain_config.json --l2chainname orbit-dev-test --l2chaininfo /config/deployed_l3_chain_info.json --maxDataSize 104857 $EXTRA_L3_DEPLOY_FLAG @@ -409,7 +416,7 @@ if $force_init; then if $l3_token_bridge; then echo == Deploying L2-L3 token bridge - deployer_key=`printf "%s" "user_token_bridge_deployer" | openssl dgst -sha256 | sed 's/^.*= //'` + l3_token_bridge_deployer_key=`docker compose run scripts print-private-key --account user_token_bridge_deployer | tail -n 1 | tr -d '\r\n'` rollupAddress=`docker compose run --entrypoint sh poster -c "jq -r '.[0].rollup.rollup' /config/deployed_l3_chain_info.json | tail -n 1 | tr -d '\r\n'"` l2Weth="" if $tokenbridge; then @@ -417,8 +424,12 @@ if $force_init; then # we need to pull out the L2 WETH address and pass it as an override to the L2 L3 token bridge deployment l2Weth=`docker compose run --entrypoint sh tokenbridge -c "cat l1l2_network.json" | jq -r '.l2Network.tokenBridge.l2Weth'` 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 -e PARENT_WETH_OVERRIDE=$l2Weth -e ROLLUP_OWNER_KEY=$l3ownerkey -e ROLLUP_ADDRESS=$rollupAddress -e PARENT_RPC=http://sequencer:8547 -e PARENT_KEY=$l3_token_bridge_deployer_key -e CHILD_RPC=http://l3node:3347 -e CHILD_KEY=$l3_token_bridge_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 + 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 @@ -432,6 +443,8 @@ if $force_init; then docker compose run scripts bridge-to-l3 --ethamount 500 --wait --from "key_0x$devprivkey" fi + echo == Funding user on L3 + docker compose run scripts send-l3 --ethamount 100 --to user_user --wait fi fi