Genesis Replay
Contents8 sections
Re-execute historical blocks to reconstruct state
Genesis replay re-executes historical blocks so that additional copies of state are available at any given point in time. Historically, blocks have been stored in a static archive format. This process downloads those blocks and replays them through the EVM to reconstruct full state.
Prerequisites
- monad version
0.12.3or later - Credentials and configuration to read from your chosen archive source (AWS, R2, MongoDB, MinIO,
etc.). These are the same credentials used by
monad-archiver; see Running an Archive Server for details.
Setup
1. Prepare the block database directory
Choose a directory to store EVM-format historical blocks. This guide refers to it as block-db.
2. Initialize triedb
Create an empty triedb:
monad-mpt \
--storage /dev/triedb \
--root-offsets-chunk-count 16 \
--create-empty
3. Start the block writer
Run inside tmux or create a systemd service to download blocks continuously:
monad-block-writer stream \
--block-data-source <your source string> \
--dest-path <your block-db path>
The source string follows the same format used by monad-archiver, for example
"aws mainnet-deu-009-0" or "mongodb ...".
The block writer will:
- Download all blocks from the source
- Transform them into EVM format
- Brotli-compress the data
- Write blocks into subdirectories of the form
block-db/XM/<block_number>, whereX = block_number / 1_000_000(one million blocks per directory)
Resumption behavior: The writer saves a latest file in the block-db directory. If the
process stops, on the next startup it reads latest and compares it against the latest block
available from the --block-data-source, then continues from that point.
If you only need a specific range of blocks, run monad-block-writer stream --help for range
options.
4. Configure the replay service
While monad-block-writer is running, add the following systemd override for monad-execution
in a separate terminal:
sudo systemctl edit monad-execution
[Service]
ExecStart=
ExecStart=/usr/local/bin/monad \
--chain "$CHAIN" \
--as_eth_blocks \
--block_db <your block-db path> \
--nblocks 0 \
--db /dev/triedb \
--no-compaction \
--trace_calls \
--block-db-timeout 60
AllowedCPUs=
CPUAffinity=
Restart=
Restart=always
Ensure $CHAIN is defined in your environment. Valid options:
ethereum_mainnetmonad_devnetmonad_testnetmonad_mainnet
--block-db-timeout sets the number of seconds the replay service will wait for new blocks
to appear in the block database. If the timeout is reached without new blocks, the replay service
will crash and be restarted by systemd. If this happens, verify that the block writer from step 3
is still running and writing blocks to disk. Set to 0 to disable retries.
5. Reload and start
sudo systemctl daemon-reload
sudo systemctl restart monad-execution
Running RPC on a replay host
If you want to run monad-rpc on this host, you must remove the --ipc-path flag from the
monad-rpc systemd configuration.