Use the cached consensusBranchId in DisconnectBlock
If a node is started with a set of network upgrades that don't match the serialized chain (such as when we implement NU rollbacks on testnet), RewindBlockIndex will disconnect each block in the chain until it reaches the most recent block that agrees with the node's set of network upgrades. However, the blocks themselves should be disconnected using the consensus branch ID that they were connected with, which is persisted alongside the chain and reconstructed in LoadBlockIndex.
This commit is contained in:
parent
de2e1160db
commit
27b2ce3468
|
@ -2461,7 +2461,9 @@ static DisconnectResult DisconnectBlock(const CBlock& block, CValidationState& s
|
||||||
view.PopAnchor(SaplingMerkleTree::empty_root(), SAPLING);
|
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)) {
|
if (chainparams.GetConsensus().NetworkUpgradeActive(pindex->nHeight, Consensus::UPGRADE_HEARTWOOD)) {
|
||||||
view.PopHistoryNode(consensusBranchId);
|
view.PopHistoryNode(consensusBranchId);
|
||||||
|
|
Loading…
Reference in New Issue