8000 Extract CTxIn::MAX_SEQUENCE_NONFINAL constant, rework BIP 65/68/112 docs by maflcko · Pull Request #24136 · bitcoin/bitcoin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Extract CTxIn::MAX_SEQUENCE_NONFINAL constant, rework BIP 65/68/112 docs #24136

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

Merged
merged 1 commit into from
Jan 31, 2022

Conversation

maflcko
Copy link
Member
@maflcko maflcko commented Jan 24, 2022

Extracting the constant makes it possible to attach documentation to it.

Also, rework the docs for the other "sequence constants".

Copy link
Contributor
@prusnak prusnak left a comment

Choose a reason for hiding this comment

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

Approach ACK fab3ff2

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 fab3ff2

Copy link
Contributor
@w0xlt w0xlt left a comment

Choose a reason for hiding this comment

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

ACK fab3ff2 for improving documentation.

@maflcko
Copy link
Member Author
maflcko commented Jan 26, 2022

Sorry for the force push. Clarified tx.version >= 2, requested in comment https://github.com/bitcoin/bitcoin/pull/7184/files#r47233948

@DrahtBot
Copy link
Contributor

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #24128 (wallet: BIP 326 sequence based anti-fee-snipe for taproot inputs by MarcoFalke)
  • #22871 (Discourage CSV as NOP when locktime disable is set & discourage unknown nSequence by JeremyRubin)

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.

Copy link
Contributor
@w0xlt w0xlt left a comment

Choose a reason for hiding this comment

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

reACK fa4339e for specifying the transaction version.

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.

re-ACK fa4339e

Copy link
Member
@luke-jr luke-jr left a comment

Choose a reason for hiding this comment

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

crACK fa4339e

Copy link
Member
@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

Concept ACK. Another replacement to consider:

diff --git a/src/util/rbf.h b/src/util/rbf.h
index a957617389..33a38dad88 100644
--- a/src/util/rbf.h
+++ b/src/util/rbf.h
@@ -13,11 +13,12 @@ static constexpr uint32_t MAX_BIP125_RBF_SEQUENCE{0xfffffffd};
 
 /** Check whether the sequence numbers on this transaction are signaling opt-in to replace-by-fee,
  * according to BIP 125.  Allow opt-out of transaction replacement by setting nSequence >
- * MAX_BIP125_RBF_SEQUENCE (SEQUENCE_FINAL-2) on all inputs.
+ * MA
8000
X_BIP125_RBF_SEQUENCE (SEQUENCE_FINAL - 2) on all inputs.
 *
-* 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 by opting out in their own input. */
+* CTxIn::MAX_SEQUENCE_NONFINAL (SEQUENCE_FINAL - 1) is picked to still allow use
+* of nLockTime by non-replaceable transactions. Using 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 by opting out in their own input. */
 bool SignalsOptInRBF(const CTransaction& tx);
 
 #endif // BITCOIN_UTIL_RBF_H

Also: s/All inputs/Using all inputs/

/* Below flags apply in the context of BIP 68*/
/* If this flag set, CTxIn::nSequence is NOT interpreted as a
* relative lock-time. */
// Below flags apply in the context of BIP 68. BIP 68 requires the tx
Copy link
Member

Choose a reason for hiding this comment

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

I see this is from BIP 68, but it could be better (may propose some fixups to the BIP), plus add a newline to denote that this comment applies to the next four sections of doxygen docs + constants

      * disables nLockTime. */
     static const uint32_t SEQUENCE_FINAL = 0xffffffff;
 
-    /* Below flags apply in the context of BIP 68*/
+    /* The following flags apply in the context of BIP 68: */
+
     /* If this flag set, CTxIn::nSequence is NOT interpreted as a
      * relative lock-time. */

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 should be clear that the comment, which uses plural ("flags") refers to the flags below. I think not using a newline also helps here, so going to leave as-is for now.

@maflcko maflcko merged commit 5f4c07b into bitcoin:master Jan 31, 2022
< 8000 div id="event-5979015934" data-view-component="true" class="TimelineItem js-targetable-element">
@maflcko maflcko deleted the 2201-docSeq branch January 31, 2022 08:51
@maflcko
Copy link
Member Author
maflcko commented Jan 31, 2022

Another replacement to consider:

The goal of this pull was to document consensus rules. If policy is documented, I am wondering if the following diff should also be applied:

diff --git a/src/util/rbf.h b/src/util/rbf.h
index a957617389..fc1fbb60de 100644
--- a/src/util/rbf.h
+++ b/src/util/rbf.h
@@ -9,6 +9,11 @@
 
 class CTransaction;
 
+/**
+ * This is the maximum sequence number that enables all of: BIP 125,
+ * nLockTime and OP_CHECKLOCKTIMEVERIFY (BIP 65).
+ * It has SEQUENCE_LOCKTIME_DISABLE_FLAG set (BIP 68/112).
+ */
 static constexpr uint32_t MAX_BIP125_RBF_SEQUENCE{0xfffffffd};
 
 /** Check whether the sequence numbers on this transaction are signaling opt-in to replace-by-fee,

@jonatack
Copy link
Member

If policy is documented, I am wondering if the following diff should also be applied

SGTM

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 1, 2022
@bitcoin bitcoin locked and limited conversation to collaborators Jan 31, 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.

7 participants
0