Skip to content

Commit 962c53c

Browse files
PaddyMcrandygroktac0turtle
authored
feat(chainspec): lightweight genesis chainspec for warm datadir restarts (#253)
* feat(chainspec): add lightweight genesis chainspec for warm datadir restarts * chore: cargo fmt --------- Co-authored-by: Randy Grok <98407738+randygrok@users.noreply.github.com> Co-authored-by: Marko <marko@baricevic.me>
1 parent 0e613d1 commit 962c53c

2 files changed

Lines changed: 460 additions & 4 deletions

File tree

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,58 @@ With custom configuration:
164164
--ws.api all
165165
```
166166

167+
### Lightweight Chainspec Startup
168+
169+
Large custom genesis files can be expensive to parse on every restart because the `alloc` map is
170+
part of the chainspec. After a datadir has already been initialized from the full genesis, ev-reth
171+
can start from a lightweight chainspec that omits `alloc`. When ev-reth starts from a file-based
172+
full genesis, it automatically writes a sibling lightweight file for future starts. For example,
173+
`/path/to/genesis.json` produces `/path/to/genesis.light.json`.
174+
If that file already exists for a different genesis hash, ev-reth preserves it and writes a
175+
hash-specific file such as `/path/to/genesis.78dec18c6d7d.light.json` instead.
176+
177+
```bash
178+
./target/release/ev-reth node \
179+
--chain light:/path/to/chainspec-light.json \
180+
--datadir <DATA_DIR>
181+
```
182+
183+
The lightweight file must include the canonical genesis identity plus the normal non-allocation
184+
genesis fields:
185+
186+
```json
187+
{
188+
"genesisHash": "0x...",
189+
"stateRoot": "0x...",
190+
"requiresInitializedDatadir": true,
191+
"genesis": {
192+
"config": {
193+
"chainId": 1234,
194+
"eip155Block": 0,
195+
"eip158Block": 0,
196+
"londonBlock": 0,
197+
"terminalTotalDifficulty": 0,
198+
"evolve": {
199+
"baseFeeSink": "0x00000000000000000000000000000000000000fe"
200+
}
201+
},
202+
"nonce": "0x0",
203+
"timestamp": "0x0",
204+
"extraData": "0x",
205+
"gasLimit": "0x1c9c380",
206+
"difficulty": "0x0",
207+
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
208+
"coinbase": "0x0000000000000000000000000000000000000000",
209+
"baseFeePerGas": "0x3b9aca00"
210+
}
211+
}
212+
```
213+
214+
Use the full genesis, or a trusted datadir snapshot created from it, for first startup. Lightweight
215+
mode is only for subsequent starts: it rejects `alloc`, trusts the supplied `genesisHash`, and
216+
relies on Reth's stored genesis-hash check to reject the wrong datadir. Set `genesisHash` to the
217+
block 0 hash stored in the datadir you intend to open.
218+
167219
### Engine API Integration
168220

169221
When using the Engine API, you can include transactions in the payload attributes:

0 commit comments

Comments
 (0)