Skip to content

Commit 1bf2ff2

Browse files
author
MarcoFalke
committed
Merge #16060: Bury bip9 deployments
e78aaf4 [docs] Add release notes for burying bip 9 soft fork deployments (John Newbery) 8319e73 [tests] Add coverage for the content of getblockchaininfo.softforks (James O'Beirne) 0328dcd [Consensus] Bury segwit deployment (John Newbery) 1c93b9b [Consensus] Bury CSV deployment height (John Newbery) 3862e47 [rpc] Tidy up reporting of buried and ongoing softforks (John Newbery) Pull request description: This hardcodes CSV and segwit activation heights, similar to the BIP 90 buried deployments for BIPs 34, 65 and 66. CSV and segwit have been active for over 18 months. Hardcoding the activation height is a code simplification, makes it easier to understand segwit activation status, and reduces technical debt. This was originally attempted by jl2012 in #11398 and again by me in #12360. ACKs for top commit: ajtowns: ACK e78aaf4 ; checked diff to previous acked commit, checked tests still work ariard: ACK e78aaf4, check diff, run the tests again and successfully activated csv/segwit heights on mainnet as expected. MarcoFalke: ACK e78aaf4 (still didn't check if the mainnet block heights are correct, but the code looks good now) Tree-SHA512: 7e951829106e21a81725f7d3e236eddbb59349189740907bb47e33f5dbf95c43753ac1231f47ae7bee85c8c81b2146afcdfdc11deb1503947f23093a9c399912
2 parents 367b023 + e78aaf4 commit 1bf2ff2

21 files changed

+242
-306
lines changed

doc/release-notes-16060.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Low-level RPC changes
2+
----------------------
3+
4+
- Soft fork reporting in the `getblockchaininfo` return object has been
5+
updated. For full details, see the RPC help text. In summary:
6+
- The `bip9_softforks` sub-object is no longer returned
7+
- The `softforks` sub-object now returns an object keyed by soft fork name,
8+
rather than an array
9+
- Each softfork object in the `softforks` object contains a `type` value which
10+
is either `buried` (for soft fork deployments where the activation height is
11+
hard-coded into the client implementation), or `bip9` (for soft fork deployments
12+
where activation is controlled by BIP 9 signaling).
13+
14+
- `getblocktemplate` no longer returns a `rules` array containing `CSV`
15+
and `segwit` (the BIP 9 deployments that are currently in active state).

src/chainparams.cpp

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ class CMainParams : public CChainParams {
6969
consensus.BIP34Hash = uint256S("0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8");
7070
consensus.BIP65Height = 388381; // 000000000000000004c2b624ed5d7756c508d90fd0da2c7c679febfa6c4735f0
7171
consensus.BIP66Height = 363725; // 00000000000000000379eaa19dce8c9b722d46ae6a57c2f1a988119488b50931
72+
consensus.CSVHeight = 419328; // 000000000000000004a1b34462cb8aeebd5799177f7a29cf28f2d1961716b5b5
73+
consensus.SegwitHeight = 481824; // 0000000000000000001c8018d9cb3b742ef25114f27563e3fc4a1902167f9893
7274
consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
7375
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
7476
consensus.nPowTargetSpacing = 10 * 60;
@@ -80,16 +82,6 @@ class CMainParams : public CChainParams {
8082
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
8183
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
8284

83-
// Deployment of BIP68, BIP112, and BIP113.
84-
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0;
85-
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 1462060800; // May 1st, 2016
86-
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = 1493596800; // May 1st, 2017
87-
88-
// Deployment of SegWit (BIP141, BIP143, and BIP147)
89-
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
90-
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = 1479168000; // November 15th, 2016.
91-
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 1510704000; // November 15th, 2017.
92-
9385
// The best chain should have at least this much work.
9486
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000051dc8b82f450202ecb3d471");
9587

@@ -183,6 +175,8 @@ class CTestNetParams : public CChainParams {
183175
consensus.BIP34Hash = uint256S("0x0000000023b3a96d3484e5abb3755c413e7d41500f8e2a5c3f0dd01299cd8ef8");
184176
consensus.BIP65Height = 581885; // 00000000007f6655f22f98e72ed80d8b06dc761d5da09df0fa1dc4be4f861eb6
185177
consensus.BIP66Height = 330776; // 000000002104c8c45e99a8853285a3b592602a3ccde2b832481da85e9e4ba182
178+
consensus.CSVHeight = 770112; // 00000000025e930139bac5c6c31a403776da130831ab85be56578f3fa75369bb
179+
consensus.SegwitHeight = 834624; // 00000000002b980fcd729daaa248fd9316a5200e9b367f4ff2c42453e84201ca
186180
consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
187181
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
188182
consensus.nPowTargetSpacing = 10 * 60;
@@ -194,16 +188,6 @@ class CTestNetParams : public CChainParams {
194188
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
195189
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
196190

197-
// Deployment of BIP68, BIP112, and BIP113.
198-
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0;
199-
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 1456790400; // March 1st, 2016
200-
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = 1493596800; // May 1st, 2017
201-
202-
// Deployment of SegWit (BIP141, BIP143, and BIP147)
203-
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
204-
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = 1462060800; // May 1st 2016
205-
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 1493596800; // May 1st 2017
206-
207191
// The best chain should have at least this much work.
208192
consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000007dbe94253893cbd463");
209193

@@ -275,6 +259,8 @@ class CRegTestParams : public CChainParams {
275259
consensus.BIP34Hash = uint256();
276260
consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in functional tests)
277261
consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in functional tests)
262+
consensus.CSVHeight = 432; // CSV activated on regtest (Used in rpc activation tests)
263+
consensus.SegwitHeight = 0; // SEGWIT is always activated on regtest unless overridden
278264
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
279265
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
280266
consensus.nPowTargetSpacing = 10 * 60;
@@ -285,12 +271,6 @@ class CRegTestParams : public CChainParams {
285271
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
286272
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0;
287273
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
288-
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0;
289-
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 0;
290-
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
291-
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
292-
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
293-
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
294274

295275
// The best chain should have at least this much work.
296276
consensus.nMinimumChainWork = uint256S("0x00");
@@ -307,7 +287,7 @@ class CRegTestParams : public CChainParams {
307287
m_assumed_blockchain_size = 0;
308288
m_assumed_chain_state_size = 0;
309289

310-
UpdateVersionBitsParametersFromArgs(args);
290+
UpdateActivationParametersFromArgs(args);
311291

312292
genesis = CreateGenesisBlock(1296688602, 2, 0x207fffff, 1, 50 * COIN);
313293
consensus.hashGenesisBlock = genesis.GetHash();
@@ -350,11 +330,22 @@ class CRegTestParams : public CChainParams {
350330
consensus.vDeployments[d].nStartTime = nStartTime;
351331
consensus.vDeployments[d].nTimeout = nTimeout;
352332
}
353-
void UpdateVersionBitsParametersFromArgs(const ArgsManager& args);
333+
void UpdateActivationParametersFromArgs(const ArgsManager& args);
354334
};
355335

356-
void CRegTestParams::UpdateVersionBitsParametersFromArgs(const ArgsManager& args)
336+
void CRegTestParams::UpdateActivationParametersFromArgs(const ArgsManager& args)
357337
{
338+
if (gArgs.IsArgSet("-segwitheight")) {
339+
int64_t height = gArgs.GetArg("-segwitheight", consensus.SegwitHeight);
340+
if (height < -1 || height >= std::numeric_limits<int>::max()) {
341+
throw std::runtime_error(strprintf("Activation height %ld for segwit is out of valid range. Use -1 to disable segwit.", height));
342+
} else if (height == -1) {
343+
LogPrintf("Segwit disabled for testing\n");
344+
height = std::numeric_limits<int>::max();
345+
}
346+
consensus.SegwitHeight = static_cast<int>(height);
347+
}
348+
358349
if (!args.IsArgSet("-vbparams")) return;
359350

360351
for (const std::string& strDeployment : args.GetArgs("-vbparams")) {

src/chainparamsbase.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ void SetupChainParamsBaseOptions()
1919
{
2020
gArgs.AddArg("-regtest", "Enter regression test mode, which uses a special chain in which blocks can be solved instantly. "
2121
"This is intended for regression testing tools and app development.", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
22+
gArgs.AddArg("-segwitheight=<n>", "Set the activation height of segwit. -1 to disable. (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
2223
gArgs.AddArg("-testnet", "Use the test chain", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
2324
gArgs.AddArg("-vbparams=deployment:start:end", "Use given start/end times for specified version bits deployment (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
2425
}

src/consensus/params.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ namespace Consensus {
1616
enum DeploymentPos
1717
{
1818
DEPLOYMENT_TESTDUMMY,
19-
DEPLOYMENT_CSV, // Deployment of BIP68, BIP112, and BIP113.
20-
DEPLOYMENT_SEGWIT, // Deployment of BIP141, BIP143, and BIP147.
2119
// NOTE: Also add new deployments to VersionBitsDeploymentInfo in versionbits.cpp
2220
MAX_VERSION_BITS_DEPLOYMENTS
2321
};
@@ -58,6 +56,12 @@ struct Params {
5856
int BIP65Height;
5957
/** Block height at which BIP66 becomes active */
6058
int BIP66Height;
59+
/** Block height at which CSV (BIP68, BIP112 and BIP113) becomes active */
60+
int CSVHeight;
61+
/** Block height at which Segwit (BIP141, BIP143 and BIP147) becomes active.
62+
* Note that segwit v0 script rules are enforced on all blocks except the
63+
* BIP 16 exception blocks. */
64+
int SegwitHeight;
6165
/**
6266
* Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period,
6367
* (nPowTargetTimespan / nPowTargetSpacing) which is also used for BIP9 deployments.

src/init.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,12 +1678,9 @@ bool AppInitMain(InitInterfaces& interfaces)
16781678
}
16791679
}
16801680

1681-
if (chainparams.GetConsensus().vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout != 0) {
1682-
// Only advertise witness capabilities if they have a reasonable start time.
1683-
// This allows us to have the code merged without a defined softfork, by setting its
1684-
// end time to 0.
1685-
// Note that setting NODE_WITNESS is never required: the only downside from not
1686-
// doing so is that after activation, no upgraded nodes will fetch from you.
1681+
if (chainparams.GetConsensus().SegwitHeight != std::numeric_limits<int>::max()) {
1682+
// Advertise witness capabilities.
1683+
// The option to not set NODE_WITNESS is only used in the tests and should be removed.
16871684
nLocalServices = ServiceFlags(nLocalServices | NODE_WITNESS);
16881685
}
16891686

0 commit comments

Comments
 (0)