loadtxoutset trusts several counts that are not part of the committed UTXO hash. Empty groups and duplicate records can change the serialized file and reported count without changing the loaded UTXO set, while one transaction group can claim more outputs than any valid block could contain.
<details> <summary>Reproducer</summary>
diff --git a/test/functional/feature_assumeutxo.py b/test/functional/feature_assumeutxo.py
index fa9466f2d8..1bb8e31629 100755
--- a/test/functional/feature_assumeutxo.py
+++ b/test/functional/feature_assumeutxo.py
@@ -20,12 +20,16 @@ from test_framework.compressor import (
)
from test_framework.messages import (
CBlockHeader,
+ CTxOut,
from_hex,
MAGIC_BYTES,
+ MAX_BLOCK_WEIGHT,
MAX_MONEY,
msg_headers,
+ ser_compact_size,
ser_varint,
tx_from_hex,
+ WITNESS_SCALE_FACTOR,
)
from test_framework.p2p import (
P2PInterface,
@@ -136,6 +140,15 @@ class AssumeutxoTest(BitcoinTestFramework):
f.write(valid_snapshot_contents[43 + 8:])
expected_error(msg="Bad snapshot - coins left over after deserializing 298 coins." if off == -1 else "Bad snapshot format or truncated snapshot after deserializing 299 coins.")
+ self.log.info(" - snapshot file with more outputs for one txid than fit in a block")
+ max_outputs_per_block = MAX_BLOCK_WEIGHT // (WITNESS_SCALE_FACTOR * len(CTxOut().serialize()))
+ with open(bad_snapshot_path, "wb") as f:
+ f.write(valid_snapshot_contents[:43])
+ f.write((max_outputs_per_block + 1).to_bytes(8, "little"))
+ f.write(valid_snapshot_contents[51:83])
+ f.write(ser_compact_size(max_outputs_per_block + 1))
+ expected_error(msg="Bad snapshot format or truncated snapshot after deserializing 0 coins.") # TODO: Reject the impossible output count before reading coins
+
self.log.info(" - snapshot file with alternated but parsable UTXO data results in different hash")
cases = [
# (content, offset, wrong_hash, custom_message)
</details>
Closed #36500 proposed rejecting empty groups and checking the unique total coin count, but a complete fix would also apply the existing block-derived output limit to each group. Given that these checks keep accumulating around snapshot parsing, I'm proposing to remove AssumeUTXO entirely in #36598 instead.