Skip to content

test(node): mine regtest proof of work for the verifychain level 4 fixture - #32

Open
MeABzZz wants to merge 1 commit into
BTCDecoded:mainfrom
MeABzZz:criticals/verifychain-fixture-pow
Open

MeABzZz wants to merge 1 commit into
BTCDecoded:mainfrom
MeABzZz:criticals/verifychain-fixture-pow

Conversation

@MeABzZz

@MeABzZz MeABzZz commented Oct 21, 2026 •

Copy link
Copy Markdown

What

This is the companion to the blvm-consensus PoW fix (fix(consensus): reject a block whose hash is above its target on connect).

test_verify_chain_level4_with_undo_logs builds its genesis and block 1 with bits: 0x0f00ffff and nonce 1 and 2. No hash meets that target. verifychain level 4 replays those blocks through connect with the ancestor lookup, and once connect checks proof of work it rejects them:

{"checked_blocks":2,"errors":["Block at height 0 invalid: Block hash does not meet its proof of work target"],"valid":false}

This PR gives the fixture regtest bits (0x207fffff) and grinds the nonce (mine_regtest, about 2 tries per header). Headers that meet their target pass with or without the consensus change. Only test code changes.

Evidence

  • With the consensus PoW fix patched in, before this change: blockchain_rpc_tests had 3 passed and 1 failed, the failure shown above. It was the only failure in the full node suite (3018 passed).
  • After this change: cargo test --test blockchain_rpc_tests has 4 passed and 0 failed.
  • cargo fmt --all -- --check: clean.

Merge order

This can go in before or after the consensus PR. It must be in before node CI builds against a consensus that includes the PoW check.


Review notes: merge order and open decisions (BLVM criticals set)

This PR is one of 7 fixing the four criticals from the BLVM three-lens review:
blvm-consensus#22 (undo log), blvm-consensus#23 (PoW vs target), blvm-node#32 (PoW test fixture), blvm-primitives#2 (min chainwork), blvm-node#31 (assume-valid), blvm-secp256k1#1 (no CUDA by default), blvm#10 (release build + no-CUDA check).

Merge order

  1. blvm-node#32 before blvm-consensus#23, otherwise node CI breaks (old fixture headers have no valid PoW).
  2. After the blvm-primitives release with Improve error handling #2, regenerate the consensus golden file consensus_config_default.json, or its test fails.
  3. After the blvm-secp256k1 release with Add RPC method examples #1, run cargo update -p blvm-secp256k1 in blvm, then cut a release with blvm#10. v0.1.63 and v0.1.64 stay broken (need libcudart) until then.

Decisions for the reviewer

Known, not fixed here: -assumevalid=<hash> CLI parses the hash in the wrong byte order; the GHCR image ships a different binary (blvm 0.1.0).

…xture

The fixture headers used bits 0x0f00ffff with nonce 1 and 2, which no
hash meets. verifychain level 4 replays them through connect, and
connect now checks proof of work (blvm-consensus criticals/connect-pow),
so the replay rejected genesis. Set regtest bits and grind the nonce;
valid headers pass with or without that change.
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.

1 participant