From b4513498e5403bd4a4b47a0b734dcad9fc3d537a Mon Sep 17 00:00:00 2001 From: DanS Date: Wed, 28 Oct 2026 10:48:35 -0500 Subject: [PATCH] wallet: say what the startup witness check did VerifyAndSetInitialWitness logs one line per reseeded note and nothing else, so the pass that root-checks every note after a start (seconds on a large wallet) is invisible, and the reseed line's " of " reads like progress although is the tx's place in mapWallet and is mapWallet.size(): transactions, not notes. Append "[reseed ]", the running count of reseeded notes, to the reseed line. Its prefix, the comma after the hash and " of " stay exactly as they were: ObsidianDragon parses them (the hash between "for tx " and the comma, the number after " of ") to track progress. Add one summary line at the end of a pass that validated or reseeded anything: the notes validated, reseeded, already valid and ahead of the chain, the lowest witness height and the elapsed ms. A routine block with nothing to check prints nothing new. Logging only; the counters feed no decision. Co-Authored-By: Claude Opus 5.5 --- src/wallet/wallet.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 1f2c55930..8994e217f 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1387,6 +1387,9 @@ int CWallet::VerifyAndSetInitialWitness(const CBlockIndex* pindex, bool witnessO int nWitnessTxIncrement = 0; int nWitnessTotalTxCount = mapWallet.size(); int nMinimumHeight = pindex->GetHeight(); + // For the end-of-pass summary only; no decision reads them. + const int64_t nPassStart = GetTimeMicros(); + int nNotesValidated = 0, nNotesReseeded = 0, nNotesKnownGood = 0, nNotesAhead = 0; // root() walks a witness's whole depth-32 path, ~1.7-2.4ms, and after a restart every note needs // one: ~30s for a 16k-note wallet, with cs_main and cs_wallet held. So compute those roots first, @@ -1478,11 +1481,14 @@ int CWallet::VerifyAndSetInitialWitness(const CBlockIndex* pindex, bool witnessO if (!nd->witnesses.empty() && nd->witnessHeight > 0) { //Skip all functions for validated witness while witness only = true - if (nd->witnessRootValidated && witnessOnly) + if (nd->witnessRootValidated && witnessOnly) { + nNotesKnownGood++; continue; + } //Skip Validation when witness root has been validated if (nd->witnessRootValidated) { + nNotesKnownGood++; nMinimumHeight = SaplingWitnessMinimumHeight(item.second.nullifier, nd->witnessHeight, nMinimumHeight); continue; } @@ -1495,11 +1501,13 @@ int CWallet::VerifyAndSetInitialWitness(const CBlockIndex* pindex, bool witnessO CBlockIndex* whIndex = chainActive[nd->witnessHeight]; if (whIndex == NULL) { //witnessHeight strictly above the active chain (transient catch-up): cannot validate yet + nNotesAhead++; nMinimumHeight = SaplingWitnessMinimumHeight(item.second.nullifier, nd->witnessHeight, nMinimumHeight); continue; } if (cachedRoot(nd) == whIndex->hashFinalSaplingRoot) { nd->witnessRootValidated = true; + nNotesValidated++; nMinimumHeight = SaplingWitnessMinimumHeight(item.second.nullifier, nd->witnessHeight, nMinimumHeight); continue; } @@ -1512,6 +1520,7 @@ int CWallet::VerifyAndSetInitialWitness(const CBlockIndex* pindex, bool witnessO blockRoot = pblockindex->hashFinalSaplingRoot; if (witnessRoot == blockRoot) { nd->witnessRootValidated = true; + nNotesValidated++; nMinimumHeight = SaplingWitnessMinimumHeight(item.second.nullifier, nd->witnessHeight, nMinimumHeight); continue; } @@ -1521,8 +1530,11 @@ int CWallet::VerifyAndSetInitialWitness(const CBlockIndex* pindex, bool witnessO pblockindex = chainActive[wtxHeight]; ::ClearSingleNoteWitnessCache(nd); nWitnessGeneration++; + nNotesReseeded++; - LogPrintf("%s: Setting Initial Sapling Witness for tx %s, %i of %i\n", __func__, wtxHash.ToString(), nWitnessTxIncrement, nWitnessTotalTxCount); + //The GUI parses this line (the hash between "for tx " and the comma, and the count after " of "): + //keep that part as it is and only append. of is the tx's place in mapWallet, not a note count. + LogPrintf("%s: Setting Initial Sapling Witness for tx %s, %i of %i [reseed %d]\n", __func__, wtxHash.ToString(), nWitnessTxIncrement, nWitnessTotalTxCount, nNotesReseeded); SaplingMerkleTree saplingTree; blockRoot = pblockindex->pprev->hashFinalSaplingRoot; @@ -1570,6 +1582,10 @@ int CWallet::VerifyAndSetInitialWitness(const CBlockIndex* pindex, bool witnessO } } + if (nNotesValidated > 0 || nNotesReseeded > 0) + LogPrintf("%s: block %d: %d note witness(es) validated, %d reseeded, %d already valid, %d ahead of the chain; " + "lowest witness height %d; %ldms\n", __func__, pindex->GetHeight(), nNotesValidated, nNotesReseeded, + nNotesKnownGood, nNotesAhead, nMinimumHeight, (long)((GetTimeMicros() - nPassStart) / 1000)); if(fZdebug) LogPrintf("%s: nMinimumHeight=%d\n",__func__, nMinimumHeight); return nMinimumHeight;