mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-21 22:31:21 +02:00
[miner] allow bypassing TestBlockValidity
Allows us to test BlockAssembler on transactions without signatures or mature coinbases (which is what PopulateMempool creates). Also means that `TestBlockValidity()` is not included in the bench timing.
This commit is contained in:
parent
c058852308
commit
cba5934eb6
@ -60,10 +60,12 @@ BlockAssembler::Options::Options()
|
|||||||
{
|
{
|
||||||
blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE);
|
blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE);
|
||||||
nBlockMaxWeight = DEFAULT_BLOCK_MAX_WEIGHT;
|
nBlockMaxWeight = DEFAULT_BLOCK_MAX_WEIGHT;
|
||||||
|
test_block_validity = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockAssembler::BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool, const Options& options)
|
BlockAssembler::BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool, const Options& options)
|
||||||
: chainparams{chainstate.m_chainman.GetParams()},
|
: test_block_validity{options.test_block_validity},
|
||||||
|
chainparams{chainstate.m_chainman.GetParams()},
|
||||||
m_mempool(mempool),
|
m_mempool(mempool),
|
||||||
m_chainstate(chainstate)
|
m_chainstate(chainstate)
|
||||||
{
|
{
|
||||||
@ -174,7 +176,8 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
|
|||||||
pblocktemplate->vTxSigOpsCost[0] = WITNESS_SCALE_FACTOR * GetLegacySigOpCount(*pblock->vtx[0]);
|
pblocktemplate->vTxSigOpsCost[0] = WITNESS_SCALE_FACTOR * GetLegacySigOpCount(*pblock->vtx[0]);
|
||||||
|
|
||||||
BlockValidationState state;
|
BlockValidationState state;
|
||||||
if (!TestBlockValidity(state, chainparams, m_chainstate, *pblock, pindexPrev, GetAdjustedTime, false, false)) {
|
if (test_block_validity && !TestBlockValidity(state, chainparams, m_chainstate, *pblock, pindexPrev,
|
||||||
|
GetAdjustedTime, /*fCheckPOW=*/false, /*fCheckMerkleRoot=*/false)) {
|
||||||
throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", __func__, state.ToString()));
|
throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", __func__, state.ToString()));
|
||||||
}
|
}
|
||||||
const auto time_2{SteadyClock::now()};
|
const auto time_2{SteadyClock::now()};
|
||||||
|
@ -136,6 +136,9 @@ private:
|
|||||||
unsigned int nBlockMaxWeight;
|
unsigned int nBlockMaxWeight;
|
||||||
CFeeRate blockMinFeeRate;
|
CFeeRate blockMinFeeRate;
|
||||||
|
|
||||||
|
// Whether to call TestBlockValidity() at the end of CreateNewBlock().
|
||||||
|
const bool test_block_validity;
|
||||||
|
|
||||||
// Information on the current status of the block
|
// Information on the current status of the block
|
||||||
uint64_t nBlockWeight;
|
uint64_t nBlockWeight;
|
||||||
uint64_t nBlockTx;
|
uint64_t nBlockTx;
|
||||||
@ -156,6 +159,7 @@ public:
|
|||||||
Options();
|
Options();
|
||||||
size_t nBlockMaxWeight;
|
size_t nBlockMaxWeight;
|
||||||
CFeeRate blockMinFeeRate;
|
CFeeRate blockMinFeeRate;
|
||||||
|
bool test_block_validity;
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool);
|
explicit BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user