fix: decode parent block validation data after runtime upgrade#1004
fix: decode parent block validation data after runtime upgrade#1004manuelmauro wants to merge 2 commits intoAcalaNetwork:masterfrom
Conversation
…r runtime upgrade After a runtime upgrade that changes the setValidationData extrinsic format (1-arg → 2-arg in polkadot-stable2512), chopsticks couldn't decode the parent block's validation data because block.meta returns the post-upgrade metadata while the extrinsics use the pre-upgrade format. This caused two failures: 1. Type decoding error on the parent block's setValidationData 2. Relay slot off-by-1 from the grandparent fallback path The patch adds tryDecodeValidationData() which first tries the block's own metadata, then falls back to the grandparent's (pre-upgrade) metadata. This correctly decodes the validation data and keeps the relay slot synchronized with the parachain timestamp. Re-enables chopsticks-upgrade-test CI job. Upstream PR: AcalaNetwork/chopsticks#1004
…r runtime upgrade After a runtime upgrade that changes the setValidationData extrinsic format (1-arg → 2-arg in polkadot-stable2512), chopsticks couldn't decode the parent block's validation data because block.meta returns the post-upgrade metadata while the extrinsics use the pre-upgrade format. This caused two failures: 1. Type decoding error on the parent block's setValidationData 2. Relay slot off-by-1 from the grandparent fallback path The patch adds tryDecodeValidationData() which first tries the block's own metadata, then falls back to the grandparent's (pre-upgrade) metadata. This correctly decodes the validation data and keeps the relay slot synchronized with the parachain timestamp. Re-enables chopsticks-upgrade-test CI job. Upstream PR: AcalaNetwork/chopsticks#1004
packages/core/src/blockchain/inherent/parachain/validation-data.ts
Outdated
Show resolved
Hide resolved
|
This doesn't seem like a solid solution. The issue must be elsewhere since validation data is decoded with parents metadata |
7b8a399 to
685a8bf
Compare
After a runtime upgrade, Block.meta returns post-upgrade metadata (recomputed from new wasm), but the block's extrinsics were encoded with the pre-upgrade runtime. This caused getValidationData to fail decoding the parent's setValidationData extrinsic when the format changed (e.g. 1-arg to 2-arg in polkadot-stable2512). Fix: add Block.extrinsicMeta that preserves the parent's metadata through runtime upgrades, and use it in getValidationData for extrinsic decoding. Fixes AcalaNetwork#1003
685a8bf to
c8b2379
Compare
The fix is validated via the moonbeam-stable2512 test suite. Remove the moonbase-specific runtime blob, network config, and e2e test from the chopsticks repo.
Hi @ermalkaleci , thank you for your feedback! I tried a different approach. |
|
It's working for your case because you're using grandparent block and it produces correct slot for your specific case. Implementation is incorrect. |
|
can you provide runtime wasm so I can debug & fix it? |
|
Thank you! We are experiencing the problem on this PR: moonbeam-foundation/moonbeam#3633 as you can see I patched the |
|
Can't perform upgrade with uncompressed wasm (15Mb) |
Please, find the compressed one here |
|
#1005 this should fix it |
|
Thank you! This #1005 fixed the issue. Closing this PR. |
Problem
When a block performs a runtime upgrade,
getValidationDatafails to decode the parent'ssetValidationDataextrinsic. This breaks block building after any upgrade that changes the extrinsic format (e.g. the 1-arg → 2-arg change in polkadot-stable2512).Root cause
buildBlockcreates the upgrade block with itsstorageDiffcontaining:code:In the
Blockconstructor,#metais first set toparentBlock.meta(the old/correct metadata), but then immediately reset because:codechanged:Later, when building the next block,
getValidationData(parent)callsparent.meta. Since#metaisundefined, the getter lazily recomputes it by callingMetadata_metadataagainst the block's new wasm — returning post-upgrade metadata that doesn't match the extrinsics.Fix
Add
Block.extrinsicMeta— set fromparentBlock.metain the constructor and intentionally not reset when:codechanges. For remote blocks without a known parent, it falls back to fetching the parent block's metadata.In
getValidationData, replaceparent.meta→parent.extrinsicMetafor extrinsic decoding.Fixes #1003