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

Implement BIP91 Reduced threshold Segwit MASF #10444

Closed
wants to merge 12 commits into from

Conversation

jameshilliard
Copy link
Contributor

shaolinfry and others added 2 commits May 21, 2017 23:30
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.
@jonasschnelli
Copy link
Contributor

jonasschnelli commented May 24, 2017

bip68-112-113-p2p.py-tests are falling...

@@ -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)
Copy link
Contributor

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

Copy link
Contributor Author

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?

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

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?

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

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
Copy link
Contributor

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

Copy link
Contributor Author

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

@@ -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 &&
Copy link
Contributor

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

Copy link
Contributor Author

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?

@@ -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;
Copy link
Contributor

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 ?

Copy link
Contributor Author

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);
Copy link
Contributor

@jtimon jtimon May 31, 2017

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

@jameshilliard
Copy link
Contributor Author

I've modified the BIP91 spec slightly with a different threshold and immediate enforcement upon lock-in.

@jameshilliard
Copy link
Contributor Author

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.

@luke-jr
Copy link
Member

luke-jr commented Jun 19, 2017

NACK, this does nothing for users, and is unnecessary with BIP148 around the corner.

@earonesty
Copy link

earonesty commented Jun 19, 2017

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.

@dooglus
Copy link
Contributor

dooglus commented Jul 21, 2017

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?

@jameshilliard
Copy link
Contributor Author

@dooglus BIP91 is mostly a miner enforced soft fork, you can use this tree.

@dooglus
Copy link
Contributor

dooglus commented Jul 21, 2017

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?

@jameshilliard
Copy link
Contributor Author

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

@dooglus
Copy link
Contributor

dooglus commented Jul 21, 2017

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.

@achow101
Copy link
Member

Can this be squashed and possibly updated with the latest from the segsignal repo?

@jameshilliard
Copy link
Contributor Author

Closing this as enforcement of BIP91 is no longer required.

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants