Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --l2-anytrust option to run in AnyTrust mode #79

Merged
merged 5 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
51 changes: 51 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,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:
Expand All @@ -383,3 +431,6 @@ volumes:
config:
postgres-data:
tokenbridge-data:
das-committee-a-data:
das-committee-b-data:
das-mirror-data:
212 changes: 207 additions & 5 deletions scripts/config.ts
Original file line number Diff line number Diff line change
@@ -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");
Expand Down Expand Up @@ -163,7 +164,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,
Expand All @@ -181,7 +182,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,
Expand Down Expand Up @@ -215,7 +216,7 @@ function writeConfigs(argv: any) {
"parent-chain-wallet" : {
"account": namedAddress("sequencer"),
"password": consts.l1passphrase,
"pathname": consts.l1keystore,
"pathname": consts.l1keystore,
},
"data-poster": {
"redis-signer": {
Expand All @@ -229,6 +230,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": {
Expand All @@ -250,6 +262,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"]);
Tristan-Wilson marked this conversation as resolved.
Show resolved Hide resolved

const baseConfJSON = JSON.stringify(baseConfig)

Expand All @@ -264,11 +282,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
Tristan-Wilson marked this conversation as resolved.
Show resolved Hide resolved
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)

Expand All @@ -281,11 +308,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))
}

Expand Down Expand Up @@ -353,7 +389,7 @@ function writeL2ChainConfig(argv: any) {
"arbitrum": {
"EnableArbOS": true,
"AllowDebugPrecompiles": true,
"DataAvailabilityCommittee": false,
"DataAvailabilityCommittee": argv.anytrust,
"InitialArbOSVersion": 32,
"InitialChainOwner": argv.l2owner,
"GenesisBlockNum": 0
Expand Down Expand Up @@ -396,6 +432,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",
Expand All @@ -405,7 +527,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)
}
Expand All @@ -430,6 +568,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)
}
Expand All @@ -442,3 +587,60 @@ export const writeL3ChainConfigCommand = {
writeL3ChainConfig(argv)
}
}

export const writeL2DASCommitteeConfigCommand = {
Tristan-Wilson marked this conversation as resolved.
Show resolved Hide resolved
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(
Tristan-Wilson marked this conversation as resolved.
Show resolved Hide resolved
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(
Tristan-Wilson marked this conversation as resolved.
Show resolved Hide resolved
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)
}
}
Loading
Loading