Skip to content

Commit 155ce23

Browse files
committed
BIP 8: Add FAILING state to allow lockinontimeout upgrades
1 parent d7662ab commit 155ce23

File tree

3 files changed

+36
-15
lines changed

3 files changed

+36
-15
lines changed

bip-0008.mediawiki

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Each soft fork deployment is specified by the following per-chain parameters (fu
3333
# The '''name''' specifies a very brief description of the soft fork, reasonable for use as an identifier. For deployments described in a single BIP, it is recommended to use the name "bipN" where N is the appropriate BIP number.
3434
# The '''bit''' determines which bit in the nVersion field of the block is to be used to signal the soft fork lock-in and activation. It is chosen from the set {0,1,2,...,28}.
3535
# The '''start''' specifies the height of the first block at which the bit gains its meaning.
36-
# The '''timeout''' specifies a block height at which the miner signalling ends. Once this height has been reached, if the soft fork has not yet locked in (excluding this block's bit state), the deployment is either considered failed on all descendants of the block, or, if '''lockinontimeout'' is true, transitions to the '''LOCKED_IN''' state.
36+
# The '''timeout''' specifies a block height at which the miner signalling ends. Once this height has been reached, if the soft fork has not yet locked in (excluding this block's bit state), the deployment is either considered failed on all descendants of the block (but see the exception during '''FAILING''' state), or, if '''lockinontimeout'' is true, transitions to the '''LOCKED_IN''' state.
3737
# The '''lockinontimeout''' boolean if set to true, will transition state to '''LOCKED_IN''' at timeout if not already '''LOCKED_IN''' or '''ACTIVE'''.
3838
3939
===Selection guidelines===
@@ -44,7 +44,7 @@ The following guidelines are suggested for selecting these parameters for a soft
4444
# '''bit''' should be selected such that no two concurrent softforks use the same bit.
4545
# '''start''' should be set to some block height in the future, approximately one month after a software release date including the soft fork. This allows for some release delays, while preventing triggers as a result of parties running pre-release software, and ensures a reasonable number of full nodes have upgraded prior to activation. It should be rounded up to the next height which begins a retarget period.
4646
# '''timeout''' should be approximately 1 year after start, and on a block which begins a retarget period. Therefore, '''start''' plus 52416.
47-
# '''lockinontimeout''' should be set to true for any softfork that isn't exclusively for miner benefit.
47+
# '''lockinontimeout''' should be set to true for any softfork that is expected or found to have political opposition from a non-negligable percent of miners. (It can be set after the initial deployment, but cannot be cleared once set.)
4848
4949
A later deployment using the same bit is possible as long as the start is after the previous one's
5050
timeout or activation, but it is discouraged until necessary, and even then recommended to have a pause in between to detect buggy software.
@@ -57,7 +57,8 @@ With each block and soft fork, we associate a deployment state. The possible sta
5757
# '''STARTED''' for blocks at or beyond the start height.
5858
# '''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, or for one retarget period after the timeout when '''lockinontimeout''' is true.
5959
# '''ACTIVE''' for all blocks after the LOCKED_IN retarget period.
60-
# '''FAILED''' for all blocks after the timeout, if LOCKED_IN was not reached and '''lockinontimeout''' is false.
60+
# '''FAILING''' for one retarget period after the timeout, if LOCKED_IN was not reached and '''lockinontimeout''' is false.
61+
# '''FAILED''' for all blocks after the FAILING retarget period.
6162
6263
===Bit flags===
6364
@@ -107,25 +108,25 @@ We remain in the initial state until either we pass the start height or the time
107108
108109
case DEFINED:
109110
if (block.height >= timeout) {
110-
return (lockinontimeout == true) ? LOCKED_IN : FAILED;
111+
return (lockinontimeout == true) ? LOCKED_IN : FAILING;
111112
}
112113
if (block.height >= start) {
113114
return STARTED;
114115
}
115116
return DEFINED;
116117
117-
After a period in the STARTED state, if we're past the timeout, we switch to LOCKED_IN or FAILED. If not, we tally the bits set,
118+
After a period in the STARTED state, if we're past the timeout, we switch to LOCKED_IN or FAILING. If not, we tally the bits set,
118119
and transition to LOCKED_IN if a sufficient number of blocks in the past period set the deployment bit in their
119120
version numbers. The threshold is ≥1916 blocks (95% of 2016), or ≥1512 for testnet (75% of 2016).
120-
The transition to FAILED takes precendence, as otherwise an ambiguity can arise.
121+
The transition to FAILING takes precendence, as otherwise an ambiguity can arise.
121122
There could be two non-overlapping deployments on the same bit, where the first one transitions to LOCKED_IN while the
122123
other one simultaneously transitions to STARTED, which would mean both would demand setting the bit.
123124
124125
Note that a block's state never depends on its own nVersion; only on that of its ancestors.
125126
126127
case STARTED:
127128
if (block.height >= timeout) {
128-
return (lockinontimeout == true) ? LOCKED_IN : FAILED;
129+
return (lockinontimeout == true) ? LOCKED_IN : FAILING;
129130
}
130131
int count = 0;
131132
walk = block;
@@ -140,6 +141,19 @@ Note that a block's state never depends on its own nVersion; only on that of its
140141
}
141142
return STARTED;
142143
144+
If the deployment is not LOCKED_IN by the timeout (or '''lockinontimeout'''), it has a single retarget period during which it may still become active, only by unanimous signalling in every block.
145+
This state exists such that if '''lockinontimeout''' is set to true later, it remains compatible with the original deployment.
146+
147+
case FAILING:
148+
walk = block;
149+
for (i = 0; i < 2016; i++) {
150+
walk = walk.parent;
151+
if (walk.nVersion & 0xE0000000 == 0x20000000 && ((walk.nVersion >> bit) & 1) != 1) {
152+
return FAILED;
153+
}
154+
}
155+
return ACTIVE;
156+
143157
After a retarget period of LOCKED_IN, we automatically transition to ACTIVE.
144158
145159
case LOCKED_IN:
@@ -180,6 +194,7 @@ https://github.com/bitcoin/bitcoin/compare/master...shaolinfry:bip-uaversionbits
180194
181195
* The '''lockinontimeout''' flag is added. BIP 9 would only transition to the FAILED state when timeout was reached.
182196
* Block heights are used for the deployment monotonic clock, rather than median-time-past.
197+
* The last-ditch effort during a new FAILING state is added to allow '''lockinontimeout''' to be safely set after the initial deployment.
183198
184199
==Backwards compatibility==
185200

bip-0008/states.png

5.83 KB
Loading

bip-0008/states.svg

Lines changed: 14 additions & 8 deletions
Loading

0 commit comments

Comments
 (0)