Skip to content

Commit 6f53edb

Browse files
committed
Acquire cs_main before ATMP call in block_assemble bench
Otherwise we fail an assert in sync.cpp:AssertLockHeldInternal.
1 parent 63d73f5 commit 6f53edb

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/bench/block_assemble.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,14 @@ static void AssembleBlock(benchmark::State& state)
9797
if (NUM_BLOCKS - b >= COINBASE_MATURITY)
9898
txs.at(b) = MakeTransactionRef(tx);
9999
}
100-
for (const auto& txr : txs) {
101-
CValidationState state;
102-
bool ret{::AcceptToMemoryPool(::mempool, state, txr, nullptr /* pfMissingInputs */, nullptr /* plTxnReplaced */, false /* bypass_limits */, /* nAbsurdFee */ 0)};
103-
assert(ret);
100+
{
101+
LOCK(::cs_main); // Required for ::AcceptToMemoryPool.
102+
103+
for (const auto& txr : txs) {
104+
CValidationState state;
105+
bool ret{::AcceptToMemoryPool(::mempool, state, txr, nullptr /* pfMissingInputs */, nullptr /* plTxnReplaced */, false /* bypass_limits */, /* nAbsurdFee */ 0)};
106+
assert(ret);
107+
}
104108
}
105109

106110
while (state.KeepRunning()) {

0 commit comments

Comments
 (0)