diff --git a/cumulus/client/collator/src/service.rs b/cumulus/client/collator/src/service.rs index 921f1890f783e..a31fe43120ed4 100644 --- a/cumulus/client/collator/src/service.rs +++ b/cumulus/client/collator/src/service.rs @@ -235,7 +235,7 @@ where }; // Create the parachain block data for the validators. - let (collation_info, api_version) = self + let (collation_info, _api_version) = self .fetch_collation_info(block_hash, block.header()) .map_err(|e| { tracing::error!( @@ -247,6 +247,20 @@ where .ok() .flatten()?; + // Workaround for: https://github.com/paritytech/polkadot-sdk/issues/64 + // + // We are always using the `api_version` of the parent block. The `api_version` can only + // change with a runtime upgrade and this is when we want to observe the old `api_version`. + // Because this old `api_version` is the one used to validate this block. Otherwise we + // already assume the `api_version` is higher than what the relay chain will use and this + // will lead to validation errors. + let api_version = self + .runtime_api + .runtime_api() + .api_version::>(parent_header.hash()) + .ok() + .flatten()?; + let block_data = ParachainBlockData::::new(vec![block], compact_proof); let pov = polkadot_node_primitives::maybe_compress_pov(PoV { diff --git a/prdoc/pr_9059.prdoc b/prdoc/pr_9059.prdoc new file mode 100644 index 0000000000000..3418b0b7fe9d7 --- /dev/null +++ b/prdoc/pr_9059.prdoc @@ -0,0 +1,8 @@ +title: Fetch parent block `api_version` +doc: +- audience: Node Dev + description: |- + This is required to ensure that we use the `api_version` of the runtime that will be used on the relay chain to validate the block. Otherwise the node may thinks the runtime was already upgraded and sends data to the relay chain that can not be decoded by the runtime and thus, the validation fails. +crates: +- name: cumulus-client-collator + bump: patch