-
Notifications
You must be signed in to change notification settings - Fork 36.1k
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
Implement BIP91 Reduced threshold Segwit MASF #10444
Conversation
This is a BIP9 deployment at 65% that requires signalling of segwit upon activation if segwit is not already locked-in or activated. Signalling requirement stop at segwit expiry, or activation.
|
src/validation.cpp
Outdated
@@ -2918,6 +2930,13 @@ bool IsWitnessEnabled(const CBlockIndex* pindexPrev, const Consensus::Params& pa | |||
return (VersionBitsState(pindexPrev, params, Consensus::DEPLOYMENT_SEGWIT, versionbitscache) == THRESHOLD_ACTIVE); | |||
} | |||
|
|||
// Check if Segregated Witness is Locked In | |||
bool IsWitnessLockedIn(const CBlockIndex* pindexPrev, const Consensus::Params& params) |
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 function could be static
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.
Any reason IsWitnessEnabled isn't also static?
src/versionbits.cpp
Outdated
@@ -148,7 +152,14 @@ class VersionBitsConditionChecker : public AbstractThresholdConditionChecker { | |||
int64_t BeginTime(const Consensus::Params& params) const { return params.vDeployments[id].nStartTime; } | |||
int64_t EndTime(const Consensus::Params& params) const { return params.vDeployments[id].nTimeout; } | |||
int Period(const Consensus::Params& params) const { return params.nMinerConfirmationWindow; } | |||
int Threshold(const Consensus::Params& params) const { return params.nRuleChangeActivationThreshold; } | |||
int Threshold(const Consensus::Params& params) const { | |||
if (params.nRuleChangeActivationThreshold == 1916 && params.nMinerConfirmationWindow == 2016 && |
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.
can these magic numbers - when not being used as actual thresholds - be constants?
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 commit seems unnecessary, just don't use Consensus::DEPLOYMENT_SEGSIGNAL on chains that shouldn't use it (like regtest and testnet3).
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.
Fixed
src/versionbits.cpp
Outdated
int Threshold(const Consensus::Params& params) const { | ||
if (params.vDeployments[id].bit == params.vDeployments[Consensus::DEPLOYMENT_SEGSIGNAL].bit && | ||
params.vDeployments[id].nStartTime == params.vDeployments[Consensus::DEPLOYMENT_SEGSIGNAL].nStartTime) { | ||
return 1311; // 65% threshold for SEGSIGNAL only |
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.
Perhaps this can be a field on Consensus::Params? or at least a properly defined constant
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 now defined in chainparams
src/versionbits.cpp
Outdated
@@ -148,7 +152,13 @@ class VersionBitsConditionChecker : public AbstractThresholdConditionChecker { | |||
int64_t BeginTime(const Consensus::Params& params) const { return params.vDeployments[id].nStartTime; } | |||
int64_t EndTime(const Consensus::Params& params) const { return params.vDeployments[id].nTimeout; } | |||
int Period(const Consensus::Params& params) const { return params.nMinerConfirmationWindow; } | |||
int Threshold(const Consensus::Params& params) const { return params.nRuleChangeActivationThreshold; } | |||
int Threshold(const Consensus::Params& params) const { | |||
if (params.vDeployments[id].bit == params.vDeployments[Consensus::DEPLOYMENT_SEGSIGNAL].bit && |
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.
why not just if (id == Consensus::DEPLOYMENT_SEGSIGNAL)
?
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.
Is the behavior for that identical?
src/chainparams.cpp
Outdated
@@ -97,7 +97,7 @@ class CMainParams : public CChainParams { | |||
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 1510704000; // November 15th, 2017. | |||
|
|||
// Deployment of SEGSIGNAL | |||
consensus.vDeployments[Consensus::DEPLOYMENT_SEGSIGNAL].bit = 2; | |||
consensus.vDeployments[Consensus::DEPLOYMENT_SEGSIGNAL].bit = 4; |
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.
why bit 4 ? what's wrong with bit 2 ?
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 was chosen because it was what was listed in the NYC agreement, I made a separate BIP that uses bit 2 however.
@@ -1135,6 +1135,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request) | |||
softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams)); | |||
BIP9SoftForkDescPushBack(bip9_softforks, "csv", consensusParams, Consensus::DEPLOYMENT_CSV); | |||
BIP9SoftForkDescPushBack(bip9_softforks, "segwit", consensusParams, Consensus::DEPLOYMENT_SEGWIT); | |||
BIP9SoftForkDescPushBack(bip9_softforks, "segsignal", consensusParams, Consensus::DEPLOYMENT_SEGSIGNAL); |
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 would squash this commit and the previous one into the first commit (perhaps after review would just squash it all in one commit, it's all 1 logical change IMO).
I've modified the BIP91 spec slightly with a different threshold and immediate enforcement upon lock-in. |
bit 1 signaling is not required (and has no meaning) unless the state is STARTED
I've updated BIP91 to use an even smaller confirmation window and changed it so enforcement isn't until activation in order to give a ~2 day grace period between lock-in and enforcement. |
NACK, this does nothing for users, and is unnecessary with BIP148 around the corner. |
ACK: avoiding a chain split in a coordinated manner is certainly not "doing nothing for users". Since the -bip148 option is not available, a BIP91 feature is the best alternative. I would be fine with either. |
Apparently BIP91 was locked in today. How can I make sure my node follows the correct chain? Is this pull request on a branch somewhere or do I need to merge it in my own local repository? And what about the thousands of other nodes out there? Shouldn't this PR be merged to allow them to track the correct chain? |
As I understand Bitcoins miners don't enforce anything. They mine blocks which are either valid or invalid. It is the users who decide whether to accept their blocks or not, and thereby enforce the rules. I don't see any argument here against merging this PR other than Luke's inaccurate complaint that BIP91 does nothing for users. What am I missing? |
@dooglus Both miners and users have the ability to enforce rules, a majority of miners can add a new rule without creating a chain split(assuming other nodes don't change their rules). Since a majority of miners are adding a rule with BIP91 the blocks will be valid to existing nodes. There's mostly 2 arguments I'm seeing, one is that more users should enforce the BIP91 rules to strengthen the rule enforcement, the other is that users should not so that there is more consistency among rule enforcement. I somewhat agree with the consistency argument, however any businesses accepting transactions without many confirmations should be running both BIP91 and non-BIP91 nodes and ensuring that the transactions are confirmed on both. |
Exactly. That seems like an argument for merging this PR so that I can run a BIP91 node without having to trust or code review a non-core repository. |
Can this be squashed and possibly updated with the latest from the segsignal repo? |
Closing this as enforcement of BIP91 is no longer required. |
This is an implementation of BIP91.
BIP91 details: https://github.com/bitcoin/bips/blob/master/bip-0091.mediawiki
Previous discussion:
https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2017-May/014380.html