You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge bitcoin/bitcoin#26008: wallet: cache IsMine scriptPubKeys to improve performance of descriptor wallets
e041ed9 wallet: Retrieve ID from loaded DescSPKM directly (Ava Chow)
39640dd wallet: Use scriptPubKeyCache in GetSolvingProvider (Ava Chow)
b410f68 wallet: Use scriptPubKey cache in GetScriptPubKeyMans (Ava Chow)
edf4e73 wallet: Use scriptPubKey cache in IsMine (Ava Chow)
3723233 wallet: Cache scriptPubKeys for all DescriptorSPKMs (Ava Chow)
99a0cdd wallet: Introduce a callback called after TopUp completes (Ava Chow)
b276825 bench: Add a benchmark for ismine (Ava Chow)
Pull request description:
Wallets that have a ton of non-ranged descriptors (such as a migrated non-HD wallet) perform fairly poorly due to looping through all of the wallet's `ScriptPubKeyMan`s. This is done in various places, such as `IsMine`, and helper functions for fetching a `ScriptPubKeyMan` and a `SolvingProvider`. This also has a bit of a performance impact on standard descriptor wallets, although less noticeable due to the small number of SPKMs.
As these functions are based on doing `IsMine` for each `ScriptPubKeyMan`, we can improve this performance by caching `IsMine` scriptPubKeys for all descriptors and use that to determine which `ScriptPubKeyMan` to actually use for those things. This cache is used exclusively and we no longer iterate the SPKMs.
Also added a benchmark for `IsMine`.
ACKs for top commit:
ryanofsky:
Code review ACK e041ed9. Just suggested changes since last review
josibake:
ACK bitcoin/bitcoin@e041ed9
furszy:
Code review ACK e041ed9
Tree-SHA512: 8e7081991a025e682e9dea838b4543b0d179832d1c47397fb9fe7a97fa01eb699c15a5d5a785634926844fc83a46e6ac07ef753119f39d84423220ef8a548894
Copy file name to clipboardExpand all lines: src/wallet/scriptpubkeyman.cpp
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1288,6 +1288,9 @@ bool LegacyScriptPubKeyMan::TopUp(unsigned int kpSize)
1288
1288
}
1289
1289
if (!batch.TxnCommit()) throwstd::runtime_error(strprintf("Error during keypool top up. Cannot commit changes for wallet %s", m_storage.GetDisplayName()));
1290
1290
NotifyCanGetAddressesChanged();
1291
+
// Note: Unlike with DescriptorSPKM, LegacySPKM does not need to call
1292
+
// m_storage.TopUpCallback() as we do not know what new scripts the LegacySPKM is
1293
+
// watching for. CWallet's scriptPubKey cache is not used for LegacySPKMs.
1291
1294
returntrue;
1292
1295
}
1293
1296
@@ -2152,6 +2155,7 @@ bool DescriptorScriptPubKeyMan::TopUp(unsigned int size)
0 commit comments