Prepare L2 Genesis
simple-surge-node
If you're using simple-surge-node
to deploy L2, you can skip this section since simple-surge-node
repository already includes a ready-to-use chainspec.json
file.
This guide walks you through preparing your own L2 genesis file, chainspec file, and genesis hash which are required to deploy an L2 network.
Prerequisites
Before proceeding, ensure the following tools are installed:
Steps
1. Clone the Repository
Clone the surge-taiko-mono
repository and navigate into it:
git clone https://github.com/NethermindEth/surge-taiko-mono.git
cd surge-taiko-mono
2. Checkout Correct Branch
Checkout the surge/devnet
branch:
git checkout surge/devnet
3. Install Dependencies
Navigate to the protocol package and install dependencies:
cd packages/protocol
foundryup
pnpm install
4. Configure Environment Variables
Set required environment variables:
export CONTRACT_OWNER=0x8943545177806ED17B9F23F0a21ee5948eCaa776
export L1_CHAINID=3151908
export L2_CHAINID=763374
5. Generate L2 Genesis File
Compile L2 contracts and generate the genesis block:
pnpm compile:l2
pnpm genesis:gen
The generated files can be found at ./test/genesis/data/
.
6. Download Genesis-to-Chainspec Converter
Download the script used to convert the genesis file to a chainspec file:
curl -O https://raw.githubusercontent.com/NethermindEth/core-scripts/refs/heads/main/gen2spec/gen2spec.jq
7. Convert Genesis to Chainspec
Convert the genesis file into a chainspec file:
cat ./test/genesis/data/genesis.json | jq ". * {
difficulty: 0,
config: {
taiko: true,
londonBlock: 0,
ontakeBlock: 1,
shanghaiTime: 0
}
} | del(.config.clique)" | jq --from-file ./gen2spec.jq | jq '.params.feeCollector = "0x0000000000000000000000000000000000000000"' > ./test/genesis/data/chainspec.json
The chainspec file will be created at ./test/genesis/data/chainspec.json
.
8. Retrieve the Genesis Hash
Use the Nethermind client Docker container to retrieve the genesis hash:
docker run -d \
--name nethermind-genesis-hash \
-v ./test/genesis/data/chainspec.json:/chainspec.json \
nethermindeth/nethermind:surge-fd87ddb09 \
--config=none \
--Init.ChainSpecPath=/chainspec.json
sleep 5 # Wait a few seconds for the container to initialize
docker logs nethermind-genesis-hash 2>/dev/null | grep "Genesis hash" | head -n 1 | sed 's/.*Genesis hash : \(.*\)/\1/'
The genesis hash will be printed in the console.
9. Clean Up (Optional)
Stop and remove the Docker container after obtaining the genesis hash:
docker rm -f nethermind-genesis-hash