refactor: Use util::Result class for wallet loading #25722

pull ryanofsky wants to merge 24 commits into bitcoin:master from ryanofsky:pr/bresult-load changing 40 files +1373 −813
  1. DrahtBot added the label Refactoring on Jul 27, 2022
  2. DrahtBot commented at 8:53 pm on July 27, 2022: contributor

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

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #bitcoin-core/gui/807 (refactor: interfaces, make ‘createTransaction’ less error-prone by furszy)
    • #30364 (logging: Replace LogError and LogWarning with LogAlert by ryanofsky)
    • #30344 (kernel: remove mempool_persist by theuni)
    • #30342 (kernel, logging: Pass Logger instances to kernel objects by ryanofsky)
    • #30328 (wallet: Remove IsMine from migration code by achow101)
    • #30221 (wallet: Ensure best block matches wallet scan state by achow101)
    • #29641 (scripted-diff: Use LogInfo/LogDebug over LogPrintf/LogPrint by maflcko)
    • #29278 (Wallet: Add maxfeerate wallet startup option by ismaelsadeeq)
    • #29129 (wallet, rpc: add BIP44 account in createwallet by brunoerg)
    • #28710 (Remove the legacy wallet and BDB dependency by achow101)
    • #28574 (wallet: optimize migration process, batch db transactions by furszy)
    • #28333 (wallet: Construct ScriptPubKeyMans with all data rather than loaded progressively by achow101)
    • #27865 (wallet: Track no-longer-spendable TXOs separately by achow101)
    • #26596 (wallet: Migrate legacy wallets to descriptor wallets without requiring BDB by achow101)

    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.

  3. DrahtBot added the label Needs rebase on Aug 5, 2022
  4. ryanofsky force-pushed on Aug 5, 2022
  5. DrahtBot removed the label Needs rebase on Aug 5, 2022
  6. DrahtBot added the label Needs rebase on Aug 10, 2022
  7. ryanofsky force-pushed on Aug 15, 2022
  8. ryanofsky marked this as ready for review on Aug 15, 2022
  9. ryanofsky commented at 6:19 pm on August 15, 2022: contributor
    Rebased a09c21c05a9adf0ca5a4b6a15021b45c6c2e0b2a -> e7457d0acefeccd636c134d0c10567ffaade2fc7 (pr/bresult-load.2 -> pr/bresult-load.3, compare) due to conflict with #25616 Rebased e7457d0acefeccd636c134d0c10567ffaade2fc7 -> 874003fcea81aba1276b53d5ad9c5dadefddd5ff (pr/bresult-load.3 -> pr/bresult-load.4, compare) due to conflict with #25504 Rebased 874003fcea81aba1276b53d5ad9c5dadefddd5ff -> d020d0cce052bc7b4141347a51d34fd85f8a10a1 (pr/bresult-load.4 -> pr/bresult-load.5, compare) on top of newer base PR #25665 tag r/bresult2.18 for derived-to-base conversion bugfix Rebased d020d0cce052bc7b4141347a51d34fd85f8a10a1 -> f942d9253e39df6fedf7f3fe4b0bdb2921206de0 (pr/bresult-load.5 -> pr/bresult-load.6, compare) due to silent conflict with #19602 Rebased f942d9253e39df6fedf7f3fe4b0bdb2921206de0 -> 4e533926fe5549aafb70caf94718447ea497c84c (pr/bresult-load.6 -> pr/bresult-load.7, compare) on top of newer version of #25665 (pr/bresult2.21) Rebased 4e533926fe5549aafb70caf94718447ea497c84c -> f3d165866329ec16e39a7289bd9769ad209cd56a (pr/bresult-load.7 -> pr/bresult-load.8, compare) due to conflict with #26021 Rebased f3d165866329ec16e39a7289bd9769ad209cd56a -> f718aec8db4d92037cf21bde2f92c72ed39c1d09 (pr/bresult-load.8 -> pr/bresult-load.9, compare) due to conflict with #26005 Rebased f718aec8db4d92037cf21bde2f92c72ed39c1d09 -> 7bd578a5caf91f73ee9127cd621e2838d5a3b427 (pr/bresult-load.9 -> pr/bresult-load.10, compare) due to conflicts with #25667, #26198, and #26282 Rebased 7bd578a5caf91f73ee9127cd621e2838d5a3b427 -> 2c675f03f017125390f3b578ee6169870deae985 (pr/bresult-load.10 -> pr/bresult-load.11, compare) due to conflicts with #26238, #26462, #26594, #26618, #26758 Rebased 2c675f03f017125390f3b578ee6169870deae985 -> 2e12b25fae4bca7539c3cf7ccb9e12e03c9e517d (pr/bresult-load.11 -> pr/bresult-load.12, compare) on top of pr/bresult2.28 Rebased 2e12b25fae4bca7539c3cf7ccb9e12e03c9e517d -> 5c1be5339b05f5923b8843fe3caa183044454608 (pr/bresult-load.12 -> pr/bresult-load.13, compare) due to conflicts with #26595 and #26032 Rebased 5c1be5339b05f5923b8843fe3caa183044454608 -> 9c2817208cd5e0a521e765b43d71bb78afc5a7f9 (pr/bresult-load.13 -> pr/bresult-load.14, compare) due to conflicts with #25666 and #24845 Rebased 9c2817208cd5e0a521e765b43d71bb78afc5a7f9 -> 2a9db070ec5acfe6843e44e1f8476f86899a8e29 (pr/bresult-load.14 -> pr/bresult-load.15, compare) due to conflict with #27279
  10. DrahtBot removed the label Needs rebase on Aug 15, 2022
  11. DrahtBot added the label Needs rebase on Aug 16, 2022
  12. ryanofsky referenced this in commit 834857e56b on Aug 30, 2022
  13. ryanofsky referenced this in commit 82c549aa53 on Sep 1, 2022
  14. ryanofsky force-pushed on Sep 1, 2022
  15. DrahtBot removed the label Needs rebase on Sep 1, 2022
  16. ryanofsky referenced this in commit c14e904f66 on Sep 1, 2022
  17. ryanofsky force-pushed on Sep 1, 2022
  18. ryanofsky force-pushed on Sep 2, 2022
  19. ryanofsky referenced this in commit a8973ae714 on Sep 6, 2022
  20. ryanofsky referenced this in commit 05a97d3208 on Sep 13, 2022
  21. ryanofsky referenced this in commit e04d8a754f on Sep 13, 2022
  22. ryanofsky referenced this in commit 8e12547694 on Sep 13, 2022
  23. DrahtBot added the label Needs rebase on Sep 13, 2022
  24. ryanofsky referenced this in commit 52a4e50fb4 on Sep 13, 2022
  25. ryanofsky force-pushed on Sep 14, 2022
  26. ryanofsky referenced this in commit f9accbc6e2 on Sep 15, 2022
  27. ryanofsky referenced this in commit 776d9b3fbb on Sep 15, 2022
  28. ryanofsky force-pushed on Sep 15, 2022
  29. DrahtBot removed the label Needs rebase on Sep 15, 2022
  30. DrahtBot added the label Needs rebase on Sep 16, 2022
  31. ryanofsky referenced this in commit f05441a572 on Sep 20, 2022
  32. ryanofsky referenced this in commit 456e3d4ecc on Sep 20, 2022
  33. ryanofsky force-pushed on Sep 20, 2022
  34. DrahtBot removed the label Needs rebase on Sep 20, 2022
  35. ryanofsky referenced this in commit 8ba9cb26a1 on Sep 20, 2022
  36. ryanofsky referenced this in commit 8ebf0cd171 on Sep 20, 2022
  37. DrahtBot added the label Needs rebase on Oct 3, 2022
  38. ryanofsky referenced this in commit fee8670c7c on Oct 14, 2022
  39. ryanofsky referenced this in commit 28a6934da9 on Oct 14, 2022
  40. ryanofsky force-pushed on Oct 14, 2022
  41. DrahtBot removed the label Needs rebase on Oct 14, 2022
  42. DrahtBot added the label Needs rebase on Dec 1, 2022
  43. ryanofsky referenced this in commit f4d55d858d on Jan 6, 2023
  44. ryanofsky referenced this in commit 979dbd5c73 on Jan 6, 2023
  45. ryanofsky force-pushed on Jan 20, 2023
  46. DrahtBot removed the label Needs rebase on Jan 20, 2023
  47. DrahtBot added the label Needs rebase on Jan 23, 2023
  48. ryanofsky referenced this in commit b57a898a98 on Feb 10, 2023
  49. ryanofsky referenced this in commit 513adde96f on Feb 10, 2023
  50. ryanofsky referenced this in commit eb50fcd685 on Feb 10, 2023
  51. ryanofsky force-pushed on Feb 11, 2023
  52. DrahtBot removed the label Needs rebase on Feb 11, 2023
  53. ryanofsky referenced this in commit 501ef88b94 on Feb 16, 2023
  54. DrahtBot added the label Needs rebase on Feb 17, 2023
  55. ryanofsky referenced this in commit d785176df3 on Mar 1, 2023
  56. ryanofsky referenced this in commit 6056f7b0da on Mar 1, 2023
  57. ryanofsky force-pushed on Mar 1, 2023
  58. DrahtBot removed the label Needs rebase on Mar 1, 2023
  59. DrahtBot added the label Needs rebase on Mar 8, 2023
  60. ryanofsky referenced this in commit e766928ed1 on Mar 16, 2023
  61. ryanofsky referenced this in commit 6afc0431f0 on Mar 16, 2023
  62. ryanofsky referenced this in commit 6d7d7bbb7b on Apr 4, 2023
  63. ryanofsky referenced this in commit 460ef0a18b on Apr 4, 2023
  64. ryanofsky force-pushed on Apr 7, 2023
  65. DrahtBot removed the label Needs rebase on Apr 7, 2023
  66. DrahtBot added the label Needs rebase on Apr 12, 2023
  67. ryanofsky force-pushed on Apr 13, 2023
  68. DrahtBot removed the label Needs rebase on Apr 13, 2023
  69. in src/util/result.h:62 in 2a9db070ec outdated
    58+    }
    59+
    60+    //! Value setter methods that do nothing because this class has value type T=void.
    61+    void ConstructValue() {}
    62+    template <typename O>
    63+    void MoveValue(O& other) {}
    


    martinus commented at 8:04 am on April 16, 2023:
    Maybe it would be a bit clearer to use (O&& other) here?

    ryanofsky commented at 7:40 pm on May 2, 2023:

    re: #25722 (review)

    Maybe it would be a bit clearer to use (O&& other) here?

    Sure, changed this.

  70. in src/util/result.h:184 in 2a9db070ec outdated
    183+        this->MoveMessages(other);
    184+        Construct(fn, std::forward<Args>(args)...);
    185+    }
    186+
    187+    template <typename OT, typename OF>
    188+    void MoveConstruct(Result<OT, OF>& other)
    


    martinus commented at 8:04 am on April 16, 2023:
    Same here, I’d say void MoveConstruct(Result<OT, OF>&& other) is a bit clearer

    ryanofsky commented at 7:41 pm on May 2, 2023:

    re: #25722 (review)

    Same here, I’d say void MoveConstruct(Result<OT, OF>&& other) is a bit clearer

    Sure, changed

  71. in src/util/result.h:237 in 2a9db070ec outdated
    73+    const std::vector<bilingual_str>& GetWarnings() const LIFETIMEBOUND { return m_info ? m_info->warnings : EMPTY_LIST; }
    74+};
    75+
    76+//! Result base class for T value type. Holds value and provides accessor methods.
    77+template <typename T, typename F>
    78+class ResultBase : public ResultBase<void, F>
    


    martinus commented at 8:06 am on April 16, 2023:
    Ha, nice trick; I’ve never seen such an inheritance before :-)
  72. in src/util/result.h:154 in 2a9db070ec outdated
    153+class Result : public detail::ResultBase<T, F>
    154 {
    155-private:
    156-    std::variant<bilingual_str, T> m_variant;
    157+protected:
    158+    template <typename Fn, typename... Args>
    


    martinus commented at 10:48 am on April 16, 2023:

    It took me a while to figure out what’s going on here with the recursive Construct calls and the lambda that’s passed along. How about instead of passing a lambda along use a bool template argument like so:

     0diff --git a/src/util/result.h b/src/util/result.h
     1index 5599da43dd..3c163cf398 100644
     2--- a/src/util/result.h
     3+++ b/src/util/result.h
     4@@ -151,33 +151,35 @@ template <typename T, typename F = void>
     5 class Result : public detail::ResultBase<T, F>
     6 {
     7 protected:
     8-    template <typename Fn, typename... Args>
     9-    void Construct(const Fn& fn, Args&&... args)
    10+    template <bool IsValueConstruction, typename... Args>
    11+    void Construct(Args&&... args)
    12     {
    13-        fn(std::forward<Args>(args)...);
    14+        if constexpr (IsValueConstruction) {
    15+            this->ConstructValue(std::forward<Args>(args)...);
    16+        } else {
    17+            this->Info().failure.emplace(std::forward<Args>(args)...);
    18+        }
    19     }
    20 
    21-    template <typename Fn, typename... Args>
    22-    void Construct(const Fn& fn, Error error, Args&&... args)
    23+    template <bool IsValueConstruction, typename... Args>
    24+    void Construct(Error error, Args&&... args)
    25     {
    26         this->AddError(std::move(error.message));
    27-        Construct([&](auto&&... x) {
    28-            this->Info().failure.emplace(std::forward<decltype(x)>(x)...);
    29-        }, std::forward<Args>(args)...);
    30+        Construct<false /*always false from here on*/>(std::forward<Args>(args)...);
    31     }
    32 
    33-    template <typename Fn, typename... Args>
    34-    void Construct(const Fn& fn, Warning warning, Args&&... args)
    35+    template <bool IsValueConstruction, typename... Args>
    36+    void Construct(Warning warning, Args&&... args)
    37     {
    38         this->AddWarning(std::move(warning.message));
    39-        Construct(fn, std::forward<Args>(args)...);
    40+        Construct<IsValueConstruction>(std::forward<Args>(args)...);
    41     }
    42 
    43-    template <typename Fn, typename OT, typename OF, typename... Args>
    44-    void Construct(const Fn& fn, Result<OT, OF>&& other, Args&&... args)
    45+    template <bool IsValueConstruction, typename OT, typename OF, typename... Args>
    46+    void Construct(Result<OT, OF>&& other, Args&&... args)
    47     {
    48         this->MoveMessages(other);
    49-        Construct(fn, std::forward<Args>(args)...);
    50+        Construct<IsValueConstruction>(std::forward<Args>(args)...);
    51     }
    52 
    53     template <typename OT, typename OF>
    54@@ -198,7 +200,8 @@ public:
    55     template <typename... Args>
    56     Result(Args&&... args)
    57     {
    58-        Construct([this](auto&&... x) { this->ConstructValue(std::forward<decltype(x)>(x)...); }, std::forward<Args>(args)...);
    59+        // recursively peels of the first argument until we reach the base Construct method
    60+        Construct<true>(std::forward<Args>(args)...);
    61     }
    62 
    63     template <typename OT, typename OF>
    

    ryanofsky commented at 7:40 pm on May 2, 2023:

    re: #25722 (review)

    It took me a while to figure out what’s going on here with the recursive Construct calls and the lambda that’s passed along. How about instead of passing a lambda along use a bool template argument like so:

    Thanks, that’s much better! Took suggestion jsut renaming argument to “Failure”

  73. in src/util/result.h:230 in 2a9db070ec outdated
    214-    bool has_value() const noexcept { return m_variant.index() == 1; }
    215-    const T& value() const LIFETIMEBOUND
    216+    template <typename OT, typename OF>
    217+    Result(Result<OT, OF>&& other) { MoveConstruct(other); }
    218+
    219+    Result& Set(Result&& other) LIFETIMEBOUND
    


    martinus commented at 5:28 pm on April 16, 2023:

    Mayby explicitly mark the move-assignment as delete

    0template <typename OT, typename OF>
    1Result& operator=(Result<OT, OF>&& other) = delete;
    

    Then the compiler error messages are a bit nicer when one tries to move-assign


    ryanofsky commented at 7:41 pm on May 2, 2023:

    re: #25722 (review)

    Mayby explicitly mark the move-assignment as delete

    Thanks, that changes error message from error: object of type 'util::Result<int>' cannot be assigned because its copy assignment operator is implicitly deleted to error: overload resolution selected deleted operator=, which should be more helpful now because a comment at the deleted operator= declaration explains why the operator is deleted and recommends using Set() instead

  74. in src/util/result.h:264 in 2a9db070ec outdated
    250+    template<typename S>
    251+    void MoveMessages(S& src)
    252     {
    253-        return has_value() ? std::move(value()) : std::forward<U>(default_value);
    254+        if (src.m_info) {
    255+            if (!src.m_info->errors.empty()) detail::MoveMessages(src.m_info->errors, this->Info().errors);
    


    martinus commented at 5:33 pm on April 16, 2023:
    nit: I don’t think the if (!src.m_info->errors.empty()) check is necessary.

    ryanofsky commented at 7:41 pm on May 2, 2023:

    re: #25722 (review)

    nit: I don’t think the if (!src.m_info->errors.empty()) check is necessary.

    It’s not strictly necessary, but it avoids allocating an ErrorInfo object in the common case where there are no errors or warnings. Since this is called whenever result objects are moved, it’s good to avoid unnecessary allocations here.

  75. in src/util/result.h:161 in 2a9db070ec outdated
    147+//! types of errors, and can suffice just using the type `T` success value on
    148+//! success, and descriptive error strings when there's a failure. But
    149+//! applications that do need more complicated error-handling behavior can
    150+//! override the default `F = void` failure type and get failure values by
    151+//! calling result.GetFailure().
    152+template <typename T, typename F = void>
    


    martinus commented at 5:39 am on April 22, 2023:
    maybe consider forbidding type bool for T. I recently had similar code in another project, and its utterly confusing; because Result can convert to bool but that only tells if it has a bool or not. It’s very error prone.

    TheCharlatan commented at 12:09 pm on June 19, 2023:
    I guess the same goes for something like Result<std::optional<int>, int>, or really any type implementing operator bool()? How did you handle these cases in your code? Sometimes the non-presence of a result is not really an error.

    ryanofsky commented at 6:18 pm on July 20, 2023:

    re: #25722 (review)

    I agree with all of this and want to do more work to address it.

    I think by default types convertible to bool should be disallowed with Result. I think Result<bool> or Result<optional<T>> types are inherently ambiguous and code accessing those return values would be fragile and prone to errors from dereferencing incorrectly.

    But disallowing all types convertible to bool would go to far because being able to return types like unique_ptr and shared_ptr is important. Returning types like Result<int> should probably fine in practice too, even though ints are convertible to bool, and there could be a little ambiguity.

    So there is some fine-tuning to be done here, and I want to code to be organized so Result and ResultPtr (#26022) classes handle this safety stuff, and ResultBase class handles all the real result functionality.

  76. in src/test/result_tests.cpp:213 in 3a919e576f outdated
    155+    ExpectSuccess(TruthyFalsyFn(0, true), {}, 0);
    156+    ExpectFail(TruthyFalsyFn(0, false), Untranslated("failure value 0."), 0);
    157+    ExpectSuccess(TruthyFalsyFn(1, true), {}, 1);
    158+    ExpectFail(TruthyFalsyFn(1, false), Untranslated("failure value 1."), 1);
    159+}
    160+
    


    martinus commented at 5:45 am on April 22, 2023:

    I’d add a check somewhere to ensure that the size of the Result is as claimed in the commit message, something like that:

    0static_assert(sizeof(util::Result<int>) == sizeof(void*)*2);
    1static_assert(sizeof(util::Result<void>) == sizeof(void*));
    

    ryanofsky commented at 7:40 pm on May 2, 2023:

    I’d add a check somewhere to ensure that the size of the Result is as claimed in the commit message, something like that:

    0static_assert(sizeof(util::Result<int>) == sizeof(void*)*2);
    1static_assert(sizeof(util::Result<void>) == sizeof(void*));
    

    Thanks, added to result_tests.cpp

  77. in src/util/result.h:205 in 3a919e576f outdated
    196     }
    197-    template <class U>
    198-    T value_or(U&& default_value) &&
    199+
    200+    template <typename OT, typename OF>
    201+    Result(Result<OT, OF>&& other) { MoveConstruct(other); }
    


    martinus commented at 1:22 pm on April 22, 2023:
    move constructors should usually be noexcept, but then all methods it uses also have to be noexcept.

    ryanofsky commented at 7:41 pm on May 2, 2023:

    re: #25722 (review)

    move constructors should usually be noexcept, but then all methods it uses also have to be noexcept.

    It would be possible to add a constructor that move constructs Result<T, F> from Result<OT, OF> and is noexcept. For this to work, move constructing T from OT would have to be noexcept, and F and OF types would need to be identical so unique_ptr<ErrorInfo<F>> could be moved without any allocations.

    Right now I’m just trying to do the simplest thing that’s correct, and I think probably in most cases where the result class is used, having the move constructor be marked noexcept isn’t going impact performance. But it is something that could be optimized later.

  78. in src/wallet/spend.cpp:736 in 3a919e576f outdated
    743-        if (!res_detailed_errors.empty()) return res_detailed_errors.front();
    744+        if (!res_detailed_errors.empty()) return std::move(res_detailed_errors.front());
    745 
    746 
    747         // General "Insufficient Funds"
    748         return util::Result<SelectionResult>(util::Error());
    


    martinus commented at 1:28 pm on April 22, 2023:
    Could be just return util::Error();

    ryanofsky commented at 7:42 pm on May 2, 2023:

    re: #25722 (review)

    Could be just return util::Error();

    Thanks, simplified

  79. martinus commented at 1:37 pm on April 22, 2023: contributor
    After rebasing I get a compile error in spend.cpp ChooseSelectionResult, adding a bunch of std::move helps
  80. in src/wallet/spend.cpp:710 in 3a919e576f outdated
    714@@ -715,7 +715,7 @@ util::Result<SelectionResult> AutomaticCoinSelection(const CWallet& wallet, Coin
    715         if (CAmount total_amount = available_coins.GetTotalAmount() - total_discarded < value_to_select) {
    716             // Special case, too-long-mempool cluster.
    717             if (total_amount + total_unconf_long_chain > value_to_select) {
    718-                return util::Result<SelectionResult>({_("Unconfirmed UTXOs are available, but spending them creates a chain of transactions that will be rejected by the mempool")});
    719+                return util::Error{_("Unconfirmed UTXOs are available, but spending them creates a chain of transactions that will be rejected by the mempool")};
    720             }
    721             return util::Result<SelectionResult>(util::Error()); // General "Insufficient Funds"
    


    martinus commented at 2:22 pm on April 22, 2023:
    could be just return util::Error();

    ryanofsky commented at 7:42 pm on May 2, 2023:

    re: #25722 (review)

    could be just return util::Error();

    Thanks, simplified

  81. martinus changes_requested
  82. martinus commented at 2:25 pm on April 22, 2023: contributor
    Code review 2a9db07, apart from the compile error when rebasing I found mostly nits. This makes util::Result quite a bit more powerful, and it’s still simple to use. The code itself of util::Result is a bit hard to understand though, but I don’t have a better way either.
  83. DrahtBot added the label CI failed on Apr 23, 2023
  84. DrahtBot added the label Needs rebase on May 2, 2023
  85. ryanofsky referenced this in commit aa73bee496 on May 2, 2023
  86. ryanofsky referenced this in commit 28a954c703 on May 2, 2023
  87. ryanofsky force-pushed on May 3, 2023
  88. DrahtBot removed the label Needs rebase on May 3, 2023
  89. DrahtBot removed the label CI failed on May 3, 2023
  90. DrahtBot added the label Needs rebase on May 15, 2023
  91. ryanofsky referenced this in commit cdf11c66c0 on Jul 21, 2023
  92. ryanofsky referenced this in commit 40f09de73e on Jul 21, 2023
  93. ryanofsky force-pushed on Jul 21, 2023
  94. ryanofsky commented at 5:03 pm on July 21, 2023: contributor
    Rebased f7d4451b98014176c083adc02bdf59e6dd2b9355 -> 17891a95ab5873aa978a5bf5ed8985ee1513e728 (pr/bresult-load.16 -> pr/bresult-load.17, compare making most of the suggested changes. I’m working on some more changes that should use ResultPtr from #26022 to simplify some of the code that has changed and made it safer. It will take more work to make ResultPtr compatible, and relatedly change the Result class to discourage using it with confusing types that are convertible to bool.
  95. DrahtBot removed the label Needs rebase on Jul 21, 2023
  96. ryanofsky referenced this in commit 4d995d3fa6 on Jul 21, 2023
  97. ryanofsky referenced this in commit 775b54e881 on Jul 21, 2023
  98. DrahtBot added the label CI failed on Jul 21, 2023
  99. maflcko commented at 2:55 pm on August 1, 2023: member
    Maybe mark as draft for as long as CI is red and this is based on something else?
  100. ryanofsky marked this as a draft on Aug 1, 2023
  101. ryanofsky referenced this in commit cf01e29b9d on Aug 1, 2023
  102. ryanofsky referenced this in commit 1de05ef919 on Aug 1, 2023
  103. ryanofsky referenced this in commit 6ddcc9bec8 on Aug 1, 2023
  104. ryanofsky referenced this in commit 08f5febfc5 on Aug 1, 2023
  105. ryanofsky force-pushed on Aug 2, 2023
  106. DrahtBot removed the label CI failed on Aug 2, 2023
  107. ryanofsky referenced this in commit 9cea9e8e38 on Aug 3, 2023
  108. ryanofsky referenced this in commit b0beb4c504 on Aug 3, 2023
  109. ryanofsky referenced this in commit 835f09452b on Aug 4, 2023
  110. ryanofsky referenced this in commit 9e80d0b754 on Aug 4, 2023
  111. ryanofsky referenced this in commit b21e2b067e on Aug 7, 2023
  112. ryanofsky referenced this in commit 7f883b33bb on Aug 7, 2023
  113. DrahtBot added the label Needs rebase on Aug 24, 2023
  114. ryanofsky referenced this in commit 5529ea16ad on Sep 6, 2023
  115. ryanofsky referenced this in commit a21ac50c2b on Sep 6, 2023
  116. ryanofsky referenced this in commit ed61b012b1 on Sep 6, 2023
  117. ryanofsky referenced this in commit 956bec1eca on Sep 6, 2023
  118. ryanofsky force-pushed on Sep 25, 2023
  119. DrahtBot removed the label Needs rebase on Sep 25, 2023
  120. DrahtBot added the label CI failed on Oct 5, 2023
  121. DrahtBot added the label Needs rebase on Oct 16, 2023
  122. ryanofsky referenced this in commit 256a16e999 on Oct 18, 2023
  123. ryanofsky referenced this in commit 29f6cfdabe on Oct 18, 2023
  124. ryanofsky referenced this in commit 1f6190ac9b on Oct 18, 2023
  125. ryanofsky referenced this in commit 24999606f8 on Oct 18, 2023
  126. ryanofsky referenced this in commit e2b184ec86 on Oct 26, 2023
  127. ryanofsky referenced this in commit f158686962 on Oct 26, 2023
  128. ryanofsky referenced this in commit 2e1cc4f55f on Oct 26, 2023
  129. ryanofsky referenced this in commit 3fe48360c3 on Oct 26, 2023
  130. ryanofsky referenced this in commit 1c7d8bea4f on Jan 24, 2024
  131. ryanofsky referenced this in commit f822ac9a24 on Jan 24, 2024
  132. ryanofsky referenced this in commit 774240a82b on Feb 21, 2024
  133. ryanofsky referenced this in commit 4ec6b060a8 on Feb 21, 2024
  134. ryanofsky referenced this in commit 2c78cce3c5 on Feb 21, 2024
  135. ryanofsky referenced this in commit f27418f37e on Feb 21, 2024
  136. ryanofsky referenced this in commit b0687b7e1e on Feb 21, 2024
  137. ryanofsky referenced this in commit 2055659814 on Feb 21, 2024
  138. ryanofsky referenced this in commit b91edfa4f1 on Feb 21, 2024
  139. ryanofsky force-pushed on Feb 21, 2024
  140. ryanofsky commented at 11:39 pm on February 21, 2024: contributor
    Rebased 1b2a5f12b42543d13a4bcafb9585e3d1df488914 -> 6700299bcb6f560e9e4caf34254d7d86d4e78833 (pr/bresult-load.19 -> pr/bresult-load.20, compare) on top of #26022 using #26022 to simplify some changes in this PR
  141. DrahtBot removed the label CI failed on Feb 22, 2024
  142. DrahtBot removed the label Needs rebase on Feb 22, 2024
  143. ryanofsky referenced this in commit 16b1f910be on Feb 22, 2024
  144. ryanofsky referenced this in commit cdf7bb1756 on Feb 22, 2024
  145. ryanofsky force-pushed on Feb 22, 2024
  146. ryanofsky commented at 8:14 pm on February 22, 2024: contributor

    Updated 6700299bcb6f560e9e4caf34254d7d86d4e78833 -> 2385cb37dbbe00004f8bffe1d1d784778d89a21e (pr/bresult-load.20 -> pr/bresult-load.21, compare) splitting this up from one big to commit to multiple commits so it is reasonable to review.

    However, looking over the commits, this still belongs in draft state, because since the time this PR was opened, a lot of improvements were made to the util::Result class in base PR #25665 based on review feedback, so there are a lot of updates that can be made in this PR to make it nicer.

  147. TheCharlatan referenced this in commit 50220e34f6 on Mar 10, 2024
  148. TheCharlatan referenced this in commit 539f101dfe on Mar 10, 2024
  149. TheCharlatan referenced this in commit fe260d92a3 on Mar 11, 2024
  150. TheCharlatan referenced this in commit 5029e59b9d on Mar 11, 2024
  151. TheCharlatan referenced this in commit f3dbbbc3d5 on Mar 12, 2024
  152. TheCharlatan referenced this in commit 63b92a8c80 on Mar 12, 2024
  153. TheCharlatan referenced this in commit a72ae6a43f on Mar 12, 2024
  154. TheCharlatan referenced this in commit 76fe2f8d41 on Mar 12, 2024
  155. TheCharlatan referenced this in commit 2331edb22e on Mar 12, 2024
  156. TheCharlatan referenced this in commit 5797f3cb7c on Mar 12, 2024
  157. TheCharlatan referenced this in commit 31ae72fdfa on Mar 15, 2024
  158. TheCharlatan referenced this in commit 6b7813c256 on Mar 15, 2024
  159. TheCharlatan referenced this in commit f6118b724c on Mar 19, 2024
  160. TheCharlatan referenced this in commit ee80f88bcb on Mar 19, 2024
  161. ryanofsky referenced this in commit 40b009dfee on Mar 22, 2024
  162. ryanofsky referenced this in commit e0cbb8862c on Mar 22, 2024
  163. ryanofsky referenced this in commit d52c2e949c on Mar 26, 2024
  164. ryanofsky referenced this in commit efb463788f on Mar 26, 2024
  165. TheCharlatan referenced this in commit c7d4f43198 on Mar 26, 2024
  166. TheCharlatan referenced this in commit 5e38b42b1e on Mar 26, 2024
  167. ryanofsky referenced this in commit 88821fe2a0 on Mar 26, 2024
  168. ryanofsky referenced this in commit 110bccc371 on Mar 26, 2024
  169. ryanofsky referenced this in commit d859ea511f on Mar 26, 2024
  170. ryanofsky referenced this in commit 6adeafab68 on Mar 26, 2024
  171. ryanofsky referenced this in commit 3eb47b4641 on Mar 27, 2024
  172. ryanofsky referenced this in commit d4579e303b on Mar 27, 2024
  173. ryanofsky referenced this in commit 9fe6a68170 on Mar 28, 2024
  174. ryanofsky referenced this in commit 7a4741eaf8 on Mar 28, 2024
  175. ryanofsky referenced this in commit 5467ecbe58 on Apr 18, 2024
  176. ryanofsky referenced this in commit 28e2081210 on Apr 18, 2024
  177. ryanofsky referenced this in commit d293d0ba52 on Apr 24, 2024
  178. ryanofsky referenced this in commit c45cb13b9e on Apr 24, 2024
  179. ryanofsky referenced this in commit 6602231564 on Apr 24, 2024
  180. ryanofsky referenced this in commit f74da4c69b on Apr 24, 2024
  181. ryanofsky referenced this in commit cbcdc67c64 on Apr 24, 2024
  182. ryanofsky referenced this in commit da1f3d1c72 on Apr 24, 2024
  183. ryanofsky referenced this in commit 23abc129d2 on Apr 24, 2024
  184. ryanofsky referenced this in commit 8310de510b on Apr 24, 2024
  185. ryanofsky referenced this in commit 990f9d65c5 on Apr 24, 2024
  186. ryanofsky referenced this in commit 10ff4de2b6 on Apr 24, 2024
  187. ryanofsky referenced this in commit 98cb2e1bf9 on Apr 24, 2024
  188. ryanofsky referenced this in commit 8e0323bc8e on Apr 25, 2024
  189. ryanofsky referenced this in commit 4fb08c28ba on Apr 25, 2024
  190. ryanofsky referenced this in commit 0290a2e819 on Apr 25, 2024
  191. ryanofsky referenced this in commit 88aa093356 on Apr 25, 2024
  192. ryanofsky referenced this in commit 7cd5b8d3b6 on Apr 26, 2024
  193. ryanofsky referenced this in commit f45705988e on Apr 26, 2024
  194. ryanofsky referenced this in commit 3103e87086 on Apr 26, 2024
  195. ryanofsky referenced this in commit 0cbcb66257 on Apr 26, 2024
  196. ryanofsky referenced this in commit e9a5ad3f4b on Apr 26, 2024
  197. ryanofsky referenced this in commit 55d7de92bb on Apr 26, 2024
  198. ryanofsky referenced this in commit 9bc6779338 on Apr 26, 2024
  199. ryanofsky referenced this in commit 2d22f23766 on Apr 26, 2024
  200. ryanofsky referenced this in commit 616572cbb4 on Apr 26, 2024
  201. ryanofsky referenced this in commit e1be443315 on Apr 26, 2024
  202. ryanofsky referenced this in commit cd62acaf6a on Apr 26, 2024
  203. ryanofsky referenced this in commit 0c8a1bb144 on Apr 26, 2024
  204. ryanofsky referenced this in commit 7a1982fe1d on Apr 26, 2024
  205. ryanofsky referenced this in commit 9552619961 on Apr 26, 2024
  206. ryanofsky referenced this in commit 834f65e824 on Apr 30, 2024
  207. ryanofsky referenced this in commit 6a8b2befea on Apr 30, 2024
  208. DrahtBot added the label Needs rebase on Apr 30, 2024
  209. ryanofsky referenced this in commit 84b347df68 on May 1, 2024
  210. ryanofsky referenced this in commit db91dbb5a9 on May 1, 2024
  211. ryanofsky referenced this in commit c1db95485c on May 1, 2024
  212. ryanofsky referenced this in commit 5d8923d53e on May 1, 2024
  213. ryanofsky force-pushed on May 1, 2024
  214. DrahtBot removed the label Needs rebase on May 1, 2024
  215. DrahtBot added the label CI failed on May 1, 2024
  216. DrahtBot commented at 10:42 pm on May 1, 2024: contributor

    🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the documentation.

    Possibly this is due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    Leave a comment here, if you need help tracking down a confusing failure.

    Debug: https://github.com/bitcoin/bitcoin/runs/24477515855

  217. ryanofsky force-pushed on May 2, 2024
  218. ryanofsky force-pushed on May 2, 2024
  219. ryanofsky force-pushed on May 3, 2024
  220. DrahtBot removed the label CI failed on May 3, 2024
  221. ryanofsky commented at 5:55 pm on May 3, 2024: contributor
    Rebased 2385cb37dbbe00004f8bffe1d1d784778d89a21e -> 987b28bbc991868ed305dbfc8f0846dd8b0b893c (pr/bresult-load.21 -> pr/bresult-load.22, compare) to use newer result API in #25722. Updated 987b28bbc991868ed305dbfc8f0846dd8b0b893c -> 548bf508e26aae39c732b3e61861d5c29669df06 (pr/bresult-load.22 -> pr/bresult-load.23, compare) to fix a bug in wallet tool and an accidental change to error message ordering Updated 548bf508e26aae39c732b3e61861d5c29669df06 -> ae0b9b8fcece154bae7f4383990e9d10f6cc0d2b (pr/bresult-load.23 -> pr/bresult-load.24, compare) to fix more unintended changes to error message order. Updated ae0b9b8fcece154bae7f4383990e9d10f6cc0d2b -> 5beaefaa806e54327d5995d86fd2d56d4687d575 (pr/bresult-load.24 -> pr/bresult-load.25, compare) to fix clang-tidy errors in https://cirrus-ci.com/task/6679456805289984 and ResultExtract bug in intermediate commit https://github.com/bitcoin/bitcoin/actions/runs/8931046064/job/24532379963?pr=25722
  222. DrahtBot added the label Needs rebase on May 20, 2024
  223. janus referenced this in commit 785f5c7679 on Jun 6, 2024
  224. janus referenced this in commit 0ac7fbf62d on Jun 6, 2024
  225. refactor: Add util::Result failure values
    Add util::Result support for returning more error information. For better error
    handling, adds the ability to return a value on failure, not just a value on
    success. This is a key missing feature that made the result class not useful
    for functions like LoadChainstate() which produce different errors that need to
    be handled differently.
    
    This change also makes some more minor improvements:
    
    - Smaller type size. util::Result<int> is 16 bytes, and util::Result<void> is 8
      bytes. Previously util::Result<int> and util::Result<void> were 72 bytes.
    
    - More documentation and tests.
    41f6b999d0
  226. refactor: Add util::Result::Update() method
    Add util::Result Update method to make it possible to change the value of an
    existing Result object. This will be useful for functions that can return
    multiple error and warning messages, and want to be able to change the result
    value while keeping existing messages.
    6fff420672
  227. refactor: Use util::Result class in LoadChainstate and VerifyLoadedChainstate 79a970d4f1
  228. refactor: Add util::Result multiple error and warning messages
    Add util::Result support for returning warning messages and multiple errors,
    not just a single error string. This provides a way for functions to report
    errors and warnings in a standard way, and simplifies interfaces.
    
    The functionality is unit tested here, and put to use in followup PR
    https://github.com/bitcoin/bitcoin/pull/25722
    ba959dbed3
  229. test: add static test for util::Result memory usage
    Suggested by Martin Leitner-Ankerl <martin.ankerl@gmail.com>
    https://github.com/bitcoin/bitcoin/pull/25722#discussion_r1174298529
    
    Co-authored-by: Martin Leitner-Ankerl <martin.ankerl@gmail.com>
    b08548336e
  230. Merge remote-tracking branch 'origin/pull/25665/head' 256987e499
  231. Add util::ResultPtr class
    The util::ResultPtr class is a wrapper for util::Result providing syntax sugar
    to make it less awkward to use with returned pointers. Instead of needing to be
    deferenced twice with **result or (*result)->member, it only needs to be
    dereferenced once with *result or result->member. Also when it is used in a
    boolean context, instead of evaluating to true when there is no error and the
    pointer is null, it evaluates to false so it is straightforward to determine
    whether the result points to something.
    
    This PR is only partial a solution to #26004 because while it makes it easier
    to check for null pointer values, it does not make it impossible to return a
    null pointer value inside a successful result. It would be possible to enforce
    that successful results always contain non-null pointers by using a not_null
    type (https://github.com/bitcoin/bitcoin/issues/24423) in combination with
    ResultPtr, though.
    40d119fa42
  232. Use ResultPtr<unique_ptr> instead of Result<unique_ptr> 73ec37294e
  233. Merge remote-tracking branch 'origin/pull/26022/head' 50884d0e7c
  234. Add temporary ResultExtract helper for porting to util::Result 0d92c4f324
  235. refactor: Use util::Result class in wallet/sqlite d852f8aa8a
  236. refactor: Use util::Result class in wallet/bdb 8aa9f16a95
  237. refactor: Use util::Result class in wallet/migrate 0cf15773c6
  238. refactor: Use util::Result class in wallet::MakeDatabase 8703a07ba2
  239. refactor: Use util::Result class in wallet/dump 02c778251e
  240. refactor: Use util::Result class in wallet/salvage 27d24c65f1
  241. refactor: Use util::Result class in wallet/wallettool 8209a6fb63
  242. refactor: Use util::Result class in wallet/wallet 676335de49
  243. refactor: Use util::Result class in wallet/load 2e03eee005
  244. refactor: Use util::Result class in wallet/rpc a6e29500f4
  245. refactor: Use util::Result class in wallet/interfaces ee05b41bc6
  246. refactor: Use util::Result class in wallet/test a2d7362fc7
  247. Drop temporary ResultExtract helper for porting to util::Result ed92fbba2a
  248. scripted-diff: replace wallet DatabaseStatus with DatabaseError
    -BEGIN VERIFY SCRIPT-
    git grep -l DatabaseStatus src | xargs sed -i s/DatabaseStatus/DatabaseError/g
    sed -i '/^    SUCCESS,$/d' src/wallet/db.h
    -END VERIFY SCRIPT-
    089c58f5b0
  249. ryanofsky referenced this in commit 90f7d39983 on Jun 17, 2024
  250. ryanofsky referenced this in commit 387cf87d52 on Jun 17, 2024
  251. ryanofsky force-pushed on Jun 17, 2024
  252. DrahtBot removed the label Needs rebase on Jun 17, 2024
  253. DrahtBot added the label CI failed on Jun 18, 2024
  254. DrahtBot commented at 2:33 am on June 18, 2024: contributor

    🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the documentation.

    Possibly this is due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    Leave a comment here, if you need help tracking down a confusing failure.

    Debug: https://github.com/bitcoin/bitcoin/runs/26340616800

  255. ryanofsky force-pushed on Jun 18, 2024
  256. DrahtBot commented at 8:36 am on June 19, 2024: contributor
    0wallet/test/fuzz/wallet_bdb_parser.cpp:22:15: error: using decl 'DatabaseError' is unused [misc-unused-using-decls,-warnings-as-errors]
    1   22 | using wallet::DatabaseError;
    2      |               ^
    3wallet/test/fuzz/wallet_bdb_parser.cpp:22:15: note: remove the using
    4   22 | using wallet::DatabaseError;
    5      | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~
    6^^^ ⚠️ Failure generated from clang-tidy
    7+ echo '^^^ ⚠️ Failure generated from clang-tidy'
    8+ false
    9��������
    
  257. ryanofsky force-pushed on Jun 20, 2024
  258. DrahtBot removed the label CI failed on Jun 20, 2024
  259. DrahtBot added the label Needs rebase on Jul 2, 2024
  260. DrahtBot commented at 11:20 am on July 2, 2024: contributor

    🐙 This pull request conflicts with the target branch and needs rebase.


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-07-03 10:13 UTC

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