From 6f53edb395e0020783b6a14cb6476b637c312914 Mon Sep 17 00:00:00 2001 From: James O'Beirne Date: Mon, 30 Jul 2018 11:33:05 -0400 Subject: [PATCH] Acquire cs_main before ATMP call in block_assemble bench Otherwise we fail an assert in sync.cpp:AssertLockHeldInternal. --- src/bench/block_assemble.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/bench/block_assemble.cpp b/src/bench/block_assemble.cpp index 36fa175a76022..9b53c6b023bdf 100644 --- a/src/bench/block_assemble.cpp +++ b/src/bench/block_assemble.cpp @@ -97,10 +97,14 @@ static void AssembleBlock(benchmark::State& state) if (NUM_BLOCKS - b >= COINBASE_MATURITY) txs.at(b) = MakeTransactionRef(tx); } - for (const auto& txr : txs) { - CValidationState state; - bool ret{::AcceptToMemoryPool(::mempool, state, txr, nullptr /* pfMissingInputs */, nullptr /* plTxnReplaced */, false /* bypass_limits */, /* nAbsurdFee */ 0)}; - assert(ret); + { + LOCK(::cs_main); // Required for ::AcceptToMemoryPool. + + for (const auto& txr : txs) { + CValidationState state; + bool ret{::AcceptToMemoryPool(::mempool, state, txr, nullptr /* pfMissingInputs */, nullptr /* plTxnReplaced */, false /* bypass_limits */, /* nAbsurdFee */ 0)}; + assert(ret); + } } while (state.KeepRunning()) {