From 99b2098f89b72d29c5e4d5772831c3c364c23e84 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Thu, 16 Dec 2021 08:58:14 -0700 Subject: [PATCH] Batch-verify Orchard transactions at the block level. Fixes #5316 --- src/main.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 91863a38f..842ffcdfc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5374,12 +5374,13 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview, // Flags used to permit skipping checks for efficiency auto verifier = ProofVerifier::Disabled(); // No need to verify JoinSplits twice bool fCheckTransactions = true; - // We may as well check Orchard authorizations if we are checking - // transactions, since we can batch-validate them. - auto orchardAuth = orchard::AuthValidator::Batch(); for (CBlockIndex* pindex = chainActive.Tip(); pindex && pindex->pprev; pindex = pindex->pprev) { + // We may as well check Orchard authorizations if we are checking + // transactions, since we can batch-validate them. + auto orchardAuth = orchard::AuthValidator::Batch(); + boost::this_thread::interruption_point(); uiInterface.ShowProgress(_("Verifying blocks..."), std::max(1, std::min(99, (int)(((double)(chainActive.Height() - pindex->nHeight)) / (double)nCheckDepth * (nCheckLevel >= 4 ? 50 : 100))))); if (pindex->nHeight < chainActive.Height()-nCheckDepth) @@ -5421,6 +5422,10 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview, } } + if (!orchardAuth.Validate()) { + return error("VerifyDB(): Orchard batch validation failed for block at height %d", pindex->nHeight); + } + if (ShutdownRequested()) return true; }