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#28894: wallet: batch all individual spkms setup db writes in a single db txn
f053024 wallet: batch external signer descriptor import (Sjors Provoost)
1f65241 wallet: descriptors setup, batch db operations (furszy)
3eb769f wallet: batch legacy spkm TopUp (furszy)
075aa44 wallet: batch descriptor spkm TopUp (furszy)
bb4554c bench: add benchmark for wallet creation procedure (furszy)
Pull request description:
Work decoupled from #28574.
Instead of performing multiple single write operations per spkm
setup call, this PR batches them all within a single atomic db txn.
Speeding up the process and preventing the wallet from entering
an inconsistent state if any of the intermediate transactions fail
(which shouldn't happen but.. if it does, it is better to not store
any spkm rather than storing them partially).
To compare the changes, added benchmark in the first commit.
ACKs for top commit:
Sjors:
re-utACK f053024
achow101:
ACK f053024
BrandonOdiwuor:
ACK f053024
theStack:
Code-review ACK f053024
Tree-SHA512: aead8548473e17d4d53e8e7039bbaf5e8bf2fe83f33b33f81cdedefe8a31b7003ceb6d5379b1bad1ca2692e909492009a21284ec8338eede078df3d19046ab5a
Copy file name to clipboardExpand all lines: src/wallet/scriptpubkeyman.cpp
+19-9Lines changed: 19 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -333,7 +333,8 @@ bool LegacyScriptPubKeyMan::TopUpInactiveHDChain(const CKeyID seed_id, int64_t i
333
333
chain.m_next_external_index = std::max(chain.m_next_external_index, index + 1);
334
334
}
335
335
336
-
TopUpChain(chain, 0);
336
+
WalletBatch batch(m_storage.GetDatabase());
337
+
TopUpChain(batch, chain, 0);
337
338
338
339
returntrue;
339
340
}
@@ -1274,19 +1275,22 @@ bool LegacyScriptPubKeyMan::TopUp(unsigned int kpSize)
1274
1275
returnfalse;
1275
1276
}
1276
1277
1277
-
if (!TopUpChain(m_hd_chain, kpSize)) {
1278
+
WalletBatch batch(m_storage.GetDatabase());
1279
+
if (!batch.TxnBegin()) returnfalse;
1280
+
if (!TopUpChain(batch, m_hd_chain, kpSize)) {
1278
1281
returnfalse;
1279
1282
}
1280
1283
for (auto& [chain_id, chain] : m_inactive_hd_chains) {
1281
-
if (!TopUpChain(chain, kpSize)) {
1284
+
if (!TopUpChain(batch, chain, kpSize)) {
1282
1285
returnfalse;
1283
1286
}
1284
1287
}
1288
+
if (!batch.TxnCommit()) throwstd::runtime_error(strprintf("Error during keypool top up. Cannot commit changes for wallet %s", m_storage.GetDisplayName()));
if (!batch.TxnCommit()) throwstd::runtime_error(strprintf("Error during descriptors keypool top up. Cannot commit changes for wallet %s", m_storage.GetDisplayName()));
0 commit comments