Skip to content

Conversation

@Vui-Chee
Copy link

@Vui-Chee Vui-Chee commented Nov 20, 2025

Add support for non-zero genesis block numbers

Adds support for chains with genesis blocks that don't start at block 0, enabling compatibility with custom chain configurations.

Attempts to address issue described in #19874.

Key Changes

  • Chainspec: Genesis header now includes number and parent_hash from chain spec
  • Static File Provider: Added genesis block number tracking and getter/setter methods
  • Provider Factory: Added with_genesis_block_number() builder method with documentation
  • Initialization: Updated genesis initialization to use actual genesis block number instead of hardcoded 0
  • Static File Writer: Added append_header_direct() for non-zero genesis blocks and updated block range calculations
  • CLI/Node Builder: Automatically configure genesis block number from chain spec

This ensures all database operations, static file operations, and stage checkpoints correctly handle chains with non-zero genesis blocks.

@Vui-Chee Vui-Chee changed the title feat(provider): add configurable genesis block number to static file provider feat(provider): support non-zero genesis block numbers Nov 20, 2025
@Vui-Chee Vui-Chee changed the title feat(provider): support non-zero genesis block numbers feat: support non-zero genesis block numbers Nov 20, 2025
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

supportive in general, but would like to hear more about where and how this is currently causing issues, because I'm unsure why we need this on the db level

for this I'd also like to see an e2e that uses a modified genesis block

Comment on lines +314 to +315
/// Genesis block number, default is 0;
genesis_block_number: u64,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you elaborate on why we need this here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When static files are empty, we need this to reliably fallback to custom genesis number.

Comment on lines +76 to +77
number: genesis.number.unwrap_or_default(),
parent_hash: genesis.parent_hash.unwrap_or_default(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes sense

@Vui-Chee
Copy link
Author

Vui-Chee commented Nov 21, 2025

supportive in general, but would like to hear more about where and how this is currently causing issues, because I'm unsure why we need this on the db level

for this I'd also like to see an e2e that uses a modified genesis block

Please read the full description #19874. We need custom genesis block since we migrate from a different blockchain to reth. We want to preserve our previous block height (or block data) for our users. So it will extremely awesome if you guys can accept our change. In theory, my changes should not influence the default behavior, which starting reth from 0 block height.

Some e2e tests have been added for eth and op nodes.

@mattsse
Copy link
Collaborator

mattsse commented Nov 21, 2025

different blockchain to reth

welcome frens, and thx for the prs thus far.

as mentioned, not opposed to this in general, but I'd like to avoid doing this if feasible
so please get back to us on #19874 (comment)

because I'd prefer if we could avoid introducing additional corner cases in the static file logic.

I assume you'd need to do some form of regenesis with state snapshot anyway then?

@Vui-Chee
Copy link
Author

different blockchain to reth

welcome frens, and thx for the prs thus far.

as mentioned, not opposed to this in general, but I'd like to avoid doing this if feasible so please get back to us on #19874 (comment)

because I'd prefer if we could avoid introducing additional corner cases in the static file logic.

I assume you'd need to do some form of regenesis with state snapshot anyway then?

I will continue this conversion in #19874, but will this PR opened till we come to an mutual understanding.

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mind taking a look at this @joshieDo @shekhirin

adding genesis handling doesnt look too bad imo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants