Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gnosis specific node builders #47

Merged
merged 8 commits into from
Jan 29, 2025
Merged

Gnosis specific node builders #47

merged 8 commits into from
Jan 29, 2025

Conversation

debjit-bw
Copy link
Member

@debjit-bw debjit-bw commented Jan 17, 2025

This PR includes custom implementations for:

  • ChainSpec (GnosisChainSpec)
  • Network Builder (GnosisNetworkBuilder)
  • Boilerplate: GnosisPoolBuilder
  • CLI with GnosisChainSpec

In lib.rs, all these tie together in the pub fn components which has trait-bounds on ChainSpec, which is why all these changes have to be made together.


Changes w.r.t Eth primitives for custom node components

GnosisChainSpec

  • Custom Network forks made (posdao activation)
  • Bootnodes added
  • Genesis forkhash added for fork id calculations
  • Custom deposit_contract_address topic added

GnosisNetworkBuilder

  • Hardcoded genesis_hash for gnosis chain and chiado

CLI

  • Use GnosisNode, GnosisChainSpec and GnosisChainSpecParser instead of eth defaults

Reasoning behind the changes

Why new chainspec?

Gnosis adds some additional hardforks apart from standard Ethereum hardforks. Also, the genesis hash in reth's db is different from gnosis mainner genesis hash, owing to the 2 extra fields (step and signature), which aren't present in reth's format. To calculate the correct forkhashes, we need to start from the actual genesis hash, instead of the one in DB.

Why new Network?

Similar to the above reason, if reth broadcasts the genesis hash present in DB, peers will reject the EthStream request. We need a custom implementation to send the correct genesis hash and fork hash to peers.

Rationale behind PoolBuilder

The node components builder introduces a trait bound on the ChainSpec, needing all the components use the same chainspec type. So, if we introduce a custom GnosisChainSpec, and GnosisNetworkBuilder, we need custom implementations of the other components too. The GnosisPoolBuilder in particular is copied exactly from EthereumPoolBuilder without modifications beyond using GnosisChainSpec.

Custom CLI

CLI is also dependent on ChainSpec, but a bigger reason is it reduces a lot of duplicate code from main.rs (related to custom import and init commands) and moves them into the dedicated CLI file.


Other file changes are simply replacing ChainSpec with GnosisChainSpec.

@debjit-bw debjit-bw marked this pull request as ready for review January 17, 2025 12:39
@debjit-bw debjit-bw requested a review from dapplion January 17, 2025 12:39
src/spec.rs Outdated Show resolved Hide resolved
@debjit-bw debjit-bw requested a review from dapplion January 19, 2025 15:12
@debjit-bw debjit-bw merged commit 76d793c into master Jan 29, 2025
7 checks passed
@debjit-bw debjit-bw deleted the gnosis-chainspec branch January 29, 2025 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants