{"id":"XE-13384","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"543","source_url":"https://github.com/xeprotocol/xe/issues/543","reporter_id":2486,"title":"Statechain genesis hash is line-ending sensitive — verify-genesis and node bootstrap fail on Windows (autocrlf)","area":"ops-testnet","claimed_tier":null,"assessed_tier":null,"verdict":"duplicate","duplicate_of":"XE-0038","tracked":true,"internal_ref":"#1087","internal_url":"https://github.com/xeprotocol/core/issues/1087","status":"closed","closed_reason":"duplicate","github_state":"closed","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-14T20:42:14.809701+00:00","updated_at":"2026-11-20T13:01:18.070233+00:00","source_created_at":"2026-11-13T07:09:15+00:00","told_at":"2026-11-20T13:00:17+00:00","status_changed_at":"2026-11-20T12:59:45.668158+00:00","url":"https://bounty.xe.network/XE-13384","body":"## Summary\n\nThe statechain \"canonical\" block hash is not canonical: it depends on the file's\nline endings (LF vs CRLF), not just the semantic JSON content. On a Windows\ncheckout with git's default `core.autocrlf=true` (the repo ships no\n.gitattributes), the published genesis bundle is rewritten to CRLF on checkout,\nand `xe verify-genesis` fails with `hash mismatch`, so a user cannot verify or\nbootstrap a node by following the README.\n\n## Root cause\n\n- statechain/types.go: Op.Value is json.RawMessage.\n- encoding/json decodes each \"value\" field by capturing its raw bytes verbatim,\n  including any CRLF inside the multi-line JSON value.\n- statechain/encoding.go MarshalCanonical() writes []byte(op.Value) straight\n  into the hash buffer; statechain/crypto.go HashBlock() = sha256 of that.\n\nThe committed genesis declares hash d01aabc1... (computed over LF bytes), but a\nCRLF checkout re-hashes the same logical genesis to f620d15b....\n\n## Reproduction (Windows, Go 1.25)\n\n1. git clone https://github.com/xeprotocol/xe.git  (default autocrlf)\n2. go build ./cmd/xe\n3. ./xe verify-genesis --genesis-dir ./genesis/testnet-0005\n\nResult:\n\nerror: genesis: genesis/testnet-0005/statechain-genesis.json:\nhash mismatch: got d01aabc1...c8f296d6, want f620d15b...0ac981\n\nThe same happens to the compiled-in embedded statechain/genesis.json.\n\n4. Fix to confirm: strip the carriage returns from the genesis file (sed\n   or a text edit), the file re-hashes to the declared d01aabc1... and\n   verify-genesis passes.\n\n## Impact\n\nAny operator/researcher cloning on Windows (or any autocrlf=true checkout) and\nfollowing the README cannot verify the bundle or bootstrap a node.\n\n## Suggested fix\n\nHash the decoded/typed value instead of the raw json.RawMessage bytes (or\nnormalize op.Value before hashing). Also consider a .gitattributes forcing\n*.json to LF.\n\n## Related\n\nXE-0038 covers the embedded BIP39 wordlist under autocrlf; this is the\ngenesis-JSON surface (verify-genesis + node bootstrap), which is a distinct\nimpact.\n","patch_refs":[{"id":579,"repo":"xeprotocol/xe","kind":"pr","ref":"555","title":"statechain,genesis: normalize CRLF in canonical op encoding and enforce LF attributes (Fixes #543)","url":"https://github.com/xeprotocol/xe/pull/555","note":"","state":"open","author":"Khanhtnq","added_by":"desk","created_at":"2026-11-14T20:42:20.320934+00:00"},{"id":743,"repo":"xeprotocol/xe","kind":"pr","ref":"915","title":"fix(xe): statechain-genesis-hash-is-lin (fixes #543)","url":"https://github.com/xeprotocol/xe/pull/915","note":"","state":"open","author":"tipprb","added_by":"desk","created_at":"2026-11-20T00:46:31.108183+00:00"}],"thread":[{"id":14106,"source":"github","source_ref":"7040167383","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as https://bounty.xe.network/XE-0038, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-13384 and says what differs; it is read like any other.","created_at":"2026-11-20T13:00:17+00:00"}]}