diff --git a/src/main.cpp b/src/main.cpp index 9b50482d6..f97755e58 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2461,7 +2461,9 @@ static DisconnectResult DisconnectBlock(const CBlock& block, CValidationState& s view.PopAnchor(SaplingMerkleTree::empty_root(), SAPLING); } - auto consensusBranchId = CurrentEpochBranchId(pindex->nHeight, chainparams.GetConsensus()); + // This is guaranteed to be filled by LoadBlockIndex. + assert(pindex->nCachedBranchId); + auto consensusBranchId = pindex->nCachedBranchId.get(); if (chainparams.GetConsensus().NetworkUpgradeActive(pindex->nHeight, Consensus::UPGRADE_HEARTWOOD)) { view.PopHistoryNode(consensusBranchId);