{"id":"XE-0036","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"3","source_url":"https://github.com/xeprotocol/xe/issues/3","reporter_id":15,"title":"A node built from this repo cannot boot: statechain genesis hash mismatch (embedded genesis and published testnet-0001 bundle both fail validation)","area":"ops-testnet","claimed_tier":"high","assessed_tier":null,"verdict":"support","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"stale","github_state":"closed","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-10-29T13:57:16.857099+00:00","updated_at":"2026-11-10T00:11:45.852305+00:00","source_created_at":"2026-08-22T00:03:09+00:00","told_at":"2026-11-08T08:59:14+00:00","status_changed_at":"2026-10-29T14:22:11.143041+00:00","url":"https://bounty.xe.network/XE-0036","body":"> Reporting note: the bounty asks for private email first for Critical/Severe\n> findings. I tried security@xe.network and the address bounced. This repo\n> also does not have GitHub private vulnerability reporting enabled, so I am\n> filing here. Severity is the team's call in the end; my own read is High,\n> with a Severe argument at the bottom.\n\n## Summary\n\nThe statechain genesis validation in this tree does not reproduce the hashes\nof the published genesis artifacts. A node built from the repo (tested at\ncommit `f29463b`, current HEAD; there are no official release binaries, so\nbuilding from source is the only way to run one) fails to boot on every path\nI could find:\n\n- the default path fails on the embedded `statechain/genesis.json`;\n- the documented `--genesis-dir` path fails on the published\n  `genesis/testnet-0001/` bundle;\n- `xe verify-genesis` fails with the very hash this repo's own README\n  documents.\n\n## Reproduction (fresh clone, go1.25+; tested go1.27.0 on windows/amd64)\n\n```sh\ngit clone https://github.com/xeprotocol/xe && cd xe\ngo build -o xe ./cmd/xe\n\n# (a) Default boot: embedded genesis fails\n./xe node --data ./data --disable-mdns\n# ERROR failed to start node: statechain genesis: genesis: hash mismatch:\n#   got  96a5ac54247f0609ac51cfd925287dbfb73144adbb34eeb658784b511751c212   (declared in statechain/genesis.json)\n#   want bbe4444dcf6dda5f039c5bf4f13f7f6139adcb741bd76ac464c84436d0cbe809   (computed by this code)\n\n# (b) Documented join path: published bundle fails\n./xe node --genesis-dir ./genesis/testnet-0001 --data ./data --disable-mdns\n# ERROR genesis: hash mismatch:\n#   got  419460291afa7405e462d44b696f8284da1655634ead62196e50e09234733a29   (declared in file; matches genesis/testnet-0001/README.md)\n#   want 0a55e6f9aa4a5b38cc51ac6b63608a2d6d982604c5b2d698e931dca61858085c   (computed by this code)\n\n# (c) The repo's own verification flow fails\n./xe verify-genesis --genesis-dir ./genesis/testnet-0001 \\\n    --expect-network-id testnet-0001 \\\n    --expect-statechain-hash 419460291afa7405e462d44b696f8284da1655634ead62196e50e09234733a29\n# error: genesis: hash mismatch: got 419460…, want 0a55e6…\n\n\nMinimal check without the binary:\nraw, _ := os.ReadFile(\"genesis/testnet-0001/statechain-genesis.json\")\n_, err := statechain.ParseGenesis(raw)\n// err: \"hash mismatch: got 419460…, want 0a55e6…\"\n\nRoot cause\nstatechain.MarshalCanonical (statechain/encoding.go) hashes each op's Value (json.RawMessage) as the raw bytes taken from the JSON file. I tried three canonicalizations of the testnet-0001 artifact under the current framing code:\n| Value form | Computed hash | Matches declared 419460…? |\n| --- | --- | --- |\n| raw bytes as the file is formatted | 0a55e6… | no |\n| JSON-compacted (json.Compact) | f03ecf… | no |\n| re-marshaled via map (sorted keys) | 346e71… | no |\n\nNone of them reproduce the network hash, so the framing itself (op/value layout, length prefixes, or hashing inputs) in the running network's binaries differs from what this source computes. The published tree does not reproduce the statechain hash preimage of the running network.\n\nThe ledger genesis in the same bundle validates fine (ledger-genesis.json: declared e813eefe… equals computed e813eefe…). That rules out the bundle itself and points the finger at the statechain encoding path.\n\nThere are really two problems here.\n\nA. Source/artifact divergence, which is the boot failure. Whatever generated statechain-genesis.json and whatever binary runs the network agree with each other, but not with this code. Anyone following the README gets a node that cannot start, and the documented \"check what you are about to join\" verify-genesis flow fails.\n\nB. A design flaw: statechain block hashes depend on JSON formatting. Because op.Value is hashed as raw file bytes, two semantically identical genesis documents that differ only in whitespace produce different genesis hashes, and the genesis hash is the network identity. A re-serialization step can silently fork identity. The ledger path avoids this whole class by hashing a fixed-width binary framing.\n\nImpact\nA from-source node cannot boot with defaults and cannot join testnet-0001 through the published bundle. Both paths are fatal.\nThe repo's public identity-verification workflow fails, so third parties cannot verify the network identity from the published artifacts and source.\nThe tree does not implement the statechain hash preimage the live network uses. Even with a local boot-check patch, such a node would compute statechain hashes differently and diverge immediately.\nBefore mainnet: problem B can silently fork the network identity at genesis distribution time if any copy step re-serializes the JSON.\nSeverity (for the team to decide)\nThe Severe tier includes \"unrecoverable restart\". This is a stronger version of that: the node can never start or join from the only published distribution channel, and the source disagrees with the network's consensus hash preimage.\n\nThe High argument, as a floor: no funds are at risk, and a strict reading of \"unrecoverable restart\" implies a node that once ran. Either way this sits inside the Phase 1 scope item \"Node lifecycle: config, storage, restart, recovery\".\n\nSuggested fixes\nReconcile the framing code with the artifacts: commit the generator and encoding that produces 419460…, or regenerate the bundle from the current code with a coordinated testnet re-boot.\nMake statechain value hashing format-independent (canonical compaction of op.Value before hashing, or a typed binary encoding).\nAdd a CI gate that boots a node from a clean build against the embedded genesis and runs verify-genesis against the published bundle on every commit.\nPublish release binaries, or state clearly that source builds are the only channel, in which case a booting source tree is release-critical.\nAll testing was done locally on a fresh clone. The failure happens at boot, so I never touched the testnet. Happy to help with severity triage or any follow-up.","patch_refs":[],"thread":[{"id":12,"source":"github","source_ref":"6397318743","author":"greenblood33333","team":false,"body":"Data point for problem (B) in this report: a whitespace-only difference does flip the statechain genesis hash. On Windows with git's default `core.autocrlf=true`, the checked-out `genesis/testnet-0005/statechain-genesis.json` gets CRLF line endings (99 CR bytes) and `verify-genesis` fails with a hash mismatch; with `core.autocrlf=false` and a fresh checkout the same file verifies and matches the README hashes (`d01aabc1…8f296d6` / `3ff64041…d1e150`). Details and the embedded-genesis variant are in #31 (comment). I did not test `f29463b` or `testnet-0001`, so I cannot say whether line endings explain all of what you saw, but it is one confirmed way to hit the raw-bytes hashing you describe.","created_at":"2026-10-25T11:55:55+00:00"},{"id":795,"source":"github","source_ref":"6719547519","author":"Joseph Denne","team":true,"body":"Thanks for this, and apologies that it sat without an answer. It was filed against the testnet-0001 genesis; the network has since moved to testnet-0005 and the genesis test in the tree reproduces the current published hash, so the mismatch as reported no longer applies and this closes as stale. The CRLF data point from greenblood33333 is a real footgun: `verify-genesis` should normalise line endings or the repo should pin `.gitattributes`, and that has been noted. If a node built from current HEAD still fails `verify-genesis` against `genesis/testnet-0005/`, reopen with the output and the commit.","created_at":"2026-11-08T08:59:14+00:00"}]}