Skip to content

Commit

Permalink
Merge pull request #101 from OffchainLabs/merge-release-into-master
Browse files Browse the repository at this point in the history
Merge release into master
  • Loading branch information
PlasmaPower authored Dec 6, 2024
2 parents 1c6a92f + 02dc11d commit 5986e62
Show file tree
Hide file tree
Showing 5 changed files with 328 additions and 11 deletions.
51 changes: 51 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,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.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.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 @@ -403,4 +451,7 @@ volumes:
config:
postgres-data:
tokenbridge-data:
das-committee-a-data:
das-committee-b-data:
das-mirror-data:
boldupgrader-data:
188 changes: 183 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 @@ -160,10 +161,22 @@ 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")
const baseConfig = {
let baseConfig = {
"parent-chain": {
"connection": {
"url": argv.l1url,
Expand All @@ -181,7 +194,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 +228,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 +242,17 @@ function writeConfigs(argv: any) {
"url": argv.validationNodeUrl,
"jwtsecret": valJwtSecret,
}
},
"data-availability": {
"enable": argv.anytrust,
"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 +274,7 @@ function writeConfigs(argv: any) {
},
}

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

const baseConfJSON = JSON.stringify(baseConfig)

Expand All @@ -264,6 +289,9 @@ 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"]["rpc-aggregator"].enable = true
}
fs.writeFileSync(path.join(consts.configpath, "sequencer_config.json"), JSON.stringify(simpleConfig))
} else {
let validatorConfig = JSON.parse(baseConfJSON)
Expand All @@ -286,6 +314,9 @@ function writeConfigs(argv: any) {
let posterConfig = JSON.parse(baseConfJSON)
posterConfig.node["seq-coordinator"].enable = true
posterConfig.node["batch-poster"].enable = true
if (argv.anytrust) {
posterConfig.node["data-availability"]["rpc-aggregator"].enable = true
}
fs.writeFileSync(path.join(consts.configpath, "poster_config.json"), JSON.stringify(posterConfig))
}

Expand Down Expand Up @@ -353,7 +384,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 +427,93 @@ function writeL3ChainConfig(argv: any) {
fs.writeFileSync(path.join(consts.configpath, "l3_chain_config.json"), l3ChainConfigJSON)
}

function writeL2DASCommitteeConfig(argv: any) {
const sequencerInboxAddr = ethers.utils.hexlify(getChainInfo()[0]["rollup"]["sequencer-inbox"]);
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.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 +523,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 +564,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 +583,40 @@ export const writeL3ChainConfigCommand = {
writeL3ChainConfig(argv)
}
}

export const writeL2DASCommitteeConfigCommand = {
command: "write-l2-das-committee-config",
describe: "writes daserver committee member config file",
handler: (argv: any) => {
writeL2DASCommitteeConfig(argv)
}
}

export const writeL2DASMirrorConfigCommand = {
command: "write-l2-das-mirror-config",
describe: "writes daserver mirror config file",
handler: (argv: any) => {
const sequencerInboxAddr = ethers.utils.hexlify(getChainInfo()[0]["rollup"]["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)
}
}
40 changes: 40 additions & 0 deletions scripts/ethcommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,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 sendTransaction(argv, 0);

argv.provider.destroy();
}

export const transferERC20Command = {
command: "transfer-erc20",
describe: "transfers ERC20 token",
Expand Down Expand Up @@ -576,6 +595,27 @@ export const sendRPCCommand = {
}
}

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)
}
};

export const waitForSyncCommand = {
command: "wait-for-sync",
describe: "wait for rpc to sync",
Expand Down
Loading

0 comments on commit 5986e62

Please sign in to comment.