mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 15:04:44 +01:00
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.
This commit is contained in:
parent
decde9bba6
commit
511eb7fdea
1 changed files with 10 additions and 1 deletions
|
@ -1837,6 +1837,15 @@ DisconnectResult CChainState::DisconnectBlock(const CBlock& block, const CBlockI
|
|||
return DISCONNECT_FAILED;
|
||||
}
|
||||
|
||||
// Ignore blocks that contain transactions which are 'overwritten' by later transactions,
|
||||
// unless those are already completely spent.
|
||||
// See https://github.com/bitcoin/bitcoin/issues/22596 for additional information.
|
||||
// Note: the blocks specified here are different than the ones used in ConnectBlock because DisconnectBlock
|
||||
// unwinds the blocks in reverse. As a result, the inconsistency is not discovered until the earlier
|
||||
// blocks with the duplicate coinbase transactions are disconnected.
|
||||
bool fEnforceBIP30 = !((pindex->nHeight==91722 && pindex->GetBlockHash() == uint256S("0x00000000000271a2dc26e7667f8419f2e15416dc6955e5a6c6cdf3f2574dd08e")) ||
|
||||
(pindex->nHeight==91812 && pindex->GetBlockHash() == uint256S("0x00000000000af0aed4792b1acee3d966af36cf5def14935db8de83d6f9306f2f")));
|
||||
|
||||
// undo transactions in reverse order
|
||||
for (int i = block.vtx.size() - 1; i >= 0; i--) {
|
||||
const CTransaction &tx = *(block.vtx[i]);
|
||||
|
@ -1850,7 +1859,7 @@ DisconnectResult CChainState::DisconnectBlock(const CBlock& block, const CBlockI
|
|||
COutPoint out(hash, o);
|
||||
Coin coin;
|
||||
bool is_spent = view.SpendCoin(out, &coin);
|
||||
if (!is_spent || tx.vout[o] != coin.out || pindex->nHeight != coin.nHeight || is_coinbase != coin.fCoinBase) {
|
||||
if (fEnforceBIP30 && (!is_spent || tx.vout[o] != coin.out || pindex->nHeight != coin.nHeight || is_coinbase != coin.fCoinBase)) {
|
||||
fClean = false; // transaction output mismatch
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue