Skip to content

Add versioned migration to backfill commitment_nonce in pallet-storage-provider#270

Merged
bkontur merged 2 commits into
devfrom
runtime_migration
Jul 8, 2026
Merged

Add versioned migration to backfill commitment_nonce in pallet-storage-provider#270
bkontur merged 2 commits into
devfrom
runtime_migration

Conversation

@danielbui12

Copy link
Copy Markdown
Member

Primary Changes

  • Added #[pallet::storage_version(STORAGE_VERSION)] (v1) to pallet-storage-provider, which previously had no storage version tracking at all
  • Added pallet/src/migrations.rs with a v1::MigrateV0ToV1 migration that translates every Buckets layout to the current one (after Challenge flow overhaul #125), defaulting the new commitment_nonce field to 0 on existing BucketSnapshots nested in Bucket.snapshot
  • Wired pallet_storage_provider::migrations::v1::MigrateV0ToV1<Runtime> into the Migrations tuple in runtimes/web3-storage-paseo/src/migrations.rs, following the same pattern already used for pallet-drive-registry's prior migration
  • Fixes: PR Challenge flow overhaul #125 (Challenge flow overhaul) added the commitment_nonce: u64 field to BucketSnapshot without a migration or storage version bump, leaving pre-existing on-chain Buckets entries on paseo undecodable by the current runtime (confirmed via try-runtime on-runtime-upgrade against a previewnet); causing feat: migrate storage-client and provider-node to typed subxt bindings via storage-subxt #239 runtime migration check failed

@danielbui12
danielbui12 marked this pull request as ready for review July 7, 2026 10:25
@danielbui12
danielbui12 requested review from bkontur and ilchu July 7, 2026 10:25

@x3c41a x3c41a left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Confirmed, independently traced the same root cause and verified the fix.

Root cause matches: #125 added commitment_nonce: u64 to BucketSnapshot with no storage version or migration. Since the snapshot is nested in Bucket.snapshot, every Buckets entry carrying a snapshot changed encoding, so pre-#125 entries (previewnet) became undecodable and broke try_decode_entire_state.

Verification:

  • SCALE-decoded the exact Buckets value from the failing CI log: it fails against the current layout and decodes to zero bytes remaining against the pre-#125 layout (no commitment_nonce), so the only delta is the missing field.
  • Ran the two migration tests on this branch locally, both pass (backfill on a snapshot-bearing bucket, and no-op preservation of a snapshot-less bucket).
  • commitment_nonce: 0 is the right default: the field is only read by extend_checkpoint to verify a late signature against the original signers' payload, and a snapshot predating the field was never eligible for that flow.
  • Gating as VersionedMigration<0, 1> is correct: no-ops on fresh chains (genesis at v1), runs only where the pallet is still at v0.

LGTM.

@RafalMirowski1

Copy link
Copy Markdown
Contributor

Might be wrong but don't we also need to bump spec_version?

@danielbui12

Copy link
Copy Markdown
Member Author

@danielbui12
danielbui12 added this pull request to the merge queue Jul 7, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 7, 2026
// Backfill the `commitment_nonce` field added to `BucketSnapshot` by the
// challenge flow overhaul (#125). A real data transform, so it stays a
// `VersionedMigration` gated on the pallet's storage version.
pallet_storage_provider::migrations::v1::MigrateV0ToV1<Runtime>,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@danielbui12 for now this is ok, but for the future, if we have lots of Buckets, we need to do this by stepped multiblock migration

@danielbui12 danielbui12 Jul 7, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yep, this migration only runs once, ever, there's no risk of it re-running later; we has yet to deploy it to mainnet/testnet. In previewnet, Bucket storage is still small now.

But do you want to apply multi-block to this?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

yep, this migration only runs once, ever, there's no risk of it re-running later; we has yet to deploy it to mainnet/testnet. In previewnet, Bucket storage is still small now.

But do you want to apply multi-block to this?

no need to, probably, before going live, we will set it to 1 and remove all the migrations :)

@bkontur
bkontur added this pull request to the merge queue Jul 8, 2026
Merged via the queue into dev with commit 39ddbf3 Jul 8, 2026
38 checks passed
@bkontur
bkontur deleted the runtime_migration branch July 8, 2026 10:40
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.

4 participants