Repository navigation
p2p: move to kernel-node bitcoin-p2p on bitcoin 0.32 (SNB-854) - #84
Open
setavenger wants to merge 3 commits into
Open
setavenger wants to merge 3 commits into
setavenger wants to merge 3 commits into
Conversation
The block download used 2140-dev/bitcoin-p2p (archived, unpinned), which needs a rust-bitcoin 0.33 pre-release (16cc257c, pulled in as `bitcoin-rev`). Every block, header and transaction was therefore decoded twice or re-encoded between the two rust-bitcoin versions, and `bitcoin_rev::Network` leaked into the public API. - blindbit-lib: depend on kernel-node's `bitcoin-p2p` (crates/p2p), pinned to d421e330, which uses bitcoin 0.32. Blocks arrive as `bitcoin::Block` and go straight to `check_block`. - Use `bitcoin::Network` everywhere: `ScannerConfig`, `Scanner`, `BlockFetcher`, `BlockFetchError`, blindbit-cli and friglet config. `scanner::convert_network` is gone. - Keep the handshake peers see: kernel-node defaults to user agent "/bitcoin-p2p:0.1.0/" and feefilter 0, so set "/SwiftSync:0.1.0/" and 1000 sat/kvB as before (new test checks the version message). - friglet's own relay=true Electrum peer now uses bitcoin 0.32's `bitcoin::p2p` message types; friglet no longer depends on bitcoin-p2p. - Remove the `bitcoin-rev` dependency; Cargo.lock now holds one bitcoin (0.32.8, the version kernel-node requires). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… bitcoin 0.32.8 (SNB-854) friglet's own P2P peer sent all-zero address fields in its version message while the scanner's kernel-node connections send 127.0.0.1:1, which kernel-node does not let us override. Send 127.0.0.1:1 from both stacks so a peer sees one client, as the shared user agent intends. Raise the bitcoin floor in every manifest to 0.32.8, the version kernel-node bitcoin-p2p needs and the lockfile already resolves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…B-854) integration gained testkit_t0.rs, which imports bitcoin_rev::Network; this branch removes the bitcoin-rev dependency. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
setavenger
force-pushed
the
snb-854-kernel-node-p2p
branch
from
November 1, 2026 15:53
4ab2cda to
fa4f8ee
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.
Step 1 of SNB-853 (SNB-854): a pure dependency switch, no intended behaviour change.
What changed and why
The block download used
2140-dev/bitcoin-p2p(archived, not pinned). It needs a rust-bitcoin 0.33 pre-release (16cc257c, ourbitcoin-revdependency), so blocks, headers and transactions were re-encoded between two rust-bitcoin versions, andbitcoin_rev::Networkleaked into the public API.bitcoin-p2p(crates/p2p), pinned torev = d421e330. It uses bitcoin 0.32, so a received block is already abitcoin::Blockand goes straight tocheck_block(the decode, re-encode, decode step is gone).bitcoin::Networkis used everywhere:ScannerConfig,Scanner::new/from_changeset,BlockFetcher,BlockFetchError,FetchFailure::WrongNetwork, blindbit-cli--network, frigletResolvedConfig.scanner::convert_networkis removed. Testnet3 isNetwork::Testnetand testnet4 isNetwork::Testnet4.friglet/src/electrum/p2p.rs, kept because it needsrelay = true) is ported to bitcoin 0.32'sbitcoin::p2pmessage types. friglet no longer depends onbitcoin-p2p: it only used that crate's message re-export.bitcoin-revis removed from all three crates. Cargo.lock now has onebitcoin: 0.32.7 → 0.32.8, the minimum kernel-node requires. hex-conservative also moves 0.2.1 → 0.2.3, pulled in by that bump.Behaviour differences found
Timeouts, retries, ping/getdata logic, service requirement (none), block checks and error messages are unchanged. The new crate's
net.rsandhandshake.rswork the same way as the old crate's: the same blocking reader, the same writer thread with a 30 s ping, the same strict pre-verack message set, the same ≥ 70016 version floor and the same error enum. Only the types differ. Differences:/bitcoin-p2p:0.1.0/andfeefilter 0. We now set/SwiftSync:0.1.0/and 1000 sat/kvB explicitly, so peers see the same values as before. A new test,the_handshake_shows_the_node_the_same_client_as_before, checks this.127.0.0.1:1asaddr_recv/addr_from; the old crate sent all zeros. The crate does not let us override this. Bitcoin Core ignores both values because neither is routable. friglet's own peer now sends127.0.0.1:1too (commit 4ab2cda), so both stacks look like one client to a peer.UnexpectedMagic) instead of "handshake failed: Command string must be ASCII". Both are non-transient, so retries are unchanged.FetchFailure::Broken. The message is now the decoder's error instead ofundecodable block: ….feefilteris ani64in 0.32. friglet maps it to the sameu64as before, including the saturation for values outsideu32.transaction re-encoding failederror path is gone.alertdropped. The old crate sent a finalalertto peers below protocol version 70016. Such peers were rejected anyway, so nothing changes in practice.Verification
bitcoinfloor raised to0.32.8in every manifest. Commit fa4f8ee: integration's new testkit T0 tests importbitcoin::Networkinstead of the removedbitcoin_rev::Network.cargo build --workspace: ok.cargo test -p blindbit-lib --features serdeon top of integration 929419b:86 passed; 0 failed(75 existing, 1 new, 10 testkit T0). Before the rebase: friglet77 passed; 0 failed(+1 integration), friglet-ipc 27+1, friglet-tray 66+7; CI passes.cargo clippy --no-deps -p friglet -p friglet-ipc -p friglet-tray --all-targets -- -D warnings: clean.cargo fmt --all -- --check: clean.cargo tree -i bitcoin --workspace: a singlebitcoin v0.32.8. Before this change there were two: 0.32.7 and 0.33.0-alpha.0 (git).152.53.151.148:38333,https://signet.oracle.setor.dev, debug builds, before and after):fetch_blockof block 328628 (719,127 bytes, 227 txs):OKboth times, so the checks pass (hash, merkle root, witness commitment).mainnetagainst the signet node): the same message word for word.blockchain.block.header 300000comes over P2Pgetheadersand matches mempool.space byte for byte.blockchain.relayfeereturns the peer's feefilter.check_blockhashing: 9.0 ms → 6.8 ms, about 0.75×.BlockFetcher::fetchfrom a loopback fake peer, 4 interleaved runs of 200 fetches each: