mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-09 22:28:51 +02:00
Merge bitcoin/bitcoin#31449: coins,refactor: Reduce getblockstats RPC UTXO overhead estimation
5f36e0ff1erpc: fix getblockstats UTXO overhead accounting (Lőrinc)76190489e6coins: pack `Coin` height/coinbase consistently (Lőrinc)1f309d1aa2coins: make `Coin::fCoinBase` a bool (Lőrinc) Pull request description: The [`getblockstats` RPC](https://github.com/bitcoin/bitcoin/pull/10757) currently overestimates UTXO overhead by treating the `fCoinBase` bitfield as an additional `bool` in `PER_UTXO_OVERHEAD`. However, `fCoinBase` and `nHeight` are stored as bitfields and effectively packed into a single 32-bit value; counting an extra bool in the overhead calculation is unnecessary. This PR introduces the following changes across three commits: * Store `fCoinBase` as a `bool` bitfield to reduce implicit conversions at call sites. * Use a consistent height/coinbase packing style across `Coin` serialization, undo serialization, and coinstats hashing (casting `nHeight` to `uint32_t` before shifting to avoid signed-promotion UB). * Adjust UTXO overhead estimation to match the actual `Coin` layout and update the related tests accordingly. ACKs for top commit: achow101: ACK5f36e0ff1esedited: ACK5f36e0ff1evasild: ACK5f36e0ff1eoptout21: crACK5f36e0ff1eTree-SHA512: f4a44debed358e9e130da9d6fae5f89289daa34f0bdb7155edc3e9b691c219451f4c80b1e16aca5b011f0fa2fa975484ef1af4ca4563b7c6ba4ca9dd133f30be
This commit is contained in:
@@ -2211,7 +2211,7 @@ DisconnectResult Chainstate::DisconnectBlock(const CBlock& block, const CBlockIn
|
||||
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 (!is_spent || tx.vout[o] != coin.out || pindex->nHeight != coin.nHeight || is_coinbase != coin.IsCoinBase()) {
|
||||
if (!is_bip30_exception) {
|
||||
fClean = false; // transaction output mismatch
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user