Skip to content

Commit 1f6888e

Browse files
authored
Merge pull request bitcoin#512 from da2ce7/bip148
Stop UASF enforcement if SegWit has IsLockedIn state.
2 parents b7850ab + 5f34ed7 commit 1f6888e

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

bip-0148.mediawiki

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,30 @@ It is hoped that miners will respond to this BIP by activating segwit early, bef
3030

3131
All times are specified according to median past time.
3232

33-
This BIP will be activate between midnight August 1st 2017 (epoch time 1501545600) and midnight November 15th 2017 (epoch time 1510704000) if the existing segwit deployment is not activated before epoch time 1501545600. This BIP will cease to be active when the existing segwit deployment activates.
33+
This BIP will be active between midnight August 1st 2017 (epoch time 1501545600) and midnight November 15th 2017 (epoch time 1510704000) if the existing segwit deployment is not locked-in or activated before epoch time 1501545600. This BIP will cease to be active when segwit is locked-in.
3434

3535
While this BIP is active, all blocks must set the nVersion header top 3 bits to 001 together with bit field (1<<1) (according to the existing segwit deployment). Blocks that do not signal as required will be rejected.
3636

3737
=== Reference implementation ===
3838

3939
<pre>
40+
// Check if Segregated Witness is Locked In
41+
bool IsWitnessLockedIn(const CBlockIndex* pindexPrev, const Consensus::Params& params)
42+
{
43+
LOCK(cs_main);
44+
return (VersionBitsState(pindexPrev, params, Consensus::DEPLOYMENT_SEGWIT, versionbitscache) == THRESHOLD_LOCKED_IN);
45+
}
46+
4047
// BIP148 mandatory segwit signalling.
41-
if (pindex->GetMedianTimePast() >= 1501545600 && // Tue 1 Aug 2017 00:00:00 UTC
42-
pindex->GetMedianTimePast() <= 1510704000 && // Wed 15 Nov 2017 00:00:00 UTC
43-
!IsWitnessEnabled(pindex->pprev, chainparams.GetConsensus()))
48+
int64_t nMedianTimePast = pindex->GetMedianTimePast();
49+
if ( (nMedianTimePast >= 1501545600) && // Tue 01 Aug 2017 00:00:00 UTC
50+
(nMedianTimePast <= 1510704000) && // Wed 15 Nov 2017 00:00:00 UTC
51+
(!IsWitnessLockedIn(pindex->pprev, chainparams.GetConsensus()) && // Segwit is not locked in
52+
!IsWitnessEnabled(pindex->pprev, chainparams.GetConsensus())) ) // and is not active.
4453
{
45-
// versionbits topbit and segwit flag must be set.
46-
if ((pindex->nVersion & VERSIONBITS_TOP_MASK) != VERSIONBITS_TOP_BITS ||
47-
(pindex->nVersion & VersionBitsMask(chainparams.GetConsensus(), Consensus::DEPLOYMENT_SEGWIT)) == 0) {
54+
bool fVersionBits = (pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS;
55+
bool fSegbit = (pindex->nVersion & VersionBitsMask(chainparams.GetConsensus(), Consensus::DEPLOYMENT_SEGWIT)) != 0;
56+
if (!(fVersionBits && fSegbit)) {
4857
return state.DoS(0, error("ConnectBlock(): relayed block must signal for segwit, please upgrade"), REJECT_INVALID, "bad-no-segwit");
4958
}
5059
}

0 commit comments

Comments
 (0)