mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 09:43:55 +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:
@@ -171,16 +171,16 @@ class GetblockstatsTest(BitcoinTestFramework):
|
||||
genesis_stats = self.nodes[0].getblockstats(0)
|
||||
assert_equal(genesis_stats["blockhash"], "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")
|
||||
assert_equal(genesis_stats["utxo_increase"], 1)
|
||||
assert_equal(genesis_stats["utxo_size_inc"], 117)
|
||||
assert_equal(genesis_stats["utxo_size_inc"], 116)
|
||||
assert_equal(genesis_stats["utxo_increase_actual"], 0)
|
||||
assert_equal(genesis_stats["utxo_size_inc_actual"], 0)
|
||||
|
||||
self.log.info('Test tip including OP_RETURN')
|
||||
tip_stats = self.nodes[0].getblockstats(tip)
|
||||
assert_equal(tip_stats["utxo_increase"], 6)
|
||||
assert_equal(tip_stats["utxo_size_inc"], 441)
|
||||
assert_equal(tip_stats["utxo_size_inc"], 435)
|
||||
assert_equal(tip_stats["utxo_increase_actual"], 4)
|
||||
assert_equal(tip_stats["utxo_size_inc_actual"], 300)
|
||||
assert_equal(tip_stats["utxo_size_inc_actual"], 296)
|
||||
|
||||
self.log.info("Test when only header is known")
|
||||
block = self.generateblock(self.nodes[0], output="raw(55)", transactions=[], submit=False)
|
||||
|
||||
Reference in New Issue
Block a user