|
|
|
@ -302,7 +302,7 @@ bool CheckSequenceLocks(CBlockIndex* tip,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Returns the script flags which should be checked for a given block
|
|
|
|
|
static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consensus::Params& chainparams);
|
|
|
|
|
static unsigned int GetBlockScriptFlags(const CBlockIndex& block_index, const Consensus::Params& chainparams);
|
|
|
|
|
|
|
|
|
|
static void LimitMempoolSize(CTxMemPool& pool, CCoinsViewCache& coins_cache, size_t limit, std::chrono::seconds age)
|
|
|
|
|
EXCLUSIVE_LOCKS_REQUIRED(pool.cs, ::cs_main)
|
|
|
|
@ -939,7 +939,7 @@ bool MemPoolAccept::ConsensusScriptChecks(const ATMPArgs& args, Workspace& ws)
|
|
|
|
|
// There is a similar check in CreateNewBlock() to prevent creating
|
|
|
|
|
// invalid blocks (using TestBlockValidity), however allowing such
|
|
|
|
|
// transactions into the mempool can be exploited as a DoS attack.
|
|
|
|
|
unsigned int currentBlockScriptVerifyFlags = GetBlockScriptFlags(m_active_chainstate.m_chain.Tip(), chainparams.GetConsensus());
|
|
|
|
|
unsigned int currentBlockScriptVerifyFlags{GetBlockScriptFlags(*m_active_chainstate.m_chain.Tip(), chainparams.GetConsensus())};
|
|
|
|
|
if (!CheckInputsFromMempoolAndCache(tx, state, m_view, m_pool, currentBlockScriptVerifyFlags,
|
|
|
|
|
ws.m_precomputed_txdata, m_active_chainstate.CoinsTip())) {
|
|
|
|
|
LogPrintf("BUG! PLEASE REPORT THIS! CheckInputScripts failed against latest-block but not STANDARD flags %s, %s\n", hash.ToString(), state.ToString());
|
|
|
|
@ -1579,7 +1579,7 @@ public:
|
|
|
|
|
|
|
|
|
|
static ThresholdConditionCache warningcache[VERSIONBITS_NUM_BITS] GUARDED_BY(cs_main);
|
|
|
|
|
|
|
|
|
|
static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consensus::Params& consensusparams)
|
|
|
|
|
static unsigned int GetBlockScriptFlags(const CBlockIndex& block_index, const Consensus::Params& consensusparams)
|
|
|
|
|
{
|
|
|
|
|
unsigned int flags = SCRIPT_VERIFY_NONE;
|
|
|
|
|
|
|
|
|
@ -1589,35 +1589,35 @@ static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consens
|
|
|
|
|
// mainnet and testnet), so for simplicity, always leave P2SH
|
|
|
|
|
// on except for the one violating block.
|
|
|
|
|
if (consensusparams.BIP16Exception.IsNull() || // no bip16 exception on this chain
|
|
|
|
|
pindex->phashBlock == nullptr || // this is a new candidate block, eg from TestBlockValidity()
|
|
|
|
|
*pindex->phashBlock != consensusparams.BIP16Exception) // this block isn't the historical exception
|
|
|
|
|
block_index.phashBlock == nullptr || // this is a new candidate block, eg from TestBlockValidity()
|
|
|
|
|
*block_index.phashBlock != consensusparams.BIP16Exception) // this block isn't the historical exception
|
|
|
|
|
{
|
|
|
|
|
// Enforce WITNESS rules whenever P2SH is in effect
|
|
|
|
|
flags |= SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_WITNESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Enforce the DERSIG (BIP66) rule
|
|
|
|
|
if (DeploymentActiveAt(*pindex, consensusparams, Consensus::DEPLOYMENT_DERSIG)) {
|
|
|
|
|
if (DeploymentActiveAt(block_index, consensusparams, Consensus::DEPLOYMENT_DERSIG)) {
|
|
|
|
|
flags |= SCRIPT_VERIFY_DERSIG;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Enforce CHECKLOCKTIMEVERIFY (BIP65)
|
|
|
|
|
if (DeploymentActiveAt(*pindex, consensusparams, Consensus::DEPLOYMENT_CLTV)) {
|
|
|
|
|
if (DeploymentActiveAt(block_index, consensusparams, Consensus::DEPLOYMENT_CLTV)) {
|
|
|
|
|
flags |= SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Enforce CHECKSEQUENCEVERIFY (BIP112)
|
|
|
|
|
if (DeploymentActiveAt(*pindex, consensusparams, Consensus::DEPLOYMENT_CSV)) {
|
|
|
|
|
if (DeploymentActiveAt(block_index, consensusparams, Consensus::DEPLOYMENT_CSV)) {
|
|
|
|
|
flags |= SCRIPT_VERIFY_CHECKSEQUENCEVERIFY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Enforce Taproot (BIP340-BIP342)
|
|
|
|
|
if (DeploymentActiveAt(*pindex, consensusparams, Consensus::DEPLOYMENT_TAPROOT)) {
|
|
|
|
|
if (DeploymentActiveAt(block_index, consensusparams, Consensus::DEPLOYMENT_TAPROOT)) {
|
|
|
|
|
flags |= SCRIPT_VERIFY_TAPROOT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Enforce BIP147 NULLDUMMY (activated simultaneously with segwit)
|
|
|
|
|
if (DeploymentActiveAt(*pindex, consensusparams, Consensus::DEPLOYMENT_SEGWIT)) {
|
|
|
|
|
if (DeploymentActiveAt(block_index, consensusparams, Consensus::DEPLOYMENT_SEGWIT)) {
|
|
|
|
|
flags |= SCRIPT_VERIFY_NULLDUMMY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1625,7 +1625,6 @@ static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consens
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int64_t nTimeCheck = 0;
|
|
|
|
|
static int64_t nTimeForks = 0;
|
|
|
|
|
static int64_t nTimeVerify = 0;
|
|
|
|
@ -1811,7 +1810,7 @@ bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get the script flags for this block
|
|
|
|
|
unsigned int flags = GetBlockScriptFlags(pindex, m_params.GetConsensus());
|
|
|
|
|
unsigned int flags{GetBlockScriptFlags(*pindex, m_params.GetConsensus())};
|
|
|
|
|
|
|
|
|
|
int64_t nTime2 = GetTimeMicros(); nTimeForks += nTime2 - nTime1;
|
|
|
|
|
LogPrint(BCLog::BENCH, " - Fork checks: %.2fms [%.2fs (%.2fms/blk)]\n", MILLI * (nTime2 - nTime1), nTimeForks * MICRO, nTimeForks * MILLI / nBlocksTotal);
|
|
|
|
|