From 1d2229674d0e8e951350cd6a47ad90a357dad027 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Tue, 13 Aug 2024 13:51:18 +0200 Subject: [PATCH 1/2] 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 81deb6d1..c71857f3 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 eefcdd29..9c6028c6 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 82eeadbc..9122e6b3 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 2fd189f6..758d5a5a 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 75f6d30a..a8d7af46 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 02621d2eaa56ba85d0b55540042cfdfcc100b5a0 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Wed, 2 Oct 2024 18:22:37 +0200 Subject: [PATCH 2/2] 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 bdf13ae0..f595b66a 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 6f8bfe32..15bc6f7b 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 3311cf57..06285e79 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 e40f818f..9c7204cf 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