Skip to content

integration-tests: add BIP-54 coinbase compliance test#453

Open
Sjors wants to merge 1 commit intostratum-mining:mainfrom
Sjors:2026/04/bip54
Open

integration-tests: add BIP-54 coinbase compliance test#453
Sjors wants to merge 1 commit intostratum-mining:mainfrom
Sjors:2026/04/bip54

Conversation

@Sjors
Copy link
Copy Markdown
Contributor

@Sjors Sjors commented Apr 24, 2026

BIP-54 (Consensus Cleanup) requires that every block's coinbase transaction has nLockTime equal to the block height minus one and a non-final nSequence (not 0xffffffff) on its sole input.

Add an integration test that drives a block end-to-end through the SV2 stack (minerd -> translator -> JDC -> JDS/Pool -> Template Provider) and, once the new tip is accepted by Bitcoin Core, fetches the block and asserts both invariants on its coinbase.

A small get_block helper is exposed on BitcoinCore and TemplateProvider to allow tests to inspect freshly accepted blocks.

@Sjors
Copy link
Copy Markdown
Contributor Author

Sjors commented Apr 24, 2026

100% vibe coded :-)

@Sjors Sjors marked this pull request as ready for review April 24, 2026 13:28
@plebhash plebhash requested a review from xyephy April 24, 2026 13:44
Copy link
Copy Markdown
Collaborator

@xyephy xyephy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK 8325c83.

Tested locally on Bitcoin Core 31.0 / sv2-tp 1.1.0 (regtest, macOS arm64).

Comment on lines +47 to +48
new_best_hash = tp.get_best_block_hash().unwrap();
new_height = tp.get_blockchain_info().unwrap().blocks;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_best_block_hash() and get_blockchain_info() are separate RPCs; hash and height can disagree under load (saw 4 blocks/run locally). Suggest mirroring jdc_block_propagation.rs — sniff SUBMIT_SOLUTION JDC→TP, then read the tip once.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +78 to +79
.first()
.expect("coinbase must have exactly one input");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: unreachable since is_coinbase() already enforces input.len() == 1. &coinbase.input[0] will do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

BIP-54 (Consensus Cleanup) requires that every block's coinbase
transaction has nLockTime equal to the block height minus one and a
non-final nSequence (not 0xffffffff) on its sole input. Add an
integration test that drives a block end-to-end through the SV2 stack
(minerd -> translator -> JDC -> JDS/Pool -> Template Provider) and,
once the new tip is accepted by Bitcoin Core, fetches the block and
asserts both invariants on its coinbase.

A small get_block helper is exposed on BitcoinCore and TemplateProvider
to allow tests to inspect freshly accepted blocks.

See https://github.com/bitcoin/bips/blob/master/bip-0054.md
@Sjors Sjors force-pushed the 2026/04/bip54 branch from 8325c83 to b60623b Compare May 6, 2026 08:32
@Sjors
Copy link
Copy Markdown
Contributor Author

Sjors commented May 6, 2026

Rebased and addressed @xyephy's feedback.

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