Skip to content

build(hashes)!: move to bitcoin_hashes 1.x - #1320

Merged
ZocoLini merged 7 commits into
devfrom
build/bitcoin-hashes-1x
Nov 4, 2026
Merged

ZocoLini merged 7 commits into
devfrom
build/bitcoin-hashes-1x

Conversation

@xdustinface

@xdustinface xdustinface commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Moves dashcore_hashes and every crate that uses it from bitcoin_hashes 0.14 to 1.x. This replaces the Dependabot bump in #1314, which fails CI because 1.x is an API redesign, not a drop-in upgrade.

bitcoin_hashes now comes from the same rust-bitcoin git revision as bitcoin-crypto, bitcoin-units and the base-sdk crates, not from crates.io. The workspace already pulled 1.2.0 from that revision through those crates, so our hash types now unify with theirs. Platform already patches crates.io bitcoin_hashes to the same revision. The 0.14 and 0.16 copies stay in the tree because bip39 and bip324 have no 1.x release yet.

In 1.x the Hash trait only converts to and from byte arrays. Our hash newtypes keep from_slice and all_zeros as inherent methods, and hashes::Error / FromSliceError keep their 0.14 shape and message, so most existing callers compile unchanged. Hashing a newtype now goes through its inner hash: Txid::from_raw_hash(sha256d::Hash::hash(..)), or an engine from sha256d::Hash::engine() finished with finalize().

No hash output changes. The X11, tagged SHA256, SipHash, sighash, txid, merkle and block hash vectors all pass unchanged.

Breaking changes

  • Hash newtypes no longer have hash, engine or from_engine. They gain const inherent from_byte_array, to_byte_array and as_byte_array, so many use dashcore::hashes::Hash imports become unused.
  • HashEngine uses finalize(), and midstate() / MidState are gone.
  • HmacEngine<T> is parameterized by the engine type, and Hmac::from_engine is replaced by finalize().
  • sha256t is upstream's module. sha256t_hash_newtype!, the sha256t_hash_newtype_tag macros and siphash24::State are removed. Nothing in this repo or Platform uses them.
  • Upstream base types such as sha256d::Hash lose all_zeros, from_slice and indexing, and print a different Debug. Our newtypes keep their exact 0.14 formatting.
  • merkle_tree::calculate_root and calculate_root_inline require T: From<sha256d::Hash> and always combine with SHA256d. Every caller already passes SHA256d hashes.

Platform impact

Counted in Platform's packages/:

  • 7 sites call engine() / from_engine() on QuorumSigningRequestId (rs-drive-abci) and SpecialTransactionPayloadHash (rs-platform-wallet). Each becomes a hash through sha256d::Hash wrapped with from_raw_hash.
  • 2 test lines call dashcore::hashes::Hash::all_zeros() through the trait. They become Txid::all_zeros().
  • Unused Hash imports fail under -D warnings. cargo clippy --fix removes them.

Testing

  • cargo fmt --check, cargo clippy --workspace --all-features --all-targets -D warnings, default and --no-default-features checks, just doc, the 1.89 MSRV check, cargo deny and the pre-push hooks pass.
  • Workspace tests with dashd: 2,802 passed. The one failure, test_runtime_add_with_tip_advance_during_rescan, was a dashd RPC timeout in the test harness under heavy machine load. It passed on rerun.

PR Hygiene · 9401c9f

  • Bots — coderabbitai skipped by xdustinface
  • Self-review — posted; again after any push
  • Build green
  • Approvals — you own every area touched; none needed

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Too many files!

This PR contains 157 files, which is 57 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.

Run configuration
Commits

Reviewing files that changed from the base of the PR and between aa74423 and 9401c9f.

Files selected for processing: 157
  • Cargo.toml
  • crypto/src/eddsa.rs
  • crypto/src/key.rs
  • dash-spv/benches/storage.rs
  • dash-spv/src/client/queries.rs
  • dash-spv/src/network/broker.rs
  • dash-spv/src/network/costs.rs
  • dash-spv/src/network/mod.rs
  • dash-spv/src/sml_engine.rs
  • dash-spv/src/sml_engine/helpers.rs
  • dash-spv/src/sml_engine/rotated_quorum_construction.rs
  • dash-spv/src/sml_engine/validation.rs
  • dash-spv/src/storage/header_hash_index.rs
  • dash-spv/src/storage/masternode.rs
  • dash-spv/src/storage/segments.rs
  • dash-spv/src/sync/block_headers/sync_manager.rs
  • dash-spv/src/sync/blocks/manager.rs
  • dash-spv/src/sync/blocks/pipeline.rs
  • dash-spv/src/sync/chainlock/manager.rs
  • dash-spv/src/sync/filter_headers/manager.rs
  • dash-spv/src/sync/filter_headers/pipeline.rs
  • dash-spv/src/sync/filter_headers/util.rs
  • dash-spv/src/sync/filters/manager.rs
  • dash-spv/src/sync/filters/pipeline.rs
  • dash-spv/src/sync/filters/util.rs
  • dash-spv/src/sync/instantsend/manager.rs
  • dash-spv/src/sync/masternodes/manager.rs
  • dash-spv/src/sync/masternodes/pipeline.rs
  • dash-spv/src/sync/masternodes/sync_manager.rs
  • dash-spv/src/sync/mempool/filter.rs
  • dash-spv/src/sync/mempool/manager.rs
  • dash-spv/src/sync/mempool/sync_manager.rs
  • dash-spv/src/validation/chainlock.rs
  • dash-spv/src/validation/filter.rs
  • dash-spv/src/validation/header.rs
  • dash-spv/src/validation/instantlock.rs
  • dash-spv/tests/dashd_masternode/tests_sync.rs
  • dash-spv/tests/qrinfo_integration_test.rs
  • dash-spv/tests/v2_transport.rs
  • dash/src/address.rs
  • dash/src/bip152.rs
  • dash/src/bip158.rs
  • dash/src/blockdata/block.rs
  • dash/src/blockdata/constants.rs
  • dash/src/blockdata/script/borrowed.rs
  • dash/src/blockdata/script/tests.rs
  • dash/src/blockdata/transaction/mod.rs
  • dash/src/blockdata/transaction/outpoint.rs
  • dash/src/blockdata/transaction/special_transaction/asset_unlock/qualified_asset_unlock.rs
  • dash/src/blockdata/transaction/special_transaction/asset_unlock/request_info.rs
  • dash/src/blockdata/transaction/special_transaction/coinbase.rs
  • dash/src/blockdata/transaction/special_transaction/mnhf_signal.rs
  • dash/src/blockdata/transaction/special_transaction/provider_dissolve.rs
  • dash/src/blockdata/transaction/special_transaction/provider_registration.rs
  • dash/src/blockdata/transaction/special_transaction/provider_update_registrar.rs
  • dash/src/blockdata/transaction/special_transaction/provider_update_revocation.rs
  • dash/src/blockdata/transaction/special_transaction/provider_update_service.rs
  • dash/src/blockdata/transaction/special_transaction/provider_update_share.rs
  • dash/src/blockdata/transaction/special_transaction/provider_update_shared_registrar.rs
  • dash/src/blockdata/transaction/special_transaction/quorum_commitment.rs
  • dash/src/blockdata/transaction/txin.rs
  • dash/src/consensus/encode.rs
  • dash/src/crypto/sighash.rs
  • dash/src/ephemerealdata/chain_lock.rs
  • dash/src/ephemerealdata/instant_lock.rs
  • dash/src/hash_types.rs
  • dash/src/merkle_tree/block.rs
  • dash/src/merkle_tree/mod.rs
  • dash/src/network/constants.rs
  • dash/src/network/message.rs
  • dash/src/network/message_blockdata.rs
  • dash/src/network/message_headers2.rs
  • dash/src/network/message_qrinfo.rs
  • dash/src/platform_node_id.rs
  • dash/src/pow.rs
  • dash/src/sign_message.rs
  • dash/src/signer.rs
  • dash/src/sml/llmq_entry_verification.rs
  • dash/src/sml/masternode_list/debug_helpers.rs
  • dash/src/sml/masternode_list/from_diff.rs
  • dash/src/sml/masternode_list/merkle_roots.rs
  • dash/src/sml/masternode_list/peer_addresses.rs
  • dash/src/sml/masternode_list_entry/hash.rs
  • dash/src/sml/masternode_list_entry/mod.rs
  • dash/src/sml/masternode_list_entry/qualified_masternode_list_entry.rs
  • dash/src/sml/quorum_entry/hash.rs
  • dash/src/sml/quorum_entry/qualified_quorum_entry.rs
  • dash/src/sml/quorum_entry/quorum_modifier_type.rs
  • dash/src/sml/quorum_entry/validation.rs
  • dash/src/sml/quorum_entry/verify_message.rs
  • dash/src/test_utils/address.rs
  • dash/src/test_utils/block.rs
  • dash/src/test_utils/filter.rs
  • dash/src/test_utils/sml.rs
  • dash/src/test_utils/transaction.rs
  • dash/tests/core_v24_devnet_vectors.rs
  • dash/tests/headers2_compatibility_test.rs
  • deny.toml
  • fuzz/fuzz_targets/hashes/ripemd160.rs
  • fuzz/fuzz_targets/hashes/sha1.rs
  • fuzz/fuzz_targets/hashes/sha256.rs
  • fuzz/fuzz_targets/hashes/sha512.rs
  • fuzz/fuzz_targets/hashes/sha512_256.rs
  • hashes/Cargo.toml
  • hashes/benches/hashes.rs
  • hashes/benches/x11.rs
  • hashes/src/hash_x11.rs
  • hashes/src/lib.rs
  • hashes/src/serde_macros.rs
  • hashes/src/sha256t.rs
  • hashes/src/siphash24.rs
  • hashes/src/util.rs
  • key-wallet-manager/benches/filter_scan.rs
  • key-wallet-manager/src/event_tests.rs
  • key-wallet-manager/src/process_block.rs
  • key-wallet-manager/src/test_helpers.rs
  • key-wallet/src/account/bls_account.rs
  • key-wallet/src/account/eddsa_account.rs
  • key-wallet/src/bip32.rs
  • key-wallet/src/derivation.rs
  • key-wallet/src/derivation_bls_bip32.rs
  • key-wallet/src/derivation_slip10.rs
  • key-wallet/src/managed_account/address_pool.rs
  • key-wallet/src/managed_account/managed_core_funds_account.rs
  • key-wallet/src/managed_account/platform_address.rs
  • key-wallet/src/managed_account/transaction_record.rs
  • key-wallet/src/tests/advanced_transaction_tests.rs
  • key-wallet/src/tests/dashpay_contact_gap_limit_tests.rs
  • key-wallet/src/tests/edge_case_tests.rs
  • key-wallet/src/tests/keep_finalized_transactions_tests.rs
  • key-wallet/src/tests/observed_spent_outpoints_tests.rs
  • key-wallet/src/tests/provider_key_derivation_tests.rs
  • key-wallet/src/tests/restore_utxos_tests.rs
  • key-wallet/src/tests/special_transaction_matching_tests.rs
  • key-wallet/src/tests/special_transaction_tests.rs
  • key-wallet/src/tests/spent_outpoints_tests.rs
  • key-wallet/src/tests/transaction_tests.rs
  • key-wallet/src/tests/truncate_above_tests.rs
  • key-wallet/src/transaction_checking/account_checker.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/asset_unlock.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/classification.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/coinbase.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/helpers.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/identity_transactions.rs
  • key-wallet/src/transaction_checking/transaction_router/tests/provider.rs
  • key-wallet/src/transaction_checking/wallet_checker.rs
  • key-wallet/src/wallet/managed_wallet_info/asset_lock_builder.rs
  • key-wallet/src/wallet/managed_wallet_info/helpers.rs
  • key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs
  • key-wallet/src/wallet/managed_wallet_info/transaction_building.rs
  • key-wallet/src/wallet/managed_wallet_info/wallet_info_interface.rs
  • key-wallet/src/wallet/mod.rs
  • key-wallet/tests/derivation_tests.rs
  • masternode-seeds-fetcher/src/main.rs
  • rpc-integration-test/src/main.rs
  • rpc-json/src/lib.rs
  • rpc-json/tests/protx_listdiff.rs

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Nov 4, 2026
@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.20339% with 42 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.01%. Comparing base (aa74423) to head (9401c9f).
⚠️ Report is 2 commits behind head on dev.

Files with missing lines Patch % Lines
hashes/src/util.rs 71.42% 20 Missing ⚠️
hashes/src/hash_x11.rs 86.84% 5 Missing ⚠️
...transaction/asset_unlock/qualified_asset_unlock.rs 60.00% 2 Missing ⚠️
.../special_transaction/provider_update_revocation.rs 0.00% 2 Missing ⚠️
...ction/special_transaction/provider_update_share.rs 0.00% 2 Missing ⚠️
...al_transaction/provider_update_shared_registrar.rs 0.00% 2 Missing ⚠️
dash/src/ephemerealdata/chain_lock.rs 50.00% 2 Missing ⚠️
dash/src/ephemerealdata/instant_lock.rs 50.00% 2 Missing ⚠️
dash/src/hash_types.rs 66.66% 2 Missing ⚠️
key-wallet/src/derivation_slip10.rs 80.00% 2 Missing ⚠️
... and 1 more
Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #1320   +/-   ##
=======================================
  Coverage   85.01%   85.01%           
=======================================
  Files         268      267    -1     
  Lines       67624    67661   +37     
=======================================
+ Hits        57490    57525   +35     
- Misses      10134    10136    +2     
Flag Coverage Δ
core 82.00% <78.60%> (+0.02%) ⬆️
rpc 52.10% <ø> (ø)
spv 93.96% <100.00%> (-0.01%) ⬇️
wallet 83.13% <93.93%> (-0.01%) ⬇️
Files with missing lines Coverage Δ
dash-spv/src/client/queries.rs 37.83% <ø> (ø)
dash-spv/src/network/broker.rs 96.36% <ø> (ø)
dash-spv/src/network/costs.rs 94.89% <100.00%> (+0.07%) ⬆️
dash-spv/src/network/mod.rs 97.36% <ø> (ø)
dash-spv/src/sml_engine.rs 97.43% <ø> (ø)
dash-spv/src/sml_engine/helpers.rs 100.00% <ø> (ø)
...-spv/src/sml_engine/rotated_quorum_construction.rs 94.03% <ø> (ø)
dash-spv/src/sml_engine/validation.rs 94.54% <ø> (ø)
dash-spv/src/storage/header_hash_index.rs 100.00% <ø> (ø)
dash-spv/src/storage/masternode.rs 100.00% <ø> (ø)
... and 97 more

... and 1 file with indirect coverage changes

@xdustinface

Copy link
Copy Markdown
Collaborator Author

/self-reviewed

@github-actions github-actions Bot added the merge-conflict The PR conflicts with the target branch. label Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

Depend on `bitcoin_hashes` from the same `rust-bitcoin` git revision as `bitcoin-crypto`, `bitcoin-units` and `base-sdk`, so the hash types unify across them.

The 1.x `Hash` trait only converts to and from byte arrays. `hash_newtype!` implements it like upstream's macro and adds the conversions as `const` inherent functions. Newtypes keep `from_slice` and `all_zeros` as inherent functions, since Dash uses zero hashes as protocol values, but no longer get `hash`, `engine` or `from_engine`. The X11 hash gets the inherent surface of the upstream hash types plus `from_slice` and `all_zeros`, and its engine implements `finalize`.

1.x dropped `FromSliceError`, so this crate defines its own with the same shape and message, still also exported as `Error`.

`sha256t_hash_newtype!` is removed. Nothing used it and upstream deprecated its counterpart in favour of implementing `sha256t::Tag` by hand. `sha256t` is now upstream's module.
`PubkeyHash` no longer has `hash`, so hash the key through `hash160::Hash` and wrap the result.
Newtypes hash through their inner hash type and its engine: `T::from_raw_hash(sha256d::Hash::hash(..))`, or an engine from `sha256d::Hash::engine()` finished with `finalize`. Upstream hash types lost `all_zeros`, `from_slice` and indexing, so those call sites go through the byte array instead.

`BlockHash` wraps X11 or SHA256d depending on `core-block-hash-use-x11`, so a crate private `BlockHashEngine` alias picks the matching engine for `Header::block_hash`.

`merkle_tree::calculate_root` and `calculate_root_inline` now require `T: From<sha256d::Hash>` and always combine nodes with double SHA256. 1.x has no engine on the `Hash` trait, and every Dash merkle tree is SHA256d.

`from_hex` on the hash newtypes parses through the inner hash's `FromStr`, which now reports the same `hex-conservative` 1.x error.
`HmacEngine` is now parameterized by the engine type and finished with `finalize`. Upstream hash types no longer index into bytes, so fingerprints and chain codes read through `as_byte_array`. Tests hash newtypes through their inner hash and build upstream zero hashes with `from_byte_array`.
Hash newtypes are built from their inner hash instead of the removed `hash`, and upstream zero hashes use `from_byte_array`. Imports of the `Hash` trait that only served the newtype functions are dropped.
Drop the `Hash` trait imports the 1.x inherent functions no longer need and hash `Txid` through `sha256d::Hash`.
Finish engines with `finalize` and compare the hashes directly, since upstream hash types no longer index into bytes.
@xdustinface
xdustinface force-pushed the build/bitcoin-hashes-1x branch from 029b5e6 to 9401c9f Compare November 4, 2026 13:59
@github-actions github-actions Bot removed the merge-conflict The PR conflicts with the target branch. label Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@xdustinface

Copy link
Copy Markdown
Collaborator Author

/skip-bots

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. and removed waiting-bots Waiting for the review bots to report on this head labels Nov 4, 2026
@xdustinface

Copy link
Copy Markdown
Collaborator Author

/self-reviewed

@github-actions github-actions Bot removed the waiting-self-review Waiting for the author to post /self-reviewed label Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Policy satisfied — this can merge.
Full checklist in the description.

@xdustinface
xdustinface requested a review from ZocoLini November 4, 2026 14:39
@ZocoLini
ZocoLini merged commit a319c0a into dev Nov 4, 2026
36 checks passed
@ZocoLini
ZocoLini deleted the build/bitcoin-hashes-1x branch November 4, 2026 15:10
xdustinface added a commit to dashpay/platform that referenced this pull request Nov 5, 2026
dashpay/rust-dashcore#1320 moves `dashcore_hashes` onto `bitcoin_hashes` 1.x from the rust-bitcoin rev that `bitcoin-crypto` uses. The crates.io `bitcoin_hashes` 0.14 no longer gets its `io` feature, so the crates.io `bitcoin-io` and `bitcoin-consensus-encoding` 1.3.0 that took `bitcoin-internals` 0.7.0 from crates.io leave the graph. Since dashpay/rust-dashcore#1224 the same already held for `base58ck`, `bitcoin_hashes` and `bitcoin-units`. No crates.io dependency asks for a version the git rev provides, so the whole patch section goes.

`Cargo.lock` is unchanged and `cargo vendor --locked` succeeds. Closes #5648.
xdustinface added a commit to dashpay/platform that referenced this pull request Nov 5, 2026
dashpay/rust-dashcore#1320 moves `dashcore_hashes` onto `bitcoin_hashes` 1.x from the rust-bitcoin rev that `bitcoin-crypto` uses. The crates.io `bitcoin_hashes` 0.14 no longer gets its `io` feature, so the crates.io `bitcoin-io` and `bitcoin-consensus-encoding` 1.3.0 that took `bitcoin-internals` 0.7.0 from crates.io leave the graph. Since dashpay/rust-dashcore#1224 the same already held for `base58ck`, `bitcoin_hashes` and `bitcoin-units`. No crates.io dependency asks for a version the git rev provides, so the whole patch section goes.

`Cargo.lock` is unchanged and `cargo vendor --locked` succeeds. Closes #5648.
xdustinface added a commit to dashpay/platform that referenced this pull request Nov 5, 2026
dashpay/rust-dashcore#1320 moves `dashcore_hashes` onto `bitcoin_hashes` 1.x from the rust-bitcoin rev that `bitcoin-crypto` uses. The crates.io `bitcoin_hashes` 0.14 no longer gets its `io` feature, so the crates.io `bitcoin-io` and `bitcoin-consensus-encoding` 1.3.0 that took `bitcoin-internals` 0.7.0 from crates.io leave the graph. Since dashpay/rust-dashcore#1224 the same already held for `base58ck`, `bitcoin_hashes` and `bitcoin-units`. No crates.io dependency asks for a version the git rev provides, so the whole patch section goes.

`Cargo.lock` is unchanged and `cargo vendor --locked` succeeds. Closes #5648.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-review-skipped A required review bot did not report; it was skipped by the window or by a person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants