Skip to content

fix: chainconfig engine mismatch#58

Open
hominlee-wemade wants to merge 6 commits intodevfrom
fix/chainconfig-engine-mismatch
Open

fix: chainconfig engine mismatch#58
hominlee-wemade wants to merge 6 commits intodevfrom
fix/chainconfig-engine-mismatch

Conversation

@hominlee-wemade
Copy link
Contributor

Summary

This PR fixes an issue where the WBFT consensus engine is initialized using a stale ChainConfig loaded from the database before chain config overrides are applied.

As a result, hardfork settings defined in the genesis or via code-level overrides were not reflected in the consensus engine at initialization time, causing a mismatch between the blockchain and the engine configuration.

This change ensures that the consensus engine is always created using the final ChainConfig with overrides applied.

Background

In the standard Ethereum initialization flow, the final ChainConfig is resolved inside NewBlockChain via SetupGenesisBlockWithOverride.

However, in the current go-stablenet flow:

  1. LoadChainConfig loads the ChainConfig from the database
  2. The consensus engine is created using this ChainConfig
  3. NewBlockChain later applies overrides through SetupGenesisBlockWithOverride, producing the final ChainConfig

This leads to the consensus engine and the blockchain using different ChainConfig values.

Problem

Component ChainConfig used
Consensus engine Stored ChainConfig (overrides not applied)
Blockchain Final ChainConfig returned by SetupGenesisBlockWithOverride

Impact

  • Hardfork-related settings are not reflected in the consensus engine
  • WBFT engine initialization (e.g. Transitions, SystemContractUpgrades) is based on outdated configuration
  • Potential for unexpected consensus behavior or block validation errors due to configuration mismatch

Solution

Key idea

Use a lightweight helper that resolves the final ChainConfig with overrides applied without committing the genesis block, and use it to initialize the consensus engine.

Changes

  1. Add LoadChainConfigWithOverride
  • Loads ChainConfig from the database or genesis
  • Applies overrides
  • Uses the same config-resolution logic as SetupGenesisBlockWithOverride
  1. Update engine initialization flow (eth/backend.go)
  • Build overrides before engine creation
  • Replace LoadChainConfig with LoadChainConfigWithOverride
  • Create the consensus engine using the override-applied ChainConfig
  1. No changes to NewBlockChain signature
  • No impact on existing callers or tests

@hominlee-wemade hominlee-wemade self-assigned this Feb 24, 2026
@hominlee-wemade hominlee-wemade added the bug Something isn't working label Feb 24, 2026
@hominlee-wemade hominlee-wemade changed the title Fix/chainconfig engine mismatch fix: chainconfig engine mismatch Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant