Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(indexer): new JRPC method to list substates #1049

Merged
merged 12 commits into from
Jun 19, 2024

Conversation

mrnaveira
Copy link
Collaborator

Description

  • Added new columns template_address, module_name and timestamp to the substates SQLite table.
  • Added new column timestamp to the events SQLite table. For now it's populated but not used by any method yet.
  • The event_scanner fetches and stores in database the values for all the new fields in substates and events
  • New JPRC method list_substates
  • Updated TypeScript bindings related with the new indexer method
  • Removed old logic for event storing in the event_manager, it's all now done only on the event_scanner and controlled by the event filter in the indexer config

Motivation and Context

On #1043 we refactored the Indexer to automatically store all substates related to events. This PR follows on that work and adds a new JRPC method list_substates that allows to fetch and filter all the substates stored in the Indexer database. It also adds some metadata (template_address, module_name, timestamp) to substates.

The new method JRPC method list_substates has the following optional parameters:

  • filter_by_template: String with the template address of the components that we want to filter
  • filter_by_type: String with the only type of substate that we want. Possible vaules are "Component", "Resource", "Vault", "UnclaimedConfidentialOutput", "NonFungible", "TransactionReceipt" and "FeeClaim"
  • limit: u64 value for the maximum number of results that we want (intended for pagination)
  • offset: u64 with the position of the first result that we want (intended for pagination)

How Has This Been Tested?

Manually by:

  • Spawning a local network using tari_swarm
  • Performing some transactions to generate events and substates
  • Inspecting the Indexer database and also querying the new list_substate method

What process can a PR reviewer use to test or verify this change?

See previous section

Breaking Changes

  • None
  • Requires data directory to be deleted
  • Other - Please specify

Copy link

github-actions bot commented Jun 18, 2024

Test Results (CI)

538 tests  +4   538 ✅ +4   1h 49m 7s ⏱️ + 6m 47s
 64 suites ±0     0 💤 ±0 
  2 files   ±0     0 ❌ ±0 

Results for commit c185e76. ± Comparison against base commit ba41514.

♻️ This comment has been updated with latest results.

@sdbondi
Copy link
Member

sdbondi commented Jun 19, 2024

LGTM - looks like a graphQL test is missing the timestamp field or it should be optional

Copy link
Member

@sdbondi sdbondi left a comment

Choose a reason for hiding this comment

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

utACK

@sdbondi sdbondi enabled auto-merge June 19, 2024 10:48
@sdbondi sdbondi added this pull request to the merge queue Jun 19, 2024
Merged via the queue into tari-project:development with commit 03a72be Jun 19, 2024
11 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Jun 24, 2024
Description
---
* Unified the `SubstateType` enum (duplicated in both the wallet daemon
and the indexer) into the `tari_dan_common_types` crate
* Updated the indexer JRPC client to include the `list_substates` method
* Updated the `substates.list` JRPC method in the wallet daemon to proxy
the call to the corresponding method in the indexer. The request type
now includes pagination support (offset + limit) but the resulting type
(`WalletSubstateRecord`) was kept the same for now to avoid conflicts
with existing applications.
* Updated bindings for the substate type and the new pagination options
for the wallet daemon substate listing

Motivation and Context
---
On #1049 we added a new
indexer JRPC method for listing substates. The indexer substate listing
is more advanced than the one in the wallet daemon:
* Is capable of indexing all the network while the wallet only stores
substates related to its own account's transactions
* Supports pagination (limit + offset fields)

This PR changes the `substates.list` JRPC method in the wallet daemon to
proxy the call to the corresponding method in the indexer. It also adds
pagination support.

How Has This Been Tested?
---
Manually by:
* Spawning a local network with `tari_swarm`
* Doing transactions to generate substates
* Query the `substates.list` JRPC in the wallet daemon and inspecting
the results

What process can a PR reviewer use to test or verify this change?
---
See previous sections

Breaking Changes
---

- [x] None
- [ ] Requires data directory to be deleted
- [ ] Other - Please specify
sdbondi pushed a commit to tari-project/tari-snap that referenced this pull request Jun 25, 2024
After tari-project/tari-dan#1049 we now have a
way to list substates via the indexer. This PR adds a new snap method
`listSubstates` that proxies the call to the underlying indexer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants