fix(provider/genesis): provider genesis round-trip preserves per-consumer state#44
Open
giunatale wants to merge 9 commits into
Open
fix(provider/genesis): provider genesis round-trip preserves per-consumer state#44giunatale wants to merge 9 commits into
giunatale wants to merge 9 commits into
Conversation
tbruyelle
reviewed
May 19, 2026
tbruyelle
reviewed
May 19, 2026
tbruyelle
reviewed
May 19, 2026
tbruyelle
reviewed
May 19, 2026
tbruyelle
reviewed
May 19, 2026
REGISTERED/INITIALIZED consumers legitimately have an empty client_id (no IBC client created yet). Make Validate() enforce per-phase invariants matching what the keeper actually persists: pre-launch states accept empty client_id; LAUNCHED requires it; STOPPED also requires removal_time; DELETED keeps owner/metadata/init_params per the explorer-preservation policy in DeleteConsumerChain.
ExportGenesis now iterates all consumer ids (not just active phases) so that STOPPED and DELETED consumers are preserved across state-export software upgrades. Each ConsumerState carries the four new per-consumer fields read from their dedicated keeper collections; the spawn queue, removal queue, equivocation min height, and debt state are intentionally not emitted — InitGenesis re-derives them.
Reads owner/metadata/init_params/removal_time/client_id/consumer_genesis into their dedicated keeper collections, then re-derives the spawn-time queue (from INITIALIZED consumers' init_params.spawn_time), the removal-time queue (from STOPPED consumers' removal_time), and the equivocation_evidence_min_height (from LAUNCHED/STOPPED consumers' init_params.initial_height.revision_height). ConsumerDebt is left unset and re-derived by the first BeginBlock after import.
Add TestGenesisRoundTrip which seeds keeper A with all five consumer
phases (including derived spawn/removal queues and equivocation min
heights), exports, validates, imports into a fresh keeper B, re-exports,
and asserts deep equality — proving the round-trip is a fixed point.
Also fix InitGenesis to skip AppendPendingVSCPackets when the incoming
list is empty, preventing a spurious store entry that caused
GetPendingVSCPackets to return nil instead of []{} on re-export and
broke the round-trip equality check.
8ad353d to
04dea7d
Compare
Contributor
Author
|
Addressed your f/b and also migrated consumer_id to uint64 as I think it's much better/cleaner this way |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Provider
ExportGenesis/InitGenesisdidn't faithfully round-trip the keeper's per-consumer state: owner addresses, metadata, init params, and the spawn/removal queues were silently dropped on a state-export upgrade.Validatealso rejected the emptyclient_idthatExportGenesiswas emitting for pre-launch consumers, so any chain with aREGISTEREDorINITIALIZEDconsumer couldn't be re-imported at all.Added
owner_address,metadata,init_params,removal_timeto theConsumerStateproto. RewroteValidateas a phase-aware switch matching the keeper's actual per-phase invariants.The
DELETEDphase still requires metadata/init_params, mirroring the existing "kept for explorers" policy in DeleteConsumerChain.ExportGenesisnow iterates all consumer ids including STOPPED/DELETED.InitGenesisre-derives the spawn/removal queues and equivocation min height from per-consumer fields. theDebtstate isn't exported either since the firstBeginBlockafter import re-derives it from the fee pool balance.The e2e test depends on PR #43 because of a stale legacy iterator in
prepForZeroHeightGenesis. Until that PR is merged the e2e test will fail.