Bounty
XE-13384 · Bounty

Statechain genesis hash is line-ending sensitive — verify-genesis and node bootstrap fail on Windows (autocrlf)

Closed · duplicate — xe#543 filed 2026-11-13 07:09 UTC by itsmesan03

Report

Summary

The statechain "canonical" block hash is not canonical: it depends on the file's line endings (LF vs CRLF), not just the semantic JSON content. On a Windows checkout with git's default core.autocrlf=true (the repo ships no .gitattributes), the published genesis bundle is rewritten to CRLF on checkout, and xe verify-genesis fails with hash mismatch, so a user cannot verify or bootstrap a node by following the README.

Root cause

  • statechain/types.go: Op.Value is json.RawMessage.
  • encoding/json decodes each "value" field by capturing its raw bytes verbatim, including any CRLF inside the multi-line JSON value.
  • statechain/encoding.go MarshalCanonical() writes []byte(op.Value) straight into the hash buffer; statechain/crypto.go HashBlock() = sha256 of that.

The committed genesis declares hash d01aabc1... (computed over LF bytes), but a CRLF checkout re-hashes the same logical genesis to f620d15b....

Reproduction (Windows, Go 1.25)

  1. git clone https://github.com/xeprotocol/xe.git (default autocrlf)
  2. go build ./cmd/xe
  3. ./xe verify-genesis --genesis-dir ./genesis/testnet-0005

Result:

error: genesis: genesis/testnet-0005/statechain-genesis.json: hash mismatch: got d01aabc1...c8f296d6, want f620d15b...0ac981

The same happens to the compiled-in embedded statechain/genesis.json.

  1. Fix to confirm: strip the carriage returns from the genesis file (sed or a text edit), the file re-hashes to the declared d01aabc1... and verify-genesis passes.

Impact

Any operator/researcher cloning on Windows (or any autocrlf=true checkout) and following the README cannot verify the bundle or bootstrap a node.

Suggested fix

Hash the decoded/typed value instead of the raw json.RawMessage bytes (or normalize op.Value before hashing). Also consider a .gitattributes forcing *.json to LF.

Related

XE-0038 covers the embedded BIP39 wordlist under autocrlf; this is the genesis-JSON surface (verify-genesis + node bootstrap), which is a distinct impact.

Thread

Joseph Denneteam2026-11-20 13:00 UTCgithub

Thanks. This is the same finding as https://bounty.xe.network/XE-0038, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, file a new report that links https://bounty.xe.network/XE-13384 and says what differs; it is read like any other.