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

Inconsistent checking of RBF rules #256

Open
Tracked by #76
LLFourn opened this issue Dec 30, 2020 · 11 comments
Open
Tracked by #76

Inconsistent checking of RBF rules #256

LLFourn opened this issue Dec 30, 2020 · 11 comments
Assignees
Labels
discussion There's still a discussion ongoing
Milestone

Comments

@LLFourn
Copy link
Contributor

LLFourn commented Dec 30, 2020

BIP125 rules 3 and 4 are not being checked properly according to my understanding:

bdk/src/wallet/mod.rs

Lines 730 to 746 in c2b2da7

{
FeePolicy::FeeAmount(amount) => {
if *amount < details.fees {
return Err(Error::FeeTooLow {
required: details.fees,
});
}
(FeeRate::from_sat_per_vb(0.0), *amount as f32)
}
FeePolicy::FeeRate(rate) => {
if *rate < required_feerate {
return Err(Error::FeeRateTooLow {
required: required_feerate,
});
}
(*rate, tx.get_weight() as f32 / 4.0 * rate.as_sat_vb())
}

It should be checking rules 3 and 4 regardless of the fee policy chosen in txbuilder.

@afilini
Copy link
Member

afilini commented Jan 5, 2021

I think we can kinda ignore rule 3 at the moment, since we don't support merging multiple unconfirmed transactions, so this:

The replacement transaction pays an absolute fee of at least the sum paid by the original transactions.

For us basically means that we should just pay at least the previous fee.

I agree on rule 4 though, the FeeAmount branch should check for *amount < details.fees + _something_.

And now that I think about it, it's kind of a chicken-and-egg problem: rule 4 says that we should pay at least the size of the new transaction, but at this point we don't know it yet. So even the part above where required_feerate is computed is wrong.. Not sure what's the best way to handle this, I've gotta think about it a bit more..

@notmandatory notmandatory added the discussion There's still a discussion ongoing label Feb 15, 2022
nickfarrow pushed a commit to nickfarrow/bdk that referenced this issue Feb 21, 2022
@evanlinjin
Copy link
Member

evanlinjin commented Sep 14, 2022

Coin selection algorithms should take min_absolute_fee and target_feerate into consideration on the get-go (and only succeed when both constraints are satisfied).

bdk_core will solve this issue, WIP here: LLFourn/bdk_core_staging#21

@nondiremanuel
Copy link

We discussed it in the call and decided to close this issue. Please comment if you think it should be re-opened

@notmandatory
Copy link
Member

Per discussion in dev call today this doesn't seem to be fixed yet.

@notmandatory
Copy link
Member

notmandatory commented Mar 26, 2024

Per @evanlinjin we can fix this issue by using the new bdk_coin_select crate.

@notmandatory
Copy link
Member

More notes from @evanlinjin from discord chat:
"We already have the TxParams::bumping_fee field we just aren't checking them correctly. However, I am concerned about rule 4 not being enforced properly (since we are actually doing coin selection again for RBF). An easy policy (that would enforce rule 4) would be to say the new tx cannot be larger than the one we are replacing. However, this is not what we are doing with our RBF logic. We add all old inputs into TxParams::utxos which is inputs that must be spent.

Therefore, it is possible that our new transaction may be larger in weight than the old one
Right now, I'm very tempted to say let's use bdk_coin_select..."

@nondiremanuel nondiremanuel moved this from Done to Todo in BDK Mar 26, 2024
@LLFourn LLFourn self-assigned this Mar 27, 2024
@LLFourn
Copy link
Contributor Author

LLFourn commented Mar 27, 2024

I volunteer to try and fix RBF API with bdk_coin_select. Don't have an ETA yet.

@notmandatory
Copy link
Member

Thanks @LLFourn , if you can fix with integration of bdk_coin_select that'd be great.

@notmandatory
Copy link
Member

@LLFourn Since we're not going to have have a bdk_coin_select crate for 1.0 can I defer this issue to the 2.0 milestone?

@notmandatory
Copy link
Member

Yes I'd like to make the extracted bdk_coin_select one of the priorities for 2.0 so if it's better to fix this together with that I'll update the milestone.

@notmandatory notmandatory modified the milestones: 1.0.0-alpha, 2.0.0 Jun 17, 2024
@LLFourn
Copy link
Contributor Author

LLFourn commented Jun 27, 2024

Sorry ACK I haven't had time to do this work so yes you can push it to 2.0.0. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion There's still a discussion ongoing
Projects
Status: Todo
Development

No branches or pull requests

6 participants