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
bip9: add speedy trial #1101
bip9: add speedy trial #1101
Conversation
b04b049
to
4dc59a7
Compare
@@ -119,10 +123,7 @@ other one simultaneously transitions to STARTED, which would mean both would dem | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section is wrong. Also, the selection criteria above needs to be adjusted. See bitcoin/bitcoin#21377 (comment)
@@ -229,6 +235,10 @@ upgrades for successful soft forks. | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The threshold needs to be changed as well see bitcoin/bitcoin#21377 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me if the speedy trial permanently reduces the threshold, or if this was just a lazy way to set it to 90% for the trial itself. BIP 9 already allows for a lower threshold.
bip-0009/states.dot
Outdated
node [style="rounded,filled,bold", shape=box, fixedsize=true, width=1.5, fontname="Arial"]; | ||
|
||
edge [weight = 100]; | ||
"DEFINED" -> "STARTED" [label="Always"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong, too. The correct state diagram is at bitcoin/bitcoin#21377 (comment) (Edit: wrong link, see below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took over most of the diagram, but left out the DELAYED
pseudo-state. I also clarified that you can transition from STARTED
to LOCKED_IN
after the timeout (but only if it reaches the threshold in the first period). I'm not sure if this edge case is worth explaining, since AFAIK it's just there to make fuzzing easier? cc @ajtowns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bitcoin/bitcoin#21377 (comment) is the current state diagram
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I was only missing height + 1
,so added that. Also expanded the text a bit.
0c98c0f
to
6cd6b75
Compare
For the record I disapproved of revising BIP 9 back on March 17th and I'm not exactly impressed today. I can only speak for myself though and not having a BIP (or at least a pull request such as this one) to refer to for the latest state diagram of #21377 of Speedy Trial is not healthy for the review of #21377. I think the intention here is to make BIP 9 into a generalized activation BIP (like BIP 8 currently is) with multiple parameters and incorporating multiple activation mechanisms, the only parameter missing of course being the LOT parameter. And using this mix of MTP and block height for Speedy Trial instead of using block height consistently. I prefer a new BIP number for Speedy Trial personally if people are going to go to these lengths to avoid using BIP 8. BIP 9 has a lot of history and so it can't be a fresh exclusively Speedy Trial BIP. But then having two flavors of Speedy Trial (BIP 8 and BIP 9 Speedy Trial) is nonsense. Someone will need to explain the differences between BIP 8 and BIP 9 for future soft forks (good luck to whoever tries that). I honestly don't know what some people are doing anymore. The amount of time wasted on this BIP 8 vs BIP 9 and block height vs mix of block height and MTP just appalls me. |
I think BIP 8 is a better place to introduce a more drastic change like LOT. The main thing this PR introduces is a longer LOCKIN phase. The rest is cosmetics.
Yes, but these changes are backwards compatible, as explained in this PR. Since BIP 8 is entirely height based (which I also prefer) implementing it in existing clients is much more involved. The fact that
Why would that be more difficult in the future than it is now? "We're ditching time based in favor of block based, that's all" would be the explanation.
I still favor a height based approach, i.e. speedy trial with BIP 8, or just a regular BIP 8 deployment with One final point: it's still possible to refactor the BIP 9 speedy trial code to a BIP 8 speedy trial. The changes needed to switch from BIP 9 to BIP 8, which have already been coded up, can be mostly reused for that. The use of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm starting to go through the state machine logic. Some typo fixups below.
bip-0009.mediawiki
Outdated
==2021 update== | ||
|
||
* '''min_activation_height''' was added. Clients unaware of softforks introduced after SegWit can ignore this in the context of their upgrade warnings. | ||
* removed state transition from '''defined''' to '''failed'''. This change is safe to ignore for all (burried) softforks deployed before 2021. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BIP-wide: use either "soft fork" or "softfork", but maybe not both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or soft-fork? It's already inconsistent. I might just add a commit that picks one and fixes that for the existing text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When in doubt, I consult https://github.com/bitcoinops/bitcoinops.github.io/blob/master/STYLE.md (which says to use "soft fork")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some serious errors here...
I think that it's correct to say that the changes are purely soft-forks for any soft-fork activation attempt under the old rules -- some conceivable chains might switch from FAILED to ACTIVE, but none that were ACTIVE would switch to any other state. And all of csv, segwit and bip 91 did reach the ACTIVE state so even if they weren't considered buried, interpretation shouldn't change.
FWIW, I'm not convinced there's a need to have this as a separate bip rather than just documenting the delta in the taproot bip directly -- that should only be necessary if we wanted to reuse exactly this activation method again in the future, in which case having a separate bip to refer to would be helpful. That seems pretty unlikely. I have an update to bip341 that documents the activation details drafted at https://github.com/ajtowns/bips/blob/202103-bip341-speedy-trial-mtp/bip-0341.mediawiki#Deployment that I was aiming to PR today, but I would really rather avoid having another set of competing PRs on this topic. LMK if you want to persevere with this or would rather switch to that.
[EDIT: opened as #1104]
bip-0009.mediawiki
Outdated
|
||
case LOCKED_IN: | ||
return ACTIVE; | ||
if (block.height + 1 >= min_activation_height) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't correct -- bip 9's "block" is the first block in the retarget period, while versionbits.cpp's pindexPrev is the last block in the prior retarget period, so this should be block.height >= min_activation_height
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed and added your clarification from below.
bip-0009/states.dot
Outdated
"DEFINED" -> "STARTED" [label="MTP >= begin"]; | ||
"STARTED" -> "FAILED" [label="nsig < thresh\nMTP >= timeout"]; | ||
"LOCKED_IN" -> "LOCKED_IN" [label="height + 1 < min_height"]; | ||
"LOCKED_IN" -> "ACTIVE" [label="height + 1 >= min_height"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably needs to be clear that "MTP" is calculated against the last block of the previous period, while "height+1" is the height of the first block of the new period too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment below the figure, let me know if I got it right this time...
Tend to NACK. Procedurally, BIP 9 is in Final status which implies that it cannot be modified. Additionally, I consider the state machine changes to be a significant change to BIP 9, although the actual code changes themselves are small. Given those two facts, I don't think that we should be modifying BIP 9 itself to include speedy trial. Rather I think that a new BIP should be written which specifies speedy trial, the state machine changes, and the proposed |
I'm not a fan of making such significant changes to a |
6cd6b75
to
74d9008
Compare
I think it's very confusing for anyone trying to implement BIP 9 from scratch to have to look at this BIP and then look in BIP 341 for changes. Most likely they would start with reading this BIP and then look at the Bitcoin Core code, only to find it doesn't match in strange ways. Any client that already implements BIP 9 will have to make changes in order to correctly detect the Taproot fork. For them it probably doesn't matter where the info is, but this seems a more natural spot. It seems exceedingly unlikely to me that if we activate Taproot with this, that the next soft fork would use vanilla BIP 9. And it makes no sense in e.g. a ANYPREVOUT softfork to have to point to Taproot documentation. Even if the speedy trial doesn't activate, I doubt we'll revert the changes in Bitcoin Core. Hence my preference for updating this. My second preferred solution would be a fresh BIP for the activation (rather than mixing it in with Taproot specific stuff). |
74d9008
to
79de570
Compare
@ajtowns I'm confused by this. On IRC wasn't the reason for going with MTP because future soft forks will use ST, and doing so will make testing easier? Otherwise, safety and predictability favored height/BIP8 |
I think the next soft fork attempt (which might be taproot again if ST fails to activate) would want to make at least two changes compared to ST as it stands: including some form of UASF mechanism (eg, LAST_CHANCE and mandatory signalling), and using MTP rather than height for the delayed activation, presuming we can come up with a sensible way of doing that (eg addressing issues like the one Russell raised). It might be good for such a BIP to also document how activations actually occur for signet in order to test new soft forks. |
Closing this since BIP 9 is already Final status. |
Also recreates the state diagram and adds its source (based on BIP 8).
As an alternative to updating BIP 9 we could also make a new BIP from scratch, but that seems overkill since these changes are backwards compatible. When specifying activation parameters for future softforks like Taproot - if min_activation_height is used - we can point to this update. Clients that don't implement these softforks can safely ignore the changes.