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

rpc-alt: finish queryTransactionBlocks #21010

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

rpc-alt: finish queryTransactionBlocks #21010

wants to merge 10 commits into from

Conversation

amnn
Copy link
Contributor

@amnn amnn commented Jan 30, 2025

Description

Completing the filter implementations for suix_queryTransactionBlocks. It was also helpful to implement sui_getCheckpoint because the checkpoint filter is implemented by loading a checkpoint, which means we implement the checkpoint data loader, and it is helpful to then have a way to test that directly.

The PR is split into multiple self-contained commits, each with their own descriptions and tests, each responsible for implementing filters over one table.

Test plan

New E2E tests:

sui$ cargo nextest run -p sui-indexer-alt-e2e-tests

Stack


Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • gRPC:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:

@amnn amnn requested review from emmazzz, gegaowp and wlmyng January 30, 2025 13:30
@amnn amnn self-assigned this Jan 30, 2025
Copy link

vercel bot commented Jan 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 4, 2025 3:26pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Feb 4, 2025 3:26pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Feb 4, 2025 3:26pm

@amnn amnn temporarily deployed to sui-typescript-aws-kms-test-env January 30, 2025 13:30 — with GitHub Actions Inactive
@amnn amnn changed the title Amnn/rpc query tx rpc-alt: finish queryTransactionBlocks Jan 30, 2025
Base automatically changed from amnn/rpc-past-obj to main January 30, 2025 13:57
@amnn amnn force-pushed the amnn/rpc-query-tx branch from 453d8d3 to 0b2bfc6 Compare January 30, 2025 16:41
@amnn amnn temporarily deployed to sui-typescript-aws-kms-test-env January 30, 2025 16:41 — with GitHub Actions Inactive
@amnn amnn temporarily deployed to sui-typescript-aws-kms-test-env January 31, 2025 14:35 — with GitHub Actions Inactive
@amnn amnn temporarily deployed to sui-typescript-aws-kms-test-env January 31, 2025 15:45 — with GitHub Actions Inactive
TX: ExpressionMethods + Expression<SqlType = BigInt>,
TX::IsAggregate: MixedAggregates<Never, Output = No>,
{
query = query.filter(tx_sequence_number.ge(sql::<BigInt>(&format!(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will want to write some tests for this, I considered doing that using the E2E test runner, but that's probably too big a lift, so I'll likely port over Xun's test environment code (that's to come).

@amnn amnn mentioned this pull request Jan 31, 2025
7 tasks
amnn added 8 commits February 4, 2025 15:23
## Descriptioon

Filter transactions based on the functions they call.

## Test plan

New E2E tests:

```
sui$ cargo nextest run -p sui-indexer-alt-e2e-tests -- transactions/query
```
## Description

I needed to add a checkpoint data loader, so I also added the JSON-RPC
endpoint as a way to test the loader.

## Test plan

```
sui$ cargo nextest run -p sui-indexer-alt-e2e-tests -- checkpoints
```
## Description

Filter down to transactions from a particular checkpoint by loading
their digests from that checkpoint.

## Test plan

New E2E tests:

```
sui$ cargo nextest run -p sui-indexer-alt-e2e-tests \
  -- transactions/query/by_checkpoint
```
## Description

Filter transactions based on their relationships with addresses (senders
and recipients).

This completes support for transaction block querying.

## Test plan

```
sui$ cargo nextest run -p sui-indexer-alt-e2e-tests \
  -- transactions/query/by_address
```
## Description

Pull out the common parts of fetching a page of transaction digests into
a helper function, and use that in all the filter implementations.

## Test plan

Use existing tests to confirm behaviour is the same:

```
sui$ cargo nextest run -p sui-indexer-alt-e2e-tests \
  -- transactions/query
```
## Description

Refactor how `queryTransactionBlocks` works so that filters that rely on
`tx_*` tables (which produce sequence numbers) don't join against
`tx_digests`, but instead produce sequence numbers directly. These are
later converted into digests using a data loader.

This change was motivated by profiling the previous pattern (joining
against `tx_digests`) on our production tables and noticing that this
would often choose poor query plans.

## Test plan

```
sui$ cargo nextest run -p sui-indexer-alt-e2e-tests
```
## Description
Based on an observation from @wlmyng, query efficiency improves when you
explicit bound the query by the reader low-watermark, because it allows
the database to avoid scanning a number of dead tuples it hasn't cleaned
up since pruning.

## Test plan
Existing E2E tests, and local testing with our mainnet DB.
amnn added 2 commits February 4, 2025 15:23
## Description
When using `response::transaction` to convert a stored transaction into
a `SuiTransactionBlockResponse`, as part of `queryTransactionBlocks`, we
also need to detect a `NotFound` error, (usually a user error), and
translate that into an internal error, because we shouldn't be able to
query a transaction block that we can't get the contents for.

## Test plan
Tested against our production database which doesn't include
`kv_transactions` (so does trigger this internal error).
## Description

When applying a lowerbound to transaction queries, we need to take the
max lowerbound between the filter table and `tx_digests`.

## Test plan

Run a pruned indexer locally and confirm that it doesn't produce an
error when fetching the first unpruned page of transactions for any
given query.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants