Skip to content

fork-genesis assemble: zero bonded/notBonded pool bank balances when stripping validator state #145

@bdchatham

Description

@bdchatham

Problem

assemble_genesis_fork.go::stripValidatorState zeros validator/delegation/last_total_power state on the staking module (lines 223-284) but does NOT touch the bank balances on the bonded_tokens_pool / not_bonded_tokens_pool module accounts that the source chain's exported state carries over.

Cosmos staking InitGenesis (sei-cosmos/x/staking/genesis.go:112-126) panics if bondedTokens != sum(validator.tokens). After our fork-assembly:

  • bondedTokens = 0 (we stripped validators)
  • bonded_tokens_pool bank balance still holds whatever the source chain had

seid start panics on InitChain on the first run of the new fork.

Fix

In stripValidatorState, after zeroing staking state, also rewrite the bank module's balances array to set both pool module-account balances to zero. The module-account addresses are deterministic (auth.NewModuleAddress("bonded_tokens_pool") and auth.NewModuleAddress("not_bonded_tokens_pool")).

Related

Discovered via research dive on seid export round-trip (PR sei-protocol/sei-k8s-controller#179). Test coverage in assemble_genesis_fork_test.go:164-260 only inspects staking/slashing/distribution fields, not bank — explains why this didn't surface in unit tests.

Severity

Blocking for any fork ceremony. Fix before first prod run on pacific-1.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions