refactor: Get rid of more redundant chain methods #19425

pull ryanofsky wants to merge 3 commits into bitcoin:master from ryanofsky:pr/next changing 13 files +101 −150
  1. ryanofsky commented at 4:54 PM on July 1, 2020: contributor

    This just drops three interfaces::Chain methods replacing them with other calls.

    Motivation for removing these chain methods:

    Behavior is not changing in any way here. A TODO comment in ScanForWalletTransactions was removed, but just because it was invalid (see #19195 (review)), not because it was implemented.

  2. ryanofsky force-pushed on Jul 1, 2020
  3. ryanofsky commented at 5:36 PM on July 1, 2020: contributor

    Updated 0c9dea569a41c1fa50b2409fabc531cfa663ad51 -> 87bc7618cf561ed97835558b6e0c19affdc2aaeb (pr/next.1 -> pr/next.2, compare) adding comments and removing stale TODO. Still no changes in behavior Updated 87bc7618cf561ed97835558b6e0c19affdc2aaeb -> 91ac0388e88f69531bd7c957e9d0e5ee5e36b347 (pr/next.2 -> pr/next.3, compare) with more minor cleanups

  4. ryanofsky cross-referenced this on Jul 1, 2020 from issue wallet: ScanForWalletTransactions cleanup by pstratem
  5. DrahtBot commented at 5:44 PM on July 1, 2020: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #19983 (Drop some TSan suppressions by hebasto)
    • #19982 (test: Fix inconsistent lock order in wallet_tests/CreateWallet by hebasto)
    • #19195 (wallet: ScanForWalletTransactions cleanup by pstratem)
    • #19160 (multiprocess: Add basic spawn and IPC support by ryanofsky)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  6. DrahtBot added the label Refactoring on Jul 1, 2020
  7. DrahtBot added the label Tests on Jul 1, 2020
  8. DrahtBot added the label Wallet on Jul 1, 2020
  9. DrahtBot cross-referenced this on Jul 1, 2020 from issue multiprocess: Add basic spawn and IPC support by ryanofsky
  10. DrahtBot cross-referenced this on Jul 1, 2020 from issue Wallet passive startup by ryanofsky
  11. DrahtBot cross-referenced this on Jul 1, 2020 from issue Multiprocess bitcoin by ryanofsky
  12. promag commented at 8:23 AM on July 3, 2020: member

    Concept ACK.

  13. DrahtBot cross-referenced this on Jul 7, 2020 from issue multiprocess: Add bitcoin-gui -ipcconnect option by ryanofsky
  14. DrahtBot cross-referenced this on Jul 7, 2020 from issue multiprocess: Add bitcoin-wallet -ipcconnect option by ryanofsky
  15. DrahtBot cross-referenced this on Jul 8, 2020 from issue Prune locks by luke-jr
  16. laanwj commented at 4:45 PM on July 9, 2020: member

    Concept ACK. I find this code really hard to review.

  17. ryanofsky force-pushed on Jul 10, 2020
  18. in src/interfaces/chain.cpp:50 in 91ac0388e8 outdated
      45 | @@ -46,6 +46,8 @@ bool FillBlock(const CBlockIndex* index, const FoundBlock& block, UniqueLock<Rec
      46 |      if (block.m_time) *block.m_time = index->GetBlockTime();
      47 |      if (block.m_max_time) *block.m_max_time = index->GetBlockTimeMax();
      48 |      if (block.m_mtp_time) *block.m_mtp_time = index->GetMedianTimePast();
      49 | +    if (block.m_in_active_chain) *block.m_in_active_chain = ::ChainActive()[index->nHeight] == index;
      50 | +    if (block.m_next_block) FillBlock(ChainActive()[index->nHeight] == index ? ChainActive()[index->nHeight + 1] : nullptr, *block.m_next_block, lock);
    


    promag commented at 9:59 PM on July 16, 2020:

    nit, should be ::ChainActive?

    Anyway, maybe add argument CChain& chain to FillBlock to avoid multiple calls to ChainActive()?


    MarcoFalke commented at 6:05 AM on July 17, 2020:

    Also, new code should probably use node->chainman.activeChain


    ryanofsky commented at 2:16 PM on July 21, 2020:

    re: #19425 (review)

    Also, new code should probably use node->chainman.activeChain

    Removed ChainActive calls in new commit.

  19. in src/interfaces/chain.cpp:53 in 91ac0388e8 outdated
      45 | @@ -46,6 +46,8 @@ bool FillBlock(const CBlockIndex* index, const FoundBlock& block, UniqueLock<Rec
      46 |      if (block.m_time) *block.m_time = index->GetBlockTime();
      47 |      if (block.m_max_time) *block.m_max_time = index->GetBlockTimeMax();
      48 |      if (block.m_mtp_time) *block.m_mtp_time = index->GetMedianTimePast();
      49 | +    if (block.m_in_active_chain) *block.m_in_active_chain = ::ChainActive()[index->nHeight] == index;
      50 | +    if (block.m_next_block) FillBlock(ChainActive()[index->nHeight] == index ? ChainActive()[index->nHeight + 1] : nullptr, *block.m_next_block, lock);
      51 |      if (block.m_data) {
      52 |          REVERSE_LOCK(lock);
      53 |          if (!ReadBlockFromDisk(*block.m_data, index, Params().GetConsensus())) block.m_data->SetNull();
    


    promag commented at 10:05 PM on July 16, 2020:

    Unrelated, but why return true if ReadBlockfromDisk fails?


    ryanofsky commented at 11:03 PM on July 16, 2020:

    re: #19425 (review)

    Unrelated, but why return true if ReadBlockfromDisk fails?

    findBlock and related methods return true if the block is found, false if it is not found. Whether block data is available is a different question. In practice ReadBlockFromDisk fails when a block is pruned, and callers that want to see if data is pruned can check data.IsNull. We could also add more accessors to return pruning information if there's a need.

  20. ryanofsky referenced this in commit 7ed165a586 on Jul 21, 2020
  21. ryanofsky force-pushed on Jul 21, 2020
  22. ryanofsky commented at 3:13 PM on July 21, 2020: contributor

    Updated 91ac0388e88f69531bd7c957e9d0e5ee5e36b347 -> 7ed165a586ac7a32f4f80be0ead81bee0250f430 (pr/next.3 -> pr/next.4, compare) adding commit to get rid of ChainActive

  23. DrahtBot cross-referenced this on Jul 22, 2020 from issue refactor: remove ::vpwallets and related global variables by ryanofsky
  24. DrahtBot cross-referenced this on Jul 22, 2020 from issue refactor: Move wallet methods out of chain.h and node.h by ryanofsky
  25. DrahtBot cross-referenced this on Jul 22, 2020 from issue test: Remove duplicate NodeContext hacks by ryanofsky
  26. DrahtBot cross-referenced this on Jul 22, 2020 from issue Use shared pointers only in validation interface by bvbfan
  27. DrahtBot cross-referenced this on Jul 29, 2020 from issue Remove wallet.dat path handling from wallet.cpp, rpcwallet.cpp by ryanofsky
  28. DrahtBot added the label Needs rebase on Aug 7, 2020
  29. MarcoFalke removed the label Refactoring on Aug 7, 2020
  30. MarcoFalke removed the label Tests on Aug 7, 2020
  31. MarcoFalke removed the label Wallet on Aug 7, 2020
  32. MarcoFalke added the label interfaces on Aug 7, 2020
  33. in src/interfaces/chain.cpp:347 in 7ed165a586 outdated
     343 | @@ -358,7 +344,8 @@ class ChainImpl : public Chain
     344 |      {
     345 |          if (!old_tip.IsNull()) {
     346 |              LOCK(::cs_main);
     347 | -            if (old_tip == ::ChainActive().Tip()->GetBlockHash()) return;
     348 | +            const CChain& active = m_node.chainman->ActiveChain();
    


    MarcoFalke commented at 9:17 AM on August 7, 2020:
                const CChain& active = Assert(m_node.chainman)->ActiveChain();
    

    style-nit, no strong opinion, though.


    ryanofsky commented at 8:52 PM on August 7, 2020:

    re: #19425 (review)

    style-nit, no strong opinion, though.

    Thanks, switched throughout

  34. ryanofsky referenced this in commit e9c9a06444 on Aug 7, 2020
  35. ryanofsky referenced this in commit 6e10c2b883 on Aug 7, 2020
  36. ryanofsky force-pushed on Aug 7, 2020
  37. ryanofsky commented at 9:05 PM on August 7, 2020: contributor

    Rebased 7ed165a586ac7a32f4f80be0ead81bee0250f430 -> 6e10c2b8832d24cc010fd39b23e23543e00012e5 (pr/next.4 -> pr/next.5, compare) due to conflict with #19098

  38. DrahtBot removed the label Needs rebase on Aug 7, 2020
  39. DrahtBot cross-referenced this on Aug 20, 2020 from issue wallet: Add sqlite as an alternative wallet database and use it for new descriptor wallets by achow101
  40. laanwj commented at 12:33 PM on September 1, 2020: member

    I managed to review the code and am fairly sure it is correct. Code review ACK 6e10c2b8832d24cc010fd39b23e23543e00012e5

  41. DrahtBot added the label Needs rebase on Sep 7, 2020
  42. ryanofsky referenced this in commit cc4faf1996 on Sep 25, 2020
  43. ryanofsky referenced this in commit 9931714c0a on Sep 25, 2020
  44. ryanofsky force-pushed on Sep 25, 2020
  45. DrahtBot removed the label Needs rebase on Sep 25, 2020
  46. DrahtBot cross-referenced this on Sep 25, 2020 from issue Drop some TSan suppressions by hebasto
  47. DrahtBot cross-referenced this on Sep 25, 2020 from issue test: Fix inconsistent lock order in wallet_tests/CreateWallet by hebasto
  48. ryanofsky commented at 11:04 AM on September 28, 2020: contributor

    Rebased 6e10c2b8832d24cc010fd39b23e23543e00012e5 -> 9931714c0a1347d377b73f50e900c1138081d1c2 (pr/next.5 -> pr/next.6, compare) due to conflict with #19619

  49. DrahtBot cross-referenced this on Oct 15, 2020 from issue tree-wide: De-globalize ChainstateManager by dongcarl
  50. dongcarl commented at 8:47 PM on October 19, 2020: contributor

    Code Review ACK 9931714c0a1347d377b73f50e900c1138081d1c2

    • 97e683d1a1f57dd8fac080eec1a0fe83419df7ac doesn't seem to change behaviour, and seems to match FoundBlock's conventions. I found the calling conventions to be a bit weird but they're still understandable. Perhaps someone can tell me why we do it this way, is it for efficiency?
    • 9931714c0a1347d377b73f50e900c1138081d1c2 arrived at the same conclusion as I did for resolving multiple NodeContexts. See: ef1b08c (#20158) and a9539e7 (#20158). Elimination of ::ChainActive() also makes my diff for #20158 shorter.
  51. ryanofsky commented at 9:07 PM on October 19, 2020: contributor

    Thanks for reviewing!

    Perhaps someone can tell me why we do it this way, is it for efficiency?

    It's called a "fluent interface" and it's just a way emulating a way of named parameters in languages which don't support them: https://en.wikipedia.org/wiki/Fluent_interface. The alternatives are adding unnamed parameters or adding method overloads

  52. DrahtBot cross-referenced this on Nov 5, 2020 from issue tests: Create or use existing properly initialized NodeContexts by dongcarl
  53. MarcoFalke added the label Refactoring on Nov 19, 2020
  54. in src/interfaces/chain.h:49 in 9931714c0a outdated
      43 | @@ -44,6 +44,10 @@ class FoundBlock
      44 |      FoundBlock& time(int64_t& time) { m_time = &time; return *this; }
      45 |      FoundBlock& maxTime(int64_t& max_time) { m_max_time = &max_time; return *this; }
      46 |      FoundBlock& mtpTime(int64_t& mtp_time) { m_mtp_time = &mtp_time; return *this; }
      47 | +    //! Return whether block is in the active (most-work) chain.
      48 | +    FoundBlock& inActiveChain(bool& in_active_chain) { m_in_active_chain = &in_active_chain; return *this; }
      49 | +    //! Return next block in the active chain if current block is in the active chain.
    


    MarcoFalke commented at 8:30 AM on November 19, 2020:

    It seems fragile to require the caller to have to pass inActiveChain here as well and initialize the bool reference that was passed to false.

    At the very least the dev docs should mention the footgun.


    dongcarl commented at 5:01 PM on December 3, 2020:

    Curious: Why does the passed bool reference have to be initialized to false? Wouldn't it be okay for it to be initialized to true as well?


    MarcoFalke commented at 5:29 PM on December 3, 2020:

    That would imply if the block isn't found it is assumed to be in the active chain? Seems a footgun just as dangerous


    ryanofsky commented at 11:36 PM on December 7, 2020:

    re: #19425 (review)

    That would imply if the block isn't found it is assumed to be in the active chain? Seems a footgun just as dangerous

    Information about a block isn't returned if the block doesn't exist. Maybe this is a footgun but it is also pre-existing behavior and how every other accessor works here. I don't think this PR would be improved by initializing this one property while not initializing the others. Inconsistent initialization seems like a bigger footgun, worse than uniformly requiring callers to initialize values that they read.

    Maybe in the future another PR could decide on special default values to return for each block property when a block doesn't exist. Maybe this would make calling code safer in case it forgets to initialize a variable. But I could also imagine it leading to other bugs if a caller choses its own different default value and then checks against that wrong value. I could imagine it making calling code harder to read, because you may need to look up default values to understand it instead of being able to rely on initial values being unchanged. All of this is arguable and I don't have strong opinions, but I do think changing this would go beyond scope of current PR and that it would probably be better to look into separately.

  55. in src/bench/wallet_balance.cpp:27 in 9931714c0a outdated
      23 | @@ -24,15 +24,14 @@ static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const b
      24 |  
      25 |      const auto& ADDRESS_WATCHONLY = ADDRESS_BCRT1_UNSPENDABLE;
      26 |  
      27 | -    NodeContext node;
      28 | -    std::unique_ptr<interfaces::Chain> chain = interfaces::MakeChain(node);
      29 | -    CWallet wallet{chain.get(), "", CreateMockWalletDatabase()};
      30 | +    test_setup.m_node.chain = interfaces::MakeChain(test_setup.m_node);
    


    MarcoFalke commented at 9:11 AM on November 19, 2020:

    Can you explain what this is doing and why the redundant call is needed?

    diff --git a/src/bench/wallet_balance.cpp b/src/bench/wallet_balance.cpp
    index 98eac80055..aa436ee3ea 100644
    --- a/src/bench/wallet_balance.cpp
    +++ b/src/bench/wallet_balance.cpp
    @@ -24,7 +24,6 @@ static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const b
     
         const auto& ADDRESS_WATCHONLY = ADDRESS_BCRT1_UNSPENDABLE;
     
    -    test_setup.m_node.chain = interfaces::MakeChain(test_setup.m_node);
         CWallet wallet{test_setup.m_node.chain.get(), "", CreateMockWalletDatabase()};
         {
             wallet.SetupLegacyScriptPubKeyMan();
    diff --git a/src/test/interfaces_tests.cpp b/src/test/interfaces_tests.cpp
    index b8c4bc8605..73463b071e 100644
    --- a/src/test/interfaces_tests.cpp
    +++ b/src/test/interfaces_tests.cpp
    @@ -17,7 +17,7 @@ BOOST_FIXTURE_TEST_SUITE(interfaces_tests, TestChain100Setup)
     
     BOOST_AUTO_TEST_CASE(findBlock)
     {
    -    auto chain = interfaces::MakeChain(m_node);
    +    auto& chain = m_node.chain;
         const CChain& active = Assert(m_node.chainman)->ActiveChain();
     
         uint256 hash;
    @@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE(findBlock)
     
     BOOST_AUTO_TEST_CASE(findFirstBlockWithTimeAndHeight)
     {
    -    auto chain = interfaces::MakeChain(m_node);
    +    auto& chain = m_node.chain;
         const CChain& active = Assert(m_node.chainman)->ActiveChain();
         uint256 hash;
         int height;
    @@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE(findFirstBlockWithTimeAndHeight)
     
     BOOST_AUTO_TEST_CASE(findAncestorByHeight)
     {
    -    auto chain = interfaces::MakeChain(m_node);
    +    auto& chain = m_node.chain;
         const CChain& active = Assert(m_node.chainman)->ActiveChain();
         uint256 hash;
         BOOST_CHECK(chain->findAncestorByHeight(active[20]->GetBlockHash(), 10, FoundBlock().hash(hash)));
    @@ -83,7 +83,7 @@ BOOST_AUTO_TEST_CASE(findAncestorByHeight)
     
     BOOST_AUTO_TEST_CASE(findAncestorByHash)
     {
    -    auto chain = interfaces::MakeChain(m_node);
    +    auto& chain = m_node.chain;
         const CChain& active = Assert(m_node.chainman)->ActiveChain();
         int height = -1;
         BOOST_CHECK(chain->findAncestorByHash(active[20]->GetBlockHash(), active[10]->GetBlockHash(), FoundBlock().height(height)));
    @@ -93,7 +93,7 @@ BOOST_AUTO_TEST_CASE(findAncestorByHash)
     
     BOOST_AUTO_TEST_CASE(findCommonAncestor)
     {
    -    auto chain = interfaces::MakeChain(m_node);
    +    auto& chain = m_node.chain;
         const CChain& active = Assert(m_node.chainman)->ActiveChain();
         auto* orig_tip = active.Tip();
         for (int i = 0; i < 10; ++i) {
    @@ -123,7 +123,7 @@ BOOST_AUTO_TEST_CASE(findCommonAncestor)
     
     BOOST_AUTO_TEST_CASE(hasBlocks)
     {
    -    auto chain = interfaces::MakeChain(m_node);
    +    auto& chain = m_node.chain;
         const CChain& active = Assert(m_node.chainman)->ActiveChain();
     
         // Test ranges
    diff --git a/src/wallet/test/coinselector_tests.cpp b/src/wallet/test/coinselector_tests.cpp
    index f38ccba384..4127cd45f8 100644
    --- a/src/wallet/test/coinselector_tests.cpp
    +++ b/src/wallet/test/coinselector_tests.cpp
    @@ -283,7 +283,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
         // Make sure that can use BnB when there are preset inputs
         empty_wallet();
         {
    -        std::unique_ptr<CWallet> wallet = MakeUnique<CWallet>(m_chain.get(), "", CreateMockWalletDatabase());
    +        std::unique_ptr<CWallet> wallet = MakeUnique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
             bool firstRun;
             wallet->LoadWallet(firstRun);
             wallet->SetupLegacyScriptPubKeyMan();
    diff --git a/src/wallet/test/init_test_fixture.cpp b/src/wallet/test/init_test_fixture.cpp
    index c80310045a..334e4ae0d8 100644
    --- a/src/wallet/test/init_test_fixture.cpp
    +++ b/src/wallet/test/init_test_fixture.cpp
    @@ -10,7 +10,7 @@
     
     InitWalletDirTestingSetup::InitWalletDirTestingSetup(const std::string& chainName) : BasicTestingSetup(chainName)
     {
    -    m_wallet_client = MakeWalletClient(*m_chain, *Assert(m_node.args));
    +    m_wallet_client = MakeWalletClient(*m_node.chain, *Assert(m_node.args));
     
         std::string sep;
         sep += fs::path::preferred_separator;
    diff --git a/src/wallet/test/init_test_fixture.h b/src/wallet/test/init_test_fixture.h
    index f5bade77df..f666c45a34 100644
    --- a/src/wallet/test/init_test_fixture.h
    +++ b/src/wallet/test/init_test_fixture.h
    @@ -19,7 +19,6 @@ struct InitWalletDirTestingSetup: public BasicTestingSetup {
         fs::path m_datadir;
         fs::path m_cwd;
         std::map<std::string, fs::path> m_walletdir_path_cases;
    -    std::unique_ptr<interfaces::Chain> m_chain = interfaces::MakeChain(m_node);
         std::unique_ptr<interfaces::WalletClient> m_wallet_client;
     };
     
    diff --git a/src/wallet/test/ismine_tests.cpp b/src/wallet/test/ismine_tests.cpp
    index d5aed99d99..0ef8b9c4bf 100644
    --- a/src/wallet/test/ismine_tests.cpp
    +++ b/src/wallet/test/ismine_tests.cpp
    @@ -27,8 +27,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
         CKey uncompressedKey;
         uncompressedKey.MakeNewKey(false);
         CPubKey uncompressedPubkey = uncompressedKey.GetPubKey();
    -    NodeContext node;
    -    std::unique_ptr<interfaces::Chain> chain = interfaces::MakeChain(node);
    +    std::unique_ptr<interfaces::Chain>& chain = m_node.chain;
     
         CScript scriptPubKey;
         isminetype result;
    diff --git a/src/wallet/test/scriptpubkeyman_tests.cpp b/src/wallet/test/scriptpubkeyman_tests.cpp
    index f7c1337b0d..347a436429 100644
    --- a/src/wallet/test/scriptpubkeyman_tests.cpp
    +++ b/src/wallet/test/scriptpubkeyman_tests.cpp
    @@ -17,9 +17,7 @@ BOOST_FIXTURE_TEST_SUITE(scriptpubkeyman_tests, BasicTestingSetup)
     BOOST_AUTO_TEST_CASE(CanProvide)
     {
         // Set up wallet and keyman variables.
    -    NodeContext node;
    -    std::unique_ptr<interfaces::Chain> chain = interfaces::MakeChain(node);
    -    CWallet wallet(chain.get(), "", CreateDummyWalletDatabase());
    +    CWallet wallet(m_node.chain.get(), "", CreateDummyWalletDatabase());
         LegacyScriptPubKeyMan& keyman = *wallet.GetOrCreateLegacyScriptPubKeyMan();
     
         // Make a 1 of 2 multisig script
    diff --git a/src/wallet/test/wallet_test_fixture.cpp b/src/wallet/test/wallet_test_fixture.cpp
    index 4d6f427618..badf2eb459 100644
    --- a/src/wallet/test/wallet_test_fixture.cpp
    +++ b/src/wallet/test/wallet_test_fixture.cpp
    @@ -6,10 +6,10 @@
     
     WalletTestingSetup::WalletTestingSetup(const std::string& chainName)
         : TestingSetup(chainName),
    -      m_wallet(m_chain.get(), "", CreateMockWalletDatabase())
    +      m_wallet(m_node.chain.get(), "", CreateMockWalletDatabase())
     {
         bool fFirstRun;
         m_wallet.LoadWallet(fFirstRun);
    -    m_chain_notifications_handler = m_chain->handleNotifications({ &m_wallet, [](CWallet*) {} });
    +    m_chain_notifications_handler = m_node.chain->handleNotifications({ &m_wallet, [](CWallet*) {} });
         m_wallet_client->registerRpcs();
     }
    diff --git a/src/wallet/test/wallet_test_fixture.h b/src/wallet/test/wallet_test_fixture.h
    index ba8a5ff1f3..ab7fb8c42b 100644
    --- a/src/wallet/test/wallet_test_fixture.h
    +++ b/src/wallet/test/wallet_test_fixture.h
    @@ -20,8 +20,7 @@
     struct WalletTestingSetup : public TestingSetup {
         explicit WalletTestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
     
    -    std::unique_ptr<interfaces::Chain> m_chain = interfaces::MakeChain(m_node);
    -    std::unique_ptr<interfaces::WalletClient> m_wallet_client = interfaces::MakeWalletClient(*m_chain, *Assert(m_node.args));
    +    std::unique_ptr<interfaces::WalletClient> m_wallet_client = interfaces::MakeWalletClient(*m_node.chain, *Assert(m_node.args));
         CWallet m_wallet;
         std::unique_ptr<interfaces::Handler> m_chain_notifications_handler;
     };
    diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp
    index 156be053d0..eb0bbb6ccc 100644
    --- a/src/wallet/test/wallet_tests.cpp
    +++ b/src/wallet/test/wallet_tests.cpp
    @@ -83,8 +83,6 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
         CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
         CBlockIndex* newTip = ::ChainActive().Tip();
     
    -    m_node.chain = interfaces::MakeChain(m_node);
    -
         // Verify ScanForWalletTransactions fails to read an unknown start block.
         {
             CWallet wallet(m_node.chain.get(), "", CreateDummyWalletDatabase());
    @@ -182,8 +180,6 @@ BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain100Setup)
         CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
         CBlockIndex* newTip = ::ChainActive().Tip();
     
    -    m_node.chain = interfaces::MakeChain(m_node);
    -
         // Prune the older block file.
         {
             LOCK(cs_main);
    @@ -253,8 +249,6 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
         SetMockTime(KEY_TIME);
         m_coinbase_txns.emplace_back(CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())).vtx[0]);
     
    -    m_node.chain = interfaces::MakeChain(m_node);
    -
         std::string backup_file = (GetDataDir() / "wallet.backup").string();
     
         // Import key into wallet and call dumpwallet to create backup file.
    @@ -489,7 +483,6 @@ public:
         ListCoinsTestingSetup()
         {
             CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
    -        m_node.chain = interfaces::MakeChain(m_node);
             wallet = MakeUnique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
             {
                 LOCK2(wallet->cs_wallet, ::cs_main);
    @@ -701,7 +694,6 @@ BOOST_FIXTURE_TEST_CASE(wallet_descriptor_test, BasicTestingSetup)
     BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
     {
         // Create new wallet with known key and unload it.
    -    m_node.chain = interfaces::MakeChain(m_node);
         auto wallet = TestLoadWallet(*m_node.chain);
         CKey key;
         key.MakeNewKey(true);
    @@ -794,8 +786,7 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
     
     BOOST_FIXTURE_TEST_CASE(ZapSelectTx, TestChain100Setup)
     {
    -    auto chain = interfaces::MakeChain(m_node);
    -    auto wallet = TestLoadWallet(*chain);
    +    auto wallet = TestLoadWallet(*m_node.chain);
         CKey key;
         key.MakeNewKey(true);
         AddKey(*wallet, key);
    

    dongcarl commented at 4:46 PM on December 3, 2020:

    Right, looks like anything that has a fixture which inherits from BasicTestingSetup will have m_node.chain properly initialized: https://github.com/bitcoin/bitcoin/blob/a0489f3472f3799dc1ece32a59556fd239c4c14b/src/test/util/setup_common.cpp#L109


    ryanofsky commented at 11:37 PM on December 7, 2020:

    re: #19425 (review)

    Right, looks like anything that has a fixture which inherits from BasicTestingSetup will have m_node.chain properly initialized:

    https://github.com/bitcoin/bitcoin/blob/a0489f3472f3799dc1ece32a59556fd239c4c14b/src/test/util/setup_common.cpp#L109

    Thanks, removed this and included Marco's patch in new commit 5baa88fd38c8efa0e361636bb2c60af89d27b5d5. This code in commit 6965f1352d2d7086d308750ce83a84f191a17755 was written July and had to call MakeChain because the change which started setting m_node.chain (#19098) was only merged in August.

  56. MarcoFalke approved
  57. MarcoFalke commented at 9:12 AM on November 19, 2020: member

    cr ACK 9931714c0a1347d377b73f50e900c1138081d1c2 🍲

    <details><summary>Show signature and timestamp</summary>

    Signature:

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA512
    
    cr ACK 9931714c0a1347d377b73f50e900c1138081d1c2 🍲
    -----BEGIN PGP SIGNATURE-----
    
    iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
    pUhUOQwAomF3ZBN9ZKEQ+0iRMfzrYW8WoUmJUUGE+3exY2nV+2nnySpCT2N+nGg6
    YnQk5UWMExmUSqK9JAD783Zfun1YLRASpfL7uZicLs3ZLMVM/4cFLnaoEk9RvrZk
    zZdfdwRcPhhz0WLMjRCgFbubwWNxd2BqVObzUpfhenQBUlggrRn2auHsvJTa0vTN
    19ZWvNDIgq9UYJVwJ47b2X4eu5bJeLcmKWuc+pGxchmAnYfAA6iDklIuG+3AVBWm
    DdDNUttzy5z1o8Bd7s9m8b/EzrhiVUPRx3YsX4hWPCD+YlEb5ATLzERoiFYlqUTY
    RJCuOZPRmLQRhqjRVdAklDVlz7BClOT4cMBwdZeBR0s8keEJqH+F8aCn0U72eFWq
    ix8Fer2Fsj0YOvYIClryzamuFgPvA6e9D+idKdDjY6XXdoLsRljzRSejdOCcbVXu
    wAdcVkI891WiN/EgBmWO9LHi+UCzwbQe1iuJ3j28fzKVcdrZGf6PBsGd+s1WS0XU
    0UUQV8km
    =T1NN
    -----END PGP SIGNATURE-----
    

    python: error while loading shared libraries: libpython3.8.so.1.0: cannot open shared object file: No such file or directory

    </details>

  58. DrahtBot added the label Needs rebase on Dec 1, 2020
  59. refactor: Get rid of more redundant chain methods
    This just drops three interfaces::Chain methods replacing them with other calls.
    
    Motivation for removing these chain methods:
    
    - Need to get rid of findFirstBlockWithTimeAndHeight for #10102, which doesn't
      support overloaded methods
    - Followup from
      https://github.com/bitcoin/bitcoin/pull/16426#discussion_r412487403
    - phantomcircuit comments about findNextBlock test
      http://www.erisian.com.au/bitcoin-core-dev/log-2020-06-06.html#l-214
    
    Behavior is not changing in any way here. A TODO comment in
    ScanForWalletTransactions was removed, but just because it was invalid (see
    https://github.com/bitcoin/bitcoin/pull/19195#discussion_r448020762), not
    because it was implemented.
    3fbbb9a640
  60. refactor: Replace uses ChainActive() in interfaces/chain.cpp
    Suggested https://github.com/bitcoin/bitcoin/pull/19425#discussion_r456236407
    6965f1352d
  61. test: Remove no longer needed MakeChain calls
    These calls are no longer needed after edc316020e8270dafc5e31465d532baebdafd3dd
    from #19098 which started instantiating BasicTestingSetup.m_node.chain
    
    Patch from MarcoFalke <falke.marco@gmail.com> in
    https://github.com/bitcoin/bitcoin/pull/19425#discussion_r526701954
    
    Co-authored-by: MarcoFalke <falke.marco@gmail.com>
    5baa88fd38
  62. ryanofsky referenced this in commit a85f9b5d19 on Dec 8, 2020
  63. ryanofsky force-pushed on Dec 8, 2020
  64. ryanofsky commented at 2:24 AM on December 8, 2020: contributor

    Rebased 9931714c0a1347d377b73f50e900c1138081d1c2 -> 5baa88fd38c8efa0e361636bb2c60af89d27b5d5 (pr/next.6 -> pr/next.7, compare) due to conflict with #20494 and removed MakeChain calls no longer needed after #19098 as suggested

  65. DrahtBot removed the label Needs rebase on Dec 8, 2020
  66. MarcoFalke commented at 11:42 AM on December 8, 2020: member

    re-ACK 5baa88fd38c8efa0e361636bb2c60af89d27b5d5 🕶

    <details><summary>Show signature and timestamp</summary>

    Signature:

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA512
    
    re-ACK 5baa88fd38c8efa0e361636bb2c60af89d27b5d5 🕶
    -----BEGIN PGP SIGNATURE-----
    
    iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
    pUgRQAv6A0yyCNiZr7DYQtS7ubtoC310OFwRL/ghzzgjyS605iRdOHFWzvQxFLaP
    9bKMhe5T5XMu7SE+0Ow3eXiVqXhCAsGqEXvdFxmPSqbmzCoG2bokdG6ZNNzsZ65/
    IvzFdHkmLkT9Cj5knqZhZu9Qc24ncyw212cEQ674OQA53y+76HcE7cyJsS2kx56n
    eBDajcd5wa9GaOSrT0SF4UOgotXCHX+NQgM+QSJRN/ZNAFUbGu4Q+/Qj9YMlvFvg
    zG3TOSI8bi4PX/ygR/J8Ju4Sc4fosMWwsIwaLV0e6ErNEF3dtK/JVCzRvnjyQ38G
    bId7rr1OBLi+pfQBB4oTPYDMgbf06R3cAV+jJ5rlAEcTWw+xMRfxhZEdZqdFGHOz
    ZR1YuPn5EEibs2VmmQMqeuHmBVxYJzaWAjH9OwQI7qkE+CQAa6I/nmoEBmiRk7m4
    z3YbBAY7XfaNH6l455wPcFhaxAcfSWvADHt24amYpmSSH0kvpaWVu9g4QzeCMqtY
    yy+lKj94
    =j9ux
    -----END PGP SIGNATURE-----
    

    Timestamp of file with hash 19b54d707dfb2ae462bb723d421d5753739d3d2543051b56a0b9445ec9485431 -

    </details>

  67. dongcarl commented at 5:30 PM on December 8, 2020: contributor

    ACK 5baa88fd38c8efa0e361636bb2c60af89d27b5d5

  68. MarcoFalke merged this on Dec 8, 2020
  69. MarcoFalke closed this on Dec 8, 2020

  70. sidhujag referenced this in commit 02ed55541b on Dec 8, 2020
  71. bitcoin locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-19 06:53 UTC