diff --git a/src/consensus/consensus.h b/src/consensus/consensus.h --- a/src/consensus/consensus.h +++ b/src/consensus/consensus.h @@ -18,8 +18,6 @@ static const uint64_t LEGACY_MAX_BLOCK_SIZE = ONE_MEGABYTE; /** Default setting for maximum allowed size for a block, in bytes */ static const uint64_t DEFAULT_MAX_BLOCK_SIZE = 32 * ONE_MEGABYTE; -/** allowed number of signature check operations (sigops) per transaction. */ -static const uint64_t MAX_TX_SIGOPS_COUNT = 20000; /** Allowed number of signature check operations per transaction. */ static const uint64_t MAX_TX_SIGCHECKS = 3000; /** diff --git a/src/consensus/tx_verify.h b/src/consensus/tx_verify.h --- a/src/consensus/tx_verify.h +++ b/src/consensus/tx_verify.h @@ -63,35 +63,4 @@ bool SequenceLocks(const CTransaction &tx, int flags, std::vector *prevHeights, const CBlockIndex &block); -/** - * Count ECDSA signature operations the old-fashioned (pre-0.6) way - * @return number of sigops this transaction's outputs will produce when spent - * @see CTransaction::FetchInputs - */ -uint64_t GetSigOpCountWithoutP2SH(const CTransaction &tx, uint32_t flags); - -/** - * Count ECDSA signature operations in pay-to-script-hash inputs. - * - * @param[in] mapInputs Map of previous transactions that have outputs we're - * spending - * @return maximum number of sigops required to validate this transaction's - * inputs - * @see CTransaction::FetchInputs - */ -uint64_t GetP2SHSigOpCount(const CTransaction &tx, - const CCoinsViewCache &mapInputs, uint32_t flags); - -/** - * Compute total signature operation of a transaction. - * @param[in] tx Transaction for which we are computing the count - * @param[in] inputs Map of previous transactions that have outputs we're - * spending - * @param[in] flags Script verification flags - * @return Total signature operation count of tx - */ -uint64_t GetTransactionSigOpCount(const CTransaction &tx, - const CCoinsViewCache &inputs, - uint32_t flags); - #endif // BITCOIN_CONSENSUS_TX_VERIFY_H diff --git a/src/consensus/tx_verify.cpp b/src/consensus/tx_verify.cpp --- a/src/consensus/tx_verify.cpp +++ b/src/consensus/tx_verify.cpp @@ -152,21 +152,6 @@ block, CalculateSequenceLocks(tx, flags, prevHeights, block)); } -uint64_t GetSigOpCountWithoutP2SH(const CTransaction &tx, uint32_t flags) { - return 0; -} - -uint64_t GetP2SHSigOpCount(const CTransaction &tx, const CCoinsViewCache &view, - uint32_t flags) { - return 0; -} - -uint64_t GetTransactionSigOpCount(const CTransaction &tx, - const CCoinsViewCache &view, uint32_t flags) { - return GetSigOpCountWithoutP2SH(tx, flags) + - GetP2SHSigOpCount(tx, view, flags); -} - namespace Consensus { bool CheckTxInputs(const CTransaction &tx, CValidationState &state, const CCoinsViewCache &inputs, int nSpendHeight, diff --git a/src/policy/policy.h b/src/policy/policy.h --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -43,10 +43,6 @@ */ static const unsigned int MAX_TX_IN_SCRIPT_SIG_SIZE = 1650; -/** - * The maximum number of sigops we're willing to relay/mine in a single tx. - */ -static const unsigned int MAX_STANDARD_TX_SIGOPS = MAX_TX_SIGOPS_COUNT / 5; /** * Default for -maxmempool, maximum megabytes of mempool memory usage. */ diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -513,18 +513,6 @@ break; } } - auto nSigOpsCount = - GetTransactionSigOpCount(tx, view, nextBlockScriptVerifyFlags); - - // Check that the transaction doesn't have an excessive number of - // sigops. - static_assert(MAX_STANDARD_TX_SIGOPS <= MAX_TX_SIGOPS_COUNT, - "we don't want transactions we can't even mine"); - if (nSigOpsCount > MAX_STANDARD_TX_SIGOPS) { - return state.DoS(0, false, REJECT_NONSTANDARD, - "bad-txns-too-many-sigops", false, - strprintf("%d", nSigOpsCount)); - } unsigned int nSize = tx.GetTotalSize(); @@ -553,16 +541,8 @@ return false; } - // After the sigchecks activation we repurpose the 'sigops' tracking in - // mempool/mining to actually track sigchecks instead. (Proper SigOps - // will not need to be counted any more since it's getting deactivated.) - auto nSigChecksOrOps = - (nextBlockScriptVerifyFlags & SCRIPT_REPORT_SIGCHECKS) - ? nSigChecksStandard - : nSigOpsCount; - CTxMemPoolEntry entry(ptx, nFees, nAcceptTime, ::ChainActive().Height(), - fSpendsCoinbase, nSigChecksOrOps, lp); + fSpendsCoinbase, nSigChecksStandard, lp); unsigned int nVirtualSize = entry.GetTxVirtualSize(); @@ -1766,14 +1746,6 @@ REJECT_INVALID, "bad-txns-accumulated-fee-outofrange"); } - // GetTransactionSigOpCount counts 2 types of sigops: - // * legacy (always) - // * p2sh (when P2SH enabled in flags and excludes coinbase) - auto txSigOpsCount = GetTransactionSigOpCount(tx, view, flags); - if (txSigOpsCount > MAX_TX_SIGOPS_COUNT) { - return state.DoS(100, false, REJECT_INVALID, "bad-txn-sigops"); - } - // The following checks do not apply to the coinbase. if (isCoinBase) { continue; @@ -3691,11 +3663,6 @@ const bool fIsMagneticAnomalyEnabled = IsMagneticAnomalyEnabled(params, pindexPrev); - // Note that pindexPrev may be null if reindexing genesis block. - const auto scriptFlags = pindexPrev - ? GetNextBlockScriptFlags(params, pindexPrev) - : SCRIPT_VERIFY_NONE; - // Check transactions: // - canonical ordering // - ensure they are finalized @@ -3727,14 +3694,6 @@ } } - // Count the sigops for the current transaction. If the tx or total - // sigops counts are too high, then the block is invalid. - const auto txSigOps = GetSigOpCountWithoutP2SH(tx, scriptFlags); - if (txSigOps > MAX_TX_SIGOPS_COUNT) { - return state.DoS(100, false, REJECT_INVALID, "bad-txn-sigops", - false, "out-of-bounds SigOpCount"); - } - if (!ContextualCheckTransaction(params, tx, state, nHeight, nLockTimeCutoff, nMedianTimePast)) { // state set by ContextualCheckTransaction.