Commit Graph

25 Commits

Author SHA1 Message Date
Ryan Ofsky ef29c8b662 assumeutxo: Get rid of faked nTx and nChainTx values
The `PopulateAndValidateSnapshot` function introduced in
f6e2da5fb7 from #19806 has been setting fake
`nTx` and `nChainTx` values that can show up in RPC results (see #29328) and
make `CBlockIndex` state hard to reason about, because it is difficult to know
whether the values are real or fake.

Revert to previous behavior of setting `nTx` and `nChainTx` to 0 when the
values are unknown, instead of faking them.

This commit fixes at least two assert failures in the (pindex->nChainTx ==
pindex->nTx + prev_chain_tx) check that would happen previously. Tests for
these failures are added separately in the next two commits.

Compatibility note: This change could result in -checkblockindex failures if a
snapshot was loaded by a previous version of Bitcoin Core and not fully
validated, because fake nTx values will have been saved to the block index. It
would be pretty easy to avoid these failures by adding some compatibility code
to `LoadBlockIndex` and changing `nTx` values from 1 to 0 when they are fake
(when `(pindex->nStatus & BLOCK_VALID_MASK) < BLOCK_VALID_TRANSACTIONS`), but a
little simpler not to worry about being compatible in this case.
2024-03-18 11:28:40 -05:00
Ryan Ofsky f252e687ec assumeutxo test: Add RPC test for fake nTx and nChainTx values
The fake values will be removed in an upcoming commit, so it is useful to have
test coverage confirming the change in behavior.
2024-03-18 11:28:40 -05:00
Fabian Jahr 1ec6684b08
test: Add test for loadtxoutset when headers are not synced 2024-02-26 18:26:26 +01:00
Fabian Jahr 2bc1ecfaa9
test: Remove unnecessary sync_blocks in assumeutxo tests
The nodes are not connected at this point and no blocks have been mined, so it does not seem do anything
2024-02-26 17:04:46 +01:00
Hernan Marino 8d20602e55 test, assumeutxo: Add test to ensure failure when mempool not empty 2024-02-09 00:30:17 -03:00
MarcoFalke fa5cd66f0a
test: Assumeutxo with more than just coinbase transactions 2024-01-31 12:39:51 +01:00
Sebastian Falbesoner 931575418e test: assumeutxo: spend coin from snapshot chainstate after loading
Check that an UTXO that is only available in the snapshot chainstate
is also visible to the mempool by submitting a spending transaction.
2024-01-10 01:18:27 +01:00
fanquake 22025d06e5
Merge bitcoin/bitcoin#28605: Fix typos
43de4d3630 doc: fix typos (Sjors Provoost)

Pull request description:

  This PR fixes typos found by lint-spelling.py using codespell 2.2.6.

  Our CI linter job uses codespell 2.2.5 and found fewer typos that I did locally. In any case it's happy now.

ACKs for top commit:
  pablomartin4btc:
    re ACK 43de4d3630

Tree-SHA512: c032fe86cb49c924a468385653b31f309a9db68c478d70335bba3e65a1ff3826abe80284fe00a090ab5a509e1edbf17e476f6922fb15d055e50f1103dad2ccb0
2023-11-16 10:35:49 +00:00
pablomartin4btc 7de7685372 test, assumeutxo: Use assert_debug_log for error details
This is a follow-up on the invalid hash dump fix PR #28698.

https://github.com/bitcoin/bitcoin/pull/28698#pullrequestreview-1698178157
2023-11-09 18:54:27 -03:00
Sjors Provoost 43de4d3630
doc: fix typos
As found by lint-spelling.py using codespell 2.2.6.
2023-11-07 10:21:51 +09:00
pablomartin4btc 811067ca1c test: add coverage for snapshot chainstate not matching AssumeUTXO parameters
Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
Co-authored-by: Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
2023-10-25 11:14:43 -03:00
Fabian Jahr 351370a1d2
coinstats: Fix hash_serialized2 calculation
The legacy serialization was vulnerable to maleation and is fixed by
adopting the same serialization procedure as was already in use for
MuHash.

This also includes necessary test fixes where the hash_serialized2 was
hardcoded as well as correction of the regtest chainparams.

Co-authored-by: Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
2023-10-20 22:53:05 +02:00
Fabian Jahr d3223685b1
test: De-dublicate/optimize assumeutxo test for further extensions 2023-10-20 14:39:23 +02:00
Fabian Jahr 0a576d62fe
test: check au file with changed outpoint index 2023-10-20 14:39:21 +02:00
Ryan Ofsky 655dc716aa
Merge bitcoin/bitcoin#28666: test: assumeutxo file with unknown block hash
621db2f004 test: assumeutxo file with unknown block hash (Fabian Jahr)

Pull request description:

  Takes care of one of the open Todos in the assumeutxo functional test. Since an unknown block could be any hash, I simply chose one placeholder, it could also be a random string though.

ACKs for top commit:
  maflcko:
    lgtm ACK 621db2f004
  pablomartin4btc:
    cr ACK 621db2f004
  theStack:
    ACK 621db2f004
  ryanofsky:
    Code review ACK 621db2f004

Tree-SHA512: ee0438ce619f7348c6f88e39b0ea7ddddb8832956d9034ecc795c6033d5d905c09d11b7d0d5afc38231b2fd091ea7c1bd0a0be99d9c32c4e6357a25d76294142
2023-10-18 08:18:48 -04:00
Fabian Jahr 621db2f004
test: assumeutxo file with unknown block hash 2023-10-17 17:12:29 +02:00
MarcoFalke fa68571566
test: Add assumeutxo test for wrong hash 2023-10-17 13:24:07 +02:00
Sebastian Falbesoner 9620cb4493 assumeutxo: fail early if snapshot block hash doesn't match AssumeUTXO parameters 2023-10-16 17:20:59 +02:00
MarcoFalke fafde92f84
test: Check snapshot file with wrong number of coins
Also, fix a bug in an assert_debug_log call.
2023-10-12 11:14:56 +02:00
Sebastian Falbesoner 2e31250027 test: check that loading snapshot not matching AssumeUTXO parameters fails 2023-10-10 09:43:10 +02:00
Fabian Jahr 4e915e926b
test: Improvements of feature_assumeutxo
- Remove usage of the internal wait_until_helper function
- Use framework self.no_op instead of new no_sync function

co-authored-by: Andrew Chow <github@achow101.com>
2023-10-06 18:39:02 +02:00
Ryan Ofsky a9ef702a87 assumeutxo: change getchainstates RPC to return a list of chainstates
Current getchainstates RPC returns "normal" and "snapshot" fields which are not
ideal because it requires new "normal" and "snapshot" terms to be defined, and
the definitions are not really consistent with internal code. (In the RPC
interface, the "snapshot" chainstate becomes the "normal" chainstate after it
is validated, while in internal code there is no "normal chainstate" and the
"snapshot chainstate" is still called that temporarily after it is validated).

The current getchainstatees RPC is also awkward to use if you to want
information about the most-work chainstate because you have to look at the
"snapshot" field if it exists, and otherwise fall back to the "normal" field.

Fix these issues by having getchainstates just return a flat list of
chainstates ordered by work, and adding new chainstate "validated" field
alongside the existing "snapshot_blockhash" so it is explicit if a chainstate
was originally loaded from a snapshot, and whether the snapshot has been
validated.
2023-10-05 09:41:43 -04:00
James O'Beirne 7e40032260 tests: assumeutxo: accept final height from either chainstate 2023-10-04 11:32:36 -04:00
James O'Beirne 5bd2010f02 test: assumeutxo: avoid race in functional test 2023-10-04 11:05:27 -04:00
James O'Beirne 42cae39356 test: add feature_assumeutxo functional test
Most ideas for test improvements (TODOs) provided by Russ Yanofsky.
2023-09-30 06:41:23 -04:00