feat: probe Bitcoin provider by genesis block hash - #4067
Conversation
Pull request overviewAdds the Bitcoin leg of the network-fingerprint probe (#4003). Since Bitcoin exposes no chain id, the fingerprint is the genesis block hash, obtained via The implementation mirrors the Starknet/EVM legs of the same stack one-for-one ( Changes:
Reviewed changesPer-file summary
FindingsNo blocking issues. Correctness spot checks that held up: Non-blocking (nits, follow-ups, suggestions):
✅ Approved |
665e20a to
605f520
Compare
f270c33 to
9dde2cc
Compare
| }) | ||
| .await | ||
| } | ||
| // TODO(#4003): probe Aptos and Sui. Ethereum, Solana and Ton have no inspector, so |
There was a problem hiding this comment.
Reminds me, we need to pick up the Ton inspector. Daniel's PR is growing stale there 😅
1888570 to
eeb2b2d
Compare
| /// RPC response for `getblockhash`: a block hash in the byte order block explorers render. | ||
| /// <https://developer.bitcoin.org/reference/rpc/getblockhash.html> | ||
| /// | ||
| /// Kept as text rather than parsed into a [`TransportBitcoinBlockHash`]. |
There was a problem hiding this comment.
It's best to avoid paraphrasing the code (as per our engineering standards).
This comment would be more helpful if it explained why we keep it as a string instead of a TransportBitcoinBlockhash.
There was a problem hiding this comment.
Curious why Claude didn’t catch that. I recently added it to AGENTS.md too:
Line 139 in 4659ad7
| /// Bitcoin mainnet's genesis block hash, as shipped in `expected_network_fingerprint`. | ||
| const EXPECTED_NETWORK_FINGERPRINT: &str = | ||
| "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"; |
There was a problem hiding this comment.
as shipped in
expected_network_fingerprint
What is this referring to? I don't understand that second part of the comment.
3bb1fa8
Bitcoin has no chain id, so `getblockhash` at height 0 is what tells its networks apart. Normalization keeps leading zeros, since they are digits of the hash rather than padding.
Starknet and the EVM chains already match the prefix either way, and an operator writes this value by hand. Folds the two inspector tests into one that answers the upper cased hash, and renames the mock helper, which no longer serves only chain ids.
Say why the response type keeps the provider's text verbatim, and name the config field the manual test's fingerprint constant mirrors.
3bb1fa8 to
26932d2
Compare
Closes #4091.
Bitcoin has no chain id, so the fingerprint is the genesis block hash and the probe is
getblockhashat height 0, the method the inspector's canonical chain check already uses.Notes for review
0xprefix stripped. Text that is not 64 hex characters reads back unchanged, so the report shows what the provider actually claimed.