refactor: Redefine IsSolvable() using descriptors #25664

pull darosior wants to merge 2 commits into bitcoin:master from darosior:redefine_issolvable changing 8 files +4 −34
  1. darosior commented at 10:13 am on July 21, 2022: member

    Now that we have descriptors there is no need to try to sign for a scriptPubKey using dummy signatures, and using a mocked verification of this witness against the interpreter, just to make sure we know how to spend such a Script. Just try to infer a solvable descriptor: any scriptPubKey that we can sign for can be inferred as such.

    This came up in #24149 but i think it’s worth it on its own.

  2. DrahtBot added the label Refactoring on Jul 21, 2022
  3. DrahtBot commented at 6:26 pm on July 21, 2022: contributor

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #25748 (refactor: Avoid copies in FlatSigningProvider Merge by MarcoFalke)
    • #24149 (Signing support for Miniscript Descriptors by darosior)
    • #19602 (wallet: Migrate legacy wallets to descriptor wallets 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.

  4. achow101 commented at 8:28 pm on July 28, 2022: member
    ACK 3693771b9aef4e23a1b92b2c52b19ad44dac75da
  5. DrahtBot added the label Needs rebase on Aug 5, 2022
  6. in src/wallet/rpc/addresses.cpp:581 in 52f273a659 outdated
    577@@ -578,7 +578,7 @@ RPCHelpMan getaddressinfo()
    578 
    579     if (provider) {
    580         auto inferred = InferDescriptor(scriptPubKey, *provider);
    581-        bool solvable = inferred->IsSolvable() || IsSolvable(*provider, scriptPubKey);
    582+        bool solvable = inferred->IsSolvable();
    


    furszy commented at 2:40 pm on August 6, 2022:

    nit:

    0        bool solvable = inferred && inferred->IsSolvable();
    

    darosior commented at 9:10 pm on August 7, 2022:
    I don’t want to change the behaviour in this pull. The current code is an implicit assertion that we can infer a descriptor if we could get a provider (we’d crash otherwise), and this patch would silently mark the address as not solvable instead.

    furszy commented at 1:25 pm on August 8, 2022:

    In that sense, then might be better to add an explicit assertion so we don’t rely on a nullptr crash?

    0auto inferred = Assert(InferDescriptor(scriptPubKey, *provider));
    

    (np on doing it here or not)


    darosior commented at 8:47 am on August 11, 2022:
    I added an explicit assertion, but there is a linter failure about using CHECK_NONFATAL instead because it happens to be in RPC code.. But it’s not nonfatal, currently it is. Anyhow, it’s not related to this PR, so i just pushed back the previous state of this branch without the assertion.
  7. in src/wallet/spend.cpp:190 in 52f273a659 outdated
    186@@ -187,7 +187,7 @@ CoinsResult AvailableCoins(const CWallet& wallet,
    187 
    188             std::unique_ptr<SigningProvider> provider = wallet.GetSolvingProvider(output.scriptPubKey);
    189 
    190-            bool solvable = provider ? IsSolvable(*provider, output.scriptPubKey) : false;
    191+            bool solvable = provider ? IsSolvable(output.scriptPubKey, *provider) : false;
    


    furszy commented at 2:43 pm on August 6, 2022:

    nit:

    0            bool solvable = provider && IsSolvable(output.scriptPubKey, *provider)
    

    darosior commented at 9:11 pm on August 7, 2022:
    Would have taken the suggestion, thanks, but this call site is gone in the rebase. :)
  8. furszy commented at 2:52 pm on August 6, 2022: member

    Needs rebase but ACK 3693771b

    Nice that we don’t longer need to produce so many dummy signatures. Should get us a pretty decent speedup in AvailableCoins for big wallets.

  9. outputtype: remove redundant check for uncompressed keys in AddAndGetDestinationForScript
    It's already checked by its (only) caller, AddAndGetMultisigDestination.
    c232ef20c0
  10. darosior force-pushed on Aug 7, 2022
  11. darosior commented at 10:12 pm on August 7, 2022: member
    Rebased.
  12. DrahtBot removed the label Needs rebase on Aug 7, 2022
  13. furszy approved
  14. furszy commented at 1:30 pm on August 8, 2022: member
    Code review ACK fa3c84d8 after rebase.
  15. darosior force-pushed on Aug 11, 2022
  16. darosior force-pushed on Aug 11, 2022
  17. fanquake requested review from instagibbs on Aug 11, 2022
  18. in src/wallet/walletutil.cpp:47 in c90e4231a8 outdated
    42@@ -43,4 +43,10 @@ WalletFeature GetClosestWalletFeature(int version)
    43     }
    44     return static_cast<WalletFeature>(0);
    45 }
    46+
    47+bool IsSolvable(const CScript& script, const SigningProvider& provider) {
    


    instagibbs commented at 1:21 pm on August 11, 2022:
    I don’t see why introducing the new IsSolvable, with swapped arguments, is clearer than ripping out the old one at the same time. Last two commits can be same commit imo

    darosior commented at 1:36 pm on August 11, 2022:
    There were more call sites before the rebase. Agree we can actually drop the new IsSolvable helper now.

    darosior commented at 1:45 pm on August 11, 2022:
    Done

    instagibbs commented at 1:51 pm on August 11, 2022:
    Looks like you nuked the new definition, a bit more than I asked for :P

    darosior commented at 1:53 pm on August 11, 2022:
    Yes, it was only used once in tests, i didn’t see the need for keeping the helper then :)
  19. script/sign: remove needless IsSolvable() utility
    It was used back when we didn't have a concept of descriptor. Now we
    can check for solvability using descriptors.
    b16f93cadd
  20. darosior force-pushed on Aug 11, 2022
  21. fanquake requested review from achow101 on Aug 11, 2022
  22. fanquake requested review from furszy on Aug 11, 2022
  23. achow101 commented at 4:16 pm on August 11, 2022: member
    re-ACK b16f93caddcd3254eaf3dc43e09adf2142a9c40a
  24. furszy approved
  25. furszy commented at 5:12 pm on August 11, 2022: member
    ACK b16f93ca, only change is the IsSolvable helper function removal.
  26. achow101 merged this on Aug 11, 2022
  27. achow101 closed this on Aug 11, 2022

  28. sidhujag referenced this in commit 003f94abf7 on Aug 11, 2022
  29. bitcoin locked this on Aug 11, 2023

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-08 22:13 UTC

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