Skip to content

test(genesis): refuse a genesis file that does not match the published hash (Gate 3 G3-1, failing until fixed) - #1066

Draft
hackobi wants to merge 1 commit into
stabilisationfrom
g3-1-genesis-hash-test
Draft

hackobi wants to merge 1 commit into
stabilisationfrom
g3-1-genesis-hash-test

Conversation

@hackobi

@hackobi hackobi commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Gate 3 (Nov 8), task G3-1. This PR adds a test only, and the test fails on purpose. It turns green when the work is done.

What it checks: a node whose data/genesis.json does not hash to the published value (EXPECTED_GENESIS_HASH) must refuse to start, before Chain.generateGenesisBlock writes block 0.

  • Today EXPECTED_GENESIS_HASH is only compared in peerBootstrap, after block 0 has been built from the local file, and only when a peer answers.
  • So the first node of a network, or a node with no reachable peer, boots on whatever file it was given.

Run it: bun test src/libs/blockchain/routines/findGenesisBlock.expectedHash.test.ts

  • Control case (pin matches): passes.
  • G3-1 case (pin off by one character): fails, because block 0 is still generated.

Done when: this test passes with the check in findGenesisBlock, and the owner either merges it with the fix or replaces it with an equivalent test.

Not covered here:

  • A node restarting with block 0 already stored returns early and is never checked against the pin.
  • "Every validator loaded the same genesis" needs a devnet check comparing getGenesisDataHash across validators.

@coderabbitai

coderabbitai Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants