A node built from this repo cannot boot: statechain genesis hash mismatch (embedded genesis and published testnet-0001 bundle both fail validation)
Report
Reporting note: the bounty asks for private email first for Critical/Severe findings. I tried security@xe.network and the address bounced. This repo also does not have GitHub private vulnerability reporting enabled, so I am filing here. Severity is the team's call in the end; my own read is High, with a Severe argument at the bottom.
Summary
The statechain genesis validation in this tree does not reproduce the hashes
of the published genesis artifacts. A node built from the repo (tested at
commit f29463b, current HEAD; there are no official release binaries, so
building from source is the only way to run one) fails to boot on every path
I could find:
- the default path fails on the embedded
statechain/genesis.json; - the documented
--genesis-dirpath fails on the publishedgenesis/testnet-0001/bundle; xe verify-genesisfails with the very hash this repo's own README documents.
Reproduction (fresh clone, go1.25+; tested go1.27.0 on windows/amd64)
git clone https://github.com/xeprotocol/xe && cd xe
go build -o xe ./cmd/xe
# (a) Default boot: embedded genesis fails
./xe node --data ./data --disable-mdns
# ERROR failed to start node: statechain genesis: genesis: hash mismatch:
# got 96a5ac54247f0609ac51cfd925287dbfb73144adbb34eeb658784b511751c212 (declared in statechain/genesis.json)
# want bbe4444dcf6dda5f039c5bf4f13f7f6139adcb741bd76ac464c84436d0cbe809 (computed by this code)
# (b) Documented join path: published bundle fails
./xe node --genesis-dir ./genesis/testnet-0001 --data ./data --disable-mdns
# ERROR genesis: hash mismatch:
# got 419460291afa7405e462d44b696f8284da1655634ead62196e50e09234733a29 (declared in file; matches genesis/testnet-0001/README.md)
# want 0a55e6f9aa4a5b38cc51ac6b63608a2d6d982604c5b2d698e931dca61858085c (computed by this code)
# (c) The repo's own verification flow fails
./xe verify-genesis --genesis-dir ./genesis/testnet-0001 \
--expect-network-id testnet-0001 \
--expect-statechain-hash 419460291afa7405e462d44b696f8284da1655634ead62196e50e09234733a29
# error: genesis: hash mismatch: got 419460…, want 0a55e6…
Minimal check without the binary:
raw, _ := os.ReadFile("genesis/testnet-0001/statechain-genesis.json")
_, err := statechain.ParseGenesis(raw)
// err: "hash mismatch: got 419460…, want 0a55e6…"
Root cause
statechain.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:
| Value form | Computed hash | Matches declared 419460…? |
| --- | --- | --- |
| raw bytes as the file is formatted | 0a55e6… | no |
| JSON-compacted (json.Compact) | f03ecf… | no |
| re-marshaled via map (sorted keys) | 346e71… | no |
None 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.
The 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.
There are really two problems here.
A. 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.
B. 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.
Impact
A from-source node cannot boot with defaults and cannot join testnet-0001 through the published bundle. Both paths are fatal.
The repo's public identity-verification workflow fails, so third parties cannot verify the network identity from the published artifacts and source.
The 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.
Before mainnet: problem B can silently fork the network identity at genesis distribution time if any copy step re-serializes the JSON.
Severity (for the team to decide)
The 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.
The 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".
Suggested fixes
Reconcile 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.
Make statechain value hashing format-independent (canonical compaction of op.Value before hashing, or a typed binary encoding).
Add 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.
Publish release binaries, or state clearly that source builds are the only channel, in which case a booting source tree is release-critical.
All 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.
Thread
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.
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.