Skip to content

Commit

Permalink
Fix PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan-Wilson committed Oct 3, 2024
1 parent e0f7b8e commit 02621d2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 73 deletions.
4 changes: 2 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
62 changes: 19 additions & 43 deletions scripts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -232,7 +244,7 @@ function writeConfigs(argv: any) {
}
},
"data-availability": {
"enable": false,
"enable": argv.anytrust,
"rpc-aggregator": dasBackendsJsonConfig(argv),
"rest-aggregator": {
"enable": true,
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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))
}
Expand Down Expand Up @@ -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": {
Expand All @@ -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) {
Expand Down Expand Up @@ -591,36 +587,16 @@ 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)
}
}

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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/ethcommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
43 changes: 16 additions & 27 deletions test-node.bash
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ while [[ $# -gt 0 ]]; do
shift
;;
--l2-anytrust)
l2anytrust=true
shift
;;
l2anytrust=true
shift
;;
--redundantsequencers)
simple=false
redundantsequencers=$2
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 02621d2

Please sign in to comment.