Skip to content

Conversation

glozow
Copy link
Member

@glozow glozow commented Sep 1, 2021

Followups to #22675 and documentation-only changes intended to clarify the code/logic concerning mempool Replace-by-Fee.

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 2, 2021

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #22539 (Re-include RBF replacement txs in fee estimation by darosior)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@glozow glozow changed the title RBF move 3/3: improve RBF documentation RBF move 3/3: move followups + improve RBF documentation Sep 8, 2021
@glozow glozow marked this pull request as ready for review September 10, 2021 08:43
Document a few non-obvious things and delete no-longer-relevant comments
(e.g. about taking a lock that we're already holding).
No change in behavior.
@fanquake
Copy link
Member

Concept ACK. While you're tidying up might as well add all the missing <std> headers to policy/rbf.*, and MAX_BIP125_RBF_SEQUENCE can be constexpr.

@@ -17,7 +17,7 @@ static const uint32_t MAX_BIP125_RBF_SEQUENCE = 0xfffffffd;
*
* SEQUENCE_FINAL-1 is picked to still allow use of nLockTime by non-replaceable transactions. All
* inputs rather than just one is for the sake of multi-party protocols, where we don't want a single
* party to be able to disable replacement. */
bool SignalsOptInRBF(const CTransaction &tx);
* party to be able to disable replacement by opting out in their own input. */
Copy link

Choose a reason for hiding this comment

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

micro-nit "by opting out of their single-owned input". If the input spent is 2-of-2 like LN's commitment you should check that counterparty's signature is covering a RBF-signaling nSequence field.

// replacement doesn't pay more fees than its direct conflicts, then we can be sure it's not
// more economically rational to mine. Before we go digging through the mempool for all
// transactions that would need to be removed (direct conflicts and all descendants), check
// that the replacement transaction pays more than its direct conflicts.
if (const auto err_string{PaysMoreThanConflicts(setIterConflicting, newFeeRate, hash)}) {
Copy link

Choose a reason for hiding this comment

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

I think it would interesting to add a comment noting that this higher-feerate than any directly replaced transactions it's not part of the BIP.

Also I think this check might bounce-off higher-fee transactions than the replaced one if the conflict transaction has a higher feerate. Let's say a 2_000 vb/10_000 sats replacement vs a 100 vb/8_000 sats conflicts. Without entering in a discussion on the miner block strategy, this is at lest consistent with BlockAssembler::addPackageTxs which is selecting packages on feerate.

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 think it would interesting to add a comment noting that this higher-feerate than any directly replaced transactions it's not part of the BIP.

I thought that's what I was doing by adding this comment 😅 but if you have a more specific wording suggestion I'd be happy to add!

Copy link
Member

@darosior darosior left a comment

Choose a reason for hiding this comment

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

ACK 3cf46f6

@theStack
Copy link
Contributor

Concept ACK

@glozow
Copy link
Member Author

glozow commented Sep 21, 2021

Thanks for the reviews, addressed comments

Copy link
Contributor

@jnewbery jnewbery left a comment

Choose a reason for hiding this comment

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

utACK 0ef08f8

If you retouch this branch, perhaps you could add the justification/motivation to the commit log for commit [policy/refactor] pass in relay fee instead of using global. If the change was suggested in a previous review comment, you could also link to it from the commit log.

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

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

ACK 0ef08f8

@fanquake fanquake merged commit 8bda5e0 into bitcoin:master Sep 23, 2021
@glozow glozow deleted the 2021-09-rbf-docs branch September 23, 2021 09:15
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 24, 2021
// replacement doesn't pay more fees than its direct conflicts, then we can be sure it's not
// more economically rational to mine. Before we go digging through the mempool for all
// transactions that would need to be removed (direct conflicts and all descendants), check
// that the replacement transaction pays more than its direct conflicts.
Copy link
Member

Choose a reason for hiding this comment

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

Sorry for the late review note, but I think this comment is confusing: in PaysMoreThanConflicts() we're checking that the feerate of the new transaction is higher than its direct conflicts, not that the total fees paid are higher (eg if the new transaction is smaller, the feerate could be higher but the total fees paid can be lower).

Copy link
Member Author

@glozow glozow Jan 4, 2022

Choose a reason for hiding this comment

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

Ah thank you, I should have said feerate.

I also misinterpreted the purpose of the code - I was thinking of mining scores=ancestor feerate so I assumed it was an incomplete-but-early-exit check. Based on the context you provided (#23121 (review)), this was checking that the replacement is a better mining candidate based on the block template code at the time. I'll open a PR to update this comment to reflect that.

fanquake added a commit to bitcoin-core/gui that referenced this pull request Feb 22, 2022
77202f0 [doc] package deduplication (glozow)
d35a3cb [doc] clarify inaccurate comment about replacements paying higher feerate (glozow)
5ae187f [validation] look up transaction by txid (glozow)

Pull request description:

  - Use txid, not wtxid, for `mempool.GetIter()`: bitcoin/bitcoin#22674 (comment)
  - Fix a historically inaccurate comment about RBF during the refactors: bitcoin/bitcoin#22855 (comment)
  - Add a section about package deduplication to policy/packages.md: bitcoin/bitcoin#24152 (comment) and bitcoin/bitcoin#24152 (comment)

  (I'm intending for this to be in v23 since it's fixups for things that are already merged, which is why I split it from #24152)

ACKs for top commit:
  t-bast:
    LGTM, ACK bitcoin/bitcoin@77202f0
  darosior:
    ACK 77202f0
  LarryRuane:
    ACK 77202f0

Tree-SHA512: a428e791dfa59c359d3ccc67e8d3a4c1239815d2f6b29898e129700079271c00b3a45f091f70b65a6e54aa00a3d5b678b6da29d2a76b6cd6f946eaa7082ea696
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 22, 2022
77202f0 [doc] package deduplication (glozow)
d35a3cb [doc] clarify inaccurate comment about replacements paying higher feerate (glozow)
5ae187f [validation] look up transaction by txid (glozow)

Pull request description:

  - Use txid, not wtxid, for `mempool.GetIter()`: bitcoin#22674 (comment)
  - Fix a historically inaccurate comment about RBF during the refactors: bitcoin#22855 (comment)
  - Add a section about package deduplication to policy/packages.md: bitcoin#24152 (comment) and bitcoin#24152 (comment)

  (I'm intending for this to be in v23 since it's fixups for things that are already merged, which is why I split it from bitcoin#24152)

ACKs for top commit:
  t-bast:
    LGTM, ACK bitcoin@77202f0
  darosior:
    ACK 77202f0
  LarryRuane:
    ACK 77202f0

Tree-SHA512: a428e791dfa59c359d3ccc67e8d3a4c1239815d2f6b29898e129700079271c00b3a45f091f70b65a6e54aa00a3d5b678b6da29d2a76b6cd6f946eaa7082ea696
@bitcoin bitcoin locked and limited conversation to collaborators Jan 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants