[ismp-parachain]: Bound RelayChainStateCommitments to last 256 entries#767
Open
[ismp-parachain]: Bound RelayChainStateCommitments to last 256 entries#767
Conversation
Wizdave97
reviewed
Apr 10, 2026
| #[pallet::getter(fn relay_chain_state)] | ||
| pub type RelayChainStateCommitments<T: Config> = | ||
| StorageMap<_, Blake2_128Concat, relay_chain::BlockNumber, relay_chain::Hash, OptionQuery>; | ||
| pub type RelayChainStateCommitments<T: Config> = CountedStorageMap< |
Member
There was a problem hiding this comment.
No need to migrate, let's kill the previous storage map gradually
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.
This PR Implements task 1 of #650 which bounds the unbounded
IsmpParachain::RelayChainStateCommitmentsmap at the most recent 256 entries (~25 minutes of relay history at 6s blocks). This is the dominant contributor to the nexus mainnet col1 (STATE) column family at 361 GB / 67.86% of total disk usage.Changes
RelayChainStateCommitmentsis now a CountedStorageMap so the per-block "are we over capacity?" check is O(1) instead of O(N).OldestRetainedRelayBlock:StorageValue<u32>eviction cursor, lazily reinitialized after the v1 → v2 drain.on_finalizeenforces the bound: insert the new relay parent's state root, evict the oldest entry when count() > MAX_RELAY_STATE_COMMITMENTS. Bounded forward walk (≤ 64 steps) handles occasional gaps in the relay block sequence.STORAGE_VERSIONbumped 1 → 2.migration::MigrationV2implementingframe_support::migrations::SteppedMigrationto drain the historical backlog one entry per step.on_finalizeskips inserts whileMultiBlockMigrator::ongoing()is true. Without this, the migration would never terminateSimnode test passes.