fix: use standard Substrate V4 format for unsigned extrinsics#218
Merged
fix: use standard Substrate V4 format for unsigned extrinsics#218
Conversation
2e7feb2 to
51c61ec
Compare
The unsigned extrinsic builder was encoding signed extensions (era, nonce, tip, CheckMetadataHash, ChargeAssetTxPayment) in the extrinsic body before the call data. Standard Substrate V4 unsigned format is: compact(length) | 0x04 | call_data Signed extensions belong only in the signing payload (computed by subxt-core's signer_payload()), not in the broadcast-format extrinsic. The non-standard format caused any tool decoding the unsigned extrinsic (polkadot-js createType, txwrapper decode, offline verification tools) to misread the extension bytes as the start of call data, producing invalid pallet/method indices. Also update the unsigned extrinsic parser to match: call data starts immediately after the version byte for unsigned transactions. BTC-3161
51c61ec to
1111b4c
Compare
davidkaplanbitgo
approved these changes
Mar 19, 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.
Summary
wasm-dot's unsigned extrinsic builder was encoding signed extensions (era, nonce, tip, etc.) in the extrinsic body before the call data:
Standard Substrate V4 unsigned format is:
Signed extensions belong only in the signing payload (computed by subxt-core's
signer_payload()), not in the extrinsic body. The non-standard format caused any tool decoding the unsigned extrinsic to misread the extension bytes as the start of call data, producing invalid pallet/method indices (e.g.[43, 127]instead of[10, 3]forbalances.transferKeepAlive).This didn't affect signed transactions (subxt rebuilds the full extrinsic correctly during signing) or broadcast, but broke offline verification and any external decoder.
Changes
builder/mod.rs: simplifiedbuild_unsigned_extrinsicto just0x04 | call_data, removed signed extension encoding logic (era/nonce/tip/CheckMetadataHash/ChargeAssetTxPayment). Era/nonce/tip are now set on the Transaction struct from the build context instead.transaction.rs: updated unsigned extrinsic parser to read call data immediately after version byte (no extension parsing for unsigned).is_empty_typeandencode_zero_valuehelpers from builder (only needed for extension encoding, still in transaction.rs for signed parsing).Testing
All 26 existing tests pass. The fix is backwards-compatible for consumers:
signablePayload(),addSignature(), andtoBroadcastFormat()continue to work correctly since they use subxt-core APIs that handle extensions internally.