Skip to content

Commit a7a3659

Browse files
committed
Merge bitcoin/bitcoin#25223: [kernel 2e/n] miner: Make mempool optional, stop constructing temporary empty mempools
0f1a259 miner: Make mempool optional for BlockAssembler (Carl Dong) cc5739b miner: Make UpdatePackagesForAdded static (Carl Dong) f024578 miner: Absorb SkipMapTxEntry into addPackageTxs (Carl Dong) Pull request description: This is part of the libbitcoinkernel project: #24303, https://github.com/bitcoin/bitcoin/projects/18 This is **_NOT_** dependent on, but is a "companion-PR" to #25215. ### Abstract This PR removes the need to construct `BlockAssembler` with temporary, empty mempools in cases where we don't want to source transactions from the mempool (e.g. in `TestChain100Setup::CreateBlock` and `generateblock`). After this PR, `BlockAssembler` will accept a `CTxMemPool` pointer and handle the `nullptr` case instead of requiring a `CTxMemPool` reference. An overview of the changes is best seen in the changes in the header file: ```diff diff --git a/src/node/miner.h b/src/node/miner.h index 7cf8e3f..7e9f503602 100644 --- a/src/node/miner.h +++ b/src/node/miner.h @@ -147,7 +147,7 @@ private: int64_t m_lock_time_cutoff; const CChainParams& chainparams; - const CTxMemPool& m_mempool; + const CTxMemPool* m_mempool; CChainState& m_chainstate; public: @@ -157,8 +157,8 @@ public: CFeeRate blockMinFeeRate; }; - explicit BlockAssembler(CChainState& chainstate, const CTxMemPool& mempool); - explicit BlockAssembler(CChainState& chainstate, const CTxMemPool& mempool, const Options& options); + explicit BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool); + explicit BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool, const Options& options); /** Construct a new block template with coinbase to scriptPubKeyIn */ std::unique_ptr<CBlockTemplate> CreateNewBlock(const CScript& scriptPubKeyIn); @@ -177,7 +177,7 @@ private: /** Add transactions based on feerate including unconfirmed ancestors * Increments nPackagesSelected / nDescendantsUpdated with corresponding * statistics from the package selection (for logging statistics). */ - void addPackageTxs(int& nPackagesSelected, int& nDescendantsUpdated) EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs); + void addPackageTxs(const CTxMemPool& mempool, int& nPackagesSelected, int& nDescendantsUpdated) EXCLUSIVE_LOCKS_REQUIRED(mempool.cs); // helper functions for addPackageTxs() /** Remove confirmed (inBlock) entries from given set */ @@ -189,15 +189,8 @@ private: * These checks should always succeed, and they're here * only as an extra check in case of suboptimal node configuration */ bool TestPackageTransactions(const CTxMemPool::setEntries& package) const; - /** Return true if given transaction from mapTx has already been evaluated, - * or if the transaction's cached data in mapTx is incorrect. */ - bool SkipMapTxEntry(CTxMemPool::txiter it, indexed_modified_transaction_set& mapModifiedTx, CTxMemPool::setEntries& failedTx) EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs); /** Sort the package in an order that is valid to appear in a block */ void SortForBlock(const CTxMemPool::setEntries& package, std::vector<CTxMemPool::txiter>& sortedEntries); - /** Add descendants of given transactions to mapModifiedTx with ancestor - * state updated assuming given transactions are inBlock. Returns number - * of updated descendants. */ - int UpdatePackagesForAdded(const CTxMemPool::setEntries& alreadyAdded, indexed_modified_transaction_set& mapModifiedTx) EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs); }; int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev); ``` ### Alternatives Aside from approach in this current PR, we can also take the approach of moving the `CTxMemPool*` argument from the `BlockAssembler` constructor to `BlockAssembler::CreateNewBlock`, since that's where it's needed anyway. I did not push this approach because it requires quite a lot of call sites to be changed. However, I do have it coded up and can do that if people express a strong preference. This would look something like: ``` BlockAssembler::BlockAssembler(CChainState& chainstate, const Options& options); BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn, const CTxMemPool* maybe_mempool); ``` ### Future work Although wholly out of scope for this PR, we could potentially refine the `BlockAssembler` interface further, so that we have: ``` BlockAssembler::BlockAssembler(CChainState& chainstate, const Options& options); BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn, std::vector<CTransaction>& txs); BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn, const CTxMemPool& mempool); ``` Whereby `TestChain100Setup::CreateBlock` and `generateblock` would call the `BlockAssembler::CreateNewBlock` that takes in `CTransaction`s and we can potentially remove `RegenerateCommitments` altogether. All other callers can use the `CTxMemPool` version. ACKs for top commit: glozow: ACK 0f1a259 laanwj: Code review ACK 0f1a259 MarcoFalke: ACK 0f1a259 🐊 Tree-SHA512: 2b4b1dbb43d85719f241ad1f19ceb7fc50cf764721da425a3d1ff71bd16328c4f86acff22e565bc9abee770d3ac8827a6676b66daa93dbf42dd817ad929e9448
2 parents fa07ee1 + 0f1a259 commit a7a3659

File tree

9 files changed

+56
-60
lines changed

9 files changed

+56
-60
lines changed

src/node/miner.cpp

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ BlockAssembler::Options::Options()
6262
nBlockMaxWeight = DEFAULT_BLOCK_MAX_WEIGHT;
6363
}
6464

65-
BlockAssembler::BlockAssembler(CChainState& chainstate, const CTxMemPool& mempool, const Options& options)
65+
BlockAssembler::BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool, const Options& options)
6666
: chainparams{chainstate.m_chainman.GetParams()},
6767
m_mempool(mempool),
6868
m_chainstate(chainstate)
@@ -87,7 +87,7 @@ static BlockAssembler::Options DefaultOptions()
8787
return options;
8888
}
8989

90-
BlockAssembler::BlockAssembler(CChainState& chainstate, const CTxMemPool& mempool)
90+
BlockAssembler::BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool)
9191
: BlockAssembler(chainstate, mempool, DefaultOptions()) {}
9292

9393
void BlockAssembler::resetBlock()
@@ -121,7 +121,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
121121
pblocktemplate->vTxFees.push_back(-1); // updated at end
122122
pblocktemplate->vTxSigOpsCost.push_back(-1); // updated at end
123123

124-
LOCK2(cs_main, m_mempool.cs);
124+
LOCK(::cs_main);
125125
CBlockIndex* pindexPrev = m_chainstate.m_chain.Tip();
126126
assert(pindexPrev != nullptr);
127127
nHeight = pindexPrev->nHeight + 1;
@@ -138,7 +138,10 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
138138

139139
int nPackagesSelected = 0;
140140
int nDescendantsUpdated = 0;
141-
addPackageTxs(nPackagesSelected, nDescendantsUpdated);
141+
if (m_mempool) {
142+
LOCK(m_mempool->cs);
143+
addPackageTxs(*m_mempool, nPackagesSelected, nDescendantsUpdated);
144+
}
142145

143146
int64_t nTime1 = GetTimeMicros();
144147

@@ -232,15 +235,19 @@ void BlockAssembler::AddToBlock(CTxMemPool::txiter iter)
232235
}
233236
}
234237

235-
int BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& alreadyAdded,
236-
indexed_modified_transaction_set &mapModifiedTx)
238+
/** Add descendants of given transactions to mapModifiedTx with ancestor
239+
* state updated assuming given transactions are inBlock. Returns number
240+
* of updated descendants. */
241+
static int UpdatePackagesForAdded(const CTxMemPool& mempool,
242+
const CTxMemPool::setEntries& alreadyAdded,
243+
indexed_modified_transaction_set& mapModifiedTx) EXCLUSIVE_LOCKS_REQUIRED(mempool.cs)
237244
{
238-
AssertLockHeld(m_mempool.cs);
245+
AssertLockHeld(mempool.cs);
239246

240247
int nDescendantsUpdated = 0;
241248
for (CTxMemPool::txiter it : alreadyAdded) {
242249
CTxMemPool::setEntries descendants;
243-
m_mempool.CalculateDescendants(it, descendants);
250+
mempool.CalculateDescendants(it, descendants);
244251
// Insert all descendants (not yet in block) into the modified set
245252
for (CTxMemPool::txiter desc : descendants) {
246253
if (alreadyAdded.count(desc)) {
@@ -262,23 +269,6 @@ int BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& already
262269
return nDescendantsUpdated;
263270
}
264271

265-
// Skip entries in mapTx that are already in a block or are present
266-
// in mapModifiedTx (which implies that the mapTx ancestor state is
267-
// stale due to ancestor inclusion in the block)
268-
// Also skip transactions that we've already failed to add. This can happen if
269-
// we consider a transaction in mapModifiedTx and it fails: we can then
270-
// potentially consider it again while walking mapTx. It's currently
271-
// guaranteed to fail again, but as a belt-and-suspenders check we put it in
272-
// failedTx and avoid re-evaluation, since the re-evaluation would be using
273-
// cached size/sigops/fee values that are not actually correct.
274-
bool BlockAssembler::SkipMapTxEntry(CTxMemPool::txiter it, indexed_modified_transaction_set& mapModifiedTx, CTxMemPool::setEntries& failedTx)
275-
{
276-
AssertLockHeld(m_mempool.cs);
277-
278-
assert(it != m_mempool.mapTx.end());
279-
return mapModifiedTx.count(it) || inBlock.count(it) || failedTx.count(it);
280-
}
281-
282272
void BlockAssembler::SortForBlock(const CTxMemPool::setEntries& package, std::vector<CTxMemPool::txiter>& sortedEntries)
283273
{
284274
// Sort package by ancestor count
@@ -300,17 +290,17 @@ void BlockAssembler::SortForBlock(const CTxMemPool::setEntries& package, std::ve
300290
// Each time through the loop, we compare the best transaction in
301291
// mapModifiedTxs with the next transaction in the mempool to decide what
302292
// transaction package to work on next.
303-
void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpdated)
293+
void BlockAssembler::addPackageTxs(const CTxMemPool& mempool, int& nPackagesSelected, int& nDescendantsUpdated)
304294
{
305-
AssertLockHeld(m_mempool.cs);
295+
AssertLockHeld(mempool.cs);
306296

307297
// mapModifiedTx will store sorted packages after they are modified
308298
// because some of their txs are already in the block
309299
indexed_modified_transaction_set mapModifiedTx;
310300
// Keep track of entries that failed inclusion, to avoid duplicate work
311301
CTxMemPool::setEntries failedTx;
312302

313-
CTxMemPool::indexed_transaction_set::index<ancestor_score>::type::iterator mi = m_mempool.mapTx.get<ancestor_score>().begin();
303+
CTxMemPool::indexed_transaction_set::index<ancestor_score>::type::iterator mi = mempool.mapTx.get<ancestor_score>().begin();
314304
CTxMemPool::txiter iter;
315305

316306
// Limit the number of attempts to add transactions to the block when it is
@@ -319,26 +309,41 @@ void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpda
319309
const int64_t MAX_CONSECUTIVE_FAILURES = 1000;
320310
int64_t nConsecutiveFailed = 0;
321311

322-
while (mi != m_mempool.mapTx.get<ancestor_score>().end() || !mapModifiedTx.empty()) {
312+
while (mi != mempool.mapTx.get<ancestor_score>().end() || !mapModifiedTx.empty()) {
323313
// First try to find a new transaction in mapTx to evaluate.
324-
if (mi != m_mempool.mapTx.get<ancestor_score>().end() &&
325-
SkipMapTxEntry(m_mempool.mapTx.project<0>(mi), mapModifiedTx, failedTx)) {
326-
++mi;
327-
continue;
314+
//
315+
// Skip entries in mapTx that are already in a block or are present
316+
// in mapModifiedTx (which implies that the mapTx ancestor state is
317+
// stale due to ancestor inclusion in the block)
318+
// Also skip transactions that we've already failed to add. This can happen if
319+
// we consider a transaction in mapModifiedTx and it fails: we can then
320+
// potentially consider it again while walking mapTx. It's currently
321+
// guaranteed to fail again, but as a belt-and-suspenders check we put it in
322+
// failedTx and avoid re-evaluation, since the re-evaluation would be using
323+
// cached size/sigops/fee values that are not actually correct.
324+
/** Return true if given transaction from mapTx has already been evaluated,
325+
* or if the transaction's cached data in mapTx is incorrect. */
326+
if (mi != mempool.mapTx.get<ancestor_score>().end()) {
327+
auto it = mempool.mapTx.project<0>(mi);
328+
assert(it != mempool.mapTx.end());
329+
if (mapModifiedTx.count(it) || inBlock.count(it) || failedTx.count(it)) {
330+
++mi;
331+
continue;
332+
}
328333
}
329334

330335
// Now that mi is not stale, determine which transaction to evaluate:
331336
// the next entry from mapTx, or the best from mapModifiedTx?
332337
bool fUsingModified = false;
333338

334339
modtxscoreiter modit = mapModifiedTx.get<ancestor_score>().begin();
335-
if (mi == m_mempool.mapTx.get<ancestor_score>().end()) {
340+
if (mi == mempool.mapTx.get<ancestor_score>().end()) {
336341
// We're out of entries in mapTx; use the entry from mapModifiedTx
337342
iter = modit->iter;
338343
fUsingModified = true;
339344
} else {
340345
// Try to compare the mapTx entry to the mapModifiedTx entry
341-
iter = m_mempool.mapTx.project<0>(mi);
346+
iter = mempool.mapTx.project<0>(mi);
342347
if (modit != mapModifiedTx.get<ancestor_score>().end() &&
343348
CompareTxMemPoolEntryByAncestorFee()(*modit, CTxMemPoolModifiedEntry(iter))) {
344349
// The best entry in mapModifiedTx has higher score
@@ -393,7 +398,7 @@ void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpda
393398
CTxMemPool::setEntries ancestors;
394399
uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
395400
std::string dummy;
396-
m_mempool.CalculateMemPoolAncestors(*iter, ancestors, nNoLimit, nNoLimit, nNoLimit, nNoLimit, dummy, false);
401+
mempool.CalculateMemPoolAncestors(*iter, ancestors, nNoLimit, nNoLimit, nNoLimit, nNoLimit, dummy, false);
397402

398403
onlyUnconfirmed(ancestors);
399404
ancestors.insert(iter);
@@ -423,7 +428,7 @@ void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpda
423428
++nPackagesSelected;
424429

425430
// Update transactions that depend on each of these
426-
nDescendantsUpdated += UpdatePackagesForAdded(ancestors, mapModifiedTx);
431+
nDescendantsUpdated += UpdatePackagesForAdded(mempool, ancestors, mapModifiedTx);
427432
}
428433
}
429434
} // namespace node

src/node/miner.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class BlockAssembler
147147
int64_t m_lock_time_cutoff;
148148

149149
const CChainParams& chainparams;
150-
const CTxMemPool& m_mempool;
150+
const CTxMemPool* const m_mempool;
151151
CChainState& m_chainstate;
152152

153153
public:
@@ -157,8 +157,8 @@ class BlockAssembler
157157
CFeeRate blockMinFeeRate;
158158
};
159159

160-
explicit BlockAssembler(CChainState& chainstate, const CTxMemPool& mempool);
161-
explicit BlockAssembler(CChainState& chainstate, const CTxMemPool& mempool, const Options& options);
160+
explicit BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool);
161+
explicit BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool, const Options& options);
162162

163163
/** Construct a new block template with coinbase to scriptPubKeyIn */
164164
std::unique_ptr<CBlockTemplate> CreateNewBlock(const CScript& scriptPubKeyIn);
@@ -177,7 +177,7 @@ class BlockAssembler
177177
/** Add transactions based on feerate including unconfirmed ancestors
178178
* Increments nPackagesSelected / nDescendantsUpdated with corresponding
179179
* statistics from the package selection (for logging statistics). */
180-
void addPackageTxs(int& nPackagesSelected, int& nDescendantsUpdated) EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs);
180+
void addPackageTxs(const CTxMemPool& mempool, int& nPackagesSelected, int& nDescendantsUpdated) EXCLUSIVE_LOCKS_REQUIRED(mempool.cs);
181181

182182
// helper functions for addPackageTxs()
183183
/** Remove confirmed (inBlock) entries from given set */
@@ -189,15 +189,8 @@ class BlockAssembler
189189
* These checks should always succeed, and they're here
190190
* only as an extra check in case of suboptimal node configuration */
191191
bool TestPackageTransactions(const CTxMemPool::setEntries& package) const;
192-
/** Return true if given transaction from mapTx has already been evaluated,
193-
* or if the transaction's cached data in mapTx is incorrect. */
194-
bool SkipMapTxEntry(CTxMemPool::txiter it, indexed_modified_transaction_set& mapModifiedTx, CTxMemPool::setEntries& failedTx) EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs);
195192
/** Sort the package in an order that is valid to appear in a block */
196193
void SortForBlock(const CTxMemPool::setEntries& package, std::vector<CTxMemPool::txiter>& sortedEntries);
197-
/** Add descendants of given transactions to mapModifiedTx with ancestor
198-
* state updated assuming given transactions are inBlock. Returns number
199-
* of updated descendants. */
200-
int UpdatePackagesForAdded(const CTxMemPool::setEntries& alreadyAdded, indexed_modified_transaction_set& mapModifiedTx) EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs);
201194
};
202195

203196
int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev);

src/rpc/mining.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static UniValue generateBlocks(ChainstateManager& chainman, const CTxMemPool& me
144144
{
145145
UniValue blockHashes(UniValue::VARR);
146146
while (nGenerate > 0 && !ShutdownRequested()) {
147-
std::unique_ptr<CBlockTemplate> pblocktemplate(BlockAssembler{chainman.ActiveChainstate(), mempool}.CreateNewBlock(coinbase_script));
147+
std::unique_ptr<CBlockTemplate> pblocktemplate(BlockAssembler{chainman.ActiveChainstate(), &mempool}.CreateNewBlock(coinbase_script));
148148
if (!pblocktemplate.get())
149149
throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block");
150150
CBlock *pblock = &pblocktemplate->block;
@@ -354,8 +354,7 @@ static RPCHelpMan generateblock()
354354
{
355355
LOCK(cs_main);
356356

357-
CTxMemPool empty_mempool;
358-
std::unique_ptr<CBlockTemplate> blocktemplate(BlockAssembler{chainman.ActiveChainstate(), empty_mempool}.CreateNewBlock(coinbase_script));
357+
std::unique_ptr<CBlockTemplate> blocktemplate(BlockAssembler{chainman.ActiveChainstate(), nullptr}.CreateNewBlock(coinbase_script));
359358
if (!blocktemplate) {
360359
throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block");
361360
}
@@ -753,7 +752,7 @@ static RPCHelpMan getblocktemplate()
753752

754753
// Create new block
755754
CScript scriptDummy = CScript() << OP_TRUE;
756-
pblocktemplate = BlockAssembler{active_chainstate, mempool}.CreateNewBlock(scriptDummy);
755+
pblocktemplate = BlockAssembler{active_chainstate, &mempool}.CreateNewBlock(scriptDummy);
757756
if (!pblocktemplate)
758757
throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory");
759758

src/test/blockfilter_index_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ CBlock BuildChainTestingSetup::CreateBlock(const CBlockIndex* prev,
6565
const std::vector<CMutableTransaction>& txns,
6666
const CScript& scriptPubKey)
6767
{
68-
std::unique_ptr<CBlockTemplate> pblocktemplate = BlockAssembler{m_node.chainman->ActiveChainstate(), *m_node.mempool}.CreateNewBlock(scriptPubKey);
68+
std::unique_ptr<CBlockTemplate> pblocktemplate = BlockAssembler{m_node.chainman->ActiveChainstate(), m_node.mempool.get()}.CreateNewBlock(scriptPubKey);
6969
CBlock& block = pblocktemplate->block;
7070
block.hashPrevBlock = prev->GetBlockHash();
7171
block.nTime = prev->nTime + 1;

src/test/fuzz/tx_pool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void Finish(FuzzedDataProvider& fuzzed_data_provider, MockedTxPool& tx_pool, CCh
9797
BlockAssembler::Options options;
9898
options.nBlockMaxWeight = fuzzed_data_provider.ConsumeIntegralInRange(0U, MAX_BLOCK_WEIGHT);
9999
options.blockMinFeeRate = CFeeRate{ConsumeMoney(fuzzed_data_provider, /*max=*/COIN)};
100-
auto assembler = BlockAssembler{chainstate, *static_cast<CTxMemPool*>(&tx_pool), options};
100+
auto assembler = BlockAssembler{chainstate, &tx_pool, options};
101101
auto block_template = assembler.CreateNewBlock(CScript{} << OP_TRUE);
102102
Assert(block_template->block.vtx.size() >= 1);
103103
}

src/test/miner_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ BlockAssembler MinerTestingSetup::AssemblerForTest(const CChainParams& params)
5252

5353
options.nBlockMaxWeight = MAX_BLOCK_WEIGHT;
5454
options.blockMinFeeRate = blockMinFeeRate;
55-
return BlockAssembler{m_node.chainman->ActiveChainstate(), *m_node.mempool, options};
55+
return BlockAssembler{m_node.chainman->ActiveChainstate(), m_node.mempool.get(), options};
5656
}
5757

5858
constexpr static struct {

src/test/util/mining.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ CTxIn MineBlock(const NodeContext& node, const CScript& coinbase_scriptPubKey)
7777
std::shared_ptr<CBlock> PrepareBlock(const NodeContext& node, const CScript& coinbase_scriptPubKey)
7878
{
7979
auto block = std::make_shared<CBlock>(
80-
BlockAssembler{Assert(node.chainman)->ActiveChainstate(), *Assert(node.mempool)}
80+
BlockAssembler{Assert(node.chainman)->ActiveChainstate(), Assert(node.mempool.get())}
8181
.CreateNewBlock(coinbase_scriptPubKey)
8282
->block);
8383

src/test/util/setup_common.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,7 @@ CBlock TestChain100Setup::CreateBlock(
277277
const CScript& scriptPubKey,
278278
CChainState& chainstate)
279279
{
280-
CTxMemPool empty_pool;
281-
CBlock block = BlockAssembler{chainstate, empty_pool}.CreateNewBlock(scriptPubKey)->block;
280+
CBlock block = BlockAssembler{chainstate, nullptr}.CreateNewBlock(scriptPubKey)->block;
282281

283282
Assert(block.vtx.size() == 1);
284283
for (const CMutableTransaction& tx : txns) {

src/test/validation_block_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ std::shared_ptr<CBlock> MinerTestingSetup::Block(const uint256& prev_hash)
6565
static int i = 0;
6666
static uint64_t time = Params().GenesisBlock().nTime;
6767

68-
auto ptemplate = BlockAssembler{m_node.chainman->ActiveChainstate(), *m_node.mempool}.CreateNewBlock(CScript{} << i++ << OP_TRUE);
68+
auto ptemplate = BlockAssembler{m_node.chainman->ActiveChainstate(), m_node.mempool.get()}.CreateNewBlock(CScript{} << i++ << OP_TRUE);
6969
auto pblock = std::make_shared<CBlock>(ptemplate->block);
7070
pblock->hashPrevBlock = prev_hash;
7171
pblock->nTime = ++time;
@@ -327,7 +327,7 @@ BOOST_AUTO_TEST_CASE(witness_commitment_index)
327327
{
328328
CScript pubKey;
329329
pubKey << 1 << OP_TRUE;
330-
auto ptemplate = BlockAssembler{m_node.chainman->ActiveChainstate(), *m_node.mempool}.CreateNewBlock(pubKey);
330+
auto ptemplate = BlockAssembler{m_node.chainman->ActiveChainstate(), m_node.mempool.get()}.CreateNewBlock(pubKey);
331331
CBlock pblock = ptemplate->block;
332332

333333
CTxOut witness;

0 commit comments

Comments
 (0)