mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
Merge 4687832680 into merged_master (Bitcoin PR bitcoin/bitcoin#30425)
This commit is contained in:
commit
3b875eae79
4 changed files with 60 additions and 57 deletions
|
|
@ -2691,15 +2691,6 @@ static unsigned int GetBlockScriptFlags(const CBlockIndex& block_index, const Ch
|
|||
}
|
||||
|
||||
|
||||
static SteadyClock::duration time_check{};
|
||||
static SteadyClock::duration time_forks{};
|
||||
static SteadyClock::duration time_connect{};
|
||||
static SteadyClock::duration time_verify{};
|
||||
static SteadyClock::duration time_undo{};
|
||||
static SteadyClock::duration time_index{};
|
||||
static SteadyClock::duration time_total{};
|
||||
static int64_t num_blocks_total = 0;
|
||||
|
||||
bool CheckPeginRipeness(const CBlock& block, const std::vector<std::pair<CScript, CScript>>& fedpegscripts) {
|
||||
for (unsigned int i = 0; i < block.vtx.size(); i++) {
|
||||
const CTransaction &tx = *(block.vtx[i]);
|
||||
|
|
@ -2755,7 +2746,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
|||
}
|
||||
view.SetBestBlock(pindex->GetBlockHash());
|
||||
}
|
||||
num_blocks_total++;
|
||||
m_chainman.num_blocks_total++;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -2783,7 +2774,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
|||
return false;
|
||||
}
|
||||
|
||||
num_blocks_total++;
|
||||
m_chainman.num_blocks_total++;
|
||||
|
||||
// Check that all non-zero policyAsset coinbase outputs pay to the required destination
|
||||
const CScript& mandatory_coinbase_destination = params.GetConsensus().mandatory_coinbase_destination;
|
||||
|
|
@ -2828,13 +2819,13 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
|||
}
|
||||
}
|
||||
|
||||
assert(num_blocks_total > 0);
|
||||
assert(m_chainman.num_blocks_total > 0);
|
||||
const auto time_1{SteadyClock::now()};
|
||||
time_check += time_1 - time_start;
|
||||
m_chainman.time_check += time_1 - time_start;
|
||||
LogPrint(BCLog::BENCH, " - Sanity checks: %.2fms [%.2fs (%.2fms/blk)]\n",
|
||||
Ticks<MillisecondsDouble>(time_1 - time_start),
|
||||
Ticks<SecondsDouble>(time_check),
|
||||
Ticks<MillisecondsDouble>(time_check) / num_blocks_total);
|
||||
Ticks<SecondsDouble>(m_chainman.time_check),
|
||||
Ticks<MillisecondsDouble>(m_chainman.time_check) / m_chainman.num_blocks_total);
|
||||
|
||||
// Do not allow blocks that contain transactions which 'overwrite' older transactions,
|
||||
// unless those are already completely spent.
|
||||
|
|
@ -2932,11 +2923,11 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
|||
unsigned int flags{GetBlockScriptFlags(*pindex, m_chainman)};
|
||||
|
||||
const auto time_2{SteadyClock::now()};
|
||||
time_forks += time_2 - time_1;
|
||||
m_chainman.time_forks += time_2 - time_1;
|
||||
LogPrint(BCLog::BENCH, " - Fork checks: %.2fms [%.2fs (%.2fms/blk)]\n",
|
||||
Ticks<MillisecondsDouble>(time_2 - time_1),
|
||||
Ticks<SecondsDouble>(time_forks),
|
||||
Ticks<MillisecondsDouble>(time_forks) / num_blocks_total);
|
||||
Ticks<SecondsDouble>(m_chainman.time_forks),
|
||||
Ticks<MillisecondsDouble>(m_chainman.time_forks) / m_chainman.num_blocks_total);
|
||||
|
||||
CBlockUndo blockundo;
|
||||
|
||||
|
|
@ -3056,12 +3047,12 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
|||
|
||||
}
|
||||
const auto time_3{SteadyClock::now()};
|
||||
time_connect += time_3 - time_2;
|
||||
m_chainman.time_connect += time_3 - time_2;
|
||||
LogPrint(BCLog::BENCH, " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs (%.2fms/blk)]\n", (unsigned)block.vtx.size(),
|
||||
Ticks<MillisecondsDouble>(time_3 - time_2), Ticks<MillisecondsDouble>(time_3 - time_2) / block.vtx.size(),
|
||||
nInputs <= 1 ? 0 : Ticks<MillisecondsDouble>(time_3 - time_2) / (nInputs - 1),
|
||||
Ticks<SecondsDouble>(time_connect),
|
||||
Ticks<MillisecondsDouble>(time_connect) / num_blocks_total);
|
||||
Ticks<SecondsDouble>(m_chainman.time_connect),
|
||||
Ticks<MillisecondsDouble>(m_chainman.time_connect) / m_chainman.num_blocks_total);
|
||||
|
||||
CAmountMap block_reward = fee_map;
|
||||
block_reward[consensusParams.subsidy_asset] += GetBlockSubsidy(pindex->nHeight, consensusParams);
|
||||
|
|
@ -3079,12 +3070,12 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
|||
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "block-validation-failed");
|
||||
}
|
||||
const auto time_4{SteadyClock::now()};
|
||||
time_verify += time_4 - time_2;
|
||||
m_chainman.time_verify += time_4 - time_2;
|
||||
LogPrint(BCLog::BENCH, " - Verify %u txins: %.2fms (%.3fms/txin) [%.2fs (%.2fms/blk)]\n", nInputs - 1,
|
||||
Ticks<MillisecondsDouble>(time_4 - time_2),
|
||||
nInputs <= 1 ? 0 : Ticks<MillisecondsDouble>(time_4 - time_2) / (nInputs - 1),
|
||||
Ticks<SecondsDouble>(time_verify),
|
||||
Ticks<MillisecondsDouble>(time_verify) / num_blocks_total);
|
||||
Ticks<SecondsDouble>(m_chainman.time_verify),
|
||||
Ticks<MillisecondsDouble>(m_chainman.time_verify) / m_chainman.num_blocks_total);
|
||||
|
||||
if (fJustCheck)
|
||||
return true;
|
||||
|
|
@ -3094,11 +3085,11 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
|||
}
|
||||
|
||||
const auto time_5{SteadyClock::now()};
|
||||
time_undo += time_5 - time_4;
|
||||
m_chainman.time_undo += time_5 - time_4;
|
||||
LogPrint(BCLog::BENCH, " - Write undo data: %.2fms [%.2fs (%.2fms/blk)]\n",
|
||||
Ticks<MillisecondsDouble>(time_5 - time_4),
|
||||
Ticks<SecondsDouble>(time_undo),
|
||||
Ticks<MillisecondsDouble>(time_undo) / num_blocks_total);
|
||||
Ticks<SecondsDouble>(m_chainman.time_undo),
|
||||
Ticks<MillisecondsDouble>(m_chainman.time_undo) / m_chainman.num_blocks_total);
|
||||
|
||||
if (!pindex->IsValid(BLOCK_VALID_SCRIPTS)) {
|
||||
pindex->RaiseValidity(BLOCK_VALID_SCRIPTS);
|
||||
|
|
@ -3109,11 +3100,11 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
|||
view.SetBestBlock(pindex->GetBlockHash());
|
||||
|
||||
const auto time_6{SteadyClock::now()};
|
||||
time_index += time_6 - time_5;
|
||||
m_chainman.time_index += time_6 - time_5;
|
||||
LogPrint(BCLog::BENCH, " - Index writing: %.2fms [%.2fs (%.2fms/blk)]\n",
|
||||
Ticks<MillisecondsDouble>(time_6 - time_5),
|
||||
Ticks<SecondsDouble>(time_index),
|
||||
Ticks<MillisecondsDouble>(time_index) / num_blocks_total);
|
||||
Ticks<SecondsDouble>(m_chainman.time_index),
|
||||
Ticks<MillisecondsDouble>(m_chainman.time_index) / m_chainman.num_blocks_total);
|
||||
|
||||
TRACE6(validation, block_connected,
|
||||
block_hash.data(),
|
||||
|
|
@ -3539,11 +3530,6 @@ bool Chainstate::DisconnectTip(BlockValidationState& state, DisconnectedBlockTra
|
|||
return true;
|
||||
}
|
||||
|
||||
static SteadyClock::duration time_connect_total{};
|
||||
static SteadyClock::duration time_flush{};
|
||||
static SteadyClock::duration time_chainstate{};
|
||||
static SteadyClock::duration time_post_connect{};
|
||||
|
||||
struct PerBlockConnectTrace {
|
||||
CBlockIndex* pindex = nullptr;
|
||||
std::shared_ptr<const CBlock> pblock;
|
||||
|
|
@ -3642,31 +3628,31 @@ bool Chainstate::ConnectTip(BlockValidationState& state, CBlockIndex* pindexNew,
|
|||
return false;
|
||||
}
|
||||
time_3 = SteadyClock::now();
|
||||
time_connect_total += time_3 - time_2;
|
||||
assert(num_blocks_total > 0);
|
||||
m_chainman.time_connect_total += time_3 - time_2;
|
||||
assert(m_chainman.num_blocks_total > 0);
|
||||
LogPrint(BCLog::BENCH, " - Connect total: %.2fms [%.2fs (%.2fms/blk)]\n",
|
||||
Ticks<MillisecondsDouble>(time_3 - time_2),
|
||||
Ticks<SecondsDouble>(time_connect_total),
|
||||
Ticks<MillisecondsDouble>(time_connect_total) / num_blocks_total);
|
||||
Ticks<SecondsDouble>(m_chainman.time_connect_total),
|
||||
Ticks<MillisecondsDouble>(m_chainman.time_connect_total) / m_chainman.num_blocks_total);
|
||||
bool flushed = view.Flush();
|
||||
assert(flushed);
|
||||
}
|
||||
const auto time_4{SteadyClock::now()};
|
||||
time_flush += time_4 - time_3;
|
||||
m_chainman.time_flush += time_4 - time_3;
|
||||
LogPrint(BCLog::BENCH, " - Flush: %.2fms [%.2fs (%.2fms/blk)]\n",
|
||||
Ticks<MillisecondsDouble>(time_4 - time_3),
|
||||
Ticks<SecondsDouble>(time_flush),
|
||||
Ticks<MillisecondsDouble>(time_flush) / num_blocks_total);
|
||||
Ticks<SecondsDouble>(m_chainman.time_flush),
|
||||
Ticks<MillisecondsDouble>(m_chainman.time_flush) / m_chainman.num_blocks_total);
|
||||
// Write the chain state to disk, if necessary.
|
||||
if (!FlushStateToDisk(state, FlushStateMode::IF_NEEDED)) {
|
||||
return false;
|
||||
}
|
||||
const auto time_5{SteadyClock::now()};
|
||||
time_chainstate += time_5 - time_4;
|
||||
m_chainman.time_chainstate += time_5 - time_4;
|
||||
LogPrint(BCLog::BENCH, " - Writing chainstate: %.2fms [%.2fs (%.2fms/blk)]\n",
|
||||
Ticks<MillisecondsDouble>(time_5 - time_4),
|
||||
Ticks<SecondsDouble>(time_chainstate),
|
||||
Ticks<MillisecondsDouble>(time_chainstate) / num_blocks_total);
|
||||
Ticks<SecondsDouble>(m_chainman.time_chainstate),
|
||||
Ticks<MillisecondsDouble>(m_chainman.time_chainstate) / m_chainman.num_blocks_total);
|
||||
// Remove conflicting transactions from the mempool.;
|
||||
if (m_mempool) {
|
||||
// ELEMENTS: We also eject peg-outs with now-invalid PAK proofs
|
||||
|
|
@ -3679,16 +3665,16 @@ bool Chainstate::ConnectTip(BlockValidationState& state, CBlockIndex* pindexNew,
|
|||
UpdateTip(pindexNew);
|
||||
|
||||
const auto time_6{SteadyClock::now()};
|
||||
time_post_connect += time_6 - time_5;
|
||||
time_total += time_6 - time_1;
|
||||
m_chainman.time_post_connect += time_6 - time_5;
|
||||
m_chainman.time_total += time_6 - time_1;
|
||||
LogPrint(BCLog::BENCH, " - Connect postprocess: %.2fms [%.2fs (%.2fms/blk)]\n",
|
||||
Ticks<MillisecondsDouble>(time_6 - time_5),
|
||||
Ticks<SecondsDouble>(time_post_connect),
|
||||
Ticks<MillisecondsDouble>(time_post_connect) / num_blocks_total);
|
||||
Ticks<SecondsDouble>(m_chainman.time_post_connect),
|
||||
Ticks<MillisecondsDouble>(m_chainman.time_post_connect) / m_chainman.num_blocks_total);
|
||||
LogPrint(BCLog::BENCH, "- Connect block: %.2fms [%.2fs (%.2fms/blk)]\n",
|
||||
Ticks<MillisecondsDouble>(time_6 - time_1),
|
||||
Ticks<SecondsDouble>(time_total),
|
||||
Ticks<MillisecondsDouble>(time_total) / num_blocks_total);
|
||||
Ticks<SecondsDouble>(m_chainman.time_total),
|
||||
Ticks<MillisecondsDouble>(m_chainman.time_total) / m_chainman.num_blocks_total);
|
||||
|
||||
// If we are the background validation chainstate, check to see if we are done
|
||||
// validating the snapshot (i.e. our tip has reached the snapshot's base block).
|
||||
|
|
@ -3885,16 +3871,15 @@ static bool NotifyHeaderTip(ChainstateManager& chainman) LOCKS_EXCLUDED(cs_main)
|
|||
{
|
||||
bool fNotify = false;
|
||||
bool fInitialBlockDownload = false;
|
||||
static CBlockIndex* pindexHeaderOld = nullptr;
|
||||
CBlockIndex* pindexHeader = nullptr;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
pindexHeader = chainman.m_best_header;
|
||||
|
||||
if (pindexHeader != pindexHeaderOld) {
|
||||
if (pindexHeader != chainman.m_last_notified_header) {
|
||||
fNotify = true;
|
||||
fInitialBlockDownload = chainman.IsInitialBlockDownload();
|
||||
pindexHeaderOld = pindexHeader;
|
||||
chainman.m_last_notified_header = pindexHeader;
|
||||
}
|
||||
}
|
||||
// Send block tip changed notifications without cs_main
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue