Skip to content

Conversation

@theStack
Copy link
Contributor

Inspired by some manual testing I did for #28553, this PR checks that RPCs which explicitly query the UTXO set database (i.e. gettxoutsetinfo, scantxoutset and gettxout) operate on the snapshot chainstate as expected.

@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 12, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK fjahr, tdb3, achow101
Concept ACK BrandonOdiwuor

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

@DrahtBot DrahtBot added the Tests label Aug 12, 2024
@fanquake
Copy link
Member

https://github.com/bitcoin/bitcoin/actions/runs/10351325972/job/28649600800?pr=30636#step:7:23340:

 test  2024-08-12T12:48:42.142000Z TestFramework (ERROR): JSONRPC error 
                                   Traceback (most recent call last):
                                     File "/home/runner/work/_temp/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/test_framework/test_framework.py", line 132, in main
                                       self.run_test()
                                     File "/home/runner/work/_temp/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/feature_assumeutxo.py", line 354, in run_test
                                       utxo_info = n1.gettxoutsetinfo()
                                                   ^^^^^^^^^^^^^^^^^^^^
                                     File "/home/runner/work/_temp/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/test_framework/coverage.py", line 50, in __call__
                                       return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                     File "/home/runner/work/_temp/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/test_framework/authproxy.py", line 146, in __call__
                                       raise JSONRPCException(response['error'], status)
                                   test_framework.authproxy.JSONRPCException: Unable to get data because coinstatsindex is still syncing. Current height: 0 (-32603)
 node1 2024-08-12T12:48:42.142251Z (mocktime: 2011-02-02T23:17:17Z) [scheduler] [validationinterface.cpp:246] [operator()] [validation] ChainStateFlushed: block hash=3bb7ce5eba0be48939b7a521ac1ba9316afee2c7bada3a0cca24188e6d7d96c0 
 test  2024-08-12T12:48:42.149000Z TestFramework (DEBUG): Closing down network thread 

@fjahr fjahr mentioned this pull request Aug 12, 2024
32 tasks
@fjahr
Copy link
Contributor

fjahr commented Aug 12, 2024

Concept ACK

@theStack theStack force-pushed the 202408-test-assumeutxo-check_utxo_querying_rpcs branch from deda54e to 2e9072c Compare August 12, 2024 14:07
Copy link
Contributor

@fjahr fjahr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK 2e9072c137e81c75c58d0c0788295c10fdafdc9b

This is a good regression test to have. I left a bunch of minor nits but this is fine to merge as-is so feel free to leave them unless you have to re-touch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could have moved this up and used it in the gettxoutsetinfo as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought: maybe just pull all three of these loaded keys out in the beginning since you use each of them at least twice and they are used again further below... or you could deduplicate the assert_equal triplet but it's not a big deal either way...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Introduced snapshot_hash and snapshot_num_coins in the beginning and used the already existing SNAPSHOT_BASE_HEIGHT for the height.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
assert_equal(scan_result['bestblock'], loaded['tip_hash'])
assert_equal(scan_result['bestblock'], snapshot_hash)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Would be a bit more readable IMO if you would break it into two lines

Copy link
Contributor

@tdb3 tdb3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

Great test additions.
Light code review and manual test. I concur with the nits from @fjahr.

Copy link
Contributor

@BrandonOdiwuor BrandonOdiwuor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

@theStack theStack force-pushed the 202408-test-assumeutxo-check_utxo_querying_rpcs branch from 2e9072c to 917e70a Compare August 20, 2024 10:45
@theStack
Copy link
Contributor Author

Thanks for the reviews! Took the suggestions and refined the UTXO check against the scantxoutset result to also include the vout index (=0), rather than only verifying the txid.

@fjahr
Copy link
Contributor

fjahr commented Aug 20, 2024

utACK 917e70a

Only changes since last review were addressing my minor review comments.

Copy link
Contributor

@tdb3 tdb3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 917e70a

These tests are great additions.
Changes incorporate comments nicely.
Ran functionals locally (passed).

@maflcko maflcko added this to the 28.0 milestone Aug 20, 2024
@achow101
Copy link
Member

ACK 917e70a

@achow101 achow101 merged commit bc87ad9 into bitcoin:master Aug 21, 2024
@theStack theStack deleted the 202408-test-assumeutxo-check_utxo_querying_rpcs branch August 21, 2024 17:32
@bitcoin bitcoin locked and limited conversation to collaborators Oct 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants