From 4be68dd34aafbc822ac0fa4bcada5ebc60c79702 Mon Sep 17 00:00:00 2001 From: fanquake Date: Thu, 5 Aug 2021 15:58:51 +0800 Subject: [PATCH 1/3] Merge bitcoin/bitcoin#22630: test:Add missing include 6666ec9e059ea66065a11f5e25c0a17d7d0834fe test: Add missing include (MarcoFalke) Pull request description: Fix the silent merge conflict introduced in commit 7d60f7ec6bbf293c6f23f442a0fd985111a15ff7 ACKs for top commit: fanquake: ACK 6666ec9e059ea66065a11f5e25c0a17d7d0834fe - fixes: Tree-SHA512: c712715db4a41cf6ed991fb35482d8fd9016b5a27e1309654018219ebbfd8d4f98a389bdf5d7b792e7a4690928aeef943c716465b0c5e00f70320ad2e134ebb5 --- src/test/miner_tests.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index 62006020ccae2..5d1e01d388415 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2011-2020 The Bitcoin Core developers +// Copyright (c) 2011-2021 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -23,6 +23,7 @@ #include #include #include +#include #include From 5057ebb4f18f8ea7d61e399efa4f54a53e205c5f Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 4 Aug 2021 16:37:01 +0200 Subject: [PATCH 2/3] Merge bitcoin/bitcoin#22577: Close minor startup race between main and scheduler threads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 703b1e612a4bd4521e20ae21eb8fb7c19f4ef942 Close minor startup race between main and scheduler threads (Larry Ruane) Pull request description: This is a low-priority bug fix. The scheduler thread runs `CheckForStaleTipAndEvictPeers()` every 45 seconds (EXTRA_PEER_CHECK_INTERVAL). If its first run happens before the active chain is set up (`CChain::SetTip()`), `bitcoind` will assert: ``` (...) 2021-07-28T22:16:49Z init message: Loading block index… bitcoind: validation.cpp:4968: CChainState& ChainstateManager::ActiveChainstate() const: Assertion `m_active_chainstate' failed. Aborted (core dumped) ``` I ran into this while using the debugger to investigate an unrelated problem. Single-stepping through threads with a debugger can cause the relative thread execution timing to be very different than usual. I don't think any automated tests are needed for this PR. I'll give reproduction steps in the next PR comment. ACKs for top commit: MarcoFalke: cr ACK 703b1e612a4bd4521e20ae21eb8fb7c19f4ef942 tryphe: tested ACK 703b1e612a4bd4521e20ae21eb8fb7c19f4ef942 0xB10C: ACK 703b1e612a4bd4521e20ae21eb8fb7c19f4ef942 glozow: code review ACK 703b1e612a4bd4521e20ae21eb8fb7c19f4ef942 - it makes sense to me to start peerman's background tasks here, after `chainstate->LoadChainTip()` and `node.connman->Start()` have been called. Tree-SHA512: 9316ad768cba3b171f62e2eb400e3790af66c47d1886d7965edb38d9710fc8c8f8e4fb38232811c9346732ce311d39f740c5c2aaf5f6ca390ddc48c51a8d633b --- src/init.cpp | 4 +++- src/net_processing.cpp | 13 +++++++++---- src/net_processing.h | 5 ++++- src/test/denialofservice_tests.cpp | 10 +++++----- src/test/util/setup_common.cpp | 2 +- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 9389320e138d4..82be1dc73ab87 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1637,7 +1637,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) assert(!node.peerman); node.peerman = PeerManager::make(chainparams, *node.connman, *node.addrman, node.banman.get(), - *node.scheduler, chainman, *node.mempool, *node.mn_metaman, *node.mn_sync, + chainman, *node.mempool, *node.mn_metaman, *node.mn_sync, *node.govman, *node.sporkman, node.mn_activeman.get(), node.dmnman, node.cj_ctx, node.llmq_ctx, ignores_incoming_txs); RegisterValidationInterface(node.peerman.get()); @@ -2467,6 +2467,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) banman->DumpBanlist(); }, DUMP_BANS_INTERVAL); + if (node.peerman) node.peerman->StartScheduledTasks(*node.scheduler); + #if HAVE_SYSTEM StartupNotify(args); #endif diff --git a/src/net_processing.cpp b/src/net_processing.cpp index fa3f4d0004354..384e1febeb3c9 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -368,7 +368,7 @@ class PeerManagerImpl final : public PeerManager { public: PeerManagerImpl(const CChainParams& chainparams, CConnman& connman, AddrMan& addrman, BanMan* banman, - CScheduler &scheduler, ChainstateManager& chainman, CTxMemPool& pool, + ChainstateManager& chainman, CTxMemPool& pool, CMasternodeMetaMan& mn_metaman, CMasternodeSync& mn_sync, CGovernanceManager& govman, CSporkManager& sporkman, const CActiveMasternodeManager* const mn_activeman, @@ -397,6 +397,7 @@ class PeerManagerImpl final : public PeerManager EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_recent_confirmed_transactions_mutex); /** Implement PeerManager */ + void StartScheduledTasks(CScheduler& scheduler) override; void CheckForStaleTipAndEvictPeers() override; std::optional FetchBlock(NodeId peer_id, const CBlockIndex& block_index) override; bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) const override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex); @@ -1893,7 +1894,7 @@ std::optional PeerManagerImpl::FetchBlock(NodeId peer_id, const CBl } std::unique_ptr PeerManager::make(const CChainParams& chainparams, CConnman& connman, AddrMan& addrman, BanMan* banman, - CScheduler &scheduler, ChainstateManager& chainman, CTxMemPool& pool, + ChainstateManager& chainman, CTxMemPool& pool, CMasternodeMetaMan& mn_metaman, CMasternodeSync& mn_sync, CGovernanceManager& govman, CSporkManager& sporkman, const CActiveMasternodeManager* const mn_activeman, @@ -1901,11 +1902,11 @@ std::unique_ptr PeerManager::make(const CChainParams& chainparams, const std::unique_ptr& cj_ctx, const std::unique_ptr& llmq_ctx, bool ignore_incoming_txs) { - return std::make_unique(chainparams, connman, addrman, banman, scheduler, chainman, pool, mn_metaman, mn_sync, govman, sporkman, mn_activeman, dmnman, cj_ctx, llmq_ctx, ignore_incoming_txs); + return std::make_unique(chainparams, connman, addrman, banman, chainman, pool, mn_metaman, mn_sync, govman, sporkman, mn_activeman, dmnman, cj_ctx, llmq_ctx, ignore_incoming_txs); } PeerManagerImpl::PeerManagerImpl(const CChainParams& chainparams, CConnman& connman, AddrMan& addrman, BanMan* banman, - CScheduler &scheduler, ChainstateManager& chainman, CTxMemPool& pool, + ChainstateManager& chainman, CTxMemPool& pool, CMasternodeMetaMan& mn_metaman, CMasternodeSync& mn_sync, CGovernanceManager& govman, CSporkManager& sporkman, const CActiveMasternodeManager* const mn_activeman, @@ -1928,6 +1929,10 @@ PeerManagerImpl::PeerManagerImpl(const CChainParams& chainparams, CConnman& conn m_sporkman(sporkman), m_mn_activeman(mn_activeman), m_ignore_incoming_txs(ignore_incoming_txs) +{ +} + +void PeerManagerImpl::StartScheduledTasks(CScheduler& scheduler) { // Stale tip checking and peer eviction are on two different timers, but we // don't want them to get out of sync due to drift in the scheduler, so we diff --git a/src/net_processing.h b/src/net_processing.h index 4edf1f371eaef..c23abdc291d5e 100644 --- a/src/net_processing.h +++ b/src/net_processing.h @@ -57,7 +57,7 @@ class PeerManager : public CValidationInterface, public NetEventsInterface { public: static std::unique_ptr make(const CChainParams& chainparams, CConnman& connman, AddrMan& addrman, - BanMan* banman, CScheduler &scheduler, ChainstateManager& chainman, + BanMan* banman, ChainstateManager& chainman, CTxMemPool& pool, CMasternodeMetaMan& mn_metaman, CMasternodeSync& mn_sync, CGovernanceManager& govman, CSporkManager& sporkman, const CActiveMasternodeManager* const mn_activeman, @@ -75,6 +75,9 @@ class PeerManager : public CValidationInterface, public NetEventsInterface */ virtual std::optional FetchBlock(NodeId peer_id, const CBlockIndex& block_index) = 0; + /** Begin running background tasks, should only be called once */ + virtual void StartScheduledTasks(CScheduler& scheduler) = 0; + /** Get statistics from node state */ virtual bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) const = 0; diff --git a/src/test/denialofservice_tests.cpp b/src/test/denialofservice_tests.cpp index c950b95d9d7a4..32ca08eb9e244 100644 --- a/src/test/denialofservice_tests.cpp +++ b/src/test/denialofservice_tests.cpp @@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction) auto connman = std::make_unique(0x1337, 0x1337, *m_node.addrman); // Disable inactivity checks for this test to avoid interference static_cast(connman.get())->SetPeerConnectTimeout(99999s); - auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, nullptr, *m_node.scheduler, + auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, nullptr, *m_node.chainman, *m_node.mempool, *m_node.mn_metaman, *m_node.mn_sync, *m_node.govman, *m_node.sporkman, /* mn_activeman = */ nullptr, m_node.dmnman, m_node.cj_ctx, m_node.llmq_ctx, /* ignore_incoming_txs = */ false); @@ -153,7 +153,7 @@ BOOST_AUTO_TEST_CASE(stale_tip_peer_management) NodeId id{0}; const CChainParams& chainparams = Params(); auto connman = std::make_unique(0x1337, 0x1337, *m_node.addrman); - auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, nullptr, *m_node.scheduler, + auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, nullptr, *m_node.chainman, *m_node.mempool, *m_node.mn_metaman, *m_node.mn_sync, *m_node.govman, *m_node.sporkman, /* mn_activeman = */ nullptr, m_node.dmnman, m_node.cj_ctx, m_node.llmq_ctx, /* ignore_incoming_txs = */ false); @@ -233,7 +233,7 @@ BOOST_AUTO_TEST_CASE(block_relay_only_eviction) NodeId id{0}; const CChainParams& chainparams = Params(); auto connman = std::make_unique(0x1337, 0x1337, *m_node.addrman); - auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, nullptr, *m_node.scheduler, + auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, nullptr, *m_node.chainman, *m_node.mempool, *m_node.mn_metaman, *m_node.mn_sync, *m_node.govman, *m_node.sporkman, /* mn_activeman = */ nullptr, m_node.dmnman, m_node.cj_ctx, m_node.llmq_ctx, /* ignore_incoming_txs = */ false); @@ -298,7 +298,7 @@ BOOST_AUTO_TEST_CASE(peer_discouragement) const CChainParams& chainparams = Params(); auto banman = std::make_unique(m_args.GetDataDirBase() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME); auto connman = std::make_unique(0x1337, 0x1337, *m_node.addrman); - auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(), *m_node.scheduler, + auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(), *m_node.chainman, *m_node.mempool, *m_node.mn_metaman, *m_node.mn_sync, *m_node.govman, *m_node.sporkman, /* mn_activeman = */ nullptr, m_node.dmnman, m_node.cj_ctx, m_node.llmq_ctx, /* ignore_incoming_txs = */ false); @@ -416,7 +416,7 @@ BOOST_AUTO_TEST_CASE(DoS_bantime) const CChainParams& chainparams = Params(); auto banman = std::make_unique(m_args.GetDataDirBase() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME); auto connman = std::make_unique(0x1337, 0x1337, *m_node.addrman); - auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(), *m_node.scheduler, + auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(), *m_node.chainman, *m_node.mempool, *m_node.mn_metaman, *m_node.mn_sync, *m_node.govman, *m_node.sporkman, /* mn_activeman = */ nullptr, m_node.dmnman, m_node.cj_ctx, m_node.llmq_ctx, /* ignore_incoming_txs = */ false); diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index 9d84c6a300c3a..bb8ef10a67056 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -281,7 +281,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector(m_args.GetDataDirBase() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME); m_node.peerman = PeerManager::make(chainparams, *m_node.connman, *m_node.addrman, m_node.banman.get(), - *m_node.scheduler, *m_node.chainman, *m_node.mempool, *m_node.mn_metaman, *m_node.mn_sync, + *m_node.chainman, *m_node.mempool, *m_node.mn_metaman, *m_node.mn_sync, *m_node.govman, *m_node.sporkman, /* mn_activeman = */ nullptr, m_node.dmnman, m_node.cj_ctx, m_node.llmq_ctx, /* ignore_incoming_txs = */ false); { From 79f226de9e3ddbb0a13ec8447cd4db2e6952b684 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 5 Aug 2021 09:40:46 +0200 Subject: [PATCH 3/3] Merge bitcoin/bitcoin#22277: test: Properly set BIP34 height in CreateNewBlock_validity unit test faa670d3862783017f5cd1491f37648e1875f19f test: Properly set BIP34 height in CreateNewBlock_validity unit test (MarcoFalke) Pull request description: The coinbase scriptSig in this unit test has several issues: * The BIP34 height is not the "first item" as required (See https://github.com/bitcoin/bips/blob/master/bip-0034.mediawiki#specification) * It uses the wrong encoding ( See https://github.com/bitcoin/bitcoin/blob/da69d9965a112c6421fce5649b5a18beb7513526/src/validation.cpp#L3250 ) * It uses the wrong height (off by one) While BIP34 isn't currently enforced in this unit test, this should be fixed to avoid confusion and to promote self-consistency. The change obviously requires new proof of work (`BLOCKINFO`). Also change the block version from `1` to `VERSIONBITS_TOP_BITS`, because this test shouldn't care about the block version and bumping it is required for other changes. ACKs for top commit: theStack: Code review ACK faa670d3862783017f5cd1491f37648e1875f19f Tree-SHA512: 8dbe2d5300a640f3e1817ff048906e60463aca64ba50fec8ee4f18fb1c70e511008755b0b5baba81114a1a6265fdfae9a4b7ae8acadfb2c7ad43223157a0386c --- src/test/miner_tests.cpp | 68 ++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 41 deletions(-) diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index 5d1e01d388415..1ede7de587361 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -59,39 +59,27 @@ BlockAssembler MinerTestingSetup::AssemblerForTest(const CChainParams& params) constexpr static struct { unsigned char extranonce; unsigned int nonce; -} blockinfo[] = { - {0, 0x0017f257}, {0, 0x000d4581}, {0, 0x0048042c}, {0, 0x0025bff0}, - {0, 0x2002d3f8}, {0, 0x6001161f}, {0, 0xe000c5e5}, {0, 0x2000cce2}, - {0, 0x40004753}, {0, 0x80025297}, {0, 0x600009de}, {0, 0x6005780c}, - {0, 0x40025ae9}, {0, 0xc000341c}, {0, 0xc0053062}, {0, 0x40002f90}, - {0, 0xc00047ae}, {0, 0xa0015716}, {0, 0x2000d499}, {0, 0x80009b45}, - {0, 0xc000a7c9}, {0, 0x8001f8ba}, {0, 0xc000d147}, {0, 0x60018ac3}, - {0, 0xc000a9ac}, {0, 0xa003f6e6}, {0, 0x2007436e}, {0, 0xc0013f28}, - {0, 0x00010892}, {0, 0xa0000027}, {0, 0x40008de9}, {0, 0x400019f3}, - {0, 0x00025b86}, {0, 0x80002799}, {0, 0xc001eb0e}, {0, 0xe003e950}, - {0, 0xe001ff87}, {0, 0x000158b0}, {0, 0x600189da}, {0, 0x0000028c}, - {0, 0x600014ca}, {0, 0x60000e4d}, {0, 0xc0000820}, {0, 0xa005184e}, - {0, 0x40012b22}, {0, 0xe0028f6b}, {0, 0xe0027bce}, {0, 0xa0007b51}, - {0, 0x8002496d}, {0, 0xc001f211}, {0, 0x00032bf0}, {0, 0x4002d767}, - {0, 0x6008410a}, {0, 0x800361c3}, {0, 0xe000f80d}, {0, 0xe009ac97}, - {0, 0x80002103}, {0, 0x6001fab4}, {0, 0x4002843b}, {0, 0x6002b67c}, - {0, 0xa000faf3}, {0, 0x6000949e}, {0, 0x80000f1f}, {0, 0x6000c946}, - {0, 0xe00314b3}, {0, 0x20012bbf}, {0, 0x00009c7e}, {0, 0x2003e63a}, - {0, 0x20025157}, {0, 0x80041ff5}, {0, 0x60012a6c}, {0, 0x4000119b}, - {0, 0xc000a454}, {0, 0x20042c4b}, {0, 0x0003003c}, {0, 0x000558b2}, - {0, 0x2000198c}, {0, 0x200b0b3e}, {0, 0x4001c1e4}, {0, 0x80000034}, - {0, 0xe00039d1}, {0, 0xc001ded3}, {0, 0x80006740}, {0, 0xc0014546}, - {0, 0x00036a1a}, {0, 0xa001ae9c}, {0, 0x6000a148}, {0, 0xe001fd73}, - {0, 0xa001cebb}, {0, 0xa000d4b8}, {0, 0xe00154b3}, {0, 0x40004bec}, - {0, 0xc003f230}, {0, 0xe0069a26}, {0, 0xa00072b4}, {0, 0xc002e1b2}, - {0, 0x20009a02}, {0, 0xc0004a10}, {0, 0xe0045a11}, {0, 0x60034d09}, - {0, 0x000073ff}, {0, 0x00003f1c}, {0, 0x4002c4fd}, {0, 0x2000bb60}, - {0, 0x4000b6b6}, {0, 0x6000ea25}, {0, 0x400989d9}, {0, 0xc000877f}, - {0, 0x6000d17c}, {0, 0xc0009228}, {0, 0x4002827f}, {0, 0x80056a85}, - {0, 0x40045af7}, {0, 0x6000df7a}, {0, 0xe00131a1}, {0, 0x40021386}, - {0, 0xa00891b5}, {0, 0x60007854}, {0, 0x602cee70} -}; -constexpr static size_t blockinfo_size = sizeof(blockinfo) / sizeof(blockinfo[0]); +} BLOCKINFO[]{{0, 1123860}, {0, 1148713}, {0, 2157897}, {0, 6137383}, {0, 1440467}, {0, 1248137}, + {0, 974559}, {0, 3450180}, {0, 2050647}, {0, 1174391}, {0, 3336468}, {0, 464427}, + {0, 470596}, {0, 182567}, {0, 2534464}, {0, 1926037}, {0, 3526872}, {0, 2481471}, + {0, 1294544}, {0, 367787}, {0, 3164800}, {0, 917651}, {0, 654264}, {0, 3621441}, + {0, 4300293}, {0, 3692002}, {0, 3171815}, {0, 2334617}, {0, 2655536}, {0, 4862462}, + {0, 3306418}, {0, 720711}, {0, 3443522}, {0, 1435662}, {0, 833747}, {0, 2754854}, + {0, 1788881}, {0, 1006158}, {0, 3889636}, {0, 1065940}, {0, 2637337}, {0, 1540467}, + {0, 809898}, {0, 414399}, {0, 5978379}, {0, 2301882}, {0, 3224887}, {0, 2557012}, + {0, 8076465}, {0, 73633}, {0, 1285282}, {0, 3114919}, {0, 1762402}, {0, 3343293}, + {0, 3822496}, {0, 2957067}, {0, 1943866}, {0, 5933446}, {0, 886955}, {0, 975375}, + {0, 1626364}, {0, 4337875}, {0, 522971}, {0, 979749}, {0, 2343272}, {0, 2530995}, + {0, 1060534}, {0, 2522523}, {0, 1315215}, {0, 1730093}, {0, 2547908}, {0, 2889564}, + {0, 5456339}, {0, 3881378}, {0, 4533810}, {0, 1700063}, {0, 1086006}, {0, 2797169}, + {0, 2019861}, {0, 883169}, {0, 1750363}, {0, 1721942}, {0, 5058071}, {0, 3225093}, + {0, 307451}, {0, 1653602}, {0, 2281488}, {0, 1947311}, {0, 4993782}, {0, 325324}, + {0, 6304803}, {0, 4880118}, {0, 1401148}, {0, 4640270}, {0, 2548166}, {0, 3369900}, + {0, 2800169}, {0, 3305191}, {0, 2122926}, {0, 336011}, {0, 1722772}, {0, 1044908}, + {0, 642154}, {0, 5835730}, {0, 164952}, {0, 1584353}, {0, 666367}, {0, 854797}, + {0, 2407599}, {0, 3328128}, {0, 245451}, {0, 2154593}, {0, 4043042}, {0, 2939387}, + {0, 3509685}, {0, 635871}, {0, 2645814}, {0, 1788871}, {0, 2263667}}; +constexpr static size_t blockinfo_size = sizeof(BLOCKINFO) / sizeof(BLOCKINFO[0]); static CBlockIndex CreateBlockIndex(int nHeight, CBlockIndex* active_chain_tip) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { @@ -241,13 +229,11 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) CBlock *pblock = &pemptyblocktemplate->block; // pointer for convenience { LOCK(cs_main); - pblock->nVersion = 2; + pblock->nVersion = VERSIONBITS_TOP_BITS; pblock->nTime = m_node.chainman->ActiveChain().Tip()->GetMedianTimePast()+1; CMutableTransaction txCoinbase(*pblock->vtx[0]); txCoinbase.nVersion = 1; - txCoinbase.vin[0].scriptSig = CScript() << (m_node.chainman->ActiveChain().Height() + 1); - txCoinbase.vin[0].scriptSig.push_back(blockinfo[i].extranonce); - txCoinbase.vin[0].scriptSig.push_back(m_node.chainman->ActiveChain().Height()); + txCoinbase.vin[0].scriptSig = CScript{} << (m_node.chainman->ActiveChain().Height() + 1) << BLOCKINFO[i].extranonce; txCoinbase.vout[0].scriptPubKey = CScript(); pblock->vtx[0] = MakeTransactionRef(std::move(txCoinbase)); if (txFirst.size() == 0) @@ -255,10 +241,10 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) if (txFirst.size() < 4) txFirst.push_back(pblock->vtx[0]); pblock->hashMerkleRoot = BlockMerkleRoot(*pblock); - pblock->nNonce = blockinfo[i].nonce; + pblock->nNonce = BLOCKINFO[i].nonce; - // This will usually succeed in the first round as we take the nonce from blockinfo - // It's however useful when adding new blocks with unknown nonces (you should add the found block to blockinfo) + // This will usually succeed in the first round as we take the nonce from BLOCKINFO + // It's however useful when adding new blocks with unknown nonces (you should add the found block to BLOCKINFO) while (!CheckProofOfWork(pblock->GetHash(), pblock->nBits, chainparams.GetConsensus())) { pblock->nNonce++; } @@ -268,7 +254,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) pblock->hashPrevBlock = pblock->GetHash(); }; - for ([[maybe_unused]] const auto& _ : blockinfo) { + for ([[maybe_unused]] const auto& _ : BLOCKINFO) { createAndProcessEmptyBlock(); }