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 "<i> of <N>" reads like progress although <i> is the tx's place in mapWallet and <N> is mapWallet.size(): transactions, not notes. Append "[reseed <k>]", the running count of reseeded notes, to the reseed line. Its prefix, the comma after the hash and " of <N>" 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 <noreply@anthropic.com>
This commit is contained in:
+18
-2
@@ -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. <i> of <N> 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;
|
||||
|
||||
Reference in New Issue
Block a user