forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
op-node,contracts-bedrock: setup
loadAllocs
usage
Modularize the `op-node` command for creating L2 genesis blocks such that it can read a starting L1 block from disk instead of needing to fetch it from a node. This makes the process more simple and reproducible, because the block JSON file can be written to disk and committed into a repo. Also add the script for calling the `op-node` L2 genesis generation to `contracts-bedrock`. It will create the L2 genesis state in `contracts-bedrock/.testdata` which will be read by `vm.readAllocs(string)` to populate the initial state.
- Loading branch information
Showing
4 changed files
with
238 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Create a L2 genesis.json suitable for the solidity tests to | ||
# ingest using `vm.loadAllocs(string)`. | ||
# This script depends on the relative path to the op-node from | ||
# contracts-bedrock | ||
|
||
SCRIPTS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)" | ||
CONTRACTS_DIR="$(realpath "$SCRIPTS_DIR/..")" | ||
MONOREPO_BASE="$(realpath "$CONTRACTS_DIR/../..")" | ||
|
||
DEPLOY_ARTIFACT="$CONTRACTS_DIR/deployments/hardhat/.deploy" | ||
OP_NODE="$MONOREPO_BASE/op-node/cmd/main.go" | ||
L1_STARTING_BLOCK_PATH="$CONTRACTS_DIR/test/mocks/block.json" | ||
TESTDATA_DIR="$CONTRACTS_DIR/.testdata" | ||
|
||
OUTFILE_L2="$TESTDATA_DIR/genesis.json" | ||
OUTFILE_ROLLUP="$TESTDATA_DIR/rollup.json" | ||
OUTFILE_ALLOC="$TESTDATA_DIR/alloc.json" | ||
|
||
mkdir -p "$TESTDATA_DIR" | ||
|
||
if [ ! -f "$DEPLOY_ARTIFACT" ]; then | ||
forge script $CONTRACTS_DIR/scripts/Deploy.s.sol:Deploy 2>&1 /dev/null | ||
fi | ||
|
||
# TODO: | ||
# if the testdata dir doesn't exist, run the command | ||
# add a clean command to the package.json | ||
|
||
go run $OP_NODE genesis l2 \ | ||
--deploy-config "$CONTRACTS_DIR/deploy-config/hardhat.json" \ | ||
--l1-deployments "$DEPLOY_ARTIFACT" \ | ||
--l1-starting-block "$L1_STARTING_BLOCK_PATH" \ | ||
--outfile.l2 "$OUTFILE_L2" \ | ||
--outfile.rollup "$OUTFILE_ROLLUP" >/dev/null 2>&1 | ||
|
||
jq .alloc < "$OUTFILE_L2" > "$OUTFILE_ALLOC" |
Oops, something went wrong.