Page MenuHomePhabricator

[Chronik] Add `/token-id/...` endpoints
ClosedPublic

Authored by tobias_ruck on Feb 5 2024, 13:43.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCecfc05fe82b5: [Chronik] Add `/token-id/...` endpoints
Summary

For some applications (e.g. the explorer or token airdrops), it is helpful to have an endpoint that returns txs/UTXOs with a given token ID.

We add these HTTP endpoints:

  1. /token-id/:token_id/confirmed-txs
  2. /token-id/:token_id/history
  3. /token-id/:token_id/unconfirmed-txs
  4. /token-id/:token_id/utxos

Since have a generic implementation that allows us to easily group txs, this now becomes really easy, we simply add TokenIdGroup, implement Group on it and use the generic group writer + mempool to index txs by token ID.

The only tricky part is getting the auxillary data for the group, which can come from 3 different sources (for BlockConnected: from ProcessedTokenTxBatch, for BlockDisconnected: from the DB, for mempool inserts/removals: from the mempool).

Depends on D15383 and D15370.

Test Plan

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

Diff Detail

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

Event Timeline

bump CURRENT_INDEXER_VERSION

The build failed due to an unexpected infrastructure outage. The administrators have been notified to investigate. Sorry for the inconvenience.
The build failed due to an unexpected infrastructure outage. The administrators have been notified to investigate. Sorry for the inconvenience.

Failed tests logs:

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

------- Stdout: -------
2024-02-05T14:45:52.410000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-chronik-plugins/test/tmp/test_runner_₿₵_  _20240205_144120/chronik_token_burn_250
2024-02-05T14:45:53.080000Z TestFramework (INFO): Stopping nodes
[node 0] Cleaning up leftover process
------- Stderr: -------
Traceback (most recent call last):
  File "/work/test/functional/chronik_token_burn.py", line 264, in <module>
    ChronikTokenBurn().main()
  File "/work/test/functional/test_framework/test_framework.py", line 171, in main
    exit_code = self.shutdown()
  File "/work/test/functional/test_framework/test_framework.py", line 397, in shutdown
    self.stop_nodes()
  File "/work/test/functional/test_framework/test_framework.py", line 648, in stop_nodes
    node.stop_node(wait=wait, wait_until_stopped=False)
  File "/work/test/functional/test_framework/test_node.py", line 502, in stop_node
    self.stop(wait=wait)
  File "/work/test/functional/test_framework/coverage.py", line 47, in __call__
    return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
  File "/work/test/functional/test_framework/authproxy.py", line 175, in __call__
    response, status = self._request(
  File "/work/test/functional/test_framework/authproxy.py", line 125, in _request
    self.__conn.request(method, path, postdata, headers)
  File "/usr/lib/python3.9/http/client.py", line 1255, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1301, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1250, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1010, in _send_output
    self.send(msg)
  File "/usr/lib/python3.9/http/client.py", line 950, in send
    self.connect()
  File "/usr/lib/python3.9/http/client.py", line 921, in connect
    self.sock = self._create_connection(
  File "/usr/lib/python3.9/socket.py", line 843, in create_connection
    raise err
  File "/usr/lib/python3.9/socket.py", line 831, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

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

The build failed due to an unexpected infrastructure outage. The administrators have been notified to investigate. Sorry for the inconvenience.
chronik/chronik-http/src/handlers.rs
168 ↗(On Diff #44978)

This is not paginated ?

chronik/chronik-http/src/handlers.rs
168 ↗(On Diff #44978)

It's not paginated in the equivalent script endpoint either; you can see the reasoning here D13574

This revision is now accepted and ready to land.Feb 12 2024, 11:21
This revision was automatically updated to reflect the committed changes.