Skip to content

Commit

Permalink
[refactor] Remove BlockAssembler m_mempool member
Browse files Browse the repository at this point in the history
Instead, pass the mempool pointer as an argument to CreateNewBlock and
pass that on to addPackageTxs. Before, addPackageTxs had access to both
the m_mempool member and the passed in mempool, which could be
confusing.
  • Loading branch information
TheCharlatan committed Nov 10, 2023
1 parent b3898e9 commit ed71a7b
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 49 deletions.
15 changes: 7 additions & 8 deletions src/node/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
{
Expand All @@ -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()
{
Expand All @@ -103,7 +102,7 @@ void BlockAssembler::resetBlock()
nFees = 0;
}

std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn)
std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn, const CTxMemPool* mempool)
{
const auto time_start{SteadyClock::now()};

Expand Down Expand Up @@ -138,9 +137,9 @@ std::unique_ptr<CBlockTemplate> 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()};
Expand Down
7 changes: 3 additions & 4 deletions src/node/miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ class BlockAssembler
int64_t m_lock_time_cutoff;

const CChainParams& chainparams;
const CTxMemPool* const m_mempool;
Chainstate& m_chainstate;

public:
Expand All @@ -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<CBlockTemplate> CreateNewBlock(const CScript& scriptPubKeyIn);
std::unique_ptr<CBlockTemplate> CreateNewBlock(const CScript& scriptPubKeyIn, const CTxMemPool* mempool);

inline static std::optional<int64_t> m_last_block_num_txs{};
inline static std::optional<int64_t> m_last_block_weight{};
Expand Down
6 changes: 3 additions & 3 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static UniValue generateBlocks(ChainstateManager& chainman, const CTxMemPool& me
{
UniValue blockHashes(UniValue::VARR);
while (nGenerate > 0 && !ShutdownRequested()) {
std::unique_ptr<CBlockTemplate> pblocktemplate(BlockAssembler{chainman.ActiveChainstate(), &mempool}.CreateNewBlock(coinbase_script));
std::unique_ptr<CBlockTemplate> pblocktemplate(BlockAssembler{chainman.ActiveChainstate()}.CreateNewBlock(coinbase_script, &mempool));
if (!pblocktemplate.get())
throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block");

Expand Down Expand Up @@ -358,7 +358,7 @@ static RPCHelpMan generateblock()
{
LOCK(cs_main);

std::unique_ptr<CBlockTemplate> blocktemplate(BlockAssembler{chainman.ActiveChainstate(), nullptr}.CreateNewBlock(coinbase_script));
std::unique_ptr<CBlockTemplate> blocktemplate(BlockAssembler{chainman.ActiveChainstate()}.CreateNewBlock(coinbase_script, nullptr));
if (!blocktemplate) {
throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block");
}
Expand Down Expand Up @@ -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");

Expand Down
2 changes: 1 addition & 1 deletion src/test/blockfilter_index_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ CBlock BuildChainTestingSetup::CreateBlock(const CBlockIndex* prev,
const std::vector<CMutableTransaction>& txns,
const CScript& scriptPubKey)
{
std::unique_ptr<CBlockTemplate> pblocktemplate = BlockAssembler{m_node.chainman->ActiveChainstate(), m_node.mempool.get()}.CreateNewBlock(scriptPubKey);
std::unique_ptr<CBlockTemplate> 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;
Expand Down
4 changes: 2 additions & 2 deletions src/test/fuzz/mini_miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/test/fuzz/tx_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
47 changes: 23 additions & 24 deletions src/test/miner_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,21 @@ struct MinerTestingSetup : public TestingSetup {
m_node.mempool = std::make_unique<CTxMemPool>(MemPoolOptionsForTest(m_node));
return *m_node.mempool;
}
BlockAssembler AssemblerForTest(CTxMemPool& tx_mempool);
BlockAssembler AssemblerForTest();
};
} // namespace miner_tests

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 {
Expand Down Expand Up @@ -133,7 +133,7 @@ void MinerTestingSetup::TestPackageSelection(const CScript& scriptPubKey, const
uint256 hashHighFeeTx = tx.GetHash();
tx_mempool.addUnchecked(entry.Fee(50000).Time(Now<NodeSeconds>()).SpendsCoinbase(false).FromTx(tx));

std::unique_ptr<CBlockTemplate> pblocktemplate = AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey);
std::unique_ptr<CBlockTemplate> 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);
Expand All @@ -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; i<pblocktemplate->block.vtx.size(); ++i) {
BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashFreeTx);
Expand All @@ -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);
Expand All @@ -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; i<pblocktemplate->block.vtx.size(); ++i) {
Expand All @@ -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);
}
Expand All @@ -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
Expand All @@ -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"));
}

{
Expand All @@ -263,7 +263,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std::
tx_mempool.addUnchecked(entry.Fee(LOWFEE).Time(Now<NodeSeconds>()).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));
}

{
Expand All @@ -287,7 +287,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std::
tx_mempool.addUnchecked(entry.Fee(LOWFEE).Time(Now<NodeSeconds>()).SpendsCoinbase(spendsCoinbase).FromTx(tx));
tx.vin[0].prevout.hash = hash;
}
BOOST_CHECK(AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey));
BOOST_CHECK(AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool));
}

{
Expand All @@ -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<NodeSeconds>()).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"));
}

{
Expand All @@ -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<NodeSeconds>()).SpendsCoinbase(true).FromTx(tx));
BOOST_CHECK(AssemblerForTest(tx_mempool).CreateNewBlock(scriptPubKey));
BOOST_CHECK(AssemblerForTest().CreateNewBlock(scriptPubKey, &tx_mempool));
}

{
Expand All @@ -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<NodeSeconds>()).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"));
}

{
Expand All @@ -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<NodeSeconds>()).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"));
}

{
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -400,7 +400,7 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std::
hash = tx.GetHash();
tx_mempool.addUnchecked(entry.Fee(LOWFEE).Time(Now<NodeSeconds>()).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) {
Expand Down Expand Up @@ -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
Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
Expand All @@ -607,9 +607,8 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
CScript scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
std::unique_ptr<CBlockTemplate> 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 :)
Expand Down
4 changes: 2 additions & 2 deletions src/test/util/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ std::shared_ptr<CBlock> PrepareBlock(const NodeContext& node, const CScript& coi
const BlockAssembler::Options& assembler_options)
{
auto block = std::make_shared<CBlock>(
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);
Expand Down
2 changes: 1 addition & 1 deletion src/test/util/setup_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit ed71a7b

Please sign in to comment.