Page MenuHomePhabricator

[Chronik] Add `/script/:type/:payload/confirmed-txs`
ClosedPublic

Authored by tobias_ruck on Apr 4 2023, 16:15.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC12d7bb798747: [Chronik] Add `/script/:type/:payload/confirmed-txs`
Summary

This endpoint returns all the confirmed txs of a script, in the order they appear in the blockchain.

This is useful if a wallet simply wants to download all the txs of the wallet. It can then store the last page it queried, and when re-syncing, it only needs to read pages from including after the current page.

While the original plan was to implement /script/:type/:payload/history directly, it is actually not a trivial implementation, so for simplicity, we start with this endpoint. It doesn't exist in the NNG Chronik version, but in discussions with Joey, it was clear that this is clearly a beneficial feature.

In the future, we might also add a ?after=<txid> feature (used instead of ?page=), to return txs starting after the given txid (in 'blockchain' order). This would allow wallets to query new txs by providing the last known txid.

Test Plan

ninja check-crates && ninja && ./test/functional/test_runner.py chronik_script_confirmed_txs

You can also verify the txs capacity calculation by changing the log -> panic in group_history.rs, running the test plan again and it should work fine.

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Remove unnecessary MissingMempoolTx error variant

Move chunks from chronik_script_confirmed_txs.py to util.py, other minor changes

@bot build-linux64 build-linux-aarch64 build-linux-arm build-osx build-win64

Fix some naming/comments in the python test

rename query_script_history* -> query_script_txs*

Failed tests logs:

====== Bitcoin ABC functional tests: chronik_script_confirmed_txs.py ======

------- Stdout: -------
2023-04-04T18:31:39.476000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-linux-arm/test/tmp/test_runner_₿₵_  _20230404_182205/chronik_script_confirmed_txs_219
2023-04-04T18:31:41.357000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 137, in main
    self.run_test()
  File "/work/test/functional/chronik_script_confirmed_txs.py", line 121, in run_test
    query_script_history_success(
  File "/work/test/functional/chronik_script_confirmed_txs.py", line 59, in query_script_history_success
    assert_equal(response.status, 200)
  File "/work/test/functional/test_framework/util.py", line 59, in assert_equal
    raise AssertionError(
AssertionError: not(400 == 200)
2023-04-04T18:31:41.408000Z TestFramework (INFO): Stopping nodes
2023-04-04T18:31:41.565000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-linux-arm/test/tmp/test_runner_₿₵_  _20230404_182205/chronik_script_confirmed_txs_219
2023-04-04T18:31:41.565000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-linux-arm/test/tmp/test_runner_₿₵_  _20230404_182205/chronik_script_confirmed_txs_219/test_framework.log
2023-04-04T18:31:41.565000Z TestFramework (ERROR): 
2023-04-04T18:31:41.565000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-linux-arm/test/tmp/test_runner_₿₵_  _20230404_182205/chronik_script_confirmed_txs_219' to consolidate all logs
2023-04-04T18:31:41.565000Z TestFramework (ERROR): 
2023-04-04T18:31:41.565000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2023-04-04T18:31:41.565000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2023-04-04T18:31:41.565000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests: chronik_script_confirmed_txs.py

page and page_size must be u32; improve some error messages

@bot build-linux64 build-linux-aarch64 build-linux-arm build-osx build-win64

tobias_ruck retitled this revision from [Chronik] Add `/script/:script_type/:payload/confirmed-txs` to [Chronik] Add `/script/:type/:payload/confirmed-txs`.Apr 5 2023, 08:17
tobias_ruck edited the summary of this revision. (Show Details)

Add comments regarding OOM attacks and 32-bit limitations

This revision is now accepted and ready to land.Apr 5 2023, 09:13