Merge #15413: tests: Add missing cs_main locks required when accessing pcoinsdbview, pcoinsTip or pblocktree
543ef7d626
tests: Add missing cs_main locks required when accessing pcoinsdbview, pcoinsTip or pblocktree (practicalswift)
Pull request description:
Add missing `cs_main` locks required when accessing `pcoinsdbview`, `pcoinsTip` or `pblocktree`.
This is a subset of #15192: split up requested by MarcoFalke in https://github.com/bitcoin/bitcoin/pull/15192#issuecomment-462827372.
The end goal is to get the corresponding `GUARDED_BY(...)`:s in (see #15192).
Tree-SHA512: 0eb1987dba1a2f1faf0910c421f6d90a20b8a253486eb3301d5bca66d128b19120664e3a8580bdce7b428df817284faf94243250bf561f91d2d31a52d134aa67
This commit is contained in:
commit
4d2767c228
3 changed files with 8 additions and 5 deletions
|
@ -73,10 +73,12 @@ static void AssembleBlock(benchmark::State& state)
|
||||||
boost::thread_group thread_group;
|
boost::thread_group thread_group;
|
||||||
CScheduler scheduler;
|
CScheduler scheduler;
|
||||||
{
|
{
|
||||||
|
LOCK(cs_main);
|
||||||
::pblocktree.reset(new CBlockTreeDB(1 << 20, true));
|
::pblocktree.reset(new CBlockTreeDB(1 << 20, true));
|
||||||
::pcoinsdbview.reset(new CCoinsViewDB(1 << 23, true));
|
::pcoinsdbview.reset(new CCoinsViewDB(1 << 23, true));
|
||||||
::pcoinsTip.reset(new CCoinsViewCache(pcoinsdbview.get()));
|
::pcoinsTip.reset(new CCoinsViewCache(pcoinsdbview.get()));
|
||||||
|
}
|
||||||
|
{
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
thread_group.create_thread(std::bind(&CScheduler::serviceQueue, &scheduler));
|
thread_group.create_thread(std::bind(&CScheduler::serviceQueue, &scheduler));
|
||||||
GetMainSignals().RegisterBackgroundSignalScheduler(scheduler);
|
GetMainSignals().RegisterBackgroundSignalScheduler(scheduler);
|
||||||
|
|
|
@ -37,10 +37,12 @@ static void DuplicateInputs(benchmark::State& state)
|
||||||
CScheduler scheduler;
|
CScheduler scheduler;
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
{
|
{
|
||||||
|
LOCK(cs_main);
|
||||||
::pblocktree.reset(new CBlockTreeDB(1 << 20, true));
|
::pblocktree.reset(new CBlockTreeDB(1 << 20, true));
|
||||||
::pcoinsdbview.reset(new CCoinsViewDB(1 << 23, true));
|
::pcoinsdbview.reset(new CCoinsViewDB(1 << 23, true));
|
||||||
::pcoinsTip.reset(new CCoinsViewCache(pcoinsdbview.get()));
|
::pcoinsTip.reset(new CCoinsViewCache(pcoinsdbview.get()));
|
||||||
|
}
|
||||||
|
{
|
||||||
thread_group.create_thread(std::bind(&CScheduler::serviceQueue, &scheduler));
|
thread_group.create_thread(std::bind(&CScheduler::serviceQueue, &scheduler));
|
||||||
GetMainSignals().RegisterBackgroundSignalScheduler(scheduler);
|
GetMainSignals().RegisterBackgroundSignalScheduler(scheduler);
|
||||||
LoadGenesisBlock(chainparams);
|
LoadGenesisBlock(chainparams);
|
||||||
|
|
|
@ -102,7 +102,7 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)
|
||||||
// should fail.
|
// should fail.
|
||||||
// Capture this interaction with the upgraded_nop argument: set it when evaluating
|
// Capture this interaction with the upgraded_nop argument: set it when evaluating
|
||||||
// any script flag that is implemented as an upgraded NOP code.
|
// any script flag that is implemented as an upgraded NOP code.
|
||||||
static void ValidateCheckInputsForAllFlags(const CTransaction &tx, uint32_t failing_flags, bool add_to_cache)
|
static void ValidateCheckInputsForAllFlags(const CTransaction &tx, uint32_t failing_flags, bool add_to_cache) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||||
{
|
{
|
||||||
PrecomputedTransactionData txdata(tx);
|
PrecomputedTransactionData txdata(tx);
|
||||||
// If we add many more flags, this loop can get too expensive, but we can
|
// If we add many more flags, this loop can get too expensive, but we can
|
||||||
|
@ -219,11 +219,10 @@ BOOST_FIXTURE_TEST_CASE(checkinputs_test, TestChain100Setup)
|
||||||
CBlock block;
|
CBlock block;
|
||||||
|
|
||||||
block = CreateAndProcessBlock({spend_tx}, p2pk_scriptPubKey);
|
block = CreateAndProcessBlock({spend_tx}, p2pk_scriptPubKey);
|
||||||
|
LOCK(cs_main);
|
||||||
BOOST_CHECK(chainActive.Tip()->GetBlockHash() == block.GetHash());
|
BOOST_CHECK(chainActive.Tip()->GetBlockHash() == block.GetHash());
|
||||||
BOOST_CHECK(pcoinsTip->GetBestBlock() == block.GetHash());
|
BOOST_CHECK(pcoinsTip->GetBestBlock() == block.GetHash());
|
||||||
|
|
||||||
LOCK(cs_main);
|
|
||||||
|
|
||||||
// Test P2SH: construct a transaction that is valid without P2SH, and
|
// Test P2SH: construct a transaction that is valid without P2SH, and
|
||||||
// then test validity with P2SH.
|
// then test validity with P2SH.
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue