core/encoding: UnmarshalBlock silently drops the PoW nonce for multisig_open/multisig_update (tailOffset uses min keyset size) (Minor)
Report
- Area: core/encoding.go
UnmarshalBlock - Found: 2026-10-27, repo master
9787859(live nodexe/92d83d1), via an in-process Go round-trip test - Related: #84 (lease_renew has no decode case); this is multisig and a silent-data-loss failure mode, distinct
Summary
UnmarshalBlock does not round-trip multisig_open or multisig_update blocks: the PoW nonce is silently dropped (decoded as 0), even though the encoded bytes contain it.
Root cause: minLen for the two multisig types is fixedHeaderSize + 8 + representativeSize, where the 8 is the keyset HEADER only (threshold + count), i.e. a zero-key floor. tailOffset is then initialised to minLen and only corrected for genesis and send/burn, never for multisig. So for a real multisig block (keyset = 8 + 32numKeys), tailOffset is left pointing 32numKeys bytes too early, and the nonce-presence check len(data) == tailOffset+8 never matches. The 8 trailing nonce bytes after keyset+representative are ignored.
Evidence (in-process Go test against the cloned core package)
encoded 202 bytes; last 8 (LE nonce) = efbeadde00000000 # 0xDEADBEEF little-endian IS present in the bytes
in PoWNonce = 3735928559 (0xdeadbeef)
out PoWNonce = 0 (0x0) # dropped on decode
keyset threshold in/out = 2/2, keys in/out = 2/2 # the keyset itself survives; only the nonce is lost
A full round-trip test over all 14 block types shows every other type round-trips (re-encode equals encode), multisig_open and multisig_update mismatch only in the final 8 bytes (orig nonce vs 0), and lease_renew fails to decode at all (that last one is #84).
Impact
PoWNonceis a real field:ValidatePoW(hashBytes, b.PoWNonce, difficulty)is called in core/ledger.go (x2) and core/quorum.go. A multisig block whose nonce is zeroed by a binary-codec round-trip would fail PoW re-verification.- Honest scope: the binary codec (
MarshalBlock/UnmarshalBlock) currently has NO caller anywhere in the repo. Blocks are stored and gossiped as JSON (store/badger_store.go usesjson.Marshal/json.Unmarshal), which preserves the nonce. So today this is a LATENT defect in an exported API function, not a live-path failure. It matters for any tool built on the exported codec, and it is the same codec and the same class of bug as the already-filed #84. - The nonce is not part of the block hash (
HashBlockusesMarshalBlockCanonical, which excludes the nonce), so there is no hash/consensus impact. No fund risk.
Suggested fix
- Compute
tailOffsetfrom the real decoded structure for every variable-length type. For multisig, settailOffset = repOffset + representativeSizeafter the keyset is parsed, as is already done implicitly for fixed-size types, instead of leaving it atminLen. - Add a round-trip test over all 14 block types to the codec (there is currently none; the repo ships no
*_test.go).
Payout
XE address: 6591eab453dbd93b27e2cd674712f94b42d9e7e4d52980b966fa6da4ccd832dc
Thread
Hey team & @BoomGone, opened PR #118 addressing this issue:
- In
core/encoding.go:unmarshalBlock, updatedtailOffsetto be computed dynamically asrepOffset + representativeSizerather than the staticminLen. This accounts for the dynamicksLen = 8 + 32*numKeyskeyset bytes on multisig blocks (multisig_open,multisig_update) solen(data) == tailOffset+8evaluates correctly. - Added
core/encoding_test.gowithTestMultisigPoWNonceRoundTripverifying exact parity ofPoWNonceon multi-key multisig roundtrips, plus standard block types.
Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is updated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0083.