Skip to content
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

Implement proper RBF API so you can satisfy rule 4 #19

Merged
merged 2 commits into from
Jan 30, 2024

Conversation

LLFourn
Copy link
Collaborator

@LLFourn LLFourn commented Jan 24, 2024

Removes min_fee constraint in favour of proper rule 4 handling (min_fee was pretty useless).

See for rule 4:
https://github.com/bitcoin/bitcoin/blob/master/doc/policy/mempool-replacements.md#current-replace-by-fee-policy

LowestFee BnB metric updated to bound correctly for this.

A few other coin_selector API changes

Fixes: #12

Removes `min_fee` constraint in favour of proper rule 4
handling (min_fee was pretty useless).

See for rule 4:
https://github.com/bitcoin/bitcoin/blob/master/doc/policy/mempool-replacements.md#current-replace-by-fee-policy

LowestFee BnB metric updated to bound correctly for this.

A few other coin_selector API changes
@@ -14,7 +14,7 @@ fn test_wv(mut rng: impl RngCore) -> impl Iterator<Item = Candidate> {
value,
weight: rng.gen_range(0..100),
input_count: rng.gen_range(1..2),
is_segwit: rng.gen_bool(0.5),
is_segwit: false,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note we never want to choose this randomly in the proptests because we cannot accurately lower bound it.

Removes `min_fee` constraint in favour of proper rule 4
handling (min_fee was pretty useless).

See for rule 4:
https://github.com/bitcoin/bitcoin/blob/master/doc/policy/mempool-replacements.md#current-replace-by-fee-policy

LowestFee BnB metric updated to bound correctly for this.

A few other coin_selector API changes
@LLFourn LLFourn changed the title Implement proper RBF logic satisfying rule 4 Implement proper RBF API so you can satisfy rule 4 Jan 24, 2024
@LLFourn LLFourn mentioned this pull request Jan 25, 2024
Copy link
Member

@evanlinjin evanlinjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 0f7cc31

This is excellent.

@evanlinjin evanlinjin merged commit 798d7b6 into bitcoindevkit:master Jan 30, 2024
5 checks passed
evanlinjin added a commit that referenced this pull request Mar 31, 2024
c650306 fix: `CoinSelector::implied_fee` (志宇)
4d0ae4c docs: fix typos (志宇)
2e26aa5 fix: rm `Drain::none` method (志宇)
8eb582b [lowest-fee] ignore failure when selection is not possible (LLFourn)
064996c [lowest-fee] Fix off by one in test (LLFourn)
956685a [changeless] Revert number of candidates (LLFourn)
c6f0682 Remove typo in lowest_fee comment (LLFourn)
76e67a3 Move ChangePolicy to drain.rs (LLFourn)
7e82c3f Remove base_weight, put weight in Target (LLFourn)

Pull request description:

  Fixes #1

  On top of #19

  - CoinSelector no longer tracks anything but input weight
  - Previously the value of the target outputs was in `Target` but the
    weights were accounted for in CoinSelector. Now they're in all in
    target.
  - This allows us to actually figure out how many outputs there are and
    therefore the actual weight of the transaction accounting for the varint for the number of outputs.

  This wasn't what the issue had in mind but it was easier to take the `base_weight` out of `CoinSelector` and put it in `Target` rather than put `Target` in `CoinSelector`. Getting rid of `base_weight` is a more crucial change than expected because rust bitcoin changed what `Transaction::weight` returns for empty output transactions recently so using it to determine `base_weight` will get different answers between versions (this breaks our weight tests but this PR will fix it I think if we uprade dev deps). We only need to know the total weight of the outputs and how many there are now to get the right answers for weight.

ACKs for top commit:
  evanlinjin:
    ACK c650306

Tree-SHA512: bd2d6bba15a172b56451d13a9560b6221a6f005417857e1cf7f0cd7022cebd0c2e4d6ff78dac9b99690771297351f90eb3fea26f85aa34a2841c91cfe0d73f9c
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.

Allow to target suitable transaction fee for RBF
2 participants