diff --git a/src/chainparams.cpp b/src/chainparams.cpp --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -145,7 +145,7 @@ "000000000000000001d2ce557406b017a928be25ee98906397d339c3f68eec5d"); // August 1, 2017 hard fork - consensus.uahfHeight = 478559; + consensus.uahfHeight = 478558; // November 13, 2017 hard fork consensus.daaHeight = 504031; @@ -220,38 +220,38 @@ checkpointData = { .mapCheckpoints = { - {11111, uint256S("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2" - "ee92559f542fdb26e7c1d")}, - {33333, uint256S("0x000000002dd5588a74784eaa7ab0507a18ad16a236e" - "7b1ce69f00d7ddfb5d0a6")}, - {74000, uint256S("0x0000000000573993a3c9e41ce34471c079dcf5f52a0" - "e824a81e7f953b8661a20")}, - {105000, uint256S("0x00000000000291ce28027faea320c8d2b054b2e0fe" - "44a773f3eefb151d6bdc97")}, - {134444, uint256S("0x00000000000005b12ffd4cd315cd34ffd4a594f430" - "ac814c91184a0d42d2b0fe")}, - {168000, uint256S("0x000000000000099e61ea72015e79632f216fe6cb33" - "d7899acb35b75c8303b763")}, - {193000, uint256S("0x000000000000059f452a5f7340de6682a977387c17" - "010ff6e6c3bd83ca8b1317")}, - {210000, uint256S("0x000000000000048b95347e83192f69cf0366076336" - "c639f9b7228e9ba171342e")}, - {216116, uint256S("0x00000000000001b4f4b433e81ee46494af945cf960" - "14816a4e2370f11b23df4e")}, - {225430, uint256S("0x00000000000001c108384350f74090433e7fcf79a6" - "06b8e797f065b130575932")}, - {250000, uint256S("0x000000000000003887df1f29024b06fc2200b55f8a" - "f8f35453d7be294df2d214")}, - {279000, uint256S("0x0000000000000001ae8c72a0b0c301f67e3afca10e" - "819efa9041e458e9bd7e40")}, - {295000, uint256S("0x00000000000000004d9b4ef50f0f9d686fd69db2e0" - "3af35a100370c64632a983")}, + {11111, uint256S("0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee" + "92559f542fdb26e7c1d")}, + {33333, uint256S("000000002dd5588a74784eaa7ab0507a18ad16a236e7b" + "1ce69f00d7ddfb5d0a6")}, + {74000, uint256S("0000000000573993a3c9e41ce34471c079dcf5f52a0e8" + "24a81e7f953b8661a20")}, + {105000, uint256S("00000000000291ce28027faea320c8d2b054b2e0fe44" + "a773f3eefb151d6bdc97")}, + {134444, uint256S("00000000000005b12ffd4cd315cd34ffd4a594f430ac" + "814c91184a0d42d2b0fe")}, + {168000, uint256S("000000000000099e61ea72015e79632f216fe6cb33d7" + "899acb35b75c8303b763")}, + {193000, uint256S("000000000000059f452a5f7340de6682a977387c1701" + "0ff6e6c3bd83ca8b1317")}, + {210000, uint256S("000000000000048b95347e83192f69cf0366076336c6" + "39f9b7228e9ba171342e")}, + {216116, uint256S("00000000000001b4f4b433e81ee46494af945cf96014" + "816a4e2370f11b23df4e")}, + {225430, uint256S("00000000000001c108384350f74090433e7fcf79a606" + "b8e797f065b130575932")}, + {250000, uint256S("000000000000003887df1f29024b06fc2200b55f8af8" + "f35453d7be294df2d214")}, + {279000, uint256S("0000000000000001ae8c72a0b0c301f67e3afca10e81" + "9efa9041e458e9bd7e40")}, + {295000, uint256S("00000000000000004d9b4ef50f0f9d686fd69db2e03a" + "f35a100370c64632a983")}, // UAHF fork block. - {478559, uint256S("0x000000000000000000651ef99cb9fcbe0dadde1d42" - "4bd9f15ff20136191a5eec")}, + {478558, uint256S("0000000000000000011865af4122fe3b144e2cbeea86" + "142e8ff2fb4107352d43")}, // Nov, 13 DAA activation block. - {504031, uint256S("0x0000000000000000011ebf65b60d0a3de80b8175be" - "709d653b4c1a1beeb6ab9c")}, + {504031, uint256S("0000000000000000011ebf65b60d0a3de80b8175be70" + "9d653b4c1a1beeb6ab9c")}, }}; // Data as of block diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -194,8 +194,8 @@ static void FindFilesToPrune(std::set<int> &setFilesToPrune, uint64_t nPruneAfterHeight); static FILE *OpenUndoFile(const CDiskBlockPos &pos, bool fReadOnly = false); -static uint32_t GetBlockScriptFlags(const CBlockIndex *pindex, - const Config &config); +static uint32_t GetBlockScriptFlags(const Config &config, + const CBlockIndex *pChainTip); static bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime) { @@ -986,7 +986,7 @@ } // Set extraFlags as a set of flags that needs to be activated. - uint32_t extraFlags = 0; + uint32_t extraFlags = SCRIPT_VERIFY_NONE; if (hasMonolith) { extraFlags |= SCRIPT_ENABLE_MONOLITH_OPCODES; } @@ -1031,12 +1031,8 @@ // invalid blocks (using TestBlockValidity), however allowing such // transactions into the mempool can be exploited as a DoS attack. uint32_t currentBlockScriptVerifyFlags = - GetBlockScriptFlags(chainActive.Tip(), config); + GetBlockScriptFlags(config, chainActive.Tip()); - // We have an off by one error for flag activation. As a result, we need - // to set the replay protection flag manually here until this is fixed. - // FIXME: https://reviews.bitcoinabc.org/T288 - currentBlockScriptVerifyFlags |= extraFlags; if (!CheckInputsFromMempoolAndCache(tx, state, view, pool, currentBlockScriptVerifyFlags, true, txdata)) { @@ -1903,38 +1899,37 @@ static ThresholdConditionCache warningcache[VERSIONBITS_NUM_BITS]; // Returns the script flags which should be checked for a given block -static uint32_t GetBlockScriptFlags(const CBlockIndex *pindex, - const Config &config) { +static uint32_t GetBlockScriptFlags(const Config &config, + const CBlockIndex *pChainTip) { AssertLockHeld(cs_main); const Consensus::Params &consensusparams = config.GetChainParams().GetConsensus(); - // P2SH didn't become active until Apr 1 2012 - bool fStrictPayToScriptHash = - (pindex->pprev->GetMedianTimePast() >= P2SH_ACTIVATION_TIME); + uint32_t flags = SCRIPT_VERIFY_NONE; - uint32_t flags = - fStrictPayToScriptHash ? SCRIPT_VERIFY_P2SH : SCRIPT_VERIFY_NONE; + // P2SH didn't become active until Apr 1 2012 + if (pChainTip->GetMedianTimePast() >= P2SH_ACTIVATION_TIME) { + flags |= SCRIPT_VERIFY_P2SH; + } // Start enforcing the DERSIG (BIP66) rule - if ((pindex->pprev->nHeight + 1) >= consensusparams.BIP66Height) { + if ((pChainTip->nHeight + 1) >= consensusparams.BIP66Height) { flags |= SCRIPT_VERIFY_DERSIG; } // Start enforcing CHECKLOCKTIMEVERIFY (BIP65) rule - if ((pindex->pprev->nHeight + 1) >= consensusparams.BIP65Height) { + if ((pChainTip->nHeight + 1) >= consensusparams.BIP65Height) { flags |= SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY; } // Start enforcing BIP112 (CHECKSEQUENCEVERIFY) using versionbits logic. - if (VersionBitsState(pindex->pprev, consensusparams, - Consensus::DEPLOYMENT_CSV, + if (VersionBitsState(pChainTip, consensusparams, Consensus::DEPLOYMENT_CSV, versionbitscache) == THRESHOLD_ACTIVE) { flags |= SCRIPT_VERIFY_CHECKSEQUENCEVERIFY; } // If the UAHF is enabled, we start accepting replay protected txns - if (IsUAHFenabled(config, pindex->pprev)) { + if (IsUAHFenabled(config, pChainTip)) { flags |= SCRIPT_VERIFY_STRICTENC; flags |= SCRIPT_ENABLE_SIGHASH_FORKID; } @@ -1943,19 +1938,19 @@ // s in their signature. We also make sure that signature that are supposed // to fail (for instance in multisig or other forms of smart contracts) are // null. - if (IsDAAEnabled(config, pindex->pprev)) { + if (IsDAAEnabled(config, pChainTip)) { flags |= SCRIPT_VERIFY_LOW_S; flags |= SCRIPT_VERIFY_NULLFAIL; } // The monolith HF enable a set of opcodes. - if (IsMonolithEnabled(config, pindex->pprev)) { + if (IsMonolithEnabled(config, pChainTip)) { flags |= SCRIPT_ENABLE_MONOLITH_OPCODES; } // We make sure this node will have replay protection during the next hard // fork. - if (IsReplayProtectionEnabled(config, pindex->pprev)) { + if (IsReplayProtectionEnabled(config, pChainTip)) { flags |= SCRIPT_ENABLE_REPLAY_PROTECTION; } @@ -2112,9 +2107,7 @@ nLockTimeFlags |= LOCKTIME_VERIFY_SEQUENCE; } - // FIXME: This should be called with pindex->pprev, to match the result - // given to AcceptToMemoryPoolWorker: https://reviews.bitcoinabc.org/T288 - const uint32_t flags = GetBlockScriptFlags(pindex, config); + const uint32_t flags = GetBlockScriptFlags(config, pindex->pprev); int64_t nTime2 = GetTimeMicros(); nTimeForks += nTime2 - nTime1;