From 8428bc3bd3395a1067ece462c4a9f9e7ed45b228 Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Mon, 12 Aug 2024 11:20:15 +0200 Subject: [PATCH 1/2] 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 ff322260..edfcedd6 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 fcf1dca0..81a7b891 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 2fd189f6..3c83a3ec 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 74797807..6c1dd5ab 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 7ac0d6ee5fddae35454c67d61919689faf17cda5 Mon Sep 17 00:00:00 2001 From: Goran Vladika Date: Mon, 12 Aug 2024 13:56:22 +0200 Subject: [PATCH 2/2] Add comment --- test-node.bash | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test-node.bash b/test-node.bash index 6c1dd5ab..54ce48ef 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