diff --git a/src/node/miner.cpp b/src/node/miner.cpp index caa299181933a0..54e558aac82886 100644 --- a/src/node/miner.cpp +++ b/src/node/miner.cpp @@ -64,9 +64,8 @@ static BlockAssembler::Options ClampOptions(BlockAssembler::Options options) return options; } -BlockAssembler::BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool, const Options& options) +BlockAssembler::BlockAssembler(Chainstate& chainstate, const Options& options) : chainparams{chainstate.m_chainman.GetParams()}, - m_mempool{mempool}, m_chainstate{chainstate}, m_options{ClampOptions(options)} { @@ -87,8 +86,8 @@ static BlockAssembler::Options ConfiguredOptions() return options; } -BlockAssembler::BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool) - : BlockAssembler(chainstate, mempool, ConfiguredOptions()) {} +BlockAssembler::BlockAssembler(Chainstate& chainstate) + : BlockAssembler(chainstate, ConfiguredOptions()) {} void BlockAssembler::resetBlock() { @@ -103,7 +102,7 @@ void BlockAssembler::resetBlock() nFees = 0; } -std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn) +std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn, const CTxMemPool* mempool) { const auto time_start{SteadyClock::now()}; @@ -138,9 +137,9 @@ std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& sc int nPackagesSelected = 0; int nDescendantsUpdated = 0; - if (m_mempool) { - LOCK(m_mempool->cs); - addPackageTxs(*m_mempool, nPackagesSelected, nDescendantsUpdated); + if (mempool) { + LOCK(mempool->cs); + addPackageTxs(*mempool, nPackagesSelected, nDescendantsUpdated); } const auto time_1{SteadyClock::now()}; diff --git a/src/node/miner.h b/src/node/miner.h index 41735215854591..1e1d40a33baece 100644 --- a/src/node/miner.h +++ b/src/node/miner.h @@ -149,7 +149,6 @@ class BlockAssembler int64_t m_lock_time_cutoff; const CChainParams& chainparams; - const CTxMemPool* const m_mempool; Chainstate& m_chainstate; public: @@ -161,11 +160,11 @@ class BlockAssembler bool test_block_validity{true}; }; - explicit BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool); - explicit BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool, const Options& options); + explicit BlockAssembler(Chainstate& chainstate); + explicit BlockAssembler(Chainstate& chainstate, const Options& options); /** Construct a new block template with coinbase to scriptPubKeyIn */ - std::unique_ptr CreateNewBlock(const CScript& scriptPubKeyIn); + std::unique_ptr CreateNewBlock(const CScript& scriptPubKeyIn, const CTxMemPool* mempool); inline static std::optional m_last_block_num_txs{}; inline static std::optional m_last_block_weight{}; diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 76170c32018dda..feab71cfbc9db4 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -146,7 +146,7 @@ static UniValue generateBlocks(ChainstateManager& chainman, const CTxMemPool& me { UniValue blockHashes(UniValue::VARR); while (nGenerate > 0 && !ShutdownRequested()) { - std::unique_ptr pblocktemplate(BlockAssembler{chainman.ActiveChainstate(), &mempool}.CreateNewBlock(coinbase_script)); + std::unique_ptr pblocktemplate(BlockAssembler{chainman.ActiveChainstate()}.CreateNewBlock(coinbase_script, &mempool)); if (!pblocktemplate.get()) throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block"); @@ -358,7 +358,7 @@ static RPCHelpMan generateblock() { LOCK(cs_main); - std::unique_ptr blocktemplate(BlockAssembler{chainman.ActiveChainstate(), nullptr}.CreateNewBlock(coinbase_script)); + std::unique_ptr blocktemplate(BlockAssembler{chainman.ActiveChainstate()}.CreateNewBlock(coinbase_script, nullptr)); if (!blocktemplate) { throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block"); } @@ -791,7 +791,7 @@ static RPCHelpMan getblocktemplate() // Create new block CScript scriptDummy = CScript() << OP_TRUE; - pblocktemplate = BlockAssembler{active_chainstate, &mempool}.CreateNewBlock(scriptDummy); + pblocktemplate = BlockAssembler{active_chainstate}.CreateNewBlock(scriptDummy, &mempool); if (!pblocktemplate) throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory"); diff --git a/src/test/blockfilter_index_tests.cpp b/src/test/blockfilter_index_tests.cpp index 97ea5cfbf3bec6..794ccf2f2b8d89 100644 --- a/src/test/blockfilter_index_tests.cpp +++ b/src/test/blockfilter_index_tests.cpp @@ -67,7 +67,7 @@ CBlock BuildChainTestingSetup::CreateBlock(const CBlockIndex* prev, const std::vector& txns, const CScript& scriptPubKey) { - std::unique_ptr pblocktemplate = BlockAssembler{m_node.chainman->ActiveChainstate(), m_node.mempool.get()}.CreateNewBlock(scriptPubKey); + std::unique_ptr pblocktemplate = BlockAssembler{m_node.chainman->ActiveChainstate()}.CreateNewBlock(scriptPubKey, m_node.mempool.get()); CBlock& block = pblocktemplate->block; block.hashPrevBlock = prev->GetBlockHash(); block.nTime = prev->nTime + 1; diff --git a/src/test/fuzz/mini_miner.cpp b/src/test/fuzz/mini_miner.cpp index 2f53943c3174f4..af6e4cf23716c4 100644 --- a/src/test/fuzz/mini_miner.cpp +++ b/src/test/fuzz/mini_miner.cpp @@ -169,14 +169,14 @@ FUZZ_TARGET(mini_miner_selection, .init = initialize_miner) miner_options.nBlockMaxWeight = DEFAULT_BLOCK_MAX_WEIGHT; miner_options.test_block_validity = false; - node::BlockAssembler miner{g_setup->m_node.chainman->ActiveChainstate(), &pool, miner_options}; + node::BlockAssembler miner{g_setup->m_node.chainman->ActiveChainstate(), miner_options}; node::MiniMiner mini_miner{pool, outpoints}; assert(mini_miner.IsReadyToCalculate()); CScript spk_placeholder = CScript() << OP_0; // Use BlockAssembler as oracle. BlockAssembler and MiniMiner should select the same // transactions, stopping once packages do not meet target_feerate. - const auto blocktemplate{miner.CreateNewBlock(spk_placeholder)}; + const auto blocktemplate{miner.CreateNewBlock(spk_placeholder, &pool)}; mini_miner.BuildMockTemplate(target_feerate); assert(!mini_miner.IsReadyToCalculate()); auto mock_template_txids = mini_miner.GetMockTemplateTxids(); diff --git a/src/test/fuzz/tx_pool.cpp b/src/test/fuzz/tx_pool.cpp index 96095539ece8d9..80b57aae0962d6 100644 --- a/src/test/fuzz/tx_pool.cpp +++ b/src/test/fuzz/tx_pool.cpp @@ -93,8 +93,8 @@ void Finish(FuzzedDataProvider& fuzzed_data_provider, MockedTxPool& tx_pool, Cha BlockAssembler::Options options; options.nBlockMaxWeight = fuzzed_data_provider.ConsumeIntegralInRange(0U, MAX_BLOCK_WEIGHT); options.blockMinFeeRate = CFeeRate{ConsumeMoney(fuzzed_data_provider, /*max=*/COIN)}; - auto assembler = BlockAssembler{chainstate, &tx_pool, options}; - auto block_template = assembler.CreateNewBlock(CScript{} << OP_TRUE); + auto assembler = BlockAssembler{chainstate, options}; + auto block_template = assembler.CreateNewBlock(CScript{} << OP_TRUE, &tx_pool); Assert(block_template->block.vtx.size() >= 1); } const auto info_all = tx_pool.infoAll(); diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index b4c7cac223b68b..56f8cac985d7af 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -50,7 +50,7 @@ struct MinerTestingSetup : public TestingSetup { m_node.mempool = std::make_unique(MemPoolOptionsForTest(m_node)); return *m_node.mempool; } - BlockAssembler AssemblerForTest(CTxMemPool& tx_mempool); + BlockAssembler AssemblerForTest(); }; } // namespace miner_tests @@ -58,13 +58,13 @@ BOOST_FIXTURE_TEST_SUITE(miner_tests, MinerTestingSetup) static CFeeRate blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE); -BlockAssembler MinerTestingSetup::AssemblerForTest(CTxMemPool& tx_mempool) +BlockAssembler MinerTestingSetup::AssemblerForTest() { BlockAssembler::Options options; options.nBlockMaxWeight = MAX_BLOCK_WEIGHT; options.blockMinFeeRate = blockMinFeeRate; - return BlockAssembler{m_node.chainman->ActiveChainstate(), &tx_mempool, options}; + return BlockAssembler{m_node.chainman->ActiveChainstate(), options}; } constexpr static struct { @@ -133,7 +133,7 @@ void MinerTestingSetup::TestPackageSelection(const CScript& scriptPubKey, const uint256 hashHighFeeTx = tx.GetHash(); tx_mempool.addUnchecked(entry.Fee(50000).Time(Now()).SpendsCoinbase(false).FromTx(tx)); - std::unique_ptr pblocktemplate = AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey); + std::unique_ptr pblocktemplate = AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool); BOOST_REQUIRE_EQUAL(pblocktemplate->block.vtx.size(), 4U); BOOST_CHECK(pblocktemplate->block.vtx[1]->GetHash() == hashParentTx); BOOST_CHECK(pblocktemplate->block.vtx[2]->GetHash() == hashHighFeeTx); @@ -154,7 +154,7 @@ void MinerTestingSetup::TestPackageSelection(const CScript& scriptPubKey, const tx.vout[0].nValue = 5000000000LL - 1000 - 50000 - feeToUse; uint256 hashLowFeeTx = tx.GetHash(); tx_mempool.addUnchecked(entry.Fee(feeToUse).FromTx(tx)); - pblocktemplate = AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey); + pblocktemplate = AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool); // Verify that the free tx and the low fee tx didn't get selected for (size_t i=0; iblock.vtx.size(); ++i) { BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashFreeTx); @@ -168,7 +168,7 @@ void MinerTestingSetup::TestPackageSelection(const CScript& scriptPubKey, const tx.vout[0].nValue -= 2; // Now we should be just over the min relay fee hashLowFeeTx = tx.GetHash(); tx_mempool.addUnchecked(entry.Fee(feeToUse + 2).FromTx(tx)); - pblocktemplate = AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey); + pblocktemplate = AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool); BOOST_REQUIRE_EQUAL(pblocktemplate->block.vtx.size(), 6U); BOOST_CHECK(pblocktemplate->block.vtx[4]->GetHash() == hashFreeTx); BOOST_CHECK(pblocktemplate->block.vtx[5]->GetHash() == hashLowFeeTx); @@ -190,7 +190,7 @@ void MinerTestingSetup::TestPackageSelection(const CScript& scriptPubKey, const tx.vout[0].nValue = 5000000000LL - 100000000 - feeToUse; uint256 hashLowFeeTx2 = tx.GetHash(); tx_mempool.addUnchecked(entry.Fee(feeToUse).SpendsCoinbase(false).FromTx(tx)); - pblocktemplate = AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey); + pblocktemplate = AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool); // Verify that this tx isn't selected. for (size_t i=0; iblock.vtx.size(); ++i) { @@ -203,7 +203,7 @@ void MinerTestingSetup::TestPackageSelection(const CScript& scriptPubKey, const tx.vin[0].prevout.n = 1; tx.vout[0].nValue = 100000000 - 10000; // 10k satoshi fee tx_mempool.addUnchecked(entry.Fee(10000).FromTx(tx)); - pblocktemplate = AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey); + pblocktemplate = AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool); BOOST_REQUIRE_EQUAL(pblocktemplate->block.vtx.size(), 9U); BOOST_CHECK(pblocktemplate->block.vtx[8]->GetHash() == hashLowFeeTx2); } @@ -226,7 +226,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std:: LOCK(tx_mempool.cs); // Just to make sure we can still make simple blocks - auto pblocktemplate = AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey); + auto pblocktemplate = AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool); BOOST_CHECK(pblocktemplate); // block sigops > limit: 1000 CHECKMULTISIG + 1 @@ -246,7 +246,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std:: tx.vin[0].prevout.hash = hash; } - BOOST_CHECK_EXCEPTION(AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-blk-sigops")); + BOOST_CHECK_EXCEPTION(AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool), std::runtime_error, HasReason("bad-blk-sigops")); } { @@ -263,7 +263,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std:: tx_mempool.addUnchecked(entry.Fee(LOWFEE).Time(Now()).SpendsCoinbase(spendsCoinbase).SigOpsCost(80).FromTx(tx)); tx.vin[0].prevout.hash = hash; } - BOOST_CHECK(AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey)); + BOOST_CHECK(AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool)); } { @@ -287,7 +287,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std:: tx_mempool.addUnchecked(entry.Fee(LOWFEE).Time(Now()).SpendsCoinbase(spendsCoinbase).FromTx(tx)); tx.vin[0].prevout.hash = hash; } - BOOST_CHECK(AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey)); + BOOST_CHECK(AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool)); } { @@ -297,7 +297,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std:: // orphan in tx_mempool, template creation fails hash = tx.GetHash(); tx_mempool.addUnchecked(entry.Fee(LOWFEE).Time(Now()).FromTx(tx)); - BOOST_CHECK_EXCEPTION(AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-txns-inputs-missingorspent")); + BOOST_CHECK_EXCEPTION(AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool), std::runtime_error, HasReason("bad-txns-inputs-missingorspent")); } { @@ -318,7 +318,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std:: tx.vout[0].nValue = tx.vout[0].nValue + BLOCKSUBSIDY - HIGHERFEE; // First txn output + fresh coinbase - new txn fee hash = tx.GetHash(); tx_mempool.addUnchecked(entry.Fee(HIGHERFEE).Time(Now()).SpendsCoinbase(true).FromTx(tx)); - BOOST_CHECK(AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey)); + BOOST_CHECK(AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool)); } { @@ -334,7 +334,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std:: // give it a fee so it'll get mined tx_mempool.addUnchecked(entry.Fee(LOWFEE).Time(Now()).SpendsCoinbase(false).FromTx(tx)); // Should throw bad-cb-multiple - BOOST_CHECK_EXCEPTION(AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-cb-multiple")); + BOOST_CHECK_EXCEPTION(AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool), std::runtime_error, HasReason("bad-cb-multiple")); } { @@ -351,7 +351,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std:: tx.vout[0].scriptPubKey = CScript() << OP_2; hash = tx.GetHash(); tx_mempool.addUnchecked(entry.Fee(HIGHFEE).Time(Now()).SpendsCoinbase(true).FromTx(tx)); - BOOST_CHECK_EXCEPTION(AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("bad-txns-inputs-missingorspent")); + BOOST_CHECK_EXCEPTION(AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool), std::runtime_error, HasReason("bad-txns-inputs-missingorspent")); } { @@ -371,7 +371,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std:: next->BuildSkip(); m_node.chainman->ActiveChain().SetTip(*next); } - BOOST_CHECK(AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey)); + BOOST_CHECK(AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool)); // Extend to a 210000-long block chain. while (m_node.chainman->ActiveChain().Tip()->nHeight < 210000) { CBlockIndex* prev = m_node.chainman->ActiveChain().Tip(); @@ -383,7 +383,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std:: next->BuildSkip(); m_node.chainman->ActiveChain().SetTip(*next); } - BOOST_CHECK(AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey)); + BOOST_CHECK(AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool)); // invalid p2sh txn in tx_mempool, template creation fails tx.vin[0].prevout.hash = txFirst[0]->GetHash(); @@ -400,7 +400,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std:: hash = tx.GetHash(); tx_mempool.addUnchecked(entry.Fee(LOWFEE).Time(Now()).SpendsCoinbase(false).FromTx(tx)); // Should throw block-validation-failed - BOOST_CHECK_EXCEPTION(AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey), std::runtime_error, HasReason("block-validation-failed")); + BOOST_CHECK_EXCEPTION(AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool), std::runtime_error, HasReason("block-validation-failed")); // Delete the dummy blocks again. while (m_node.chainman->ActiveChain().Tip()->nHeight > nHeight) { @@ -502,7 +502,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std:: tx.vin[0].nSequence = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG | 1; BOOST_CHECK(!TestSequenceLocks(CTransaction{tx}, tx_mempool)); // Sequence locks fail - auto pblocktemplate = AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey); + auto pblocktemplate = AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool); BOOST_CHECK(pblocktemplate); // None of the of the absolute height/time locked tx should have made @@ -518,7 +518,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std:: m_node.chainman->ActiveChain().Tip()->nHeight++; SetMockTime(m_node.chainman->ActiveChain().Tip()->GetMedianTimePast() + 1); - BOOST_CHECK(pblocktemplate = AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey)); + BOOST_CHECK(pblocktemplate = AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool)); BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 5U); } @@ -585,7 +585,7 @@ void MinerTestingSetup::TestPrioritisedMining(const CScript& scriptPubKey, const uint256 hashFreeGrandchild = tx.GetHash(); tx_mempool.addUnchecked(entry.Fee(0).SpendsCoinbase(false).FromTx(tx)); - auto pblocktemplate = AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey); + auto pblocktemplate = AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool); BOOST_REQUIRE_EQUAL(pblocktemplate->block.vtx.size(), 6U); BOOST_CHECK(pblocktemplate->block.vtx[1]->GetHash() == hashFreeParent); BOOST_CHECK(pblocktemplate->block.vtx[2]->GetHash() == hashFreePrioritisedTx); @@ -607,9 +607,8 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) CScript scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG; std::unique_ptr pblocktemplate; - CTxMemPool& tx_mempool{*m_node.mempool}; // Simple block creation, nothing special yet: - BOOST_CHECK(pblocktemplate = AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey)); + BOOST_CHECK(pblocktemplate = AssemblerForTest().CreateNewBlock(scriptPubKey, Assert(m_node.mempool.get()))); // We can't make transactions until we have inputs // Therefore, load 110 blocks :) diff --git a/src/test/util/mining.cpp b/src/test/util/mining.cpp index 08d1b4c90287da..207d316493df1f 100644 --- a/src/test/util/mining.cpp +++ b/src/test/util/mining.cpp @@ -112,8 +112,8 @@ std::shared_ptr PrepareBlock(const NodeContext& node, const CScript& coi const BlockAssembler::Options& assembler_options) { auto block = std::make_shared( - BlockAssembler{Assert(node.chainman)->ActiveChainstate(), Assert(node.mempool.get()), assembler_options} - .CreateNewBlock(coinbase_scriptPubKey) + BlockAssembler{Assert(node.chainman)->ActiveChainstate(), assembler_options} + .CreateNewBlock(coinbase_scriptPubKey, Assert(node.mempool.get())) ->block); LOCK(cs_main); diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index 50cad32f10e8a9..783fdf0557cef6 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -310,7 +310,7 @@ CBlock TestChain100Setup::CreateBlock( const CScript& scriptPubKey, Chainstate& chainstate) { - CBlock block = BlockAssembler{chainstate, nullptr}.CreateNewBlock(scriptPubKey)->block; + CBlock block = BlockAssembler{chainstate}.CreateNewBlock(scriptPubKey, nullptr)->block; Assert(block.vtx.size() == 1); for (const CMutableTransaction& tx : txns) { diff --git a/src/test/validation_block_tests.cpp b/src/test/validation_block_tests.cpp index 64cb5522ebe448..498c49a0b16408 100644 --- a/src/test/validation_block_tests.cpp +++ b/src/test/validation_block_tests.cpp @@ -65,7 +65,7 @@ std::shared_ptr MinerTestingSetup::Block(const uint256& prev_hash) static int i = 0; static uint64_t time = Params().GenesisBlock().nTime; - auto ptemplate = BlockAssembler{m_node.chainman->ActiveChainstate(), m_node.mempool.get()}.CreateNewBlock(CScript{} << i++ << OP_TRUE); + auto ptemplate = BlockAssembler{m_node.chainman->ActiveChainstate()}.CreateNewBlock(CScript{} << i++ << OP_TRUE, m_node.mempool.get()); auto pblock = std::make_shared(ptemplate->block); pblock->hashPrevBlock = prev_hash; pblock->nTime = ++time; @@ -329,7 +329,7 @@ BOOST_AUTO_TEST_CASE(witness_commitment_index) LOCK(Assert(m_node.chainman)->GetMutex()); CScript pubKey; pubKey << 1 << OP_TRUE; - auto ptemplate = BlockAssembler{m_node.chainman->ActiveChainstate(), m_node.mempool.get()}.CreateNewBlock(pubKey); + auto ptemplate = BlockAssembler{m_node.chainman->ActiveChainstate()}.CreateNewBlock(pubKey, m_node.mempool.get()); CBlock pblock = ptemplate->block; CTxOut witness;