diff --git a/src/Makefile.test.include b/src/Makefile.test.include --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -174,7 +174,6 @@ test/sighash_tests.cpp \ test/sighashtype_tests.cpp \ test/sigcheckcount_tests.cpp \ - test/sigopcount_tests.cpp \ test/sigutil.h \ test/skiplist_tests.cpp \ test/streams_tests.cpp \ diff --git a/src/script/script.cpp b/src/script/script.cpp --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -371,47 +371,7 @@ } uint32_t CScript::GetSigOpCount(uint32_t flags, bool fAccurate) const { - if (flags & SCRIPT_ZERO_SIGOPS) { - return 0; - } - uint32_t n = 0; - const_iterator pc = begin(); - opcodetype lastOpcode = OP_INVALIDOPCODE; - while (pc < end()) { - opcodetype opcode; - if (!GetOp(pc, opcode)) { - break; - } - - switch (opcode) { - case OP_CHECKSIG: - case OP_CHECKSIGVERIFY: - n++; - break; - - case OP_CHECKDATASIG: - case OP_CHECKDATASIGVERIFY: - if (flags & SCRIPT_VERIFY_CHECKDATASIG_SIGOPS) { - n++; - } - break; - - case OP_CHECKMULTISIG: - case OP_CHECKMULTISIGVERIFY: - if (fAccurate && lastOpcode >= OP_1 && lastOpcode <= OP_16) { - n += DecodeOP_N(lastOpcode); - } else { - n += MAX_PUBKEYS_PER_MULTISIG; - } - break; - default: - break; - } - - lastOpcode = opcode; - } - - return n; + return 0; } uint32_t CScript::GetSigOpCount(uint32_t flags, diff --git a/src/script/script_flags.h b/src/script/script_flags.h --- a/src/script/script_flags.h +++ b/src/script/script_flags.h @@ -110,11 +110,6 @@ // Whether the new OP_REVERSEBYTES opcode can be used. SCRIPT_ENABLE_OP_REVERSEBYTES = (1U << 23), - // Setting this flag zeroes sigops counting and thus results in the removal - // of all sigop limits. This flag only affects sigops counting, and will be - // removed during cleanup of the SigChecks upgrade. - SCRIPT_ZERO_SIGOPS = (1U << 30), - // A utility flag to decide whether VerifyScript should output the correct // sigchecks value or to report zero. // This has no effect on script success / failure, and will be removed diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -175,7 +175,6 @@ sighash_tests.cpp sighashtype_tests.cpp sigcheckcount_tests.cpp - sigopcount_tests.cpp skiplist_tests.cpp streams_tests.cpp sync_tests.cpp diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -331,55 +331,8 @@ const Amount HIGHFEE = COIN; const Amount HIGHERFEE = 4 * COIN; - // block sigops > limit: 1000 CHECKMULTISIG + 1 - tx.vin.resize(1); - // NOTE: OP_NOP is used to force 20 SigOps for the CHECKMULTISIG - tx.vin[0].scriptSig = CScript() << OP_0 << OP_0 << OP_0 << OP_NOP - << OP_CHECKMULTISIG << OP_1; - tx.vin[0].prevout = COutPoint(txFirst[0]->GetId(), 0); - tx.vout.resize(1); - tx.vout[0].nValue = BLOCKSUBSIDY; - for (unsigned int i = 0; i < 1001; ++i) { - tx.vout[0].nValue -= LOWFEE; - const TxId txid = tx.GetId(); - // Only first tx spends coinbase. - bool spendsCoinbase = i == 0; - // If we don't set the # of sig ops in the CTxMemPoolEntry, template - // creation fails. - g_mempool.addUnchecked(entry.Fee(LOWFEE) - .Time(GetTime()) - .SpendsCoinbase(spendsCoinbase) - .FromTx(tx)); - tx.vin[0].prevout = COutPoint(txid, 0); - } - - BOOST_CHECK_EXCEPTION( - AssemblerForTest(chainparams, g_mempool).CreateNewBlock(scriptPubKey), - std::runtime_error, HasReason("bad-blk-sigops")); - g_mempool.clear(); - - tx.vin[0].prevout = COutPoint(txFirst[0]->GetId(), 0); - tx.vout[0].nValue = BLOCKSUBSIDY; - for (unsigned int i = 0; i < 1001; ++i) { - tx.vout[0].nValue -= LOWFEE; - const TxId txid = tx.GetId(); - // Only first tx spends coinbase. - bool spendsCoinbase = i == 0; - // If we do set the # of sig ops in the CTxMemPoolEntry, template - // creation passes. - g_mempool.addUnchecked(entry.Fee(LOWFEE) - .Time(GetTime()) - .SpendsCoinbase(spendsCoinbase) - .SigOpCount(20) - .FromTx(tx)); - tx.vin[0].prevout = COutPoint(txid, 0); - } - - BOOST_CHECK(pblocktemplate = AssemblerForTest(chainparams, g_mempool) - .CreateNewBlock(scriptPubKey)); - g_mempool.clear(); - // block size > limit + tx.vin.resize(1); tx.vin[0].scriptSig = CScript(); // 18 * (520char + DROP) + OP_1 = 9433 bytes std::vector vchData(520); @@ -389,6 +342,7 @@ tx.vin[0].scriptSig << OP_1; tx.vin[0].prevout = COutPoint(txFirst[0]->GetId(), 0); + tx.vout.resize(1); tx.vout[0].nValue = BLOCKSUBSIDY; for (unsigned int i = 0; i < 128; ++i) { tx.vout[0].nValue -= LOWFEE; diff --git a/src/test/script_p2sh_tests.cpp b/src/test/script_p2sh_tests.cpp --- a/src/test/script_p2sh_tests.cpp +++ b/src/test/script_p2sh_tests.cpp @@ -407,64 +407,6 @@ SigHashType().withForkId())); BOOST_CHECK(SignSignature(keystore, CTransaction(txFrom), txTo, 2, SigHashType().withForkId())); - // SignSignature doesn't know how to sign these. We're not testing - // validating signatures, so just create dummy signatures that DO include - // the correct P2SH scripts: - txTo.vin[3].scriptSig << OP_11 << OP_11 - << std::vector(oneAndTwo.begin(), - oneAndTwo.end()); - txTo.vin[4].scriptSig << std::vector(fifteenSigops.begin(), - fifteenSigops.end()); - - BOOST_CHECK(::AreInputsStandard(CTransaction(txTo), coins, - STANDARD_SCRIPT_VERIFY_FLAGS)); - // 22 P2SH sigops for all inputs (1 for vin[0], 6 for vin[3], 15 for vin[4] - BOOST_CHECK_EQUAL(GetP2SHSigOpCount(CTransaction(txTo), coins, - STANDARD_SCRIPT_VERIFY_FLAGS), - 22U); - // Check that no sigops show up when P2SH is not activated. - BOOST_CHECK_EQUAL( - GetP2SHSigOpCount(CTransaction(txTo), coins, SCRIPT_VERIFY_NONE), 0); - - CMutableTransaction txToNonStd1; - txToNonStd1.vout.resize(1); - txToNonStd1.vout[0].scriptPubKey = - GetScriptForDestination(key[1].GetPubKey().GetID()); - txToNonStd1.vout[0].nValue = 1000 * SATOSHI; - txToNonStd1.vin.resize(1); - txToNonStd1.vin[0].prevout = COutPoint(txFrom.GetId(), 5); - txToNonStd1.vin[0].scriptSig - << std::vector(sixteenSigops.begin(), sixteenSigops.end()); - - BOOST_CHECK(!::AreInputsStandard(CTransaction(txToNonStd1), coins, - STANDARD_SCRIPT_VERIFY_FLAGS)); - BOOST_CHECK_EQUAL(GetP2SHSigOpCount(CTransaction(txToNonStd1), coins, - STANDARD_SCRIPT_VERIFY_FLAGS), - 16U); - // Check that no sigops show up when P2SH is not activated. - BOOST_CHECK_EQUAL( - GetP2SHSigOpCount(CTransaction(txToNonStd1), coins, SCRIPT_VERIFY_NONE), - 0); - - CMutableTransaction txToNonStd2; - txToNonStd2.vout.resize(1); - txToNonStd2.vout[0].scriptPubKey = - GetScriptForDestination(key[1].GetPubKey().GetID()); - txToNonStd2.vout[0].nValue = 1000 * SATOSHI; - txToNonStd2.vin.resize(1); - txToNonStd2.vin[0].prevout = COutPoint(txFrom.GetId(), 6); - txToNonStd2.vin[0].scriptSig - << std::vector(twentySigops.begin(), twentySigops.end()); - - BOOST_CHECK(!::AreInputsStandard(CTransaction(txToNonStd2), coins, - STANDARD_SCRIPT_VERIFY_FLAGS)); - BOOST_CHECK_EQUAL(GetP2SHSigOpCount(CTransaction(txToNonStd2), coins, - STANDARD_SCRIPT_VERIFY_FLAGS), - 20U); - // Check that no sigops show up when P2SH is not activated. - BOOST_CHECK_EQUAL( - GetP2SHSigOpCount(CTransaction(txToNonStd2), coins, SCRIPT_VERIFY_NONE), - 0); } BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/sigopcount_tests.cpp b/src/test/sigopcount_tests.cpp deleted file mode 100644 --- a/src/test/sigopcount_tests.cpp +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright (c) 2012-2019 The Bitcoin Core developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include -#include -#include -#include -#include -#include -#include