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

[gql] Watermark task reads from watermarks table, use watermarks for Event::paginate #21176

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

Conversation

wlmyng
Copy link
Contributor

@wlmyng wlmyng commented Feb 11, 2025

Description

Watermark task now reads from watermarks table instead of checkpoints table. This is used for Event::paginate, so we can correctly bound the available range of data

Test plan

Pointed local graphql to current mainnet db. Ran the query below:

query Event {
  events(filter:{eventType:"0x3::validator::StakingRequestEvent"})
  {
    pageInfo {
      hasNextPage
      endCursor
    }
    nodes {
      sendingModule {
        name
        package {
          address
        }
      }
      sender {
        address
      }
      contents {
        json
      }
      
      timestamp
    }
  }
}

Received expected page of results instead of erroneous result,

{
  "data": {
    "events": {
      "pageInfo": {
        "hasNextPage": true,
        "endCursor": null
      },
      "nodes": []
    }
  }
}

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:

… table. This is used for Event::paginate, so we can correctly bound the available range of data
Copy link

vercel bot commented Feb 11, 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 11, 2025 8:54pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Feb 11, 2025 8:54pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Feb 11, 2025 8:54pm

…x for the lowest checkpoint. updated to pass test_health_check
Copy link
Contributor

@amnn amnn left a comment

Choose a reason for hiding this comment

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

The main body of this change looks good, but I think there's a subtle issue with the change to Event::paginate when a cursor supplies its own consistency cursor -- PTAL!

@@ -134,10 +134,18 @@ impl Event {
db: &Db,
page: Page<Cursor>,
filter: EventFilter,
checkpoint_viewed_at: u64,
watermark: &Watermark,
Copy link
Contributor

Choose a reason for hiding this comment

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

In general checkpoint_viewed_at and Watermark are not always interchangeable (you get into issues if this function is used to handle a paginated query that is nested in some other paginated query).

Today, I don't think we use this function for that, (I can see from this PR that you only needed to update a top-level field on Query), but we generally expect functions called paginate to work like that.

Given there's only one call-site, could we shift the boundary slightly here so that we accept both a checkpoint_viewed_at and a tx_lo, and then go on from there?

let (prev, next, results) = db
.execute(move |conn| async move {
let tx_hi: i64 = conn.first(move || {
Copy link
Contributor

Choose a reason for hiding this comment

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

This change behaves differently if there is a cursor_viewed_at, right?

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