feat(state): add ChainstateManager::validate_block() (callback) - #218
Draft
alexanderwiederin wants to merge 8 commits into
Draft
feat(state): add ChainstateManager::validate_block() (callback)#218alexanderwiederin wants to merge 8 commits into
ChainstateManager::validate_block() (callback)#218alexanderwiederin wants to merge 8 commits into
Conversation
…65fc94a39 5c65fc94a39 kernel: Add sans utxo set block validation b369e88ad40 kernel: Add outpoint equals operator e65476d050f kernel: Add outpoint creation to C header d54e309d00d kernel: Add coin creation to C header 644f73541f2 kernel: Add transaction is coinbase to C header REVERT: 70d9ec7f3d4 Merge bitcoin/bitcoin#34538: net: advertise -externalip addresses REVERT: 7bff765d514 Merge bitcoin/bitcoin#35639: external_signer: validate fingerprint from enumerate response REVERT: 773b1c9aa58 Merge bitcoin/bitcoin#35572: coins: make cursor iteration DB-only REVERT: dab7f2c984b test: cover -externalip/onlynet interaction in functional test REVERT: 657a5aa3f3d test: cover -externalip bypassing -onlynet REVERT: 8c87e32bd39 net: let -externalip bypass -onlynet REVERT: f4af02e827b net: add an add_even_if_unreachable argument to AddLocal REVERT: 4c9de7d5b32 external_signer: validate fingerprint from enumerate response REVERT: 72db4accbf5 coins: drop stale cursor null checks REVERT: 3d2f2d8de09 coins: pass UTXO stats view by reference REVERT: 35aedb28236 coins: drop cursor from base view REVERT: c6fbe2f66cf coins: pass DB view to cursor users git-subtree-dir: libbitcoinkernel-sys/bitcoin git-subtree-split: 5c65fc94a3997356374568783045e465f3cae706
Add FFI declaration for btck_transaction_is_coinbase, and expose it via TransactionExt::is_coinbase in the Rust API.
Add FFI declaration for btck_coin_create, and expose it via Coin::new() in the Rust API.
TxOut::new() Add FFI declaration for btck_transaction_out_point_create, and expose it via TxOut::new() in the Rust API.
Validate a block against caller-supplied coins instead of the chainstate's UTXO state, running CheckBlock through ConnectBlock with fJustCheck = true so the chainstate is read but never mutated. Coins are requested through the new FetchCoinCallback trait, blanket-implemented for Fn(TxOutPointRef<'_>) -> Option<Coin>. The callback is scoped to a single call, so it needs neither 'static nor Send + Sync. Panics are caught at the FFI boundary and resumed after the kernel returns. Outputs created and spent within the same block never reach the callback, so BIP-30 violations cannot be detected here.
Extract TestLog, setup_logging, create_context, testing_setup and read_block_data from tests/test.rs into tests/common so upcoming integration tests can reuse them. No behaviour change.
Pass the temp directory name in rather than hardcoding "test_chainman_regtest", so tests in other files can user their own directories. Existing call sites keep the old name.
Add tests/validate_block.rs with a UtxoSet implementing FetchCoinCallback, built up block by block from the headers-only chain. One test walks the chain validating each block against the coins accumulated so far and asserts the callback is consulted and the active chain never advances.
alexanderwiederin
force-pushed
the
callback-utxo-free
branch
from
August 26, 2026 15:52
5e9d4cb to
5c3e573
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To be compared with #205
depends on bitcoin/bitcoin#35187