Skip to content

[ismp-parachain]: Bound RelayChainStateCommitments to last 256 entries#767

Open
dharjeezy wants to merge 3 commits intomainfrom
dami/bound-relaychaincommitments
Open

[ismp-parachain]: Bound RelayChainStateCommitments to last 256 entries#767
dharjeezy wants to merge 3 commits intomainfrom
dami/bound-relaychaincommitments

Conversation

@dharjeezy
Copy link
Copy Markdown
Contributor

@dharjeezy dharjeezy commented Apr 10, 2026

This PR Implements task 1 of #650 which bounds the unbounded IsmpParachain::RelayChainStateCommitments map 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

  • RelayChainStateCommitments is now a CountedStorageMap so the per-block "are we over capacity?" check is O(1) instead of O(N).
  • New OldestRetainedRelayBlock: StorageValue<u32> eviction cursor, lazily reinitialized after the v1 → v2 drain.
  • on_finalize enforces 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_VERSION bumped 1 → 2.
  • New migration::MigrationV2 implementing frame_support::migrations::SteppedMigration to drain the historical backlog one entry per step.
  • on_finalize skips inserts while MultiBlockMigrator::ongoing() is true. Without this, the migration would never terminate

Simnode test passes.

#[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<
Copy link
Copy Markdown
Member

@Wizdave97 Wizdave97 Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to migrate, let's kill the previous storage map gradually

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants