cosmos-sdk fork: genesis.go:151-158 panics on appd export → init — mirror existing PoC skip pattern from delegation.go?
#1153
vitaly-andr
started this conversation in
Proposals
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Posting this for maintainer validation before opening a PR against
gonka-ai/cosmos-sdk. Discovered while implementing simulation tests for#982 Phase 1.
Summary
gonka-ai/cosmos-sdk@v0.53.3-ps17deliberately disables token bonding for PoCvalidators.
compute.go:SetComputeValidatorscreates bonded validators withvalidator.Tokensset but no corresponding bank coins in the BondedPool moduleaccount. This is the documented design (see
gonka/docs/cosmos_changes.md"No Token Bonding" section).
The fork already applies the matching modifications to keep this design
consistent across runtime paths:
x/staking/keeper/pool.go:78-92—TotalBondedTokensiterates validatorsmanually instead of querying bank (explicit
// PoC OVERRIDEcomment).x/staking/keeper/delegation.go—Delegateskips coin transfer whenvalidator.Description.Details == "Created after Proof of Compute".x/staking/keeper/val_state_change.go— removed transfers between bonded /not-bonded pools.
The only remaining gap is
x/staking/keeper/genesis.go:151-158, which stillenforces the upstream invariant:
This invariant is upstream cosmos-sdk and is incompatible with the PoC
design —
bondedBalanceis always zero (PoC validators don't fund bondedpool), but
bondedCoinsissum(validator.Tokens)which is non-zero for anycycle past the first PoC epoch transition.
Impact
inferenced export(which callsbApp.ExportAppStateAndValidators) producesa JSON genesis.
inferenced init <chain> --genesis <that file>then panics onboot because staking InitGenesis hits this invariant.
This means
gonka-ai/gonkacannot perform a vanillaappd export → initchainupgrade. Production has worked around this by using
x/upgradein-placehandlers exclusively (see
inference-chain/app/upgrades/v0_2_*), which migratelive state instead of re-initing from exported genesis. So the bug is latent
but not blocking today — until someone needs disaster recovery from a known-good
export, or a fork-from-genesis, or any other vanilla import-from-export flow.
Reproduction
(Once #982 Phase 1 lands.) Run any simulation that crosses an
epoch boundary, then:
The panic site is
x/staking/keeper/genesis.go:158.The new
TestAppImportExport_Postrunininference-chain/app/sim_test.goreproduces this on the first PoC epoch transition.
Proposed fix
Apply the same skip pattern that already exists in
delegation.go:(Same pattern needed for the
notBondedBalancecheck at line 173-175 — thoughit's less likely to fire in practice because PoC validators are always Bonded
status.)
Open questions for maintainers
appd export → initconsidered a supported flow for this fork, or has it been intentionally
given up in favor of
x/upgradein-place handlers?Description.Details == "Created after Proof of Compute"string matchis fragile (already used in
delegation.go, so consistent with existingfork convention). Would a typed flag on
Validatorbe preferable, or is thestring-match convention something you'd like preserved for now?
carry a PoC-specific check. Confirm this matches your architectural
direction?
Existing fork modifications referenced
The proposed fix mirrors patterns already present in this fork:
x/staking/keeper/delegation.go—Delegateskip for PoC validators (commitby
johnlong, 2024-08 "Working version"; reinforced 2025-01-10 "Add delegationto our staking override"; later "Genesis only protection" by
Gleb Morgachev2025-09-30 added a hard post-genesis ban).
x/staking/keeper/pool.go—TotalBondedTokensmanual iteration ("Genesisonly protection", "Handle missed blocks" by
Gleb Morgachev, 2025-09).x/staking/keeper/val_state_change.go— removed bonded/not-bonded transfers.x/staking/keeper/compute.go—SetComputeValidators(multiple commitsthrough 2025-12-21, mainly
Gleb Morgachevanddima).The missing modification in
genesis.go:157-158is the only gap in this set.Ready to PR
Happy to open a PR against
gonka-ai/cosmos-sdkimplementing the fix above(genesis.go only, ~10 lines mirroring existing convention) if my understanding
of the design intent is correct. Holding off until a maintainer confirms so I
don't waste a roundtrip.
Beta Was this translation helpful? Give feedback.
All reactions