sui icon indicating copy to clipboard operation
sui copied to clipboard

[GraphQL] Leverage `objects_version` table.

Open amnn opened this issue 1 year ago • 1 comments

Description

Use the objects_version table to speed up point look-ups (via data loaders) for historical objects (ID + version), and dynamic fields (object look-up bounding version by parent ID).

With this change, the restriction of accessing dynamic fields only within the available range is dropped.

Test plan

sui$ cargo nextest run -p sui-graphql-rpc
sui$ cargo nextest run -p sui-graphql-e2e-tests --features pg_integration.

Perform a query that involves fetching a large number of dynamic fields, which should now be fast. The following example, fetching dynamic fields on a deepbook pool loads 50 dynamic fields in about 5s from cold (which also requires loading packages for resolution), and then 2s from there:

query {
  owner(
    address: "0x029170bfa0a1677054263424fe4f9960c7cf05d359f6241333994c8830772bdb"
  ) {
    dynamicFields {
      pageInfo {
        hasNextPage
        endCursor
      }
      nodes {
        name {
          type {
            repr
          }
          json
        }
        value {
          ... on MoveValue {
            type {
              repr
            }
            json
          }
          ... on MoveObject {
            contents {
              json
              type {
                repr
              }
            }
          }
        }
      }
    }
  }
}

Stack

  • #17686
  • #17687
  • #17688
  • #17689
  • #17691
  • #17694
  • #17695
  • #17542
  • #17726

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):
  • [ ] Indexer:
  • [ ] JSON-RPC:
  • [x] GraphQL: Dynamic fields can now be looked up on any historical object (not just objects in the available range).
  • [ ] CLI:
  • [ ] Rust SDK:

amnn avatar May 07 '24 13:05 amnn

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 Aug 20, 2024 0:24am
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Aug 20, 2024 0:24am
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Aug 20, 2024 0:24am
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Aug 20, 2024 0:24am

vercel[bot] avatar May 07 '24 13:05 vercel[bot]

⚠️ 🦋 Changesets Warning: This PR has changes to public npm packages, but does not contain a changeset. You can create a changeset easily by running pnpm changeset in the root of the Sui repo, and following the prompts. If your change does not need a changeset (e.g. a documentation-only change), you can ignore this message. This warning will be removed when a changeset is added to this pull request.

Learn more about Changesets.

github-actions[bot] avatar Aug 19 '24 10:08 github-actions[bot]

Thanks for the review @ronny-mysten ! I'll put up a separate PR to address these because this PR is now a stack, being prepared to land as-is.

amnn avatar Aug 20 '24 12:08 amnn

PR with docs fixes: https://github.com/MystenLabs/sui/pull/19046

amnn avatar Aug 20 '24 12:08 amnn

Thanks for the review. I'll put up a separate PR to address these because this PR is now a stack, being prepared to land as-is.

Oops. Apologies. I'll start separate PRs after merge instead going forward.

ronny-mysten avatar Aug 20 '24 14:08 ronny-mysten

Oops. Apologies. I'll start separate PRs after merge instead going forward.

@ronny-mysten, no you're all good! This was a special case because I was landing all the other PRs in the stack into this one so I could then land them all together (it's faster to do it this way -- need to wait for fewer CI runs on the critical path).

I think it's fine to leave the feedback on this PR, I just wanted to explain that I was going to address it in a separate PR, so it wasn't confusing when I resolved the conversation but then landed this PR without you seeing the comments addressed here.

amnn avatar Aug 20 '24 18:08 amnn