Skip to content

Introduce broadcast queue. #220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

evanlinjin
Copy link
Member

@evanlinjin evanlinjin commented Apr 25, 2025

Fixes #40

Description

This PR builts on top of #208 and bitcoindevkit/bdk#1808.

The goal is to evaluate whether the changes introduced in bitcoindevkit/bdk#1808 provide a sufficient foundation to implement and maintain a broadcast queue within bdk_wallet.

Requirements:

  • Creating a new tx should not replace unbroadcasted txs that were already in the wallet.
  • The broadcast queue should support transaction replacements, with the most recently inserted version taking precedence.

Notes to the reviewers

Design Rationale

For getter-methods on Wallet that requires canonicalization internally, I've opted to pass in CanonicalizationParams as an input. The reasoning is it's up to the application to decide whether or not to include unbroadcasted txs in their UTXO-set/tx-list. There is a method Wallet::include_unbroadcasted() which returns a CanonicalizationParams which would assume all unbroadcasted as canonical.

The alternative would be to pass in a boolean include_unbroadcasted but I felt like it would be more brittle.

Where to start reviewing

The unbroadcasted queue in introduced in a new file wallet/unbroadcasted.rs. Other than that, the majority of the changes are in wallet/mod.rs.

Changelog notice

WIP

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

- `apply_update` no longer requires std
- Removed `apply_update_at`
- `start_sync_with_revealed_spks` is now behind "std" feature
- Added `start_sync_at`
- `start_sync_*` includes the expected spk history
- Add example test for mempool eviction, includes persistence
- Update bdk_file_store, which uses the latest from bdk_core
- `start_full_scan` requires std feature

Note that `tx_graph::ChangeSet` gained a new default-able field
`last_evicted` to account for evictions.
- Improve docs for `test_utils::insert_tx`
@evanlinjin evanlinjin force-pushed the test_canonicalization_mods_api branch from 3dbd1b4 to 5b15213 Compare April 25, 2025 12:16
@evanlinjin evanlinjin force-pushed the test_canonicalization_mods_api branch from 5b15213 to 0b05917 Compare April 25, 2025 12:17
@coveralls
Copy link

coveralls commented Apr 25, 2025

Pull Request Test Coverage Report for Build 14664394129

Details

  • 156 of 238 (65.55%) changed or added relevant lines in 6 files are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.7%) to 85.823%

Changes Missing Coverage Covered Lines Changed/Added Lines %
wallet/src/wallet/unbroadcasted.rs 30 64 46.88%
wallet/src/wallet/mod.rs 64 112 57.14%
Files with Coverage Reduction New Missed Lines %
wallet/src/wallet/mod.rs 4 82.05%
Totals Coverage Status
Change from base Build 14270666930: -0.7%
Covered Lines: 7355
Relevant Lines: 8570

💛 - Coveralls

@evanlinjin evanlinjin changed the title Test canonicalization mods API Introduce broadcast queue. Apr 25, 2025
@evanlinjin
Copy link
Member Author

evanlinjin commented May 1, 2025

To Do (as discussed)

  • Unexpose CanonicalizationParams from the public API.
  • By default, include the whole broadcast queue in assume_canonical.

In the future, if users are requesting that we expose CanonicalizationParam, we can do so via new methods. I.e. transactions_with_params.

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.

Don't double spend created transaction just because they haven't been broadcasted
3 participants