While reviewing burying of BIP 9 deployments, seen that versionbits.h wasn't that much documented. This is an attempt to improve it. It can be useful, given after burying this code isn't going to be used anymore and isn't straightforward at first sight.
doc: Improve versionbits.h documentation #16587
pull ariard wants to merge 1 commits into bitcoin:master from ariard:2019-08-docs-versionbits changing 2 files +22 −7-
ariard commented at 1:58 PM on August 12, 2019: member
- fanquake added the label Docs on Aug 12, 2019
-
emilengler commented at 7:22 PM on August 12, 2019: contributor
I like it but I NACK about the change in the header file. Why do you remove this comment?
-
ariard commented at 9:57 PM on August 12, 2019: member
@emilengler "Note that the functions below take a pindexPrev as input: they compute information for block B based on its parent." you mean this one ? I've tried to incorporate it in both
GetStateForandGetStateSinceHeightForones but should I make it clearer? -
in src/versionbits.h:65 in bcc2a0f45c outdated
61 | @@ -50,12 +62,17 @@ class AbstractThresholdConditionChecker { 62 | virtual int Threshold(const Consensus::Params& params) const =0; 63 | 64 | public: 65 | + /** Returns the numerical statistics of an in-progess BIP9 softfork in the current period */
practicalswift commented at 7:36 AM on August 14, 2019:Should be "in-progress" :-)
fanquake added the label Waiting for author on Aug 14, 2019in src/versionbits.h:26 in bcc2a0f45c outdated
27 | - DEFINED, 28 | - STARTED, 29 | - LOCKED_IN, 30 | - ACTIVE, 31 | - FAILED, 32 | + DEFINED, // First state that each softfork starts out as. The genesis block is by definition in this state for each deployment.
in src/versionbits.h:74 in bcc2a0f45c outdated
70 | ThresholdState GetStateFor(const CBlockIndex* pindexPrev, const Consensus::Params& params, ThresholdConditionCache& cache) const; 71 | + /** Returns the height since when the ThresholdState has started for pindex A based on parent pindexPrev B, all blocks of a period share the same */ 72 | int GetStateSinceHeightFor(const CBlockIndex* pindexPrev, const Consensus::Params& params, ThresholdConditionCache& cache) const; 73 | }; 74 | 75 | +/** BIP 9 allows multiple softforks being deployed in parallel. We cache per-period state for every one of them
fanquake commented at 8:53 AM on August 14, 2019:/** BIP 9 allows multiple softforks to be deployed in parallel. We cache per-period state for every one of themlaanwj commented at 12:48 PM on August 14, 2019: memberACK, thanks for adding documentation
Why do you remove this comment?
The comment is moved from the cpp to the header file, where it should be. Public functions should be documented at declaration and not at the implementation as this keeps the API documentation better together.
in src/versionbits.h:21 in bcc2a0f45c outdated
16 | @@ -17,24 +17,36 @@ static const int32_t VERSIONBITS_TOP_MASK = 0xE0000000UL; 17 | /** Total bits available for versionbits */ 18 | static const int32_t VERSIONBITS_NUM_BITS = 29; 19 | 20 | +/** BIP 9 defines a finite-state-machine to deploy a softfork in multiple stages. 21 | + * It relies on the chain being a monotonic clock to start or timeout the
jnewbery commented at 2:30 PM on August 14, 2019:nit: drop the part about 'a monotonic clock', since it's confusing. The chain is not monotonic (timestamps of blocks may precede their ancestors' timestamps). Besides, BIP 9 doesn't have any dependence on clock time.
ariard commented at 5:57 PM on August 14, 2019:Sorry was thinking in MTP. "The expression GetMedianTimePast(block.parent) is referred to as MTP in the diagram above, and is treated as a monotonic clock defined by the chain." In the context of Median-Time-Past, I think BIP 9 envision the chain as a monotonic counter. Further, softfork timeout doesn't rely on it ? (dropped it anyway, maybe too much)
in src/versionbits.h:68 in bcc2a0f45c outdated
61 | @@ -50,12 +62,17 @@ class AbstractThresholdConditionChecker { 62 | virtual int Threshold(const Consensus::Params& params) const =0; 63 | 64 | public: 65 | + /** Returns the numerical statistics of an in-progess BIP9 softfork in the current period */ 66 | BIP9Stats GetStateStatisticsFor(const CBlockIndex* pindex, const Consensus::Params& params) const; 67 | - // Note that the functions below take a pindexPrev as input: they compute information for block B based on its parent. 68 | + /** Returns the state for pindex A based on parent pindexPrev B. Applies any state transition if conditions are present. 69 | + * Caches state for first block of period. */
jnewbery commented at 2:31 PM on August 14, 2019:s/Caches state for/Caches state from/
jnewbery commented at 2:32 PM on August 14, 2019: memberConcept ACK. Thanks for adding documentation.
A couple of nits inline.
ariard force-pushed on Aug 14, 2019ariard commented at 5:58 PM on August 14, 2019: memberUpdated at 001b58b with typos and corrections, thanks all for reviews
in src/versionbits.h:30 in 001b58b204 outdated
30 | - FAILED, 31 | + DEFINED, // First state that each softfork starts out as. The genesis block is by definition in this state for each deployment. 32 | + STARTED, // For blocks past the starttime. 33 | + LOCKED_IN, // For one retarget period after the first retarget period with STARTED blocks of which at least threshold have the associated bit set in nVersion. 34 | + ACTIVE, // For all blocks after the LOCKED_IN retarget period (final state) 35 | + FAILED, // For one retarget period past the timeout time, if LOCKED_IN was not reached (final state)
ajtowns commented at 8:57 AM on August 15, 2019:The FAILED description there is verbatim from BIP-9 but it's nevertheless not accurate -- it'll be all blocks once the first retarget period after the timeout time is reached, if LOCKED_IN wasn't already reached.
ajtowns commented at 9:00 AM on August 15, 2019: memberThis seems mostly fine to me
doc: Improve versionbits.h documentation 6576a8765fariard force-pushed on Aug 15, 2019jnewbery commented at 3:25 PM on August 15, 2019: memberACK 6576a8765f67716aa6b87a2f0296fbac5956bec0
fanquake removed the label Waiting for author on Aug 16, 2019ajtowns commented at 2:45 AM on August 16, 2019: memberACK 6576a8765f67716aa6b87a2f0296fbac5956bec0
fanquake approvedfanquake merged this on Aug 16, 2019fanquake closed this on Aug 16, 2019fanquake referenced this in commit 95a5918c90 on Aug 16, 2019vijaydasmp referenced this in commit a26c281600 on Oct 27, 2021vijaydasmp referenced this in commit f4e1cd7b84 on Oct 28, 2021vijaydasmp referenced this in commit 7c8065e80c on Oct 29, 2021vijaydasmp referenced this in commit ee10392e33 on Oct 30, 2021vijaydasmp referenced this in commit 6d467c2961 on Nov 2, 2021vijaydasmp referenced this in commit ff8c57ab8d on Nov 7, 2021vijaydasmp referenced this in commit bbe16c5ccd on Nov 11, 2021vijaydasmp referenced this in commit 73416a54fb on Nov 12, 2021vijaydasmp referenced this in commit 69117a978f on Nov 13, 2021vijaydasmp referenced this in commit 218b4563d9 on Nov 14, 2021vijaydasmp referenced this in commit df47d96104 on Nov 14, 2021vijaydasmp referenced this in commit 4bf93d833e on Nov 16, 2021DrahtBot locked this on Dec 16, 2021Labels
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-21 18:14 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me