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

Consensus Cleanup BIP draft #1800

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

darosior
Copy link
Member

This is a BIP draft for a Consensus Cleanup soft fork.

This proposal builds upon Matt Corallo's 2019 proposal, which i set to revive at the end of 2023. I eventually shared my research in a Delving Bitcoin post in early 2024 (along with a semi-private companion post for the redacted sensitive details). A number of people contributed ideas, testing and otherwise fruitful discussion. This led to settling on a list of mitigations, which i updated the mailing list about in February 2025.

I think it's now ready to be officially published as a BIP.

Copy link
Contributor

@vostrnad vostrnad left a comment

Choose a reason for hiding this comment

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

First pass of review, mostly copy editing suggestions so far.

bip-cc.md Outdated

Given a block at height `N`:
- if `N % 2016` is equal to `0` the `nTime` field of the block must be set to a value higher than or
equal to the value of the `nTime` field of block at height `N-1` minus `7200`;

Choose a reason for hiding this comment

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

Maybe reword this to make it clearer that minus 7200 is subtracted from the value of nTime, and not from height N-1 (so that no one unfamiliar with the context could read it as "block at height N - 7201").

Copy link
Member Author

Choose a reason for hiding this comment

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

Is this better?

Suggested change
equal to the value of the `nTime` field of block at height `N-1` minus `7200`;
equal to the value minus `7200` of the `nTime` field of block at height `N-1`;

Copy link
Member

@Sjors Sjors 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 on the timewarp and Murch-Zawy fix, as well as the 64 byte transaction ban.

I still need to think about the worst case validation fix more, though the approach seems reasonable.

With respect to the nLockTime change, I need to get a sense of what pool software should take into account, especially since Bitoin Core does not construct the coinbase transaction.

We don't strictly need this change until height 1,983,702, but it seems better to enforce it at the same time as the rest of these changes. Otherwise we might end up with accidental forks several decades from now with nobody remembering this BIP.

I also still need to see and study the implementation(s), outside the timewarp fix, which I'm fairly familiar with by now.

@ariard
Copy link

ariard commented Mar 28, 2025

There might be a problem with the math in this BIP.

Exposing said problem clearly might be a $5k a day wreck the whole LN style of exploit.

Asking for a friend who is curious on how to handle said problem.

@darosior
Copy link
Member Author

@ariard i made sure you are on the private thread, if you want to discuss potentially sensitive details please do so there. Alternatively feel free to contact me privately.

@darosior darosior force-pushed the consensus_cleanup branch 3 times, most recently from e3a557f to 404010f Compare April 1, 2025 18:32
Copy link
Contributor

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

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

Just a quick first look and some editorial comments as I see that this is still being edited and already getting quite a bit of feedback.

@darosior darosior force-pushed the consensus_cleanup branch 2 times, most recently from 8d16f01 to 625937e Compare April 1, 2025 19:48
@darosior
Copy link
Member Author

darosior commented Apr 1, 2025

Thanks everyone for the review thus far. I think i've addressed everything.

Copy link
Contributor

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

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

This proposal looks mostly complete from an editorial standpoint. In a few segments, the style could be even more prosaic—the document could be a bit clearer by avoiding passive voice and directly referencing subjects and objects of sentences than referencing via noun phrases and pronouns. Some abstract ideas are referenced with different terms. It would be preferable if the same term is used for the same concept throughout.

Comment on lines +66 to +67
A limit is set on the number of potentially executed signature operations in validating a
transaction. It applies to all transactions in the block except the coinbase transaction[^1]. For
Copy link
Contributor

Choose a reason for hiding this comment

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

Active voice is usually preferred in technical writing, because it is clearer:

Suggested change
A limit is set on the number of potentially executed signature operations in validating a
transaction. It applies to all transactions in the block except the coinbase transaction[^1]. For
The number of potentially executed signature operations in validating a
transaction is limited. The limit applies to all transactions except coinbase transactions[^1]. For

Copy link
Member Author

Choose a reason for hiding this comment

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

This is not active voice?

Comment on lines +127 to +130
This proposal only tightens the block validation rules: there is no block that is valid under the
rules proposed in this BIP but not under the existing Bitcoin consensus rules. As a consequence
these changes are backward-compatible with unupgraded node software. That said, the authors strongly
encourage node operators to upgrade in order to fully validate all consensus rules.
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn’t seem complete. The requirement to set and enforce the locktime is not backward-compatible for block producers.

Copy link
Member Author

@darosior darosior Apr 7, 2025

Choose a reason for hiding this comment

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

I'm confused. This seems to directly follow for any consensus change: miners must take steps to produce blocks valid according to the new rules. I don't mind adding a sentence to this effect, but as far as i know the backwards compatibility section has always been used to discuss the backwards compatibility from the point of view of end users, not miners (since by definition block producers need to adapt if we are going to change block validity). See for instance the backwards compatibility section of the SegWit soft fork. Why change now?

Copy link
Member Author

@darosior darosior Apr 7, 2025

Choose a reason for hiding this comment

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

I tried adding something to this effect but anything i come up with just seems needlessly redundant and vague. For instance:

Suggested change
This proposal only tightens the block validation rules: there is no block that is valid under the
rules proposed in this BIP but not under the existing Bitcoin consensus rules. As a consequence
these changes are backward-compatible with unupgraded node software. That said, the authors strongly
encourage node operators to upgrade in order to fully validate all consensus rules.
This proposal only tightens the block validation rules: there is no block that is valid under the
rules proposed in this BIP but not under the existing Bitcoin consensus rules. As a consequence
these changes are backward-compatible with unupgraded node software. That said, the authors strongly
encourage node operators to upgrade in order to fully validate all consensus rules.
As with any consensus change, miners need to take precautions to produce blocks compatible with the
new rules. In particular this BIP introduces restrictions on the coinbase transaction and block
header timestamp, which are often set by closed source pool software.

Copy link

@zawy12 zawy12 Apr 9, 2025

Choose a reason for hiding this comment

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

Instead of
"This proposal only tightens the block validation rules: there is no block that is valid under the
rules proposed in this BIP but not under the existing Bitcoin consensus rules. As a consequence
these changes are backward-compatible with unupgraded node software. That said, the authors strongly
encourage node operators to upgrade in order to fully validate all consensus rules."
I would say
"The proposal tightens the block validation rules. It doesn't invalidate any existing blocks to be backwards-compatible. Nodes should upgrade to ensure future blocks that are invalid under the proposal are not validated."


Transactions whose witness-stripped serialized size is exactly 64 bytes are made invalid.

The coinbase transaction's `nLockTime` field must be set to the height of the block minus 1[^2]
Copy link
Member

Choose a reason for hiding this comment

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

nLockTime is the most ideal location to put an extranonce, so it seems like a bad idea to burn it for no good reason.

Copy link
Member

Choose a reason for hiding this comment

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

@luke-jr why would miners switch to something different from the current extraNonce?

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 would have been better to bring up conceptual feedback on the mailing list. "For no good reason" is unnecessarily aggressive, the point here is not to make things invalid just for the sake of it. Please engage charitably to foster productive discussions.

To your point, it's my understanding that nLockTime makes for a good extranonce because it's serialized at the very end of the coinbase transaction. Rolling it does not require re-hashing the whole transaction as you can just cache a midstate for the first 64 bytes. Could you provide more details about how you expect it to be used exactly, and under what circumstances the operation it improves may become a bottleneck?

Copy link
Member

Choose a reason for hiding this comment

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

@luke-jr why would miners switch to something different from the current extraNonce?

There is no "current extraNonce". Extranonces can be anywhere in theory. But this particular location, as @darosior says, minimises the need to re-hash a lot of data to roll it. That means it can more practically be done on ASICs or MCUs with nearly no latency.

@darosior darosior force-pushed the consensus_cleanup branch from 21a9cd5 to 797984c Compare April 7, 2025 15:24
@ariard
Copy link

ariard commented Apr 7, 2025

@ariard i made sure you are on the private thread, if you want to discuss potentially sensitive details please do so there. Alternatively feel free to contact me privately.

The friend said the potential problem is not related on the timewarp fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants