Skip to content
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

Closed
wants to merge 2 commits into from
Closed

Conversation

Sjors
Copy link
Member

@Sjors Sjors commented Apr 12, 2021

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.

@Sjors Sjors force-pushed the 2021/04/bip9_state branch 2 times, most recently from b04b049 to 4dc59a7 Compare April 12, 2021 16:53
@@ -119,10 +123,7 @@ other one simultaneously transitions to STARTED, which would mean both would dem

Copy link
Member

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.

Copy link
Member

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)

Copy link
Member Author

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.

node [style="rounded,filled,bold", shape=box, fixedsize=true, width=1.5, fontname="Arial"];

edge [weight = 100];
"DEFINED" -> "STARTED" [label="Always"];
Copy link
Member

@maflcko maflcko Apr 12, 2021

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)

Copy link
Member Author

@Sjors Sjors Apr 12, 2021

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

Copy link
Contributor

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

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 I was only missing height + 1,so added that. Also expanded the text a bit.

@Sjors Sjors force-pushed the 2021/04/bip9_state branch 5 times, most recently from 0c98c0f to 6cd6b75 Compare April 13, 2021 11:30
@michaelfolkson
Copy link
Contributor

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.

Again I've said all this on many occasions (1, 2).

@Sjors
Copy link
Member Author

Sjors commented Apr 13, 2021

the only parameter missing of course being the LOT parameter

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.

BIP 9 has a lot of history

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 min_activation_height makes BIP 9 a weird mix of time and height is easier in the implementation than it might sound.

Someone will need to explain the differences between BIP 8 and BIP 9 for future soft forks (good luck to whoever tries 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.

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 still favor a height based approach, i.e. speedy trial with BIP 8, or just a regular BIP 8 deployment with LOT=false (no delayed activation). But given that even the author of the BIP 8 PR switched his effort to BIP 9, the most useful thing for me to do for is just to review and document a BIP 9 speedy trial.

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 min_activation_height (rather than time) in fact makes that easier.

Copy link
Contributor

@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.

I'm starting to go through the state machine logic. Some typo fixups below.

bip-0009.mediawiki Outdated Show resolved Hide resolved
==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.
Copy link
Contributor

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

Copy link
Member Author

@Sjors Sjors Apr 13, 2021

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.

Copy link
Contributor

@jonatack jonatack Apr 13, 2021

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")

bip-0009.mediawiki Outdated Show resolved Hide resolved
bip-0009.mediawiki Outdated Show resolved Hide resolved
bip-0009.mediawiki Outdated Show resolved Hide resolved
bip-0009.mediawiki Outdated Show resolved Hide resolved
bip-0009.mediawiki Outdated Show resolved Hide resolved
Copy link
Contributor

@ajtowns ajtowns left a 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]


case LOCKED_IN:
return ACTIVE;
if (block.height + 1 >= min_activation_height)
Copy link
Contributor

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.

Copy link
Member Author

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.mediawiki Outdated Show resolved Hide resolved
"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"];
Copy link
Contributor

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.

Copy link
Member Author

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...

bip-0009/states.dot Outdated Show resolved Hide resolved
bip-0009.mediawiki Outdated Show resolved Hide resolved
@achow101
Copy link
Member

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 LAST_CHANCE state for UASFs. I think that for now, it would be okay to write the speedy trial modifications in BIPs 341/342, but I would prefer that a new document is drafted for the full MTP versionbits methodology that has been proposed. This new document does not need to be a full BIP that describes everything from scratch (like BIP 8 and 9 do) but rather one which refers to BIP 9 and provides additional modifications on top of it (in a similar way to BIP 350 specifying the changes from BIP 173).

@harding
Copy link
Contributor

harding commented Apr 13, 2021

I'm not a fan of making such significant changes to a Status: final BIP. I think @ajtowns's approach of including the delta to BIP341 is much more congruent with the normal BIP process.

@Sjors
Copy link
Member Author

Sjors commented Apr 13, 2021

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).

@Rspigler
Copy link
Contributor

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,

@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

@ajtowns
Copy link
Contributor

ajtowns commented Apr 14, 2021

@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.

@luke-jr
Copy link
Member

luke-jr commented Apr 22, 2021

Closing this since BIP 9 is already Final status.

@luke-jr luke-jr closed this Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants