From 2413416b8af595002cd82352703ff5e2d7287a81 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 27 Jun 2017 03:44:31 +0000 Subject: [PATCH 1/2] chainparams: Define (unset) hardfork time --- src/chainparams.cpp | 6 ++++++ src/consensus/params.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 383d9849af97..e37ac1dccdef 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -99,6 +99,8 @@ class CMainParams : public CChainParams { // The best chain should have at least this much work. consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000003f94d1ad391682fe038bf5"); + consensus.HardforkTime = std::numeric_limits::max(); + // By default assume that the signatures in ancestors of this block are valid. consensus.defaultAssumeValid = uint256S("0x00000000000000000013176bf8d7dfeab4e1db31dc93bc311b436e82ab226b90"); //453354 @@ -203,6 +205,8 @@ class CTestNetParams : public CChainParams { // The best chain should have at least this much work. consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000001f057509eba81aed91"); + consensus.HardforkTime = std::numeric_limits::max(); + // By default assume that the signatures in ancestors of this block are valid. consensus.defaultAssumeValid = uint256S("0x00000000000128796ee387cf110ccb9d2f36cffaf7f73079c995377c65ac0dcc"); //1079274 @@ -288,6 +292,8 @@ class CRegTestParams : public CChainParams { // The best chain should have at least this much work. consensus.nMinimumChainWork = uint256S("0x00"); + consensus.HardforkTime = std::numeric_limits::max(); + // By default assume that the signatures in ancestors of this block are valid. consensus.defaultAssumeValid = uint256S("0x00"); diff --git a/src/consensus/params.h b/src/consensus/params.h index 6240e82857eb..1c5739cffa4d 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -62,6 +62,10 @@ struct Params { int64_t nPowTargetTimespan; int64_t DifficultyAdjustmentInterval() const { return nPowTargetTimespan / nPowTargetSpacing; } uint256 nMinimumChainWork; + + /** Hardfork parameters */ + int64_t HardforkTime; + uint256 defaultAssumeValid; }; } // namespace Consensus From 681b0c13debf980f03c4d025f2d9b5ed752711f3 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 27 Jun 2017 07:00:19 +0000 Subject: [PATCH 2/2] Replace BIP34: Require height commitment in the generation transactions's locktime instead --- src/validation.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index c9135c442b1a..1a304b22204d 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3021,9 +3021,12 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, const Co } } - // Enforce rule that the coinbase starts with serialized block height - if (nHeight >= consensusParams.BIP34Height) - { + if (block.nTime >= consensusParams.HardforkTime) { + if (block.vtx[0]->nLockTime != (uint32_t)nHeight - 1) { + return state.DoS(100, false, REJECT_INVALID, "bad-cb-height", false, "block height mismatch in coinbase"); + } + } else if (nHeight >= consensusParams.BIP34Height) { + // Enforce rule that the coinbase starts with serialized block height CScript expect = CScript() << nHeight; if (block.vtx[0]->vin[0].scriptSig.size() < expect.size() || !std::equal(expect.begin(), expect.end(), block.vtx[0]->vin[0].scriptSig.begin())) {