Skip to content

Conversation

@danielabrozzoni
Copy link
Member

@danielabrozzoni danielabrozzoni commented Jul 1, 2022

Description

Closes #144

Notes to reviewers

#144 is describing a bug that doesn't seem to happen in BDK master anymore (BDK not respecting BIP125 rule 2). This PR just adds a test to check that the bug is fixed.

Checklists

All Submissions:

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

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

@notmandatory notmandatory added the bug Something isn't working label Jul 4, 2022
let (psbt, mut original_details) = builder.finish().unwrap();
// Now we receive one transaction with 0 confirmations. We won't be able to use that for
// fee bumping, as it's still unconfirmed!
crate::populate_test_db!(
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to test replacing txs with different amounts of inputs (where inputs are of various states of unconfirmed/confirmed)?

Not sure if it should be included for the scope of this PR though...

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure what the "end goal" of such test would be. What are you testing exactly? That we would choose only confirmed inputs for fee bumping?

Copy link
Member

@evanlinjin evanlinjin Jul 5, 2022

Choose a reason for hiding this comment

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

For example, we can test whether BDK allows for RBF of tx with unconfirmed parent.

Given:
* Wallet with 2 UTXOs (1 confirmed, 1 unconfirmed).
* We attempt to "drain wallet", resulting in a tx with 2 inputs 
  (1 unconfirmed, 1 confirmed) and 1 output to drain address.

When: 
* Attempt RBF of "drain tx".

Expect:
* Successful RBF of "drain tx".

Copy link
Member

Choose a reason for hiding this comment

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

@danielabrozzoni checking whether we only pick confirmed new inputs would be great too!

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, I'll add it, thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

For example, we can test whether BDK allows for RBF of tx with unconfirmed parent. [...]

I've added test_bump_fee_unconfirmed_input testing this scenario

checking whether we only pick confirmed new inputs would be great too!

Mh, I think this is already tested (at least partially) in test_bump_fee_unconfirmed_inputs_only, and I can't seem to find a better way to test it... Maybe I could send a lot of unconfirmed inputs and one unconfirmed output to the wallet, and check that BDK will only pick the confirmed input for fee bumping. What do you think? Is it a test worth adding in your opinion?

Copy link
Member

Choose a reason for hiding this comment

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

@danielabrozzoni Fair, let's skip it :P I like the new test!

@evanlinjin
Copy link
Member

@notmandatory It seems this PR is just test additions, should the bug label be removed?

@LLFourn
Copy link
Collaborator

LLFourn commented Jul 5, 2022

Isn't this intentional? BIP125

The replacement transaction may only include an unconfirmed input if that input was included in one of the original transactions. (An unconfirmed input spends an output from a currently-unconfirmed transaction.)

@evanlinjin
Copy link
Member

evanlinjin commented Jul 5, 2022

Isn't this intentional? BIP125

The replacement transaction may only include an unconfirmed input if that input was included in one of the original transactions. (An unconfirmed input spends an output from a currently-unconfirmed transaction.)

This ticket is wrongly labelled as bug, this is just a some additional tests from my understanding

@danielabrozzoni means that we shouldn't allow introducing new unconfirmed inputs when RBF.

@danielabrozzoni danielabrozzoni added tests and removed bug Something isn't working labels Jul 5, 2022
@danielabrozzoni
Copy link
Member Author

Yeah, I removed the "bug" label and added the "test" one. #144 was describing a bug that has been fixed since, but here I'm adding a test to check that the bug doesn't appear anymore. I'll update the review notes to make it clear!

The proposed solution is bad for privacy as well.
Let's call the initial change output, which is normally shrink when you
fee bump, change#1, and the extra output aforementioned change#2 (as,
in this case, it's going to be a change output as well). If you add change#2
you might not revel change#1, but you're still revealing change#2.
You're not improving your privacy, and you're wasting money in fees.
@danielabrozzoni danielabrozzoni force-pushed the 144_rbf_rules branch 2 times, most recently from 88aea47 to 127db37 Compare July 6, 2022 09:43
populate_test_db would previously give back a transaction with N + 1
confirmations when you asked for N.

This commit also fixes test_spend_coinbase, which would improperly
ask for a transaction with 0 confirmations instead of 1.
Fixes bitcoindevkit#144

Also removes a leftover dbg!() in a test
Copy link
Member

@afilini afilini left a comment

Choose a reason for hiding this comment

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

ACK 5d00f82

@afilini afilini merged commit 1c94108 into bitcoindevkit:master Jul 6, 2022
@danielabrozzoni danielabrozzoni deleted the 144_rbf_rules branch August 16, 2022 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add_utxo with unconfirmed output will be used in bump_fee in violation of RBF rules

5 participants