mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 02:25:40 +01:00
validation, index: Add unspendable coinbase helper functions
Making the checks to identify BIP30 available outside of validation.cpp is needed for reporting and tracking statistics on specific blocks and the UTXO set correctly.
This commit is contained in:
parent
6d40484684
commit
cb94db119f
@ -144,17 +144,13 @@ bool CoinStatsIndex::CustomAppend(const interfaces::BlockInfo& block)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Deduplicate BIP30 related code
|
||||
bool is_bip30_block{(block.height == 91722 && block.hash == uint256S("0x00000000000271a2dc26e7667f8419f2e15416dc6955e5a6c6cdf3f2574dd08e")) ||
|
||||
(block.height == 91812 && block.hash == uint256S("0x00000000000af0aed4792b1acee3d966af36cf5def14935db8de83d6f9306f2f"))};
|
||||
|
||||
// Add the new utxos created from the block
|
||||
assert(block.data);
|
||||
for (size_t i = 0; i < block.data->vtx.size(); ++i) {
|
||||
const auto& tx{block.data->vtx.at(i)};
|
||||
|
||||
// Skip duplicate txid coinbase transactions (BIP30).
|
||||
if (is_bip30_block && tx->IsCoinBase()) {
|
||||
if (IsBIP30Unspendable(*pindex) && tx->IsCoinBase()) {
|
||||
m_total_unspendable_amount += block_subsidy;
|
||||
m_total_unspendables_bip30 += block_subsidy;
|
||||
continue;
|
||||
|
@ -2083,8 +2083,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
|
||||
// Now that the whole chain is irreversibly beyond that time it is applied to all blocks except the
|
||||
// two in the chain that violate it. This prevents exploiting the issue against nodes during their
|
||||
// initial block download.
|
||||
bool fEnforceBIP30 = !((pindex->nHeight==91842 && pindex->GetBlockHash() == uint256S("0x00000000000a4d0a398161ffc163c503763b1f4360639393e0e4c8e300e0caec")) ||
|
||||
(pindex->nHeight==91880 && pindex->GetBlockHash() == uint256S("0x00000000000743f190a18c5577a3c2d2a1f610ae9601ac046a38084ccb7cd721")));
|
||||
bool fEnforceBIP30 = !IsBIP30Repeat(*pindex);
|
||||
|
||||
// Once BIP34 activated it was not possible to create new duplicate coinbases and thus other than starting
|
||||
// with the 2 existing duplicate coinbase pairs, not possible to create overwriting txs. But by the
|
||||
@ -5290,3 +5289,15 @@ Chainstate& ChainstateManager::ActivateExistingSnapshot(CTxMemPool* mempool, uin
|
||||
m_active_chainstate = m_snapshot_chainstate.get();
|
||||
return *m_snapshot_chainstate;
|
||||
}
|
||||
|
||||
bool IsBIP30Repeat(const CBlockIndex& block_index)
|
||||
{
|
||||
return (block_index.nHeight==91842 && block_index.GetBlockHash() == uint256S("0x00000000000a4d0a398161ffc163c503763b1f4360639393e0e4c8e300e0caec")) ||
|
||||
(block_index.nHeight==91880 && block_index.GetBlockHash() == uint256S("0x00000000000743f190a18c5577a3c2d2a1f610ae9601ac046a38084ccb7cd721"));
|
||||
}
|
||||
|
||||
bool IsBIP30Unspendable(const CBlockIndex& block_index)
|
||||
{
|
||||
return (block_index.nHeight==91722 && block_index.GetBlockHash() == uint256S("0x00000000000271a2dc26e7667f8419f2e15416dc6955e5a6c6cdf3f2574dd08e")) ||
|
||||
(block_index.nHeight==91812 && block_index.GetBlockHash() == uint256S("0x00000000000af0aed4792b1acee3d966af36cf5def14935db8de83d6f9306f2f"));
|
||||
}
|
||||
|
@ -1082,4 +1082,10 @@ bool DeploymentEnabled(const ChainstateManager& chainman, DEP dep)
|
||||
*/
|
||||
const AssumeutxoData* ExpectedAssumeutxo(const int height, const CChainParams& params);
|
||||
|
||||
/** Identifies blocks that overwrote an existing coinbase output in the UTXO set (see BIP30) */
|
||||
bool IsBIP30Repeat(const CBlockIndex& block_index);
|
||||
|
||||
/** Identifies blocks which coinbase output was subsequently overwritten in the UTXO set (see BIP30) */
|
||||
bool IsBIP30Unspendable(const CBlockIndex& block_index);
|
||||
|
||||
#endif // BITCOIN_VALIDATION_H
|
||||
|
Loading…
Reference in New Issue
Block a user