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: member

    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: member
    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. DrahtBot commented at 5:44 pm on July 1, 2020: member

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

    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.

  5. DrahtBot added the label Refactoring on Jul 1, 2020
  6. DrahtBot added the label Tests on Jul 1, 2020
  7. DrahtBot added the label Wallet on Jul 1, 2020
  8. promag commented at 8:23 am on July 3, 2020: member
    Concept ACK.
  9. laanwj commented at 4:45 pm on July 9, 2020: member
    Concept ACK. I find this code really hard to review.
  10. ryanofsky force-pushed on Jul 10, 2020
  11. 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.

  12. 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.

  13. ryanofsky referenced this in commit 7ed165a586 on Jul 21, 2020
  14. ryanofsky force-pushed on Jul 21, 2020
  15. ryanofsky commented at 3:13 pm on July 21, 2020: member
    Updated 91ac0388e88f69531bd7c957e9d0e5ee5e36b347 -> 7ed165a586ac7a32f4f80be0ead81bee0250f430 (pr/next.3 -> pr/next.4, compare) adding commit to get rid of ChainActive
  16. DrahtBot added the label Needs rebase on Aug 7, 2020
  17. MarcoFalke removed the label Refactoring on Aug 7, 2020
  18. MarcoFalke removed the label Tests on Aug 7, 2020
  19. MarcoFalke removed the label Wallet on Aug 7, 2020
  20. MarcoFalke added the label interfaces on Aug 7, 2020
  21. 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:
    0            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

  22. ryanofsky referenced this in commit e9c9a06444 on Aug 7, 2020
  23. ryanofsky referenced this in commit 6e10c2b883 on Aug 7, 2020
  24. ryanofsky force-pushed on Aug 7, 2020
  25. ryanofsky commented at 9:05 pm on August 7, 2020: member
    Rebased 7ed165a586ac7a32f4f80be0ead81bee0250f430 -> 6e10c2b8832d24cc010fd39b23e23543e00012e5 (pr/next.4 -> pr/next.5, compare) due to conflict with #19098
  26. DrahtBot removed the label Needs rebase on Aug 7, 2020
  27. 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
  28. DrahtBot added the label Needs rebase on Sep 7, 2020
  29. ryanofsky referenced this in commit cc4faf1996 on Sep 25, 2020
  30. ryanofsky referenced this in commit 9931714c0a on Sep 25, 2020
  31. ryanofsky force-pushed on Sep 25, 2020
  32. DrahtBot removed the label Needs rebase on Sep 25, 2020
  33. ryanofsky commented at 11:04 am on September 28, 2020: member
    Rebased 6e10c2b8832d24cc010fd39b23e23543e00012e5 -> 9931714c0a1347d377b73f50e900c1138081d1c2 (pr/next.5 -> pr/next.6, compare) due to conflict with #19619
  34. dongcarl commented at 8:47 pm on October 19, 2020: member

    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.
  35. ryanofsky commented at 9:07 pm on October 19, 2020: member

    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

  36. MarcoFalke added the label Refactoring on Nov 19, 2020
  37. 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.

  38. 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?

      0diff --git a/src/bench/wallet_balance.cpp b/src/bench/wallet_balance.cpp
      1index 98eac80055..aa436ee3ea 100644
      2--- a/src/bench/wallet_balance.cpp
      3+++ b/src/bench/wallet_balance.cpp
      4@@ -24,7 +24,6 @@ static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const b
      5 
      6     const auto& ADDRESS_WATCHONLY = ADDRESS_BCRT1_UNSPENDABLE;
      7 
      8-    test_setup.m_node.chain = interfaces::MakeChain(test_setup.m_node);
      9     CWallet wallet{test_setup.m_node.chain.get(), "", CreateMockWalletDatabase()};
     10     {
     11         wallet.SetupLegacyScriptPubKeyMan();
     12diff --git a/src/test/interfaces_tests.cpp b/src/test/interfaces_tests.cpp
     13index b8c4bc8605..73463b071e 100644
     14--- a/src/test/interfaces_tests.cpp
     15+++ b/src/test/interfaces_tests.cpp
     16@@ -17,7 +17,7 @@ BOOST_FIXTURE_TEST_SUITE(interfaces_tests, TestChain100Setup)
     17 
     18 BOOST_AUTO_TEST_CASE(findBlock)
     19 {
     20-    auto chain = interfaces::MakeChain(m_node);
     21+    auto& chain = m_node.chain;
     22     const CChain& active = Assert(m_node.chainman)->ActiveChain();
     23 
     24     uint256 hash;
     25@@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE(findBlock)
     26 
     27 BOOST_AUTO_TEST_CASE(findFirstBlockWithTimeAndHeight)
     28 {
     29-    auto chain = interfaces::MakeChain(m_node);
     30+    auto& chain = m_node.chain;
     31     const CChain& active = Assert(m_node.chainman)->ActiveChain();
     32     uint256 hash;
     33     int height;
     34@@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE(findFirstBlockWithTimeAndHeight)
     35 
     36 BOOST_AUTO_TEST_CASE(findAncestorByHeight)
     37 {
     38-    auto chain = interfaces::MakeChain(m_node);
     39+    auto& chain = m_node.chain;
     40     const CChain& active = Assert(m_node.chainman)->ActiveChain();
     41     uint256 hash;
     42     BOOST_CHECK(chain->findAncestorByHeight(active[20]->GetBlockHash(), 10, FoundBlock().hash(hash)));
     43@@ -83,7 +83,7 @@ BOOST_AUTO_TEST_CASE(findAncestorByHeight)
     44 
     45 BOOST_AUTO_TEST_CASE(findAncestorByHash)
     46 {
     47-    auto chain = interfaces::MakeChain(m_node);
     48+    auto& chain = m_node.chain;
     49     const CChain& active = Assert(m_node.chainman)->ActiveChain();
     50     int height = -1;
     51     BOOST_CHECK(chain->findAncestorByHash(active[20]->GetBlockHash(), active[10]->GetBlockHash(), FoundBlock().height(height)));
     52@@ -93,7 +93,7 @@ BOOST_AUTO_TEST_CASE(findAncestorByHash)
     53 
     54 BOOST_AUTO_TEST_CASE(findCommonAncestor)
     55 {
     56-    auto chain = interfaces::MakeChain(m_node);
     57+    auto& chain = m_node.chain;
     58     const CChain& active = Assert(m_node.chainman)->ActiveChain();
     59     auto* orig_tip = active.Tip();
     60     for (int i = 0; i < 10; ++i) {
     61@@ -123,7 +123,7 @@ BOOST_AUTO_TEST_CASE(findCommonAncestor)
     62 
     63 BOOST_AUTO_TEST_CASE(hasBlocks)
     64 {
     65-    auto chain = interfaces::MakeChain(m_node);
     66+    auto& chain = m_node.chain;
     67     const CChain& active = Assert(m_node.chainman)->ActiveChain();
     68 
     69     // Test ranges
     70diff --git a/src/wallet/test/coinselector_tests.cpp b/src/wallet/test/coinselector_tests.cpp
     71index f38ccba384..4127cd45f8 100644
     72--- a/src/wallet/test/coinselector_tests.cpp
     73+++ b/src/wallet/test/coinselector_tests.cpp
     74@@ -283,7 +283,7 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
     75     // Make sure that can use BnB when there are preset inputs
     76     empty_wallet();
     77     {
     78-        std::unique_ptr<CWallet> wallet = MakeUnique<CWallet>(m_chain.get(), "", CreateMockWalletDatabase());
     79+        std::unique_ptr<CWallet> wallet = MakeUnique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
     80         bool firstRun;
     81         wallet->LoadWallet(firstRun);
     82         wallet->SetupLegacyScriptPubKeyMan();
     83diff --git a/src/wallet/test/init_test_fixture.cpp b/src/wallet/test/init_test_fixture.cpp
     84index c80310045a..334e4ae0d8 100644
     85--- a/src/wallet/test/init_test_fixture.cpp
     86+++ b/src/wallet/test/init_test_fixture.cpp
     87@@ -10,7 +10,7 @@
     88 
     89 InitWalletDirTestingSetup::InitWalletDirTestingSetup(const std::string& chainName) : BasicTestingSetup(chainName)
     90 {
     91-    m_wallet_client = MakeWalletClient(*m_chain, *Assert(m_node.args));
     92+    m_wallet_client = MakeWalletClient(*m_node.chain, *Assert(m_node.args));
     93 
     94     std::string sep;
     95     sep += fs::path::preferred_separator;
     96diff --git a/src/wallet/test/init_test_fixture.h b/src/wallet/test/init_test_fixture.h
     97index f5bade77df..f666c45a34 100644
     98--- a/src/wallet/test/init_test_fixture.h
     99+++ b/src/wallet/test/init_test_fixture.h
    100@@ -19,7 +19,6 @@ struct InitWalletDirTestingSetup: public BasicTestingSetup {
    101     fs::path m_datadir;
    102     fs::path m_cwd;
    103     std::map<std::string, fs::path> m_walletdir_path_cases;
    104-    std::unique_ptr<interfaces::Chain> m_chain = interfaces::MakeChain(m_node);
    105     std::unique_ptr<interfaces::WalletClient> m_wallet_client;
    106 };
    107 
    108diff --git a/src/wallet/test/ismine_tests.cpp b/src/wallet/test/ismine_tests.cpp
    109index d5aed99d99..0ef8b9c4bf 100644
    110--- a/src/wallet/test/ismine_tests.cpp
    111+++ b/src/wallet/test/ismine_tests.cpp
    112@@ -27,8 +27,7 @@ BOOST_AUTO_TEST_CASE(ismine_standard)
    113     CKey uncompressedKey;
    114     uncompressedKey.MakeNewKey(false);
    115     CPubKey uncompressedPubkey = uncompressedKey.GetPubKey();
    116-    NodeContext node;
    117-    std::unique_ptr<interfaces::Chain> chain = interfaces::MakeChain(node);
    118+    std::unique_ptr<interfaces::Chain>& chain = m_node.chain;
    119 
    120     CScript scriptPubKey;
    121     isminetype result;
    122diff --git a/src/wallet/test/scriptpubkeyman_tests.cpp b/src/wallet/test/scriptpubkeyman_tests.cpp
    123index f7c1337b0d..347a436429 100644
    124--- a/src/wallet/test/scriptpubkeyman_tests.cpp
    125+++ b/src/wallet/test/scriptpubkeyman_tests.cpp
    126@@ -17,9 +17,7 @@ BOOST_FIXTURE_TEST_SUITE(scriptpubkeyman_tests, BasicTestingSetup)
    127 BOOST_AUTO_TEST_CASE(CanProvide)
    128 {
    129     // Set up wallet and keyman variables.
    130-    NodeContext node;
    131-    std::unique_ptr<interfaces::Chain> chain = interfaces::MakeChain(node);
    132-    CWallet wallet(chain.get(), "", CreateDummyWalletDatabase());
    133+    CWallet wallet(m_node.chain.get(), "", CreateDummyWalletDatabase());
    134     LegacyScriptPubKeyMan& keyman = *wallet.GetOrCreateLegacyScriptPubKeyMan();
    135 
    136     // Make a 1 of 2 multisig script
    137diff --git a/src/wallet/test/wallet_test_fixture.cpp b/src/wallet/test/wallet_test_fixture.cpp
    138index 4d6f427618..badf2eb459 100644
    139--- a/src/wallet/test/wallet_test_fixture.cpp
    140+++ b/src/wallet/test/wallet_test_fixture.cpp
    141@@ -6,10 +6,10 @@
    142 
    143 WalletTestingSetup::WalletTestingSetup(const std::string& chainName)
    144     : TestingSetup(chainName),
    145-      m_wallet(m_chain.get(), "", CreateMockWalletDatabase())
    146+      m_wallet(m_node.chain.get(), "", CreateMockWalletDatabase())
    147 {
    148     bool fFirstRun;
    149     m_wallet.LoadWallet(fFirstRun);
    150-    m_chain_notifications_handler = m_chain->handleNotifications({ &m_wallet, [](CWallet*) {} });
    151+    m_chain_notifications_handler = m_node.chain->handleNotifications({ &m_wallet, [](CWallet*) {} });
    152     m_wallet_client->registerRpcs();
    153 }
    154diff --git a/src/wallet/test/wallet_test_fixture.h b/src/wallet/test/wallet_test_fixture.h
    155index ba8a5ff1f3..ab7fb8c42b 100644
    156--- a/src/wallet/test/wallet_test_fixture.h
    157+++ b/src/wallet/test/wallet_test_fixture.h
    158@@ -20,8 +20,7 @@
    159 struct WalletTestingSetup : public TestingSetup {
    160     explicit WalletTestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
    161 
    162-    std::unique_ptr<interfaces::Chain> m_chain = interfaces::MakeChain(m_node);
    163-    std::unique_ptr<interfaces::WalletClient> m_wallet_client = interfaces::MakeWalletClient(*m_chain, *Assert(m_node.args));
    164+    std::unique_ptr<interfaces::WalletClient> m_wallet_client = interfaces::MakeWalletClient(*m_node.chain, *Assert(m_node.args));
    165     CWallet m_wallet;
    166     std::unique_ptr<interfaces::Handler> m_chain_notifications_handler;
    167 };
    168diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp
    169index 156be053d0..eb0bbb6ccc 100644
    170--- a/src/wallet/test/wallet_tests.cpp
    171+++ b/src/wallet/test/wallet_tests.cpp
    172@@ -83,8 +83,6 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
    173     CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
    174     CBlockIndex* newTip = ::ChainActive().Tip();
    175 
    176-    m_node.chain = interfaces::MakeChain(m_node);
    177-
    178     // Verify ScanForWalletTransactions fails to read an unknown start block.
    179     {
    180         CWallet wallet(m_node.chain.get(), "", CreateDummyWalletDatabase());
    181@@ -182,8 +180,6 @@ BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain100Setup)
    182     CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
    183     CBlockIndex* newTip = ::ChainActive().Tip();
    184 
    185-    m_node.chain = interfaces::MakeChain(m_node);
    186-
    187     // Prune the older block file.
    188     {
    189         LOCK(cs_main);
    190@@ -253,8 +249,6 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
    191     SetMockTime(KEY_TIME);
    192     m_coinbase_txns.emplace_back(CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())).vtx[0]);
    193 
    194-    m_node.chain = interfaces::MakeChain(m_node);
    195-
    196     std::string backup_file = (GetDataDir() / "wallet.backup").string();
    197 
    198     // Import key into wallet and call dumpwallet to create backup file.
    199@@ -489,7 +483,6 @@ public:
    200     ListCoinsTestingSetup()
    201     {
    202         CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
    203-        m_node.chain = interfaces::MakeChain(m_node);
    204         wallet = MakeUnique<CWallet>(m_node.chain.get(), "", CreateMockWalletDatabase());
    205         {
    206             LOCK2(wallet->cs_wallet, ::cs_main);
    207@@ -701,7 +694,6 @@ BOOST_FIXTURE_TEST_CASE(wallet_descriptor_test, BasicTestingSetup)
    208 BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
    209 {
    210     // Create new wallet with known key and unload it.
    211-    m_node.chain = interfaces::MakeChain(m_node);
    212     auto wallet = TestLoadWallet(*m_node.chain);
    213     CKey key;
    214     key.MakeNewKey(true);
    215@@ -794,8 +786,7 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup)
    216 
    217 BOOST_FIXTURE_TEST_CASE(ZapSelectTx, TestChain100Setup)
    218 {
    219-    auto chain = interfaces::MakeChain(m_node);
    220-    auto wallet = TestLoadWallet(*chain);
    221+    auto wallet = TestLoadWallet(*m_node.chain);
    222     CKey key;
    223     key.MakeNewKey(true);
    224     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.

  39. MarcoFalke approved
  40. MarcoFalke commented at 9:12 am on November 19, 2020: member

    cr ACK 9931714c0a1347d377b73f50e900c1138081d1c2 🍲

    Signature:

     0-----BEGIN PGP SIGNED MESSAGE-----
     1Hash: SHA512
     2
     3cr ACK 9931714c0a1347d377b73f50e900c1138081d1c2 🍲
     4-----BEGIN PGP SIGNATURE-----
     5
     6iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
     7pUhUOQwAomF3ZBN9ZKEQ+0iRMfzrYW8WoUmJUUGE+3exY2nV+2nnySpCT2N+nGg6
     8YnQk5UWMExmUSqK9JAD783Zfun1YLRASpfL7uZicLs3ZLMVM/4cFLnaoEk9RvrZk
     9zZdfdwRcPhhz0WLMjRCgFbubwWNxd2BqVObzUpfhenQBUlggrRn2auHsvJTa0vTN
    1019ZWvNDIgq9UYJVwJ47b2X4eu5bJeLcmKWuc+pGxchmAnYfAA6iDklIuG+3AVBWm
    11DdDNUttzy5z1o8Bd7s9m8b/EzrhiVUPRx3YsX4hWPCD+YlEb5ATLzERoiFYlqUTY
    12RJCuOZPRmLQRhqjRVdAklDVlz7BClOT4cMBwdZeBR0s8keEJqH+F8aCn0U72eFWq
    13ix8Fer2Fsj0YOvYIClryzamuFgPvA6e9D+idKdDjY6XXdoLsRljzRSejdOCcbVXu
    14wAdcVkI891WiN/EgBmWO9LHi+UCzwbQe1iuJ3j28fzKVcdrZGf6PBsGd+s1WS0XU
    150UUQV8km
    16=T1NN
    17-----END PGP SIGNATURE-----
    

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

  41. DrahtBot added the label Needs rebase on Dec 1, 2020
  42. 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
  43. refactor: Replace uses ChainActive() in interfaces/chain.cpp
    Suggested https://github.com/bitcoin/bitcoin/pull/19425#discussion_r456236407
    6965f1352d
  44. 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
  45. ryanofsky referenced this in commit a85f9b5d19 on Dec 8, 2020
  46. ryanofsky force-pushed on Dec 8, 2020
  47. ryanofsky commented at 2:24 am on December 8, 2020: member
    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
  48. DrahtBot removed the label Needs rebase on Dec 8, 2020
  49. MarcoFalke commented at 11:42 am on December 8, 2020: member

    re-ACK 5baa88fd38c8efa0e361636bb2c60af89d27b5d5 🕶

    Signature:

     0-----BEGIN PGP SIGNED MESSAGE-----
     1Hash: SHA512
     2
     3re-ACK 5baa88fd38c8efa0e361636bb2c60af89d27b5d5 🕶
     4-----BEGIN PGP SIGNATURE-----
     5
     6iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
     7pUgRQAv6A0yyCNiZr7DYQtS7ubtoC310OFwRL/ghzzgjyS605iRdOHFWzvQxFLaP
     89bKMhe5T5XMu7SE+0Ow3eXiVqXhCAsGqEXvdFxmPSqbmzCoG2bokdG6ZNNzsZ65/
     9IvzFdHkmLkT9Cj5knqZhZu9Qc24ncyw212cEQ674OQA53y+76HcE7cyJsS2kx56n
    10eBDajcd5wa9GaOSrT0SF4UOgotXCHX+NQgM+QSJRN/ZNAFUbGu4Q+/Qj9YMlvFvg
    11zG3TOSI8bi4PX/ygR/J8Ju4Sc4fosMWwsIwaLV0e6ErNEF3dtK/JVCzRvnjyQ38G
    12bId7rr1OBLi+pfQBB4oTPYDMgbf06R3cAV+jJ5rlAEcTWw+xMRfxhZEdZqdFGHOz
    13ZR1YuPn5EEibs2VmmQMqeuHmBVxYJzaWAjH9OwQI7qkE+CQAa6I/nmoEBmiRk7m4
    14z3YbBAY7XfaNH6l455wPcFhaxAcfSWvADHt24amYpmSSH0kvpaWVu9g4QzeCMqtY
    15yy+lKj94
    16=j9ux
    17-----END PGP SIGNATURE-----
    

    Timestamp of file with hash 19b54d707dfb2ae462bb723d421d5753739d3d2543051b56a0b9445ec9485431 -

  50. dongcarl commented at 5:30 pm on December 8, 2020: member
    ACK 5baa88fd38c8efa0e361636bb2c60af89d27b5d5
  51. MarcoFalke merged this on Dec 8, 2020
  52. MarcoFalke closed this on Dec 8, 2020

  53. sidhujag referenced this in commit 02ed55541b on Dec 8, 2020
  54. DrahtBot 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: 2024-12-21 15:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me