fix: decode v4 extrinsics with transaction extension version 0 - #2277
Merged
Conversation
A v4 extrinsic encodes no transaction extension version and is defined to use version 0, but transaction_extension_version_to_use_for_decoding returned the highest version in the metadata. That was harmless while chains only exposed version 0. Polkadot Asset Hub spec 2005000 exposes [0, 1], where version 1 prepends UnitTransactionExtension and VerifyMultiSignature, so the v4 extras were read against the wrong extension set and decoding failed with VariantNotFound. V5 extrinsics are unaffected, since they carry an explicit version that is passed through and used as given. Encoding still prefers the newest version, which is a separate decision. Metadata below V16 only ever populates version 0, so this is a no op for V14, V15 and legacy metadata. Addresses the v4 half of #1998.
pgherveou
approved these changes
Sep 11, 2026
Imod7
approved these changes
Sep 11, 2026
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.
Addresses the v4 half of #1998.
Description
A v4 extrinsic encodes no transaction extension version and is defined to use version 0.
transaction_extension_version_to_use_for_decodinginstead returned the highest version in the metadata, which was harmless while chains only exposed version 0.Polkadot Asset Hub spec 2005000 exposes
[0, 1], and version 1 prependsUnitTransactionExtensionandVerifyMultiSignature. V4 extras were read against that set, so the era bytes were interpreted as enum variant indexes and decoding failed withVariantNotFound. Reproduced on Polkadot Asset Hub block 20487777, whereextrinsics().iter()yielded errors for the two v4 signed extrinsics and decoded 2 of 4. With this change it decodes 4 of 4, and block 20494727, whose signed extrinsic is a v5 General declaring version 1, still decodes 3 of 3.Downstream report: paritytech/polkadot-rest-api#405.
Changes
transaction_extension_version_to_use_for_decodingnow returns 0, matching what its doc comment already described. Metadata below V16 only ever populates version 0, so this is a no op for V14, V15 and legacy metadata, and only changes behaviour on V16 runtimes exposing more than one version.V5 extrinsics are untouched: they carry an explicit version, which is passed through
extrinsic_extension_infoand used as given.transaction_extension_version_to_use_for_encodingstill prefers the newest version.Not in scope
The other half of #1998, picking the matching rather than the newest extension set when encoding v5, needs to reconcile the configured extensions against the metadata and is left alone here.