Page MenuHomePhabricator

[Chronik] Add `/script/:type/:payload/utxos` HTTP endpoint
ClosedPublic

Authored by tobias_ruck on Apr 24 2023, 08:55.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC5e40002838e4: [Chronik] Add `/script/:type/:payload/utxos` HTTP endpoint
Summary

Allows to query the UTXOs of a script. This endpoint has no pagination as there's no obvious way to do it.

However, this endpoint is very fast, as it never reads the full tx off the disk, it only reads txid, block_height and is_coinbase, the remaining data is stored in the UTXOs (out_idx and value).

To decrease the size of ScriptUtxo protobuf messages, it doesn't contain the script directly (which would be the same for all UTXOs in the query anyway). Instead, it's in ScriptUtxos, for all UTXOs.

The allocated vector for the resulting UTXOs slightly over-allocates, by the number of DB UTXOs spent in the mempool. This could be fixed by counting the DB UTXOs spent in the mempool, but the added complexity doesn't seem worth it.

Depends on D13760 and D13761.

Test Plan

ninja && ./test/functional/test_runner.py chronik_script_utxos

Diff Detail

Repository
rABC Bitcoin ABC
Branch
chronik-http-utxos
Lint
Lint Errors
SeverityLocationCodeMessage
Errortest/functional/test_framework/chronik/client.py:81F821flake8 F821
Unit
No Test Coverage
Build Status
Buildable 23445
Build 46509: Build Diffbuild-diff · build-without-wallet · build-debug · build-clang-tidy · build-clang · build-chronik
Build 46508: arc lint + arc unit

Event Timeline

Fabien requested changes to this revision.Apr 25 2023, 09:54
Fabien added inline comments.
test/functional/chronik_script_utxos.py
21 ↗(On Diff #39908)

remove

39 ↗(On Diff #39908)
42 ↗(On Diff #39908)

you don't need the mock time

This revision now requires changes to proceed.Apr 25 2023, 09:54

Inline the ChronikClient import

The build failed due to an unexpected infrastructure outage. The administrators have been notified to investigate. Sorry for the inconvenience.
This revision is now accepted and ready to land.Apr 25 2023, 15:10