{"id":"XE-0083","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"100","source_url":"https://github.com/xeprotocol/xe/issues/100","reporter_id":25,"title":"core/encoding: UnmarshalBlock silently drops the PoW nonce for multisig_open/multisig_update (tailOffset uses min keyset size) (Minor)","area":"leasing-ledger","claimed_tier":"minor","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":true,"internal_ref":"","internal_url":null,"status":"accepted","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-10-29T13:57:24.063786+00:00","updated_at":"2026-11-10T11:38:26.076145+00:00","source_created_at":"2026-10-27T17:05:56+00:00","told_at":"2026-11-10T00:15:58+00:00","status_changed_at":"2026-10-29T14:04:13.942072+00:00","url":"https://bounty.xe.network/XE-0083","body":"- Area: core/encoding.go `UnmarshalBlock`\n- Found: 2026-10-27, repo master `9787859` (live node `xe/92d83d1`), via an in-process Go round-trip test\n- Related: #84 (lease_renew has no decode case); this is multisig and a silent-data-loss failure mode, distinct\n\n## Summary\n\n`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.\n\nRoot 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 + 32*numKeys), `tailOffset` is left pointing 32*numKeys bytes too early, and the nonce-presence check `len(data) == tailOffset+8` never matches. The 8 trailing nonce bytes after keyset+representative are ignored.\n\n## Evidence (in-process Go test against the cloned core package)\n\n```\nencoded 202 bytes; last 8 (LE nonce) = efbeadde00000000     # 0xDEADBEEF little-endian IS present in the bytes\nin  PoWNonce = 3735928559 (0xdeadbeef)\nout PoWNonce = 0 (0x0)                                        # dropped on decode\nkeyset threshold in/out = 2/2, keys in/out = 2/2             # the keyset itself survives; only the nonce is lost\n```\n\nA 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).\n\n## Impact\n\n- `PoWNonce` is 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.\n- 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 uses `json.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.\n- The nonce is not part of the block hash (`HashBlock` uses `MarshalBlockCanonical`, which excludes the nonce), so there is no hash/consensus impact. No fund risk.\n\n## Suggested fix\n\n- Compute `tailOffset` from the real decoded structure for every variable-length type. For multisig, set `tailOffset = repOffset + representativeSize` after the keyset is parsed, as is already done implicitly for fixed-size types, instead of leaving it at `minLen`.\n- Add a round-trip test over all 14 block types to the codec (there is currently none; the repo ships no `*_test.go`).\n\n## Payout\n\nXE address: `6591eab453dbd93b27e2cd674712f94b42d9e7e4d52980b966fa6da4ccd832dc`\n","patch_refs":[{"id":138,"repo":"xeprotocol/xe","kind":"pr","ref":"118","title":"core/encoding: compute tailOffset from repOffset to preserve PoWNonce on multisig blocks (#100)","url":"https://github.com/xeprotocol/xe/pull/118","note":"","state":"open","author":"fangjian-bit","added_by":"desk","created_at":"2026-10-29T13:57:30.091343+00:00"},{"id":128,"repo":"xeprotocol/xe","kind":"pr","ref":"108","title":"fix(core): add BlockLeaseRenew unmarshaling and fix multisig PoW nonce tail offset (#84, #100)","url":"https://github.com/xeprotocol/xe/pull/108","note":"","state":"open","author":"arturbarszcz78","added_by":"desk","created_at":"2026-10-29T13:57:30.091343+00:00"}],"thread":[{"id":32,"source":"github","source_ref":"6464510721","author":"fangjian-bit","team":false,"body":"Hey team & @BoomGone, opened PR #118 addressing this issue:\n\n1. In `core/encoding.go:unmarshalBlock`, updated `tailOffset` to be computed dynamically as `repOffset + representativeSize` rather than the static `minLen`. This accounts for the dynamic `ksLen = 8 + 32*numKeys` keyset bytes on multisig blocks (`multisig_open`, `multisig_update`) so `len(data) == tailOffset+8` evaluates correctly.\n2. Added `core/encoding_test.go` with `TestMultisigPoWNonceRoundTrip` verifying exact parity of `PoWNonce` on multi-key multisig roundtrips, plus standard block types.","created_at":"2026-10-28T08:40:36+00:00"},{"id":1586,"source":"github","source_ref":"6755097367","author":"XE desk","team":true,"body":"Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is\nupdated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0083.","created_at":"2026-11-10T00:15:58+00:00"}]}