Skip to content

Commit 511eb7f

Browse files
committed
Ignore problematic blocks in DisconnectBlock
When using checklevel=4, block verification fails because of duplicate coinbase transactions involving blocks 91812 and 91722. There was already a check in place for ConnectBlock to ignore the problematic blocks, but DisconnectBlock did not contain a similar check. This change ignores the blocks where these inconsistencies surface so that block verification will succeed at checklevel=4.
1 parent decde9b commit 511eb7f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/validation.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1837,6 +1837,15 @@ DisconnectResult CChainState::DisconnectBlock(const CBlock& block, const CBlockI
18371837
return DISCONNECT_FAILED;
18381838
}
18391839

1840+
// Ignore blocks that contain transactions which are 'overwritten' by later transactions,
1841+
// unless those are already completely spent.
1842+
// See https://github.com/bitcoin/bitcoin/issues/22596 for additional information.
1843+
// Note: the blocks specified here are different than the ones used in ConnectBlock because DisconnectBlock
1844+
// unwinds the blocks in reverse. As a result, the inconsistency is not discovered until the earlier
1845+
// blocks with the duplicate coinbase transactions are disconnected.
1846+
bool fEnforceBIP30 = !((pindex->nHeight==91722 && pindex->GetBlockHash() == uint256S("0x00000000000271a2dc26e7667f8419f2e15416dc6955e5a6c6cdf3f2574dd08e")) ||
1847+
(pindex->nHeight==91812 && pindex->GetBlockHash() == uint256S("0x00000000000af0aed4792b1acee3d966af36cf5def14935db8de83d6f9306f2f")));
1848+
18401849
// undo transactions in reverse order
18411850
for (int i = block.vtx.size() - 1; i >= 0; i--) {
18421851
const CTransaction &tx = *(block.vtx[i]);
@@ -1850,7 +1859,7 @@ DisconnectResult CChainState::DisconnectBlock(const CBlock& block, const CBlockI
18501859
COutPoint out(hash, o);
18511860
Coin coin;
18521861
bool is_spent = view.SpendCoin(out, &coin);
1853-
if (!is_spent || tx.vout[o] != coin.out || pindex->nHeight != coin.nHeight || is_coinbase != coin.fCoinBase) {
1862+
if (fEnforceBIP30 && (!is_spent || tx.vout[o] != coin.out || pindex->nHeight != coin.nHeight || is_coinbase != coin.fCoinBase)) {
18541863
fClean = false; // transaction output mismatch
18551864
}
18561865
}

0 commit comments

Comments
 (0)