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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ services:
- --mine
- --miner.etherbase=0x3f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E
- --gcmode=archive
- --rpc.allow-unprotected-txs

# Creates a genesis state for the beacon chain using a YAML configuration file and
# a deterministic set of validators
Expand Down Expand Up @@ -381,7 +382,10 @@ services:
NITRO_CONTRACTS_BRANCH: ${NITRO_CONTRACTS_BRANCH:-}
volumes:
- "config:/config"
- /var/run/docker.sock:/var/run/docker.sock
- "/var/run/docker.sock:/var/run/docker.sock"
- "contracts:/contracts"
- "contracts-local:/contracts-local"
- "referenceda-provider-data:/referenceda-provider"

datool:
image: nitro-node-dev-testnode
Expand All @@ -391,7 +395,7 @@ services:
- "das-committee-a-data:/das-committee-a"
- "das-committee-b-data:/das-committee-b"
- "das-mirror-data:/das-mirror"
command:
- "referenceda-provider-data:/referenceda-provider"

das-committee-a:
pid: host # allow debugging
Expand Down Expand Up @@ -431,6 +435,20 @@ services:
command:
- --conf.file=/config/l2_das_mirror.json

referenceda-provider:
pid: host # allow debugging
image: nitro-node-dev-testnode
entrypoint: /usr/local/bin/daprovider
ports:
- "127.0.0.1:9880:9880"
volumes:
- "config:/config"
- "referenceda-provider-data:/data"
- "contracts:/contracts"
- "contracts-local:/contracts-local"
command:
- --conf.file=/config/referenceda_provider.json

timeboost-auctioneer:
pid: host # allow debugging
image: nitro-node-dev-testnode
Expand Down Expand Up @@ -481,4 +499,7 @@ volumes:
das-committee-a-data:
das-committee-b-data:
das-mirror-data:
referenceda-provider-data:
timeboost-auctioneer-data:
contracts:
contracts-local:
59 changes: 57 additions & 2 deletions scripts/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fs from 'fs';
import * as consts from './consts'
import { ethers } from "ethers";
import { namedAccount, namedAddress } from './accounts'
import { namedAddress } from './accounts'

const path = require("path");

Expand Down Expand Up @@ -292,6 +292,19 @@ function writeConfigs(argv: any) {

baseConfig.node["data-availability"]["sequencer-inbox-address"] = ethers.utils.hexlify(getChainInfo()[0]["rollup"]["sequencer-inbox"]);

if (argv.referenceDA) {
(baseConfig as any).node["da"] = {
"mode": "external",
"external-provider": {
"enable": true,
"with-writer": false,
"rpc": {
"url": "http://referenceda-provider:9880"
}
}
}
}

const baseConfJSON = JSON.stringify(baseConfig)

if (argv.simple) {
Expand Down Expand Up @@ -339,6 +352,9 @@ function writeConfigs(argv: any) {
if (argv.anytrust) {
posterConfig.node["data-availability"]["rpc-aggregator"].enable = true
}
if (argv.referenceDA) {
posterConfig.node["da"]["external-provider"]["with-writer"] = true
}
fs.writeFileSync(path.join(consts.configpath, "poster_config.json"), JSON.stringify(posterConfig))
}

Expand Down Expand Up @@ -519,6 +535,26 @@ function writeL2DASKeysetConfig(argv: any) {
fs.writeFileSync(path.join(consts.configpath, "l2_das_keyset.json"), l2DASKeysetConfigJSON)
}

function writeL2ReferenceDAConfig(argv: any) {
const l2ReferenceDAConfig = {
"mode": "referenceda",
"referenceda": {
"enable": true,
"signing-key": {
"key-file": "/data/keys/ecdsa"
},
"validator-contract": argv.validatorAddress,
"parent-chain-node-url": argv.l1url,
},
"provider-server": {
"addr": "0.0.0.0",
"enable-da-writer": true,
},
}
const l2ReferenceDAConfigJSON = JSON.stringify(l2ReferenceDAConfig)
fs.writeFileSync(path.join(consts.configpath, "referenceda_provider.json"), l2ReferenceDAConfigJSON)
}

function dasBackendsJsonConfig(argv: any) {
const backends = {
"enable": false,
Expand Down Expand Up @@ -614,6 +650,11 @@ export const writeConfigCommand = {
describe: "DAS committee member B BLS pub key",
default: ""
},
referenceDA: {
boolean: true,
describe: "run nodes in reference DA mode",
default: false
},
timeboost: {
boolean: true,
describe: "run sequencer in timeboost mode",
Expand Down Expand Up @@ -649,7 +690,7 @@ export const writeL2ChainConfigCommand = {
boolean: true,
describe: "enable anytrust in chainconfig",
default: false
},
}
},
handler: (argv: any) => {
writeL2ChainConfig(argv)
Expand Down Expand Up @@ -701,3 +742,17 @@ export const writeL2DASKeysetConfigCommand = {
}
}

export const writeL2ReferenceDAConfigCommand = {
command: "write-l2-referenceda-config",
describe: "writes reference DA config file",
builder: {
validatorAddress: {
string: true,
describe: "L2 validator contract address",
demandOption: true
},
},
handler: (argv: any) => {
writeL2ReferenceDAConfig(argv)
}
}
2 changes: 2 additions & 0 deletions scripts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
writeL2DASCommitteeConfigCommand,
writeL2DASMirrorConfigCommand,
writeL2DASKeysetConfigCommand,
writeL2ReferenceDAConfigCommand,
writeTimeboostConfigsCommand
} from "./config";
import {
Expand Down Expand Up @@ -72,6 +73,7 @@ async function main() {
.command(writeL2DASCommitteeConfigCommand)
.command(writeL2DASMirrorConfigCommand)
.command(writeL2DASKeysetConfigCommand)
.command(writeL2ReferenceDAConfigCommand)
.command(writePrysmCommand)
.command(writeAccountsCommand)
.command(writeTimeboostConfigsCommand)
Expand Down
53 changes: 44 additions & 9 deletions test-node.bash
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ devprivkey=b6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659
l1chainid=1337
simple=true
l2anytrust=false
l2referenceda=false
l2timeboost=false

# Use the dev versions of nitro/blockscout
Expand Down Expand Up @@ -266,6 +267,10 @@ while [[ $# -gt 0 ]]; do
l2anytrust=true
shift
;;
--l2-referenceda)
l2referenceda=true
shift
;;
--l2-timeboost)
l2timeboost=true
shift
Expand Down Expand Up @@ -313,6 +318,7 @@ while [[ $# -gt 0 ]]; do
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-referenceda run the L2 with reference external data availability provider
echo --l2-timeboost run the L2 with Timeboost enabled, including auctioneer and bid validator
echo --batchposters batch posters [0-3]
echo --redundantsequencers redundant sequencers [0-3]
Expand All @@ -331,7 +337,7 @@ while [[ $# -gt 0 ]]; do
echo --no-build-dev-blockscout don\'t rebuild dev blockscout docker image
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 --force-build-utils force rebuilding utils, useful if NITRO_CONTRACTS_BRANCH or TOKEN_BRIDGE_BRANCH changes
echo
echo script runs inside a separate docker. For SCRIPT-ARGS, run $0 script --help
exit 0
Expand Down Expand Up @@ -365,6 +371,10 @@ if [ $batchposters -gt 2 ]; then
NODES="$NODES poster_c"
fi

if $l2anytrust && $l2referenceda; then
echo "Error: --l2-anytrust and --l2-referenceda cannot be enabled at the same time."
exit 1
fi

if $validate; then
NODES="$NODES validator"
Expand Down Expand Up @@ -497,27 +507,44 @@ if $force_init; then

if $l2anytrust; then
echo "== Writing l2 chain config (anytrust enabled)"
run_script --l2owner $l2ownerAddress write-l2-chain-config --anytrust
run_script --l2owner $l2ownerAddress write-l2-chain-config --anytrust
else
echo == Writing l2 chain config
run_script --l2owner $l2ownerAddress write-l2-chain-config
echo "== Writing l2 chain config"
run_script --l2owner $l2ownerAddress write-l2-chain-config
fi

sequenceraddress=`run_script print-address --account sequencer | tail -n 1 | tr -d '\r\n'`
l2ownerKey=`run_script print-private-key --account l2owner | tail -n 1 | tr -d '\r\n'`
wasmroot=`docker compose run --rm --entrypoint sh sequencer -c "cat /home/user/target/machines/latest/module-root.txt"`

echo == Deploying L2 chain
echo "== Deploying L2 chain"
docker compose run --rm -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
if $l2timeboost; then
docker compose run --rm --entrypoint sh rollupcreator -c 'jq ".[] | .\"track-block-metadata-from\"=1 | [.]" /config/deployed_chain_info.json > /config/l2_chain_info.json'
else
docker compose run --rm --entrypoint sh rollupcreator -c "jq [.[]] /config/deployed_chain_info.json > /config/l2_chain_info.json"
fi

if $l2referenceda; then
docker compose run --rm --entrypoint sh referenceda-provider -c "true" # Noop to mount shared volumes with contracts for manual build and deployment

echo "== Generating Reference DA keys"
docker compose run --rm --user root --entrypoint sh datool -c "mkdir /referenceda-provider/keys && chown -R 1000:1000 /referenceda-provider*"
docker compose run --rm datool keygen --dir /referenceda-provider/keys --ecdsa

referenceDASignerAddress=`docker compose run --rm --entrypoint sh rollupcreator -c "cat /referenceda-provider/keys/ecdsa.pub | sed 's/^04/0x/' | tr -d '\n' | cast keccak | tail -c 41 | cast to-check-sum-address"`

echo "== Deploying Reference DA Proof Validator contract on L2"
l2referenceDAValidatorAddress=`docker compose run --rm --entrypoint sh rollupcreator -c "cd /contracts-local && forge create src/osp/ReferenceDAProofValidator.sol:ReferenceDAProofValidator --rpc-url http://geth:8545 --private-key $l2ownerKey --broadcast --constructor-args [$referenceDASignerAddress]" | awk '/Deployed to:/ {print $NF}'`

echo "== Generating Reference DA Config"
run_script write-l2-referenceda-config --validator-address $l2referenceDAValidatorAddress
fi

fi # $force_init

anytrustNodeConfigLine=""
referenceDaNodeConfigLine=""
timeboostNodeConfigLine=""

# Remaining init may require AnyTrust committee/mirrors to have been started
Expand Down Expand Up @@ -547,16 +574,24 @@ if $l2anytrust; then
fi
fi

if $l2referenceda && $run; then
echo "== Starting Reference DA service"
docker compose up --wait referenceda-provider
fi

if $force_init; then
if $l2timeboost; then
timeboostNodeConfigLine="--timeboost"
fi
if $l2referenceda; then
referenceDaNodeConfigLine="--referenceDA"
fi

echo "== Writing configs"
if $simple; then
echo == Writing configs
run_script write-config --simple $anytrustNodeConfigLine $timeboostNodeConfigLine
run_script write-config --simple $anytrustNodeConfigLine $referenceDaNodeConfigLine $timeboostNodeConfigLine
else
echo == Writing configs
run_script write-config $anytrustNodeConfigLine $timeboostNodeConfigLine
run_script write-config $anytrustNodeConfigLine $referenceDaNodeConfigLine $timeboostNodeConfigLine

echo == Initializing redis
docker compose up --wait redis
Expand Down