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

[light-client] Fix light client rpc #19028

Merged
merged 8 commits into from
Sep 11, 2024
Merged

[light-client] Fix light client rpc #19028

merged 8 commits into from
Sep 11, 2024

Conversation

gdanezis
Copy link
Collaborator

Description

Modernise the RPC used in the light client:

  • Use GraphQL to get the end-of-epoch checkpoint.
  • Use the supported Rust SDK to get objects and other info.
  • Use a generic object store, by default provided by Mysten, for the full checkpoint data.
  • Add a cache to package loader since we observed the same package downloaded multiple times.

Test plan

Existing unit tests, and manual CLI invocations.

Copy link

vercel bot commented Aug 19, 2024

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

crates/sui-light-client/src/proof.rs Show resolved Hide resolved
crates/sui-light-client/src/proof.rs Outdated Show resolved Hide resolved
crates/sui-light-client/src/proof.rs Outdated Show resolved Hide resolved
crates/sui-light-client/src/proof.rs Outdated Show resolved Hide resolved
crates/sui-light-client/src/proof.rs Outdated Show resolved Hide resolved
crates/sui-light-client/src/proof.rs Outdated Show resolved Hide resolved
crates/sui-light-client/src/proof.rs Outdated Show resolved Hide resolved
crates/sui-light-client/src/proof.rs Outdated Show resolved Hide resolved
crates/sui-light-client/src/main.rs Outdated Show resolved Hide resolved

// Parse the JSON response to get the last checkpoint of the epoch
let v: Value = serde_json::from_str(resp.as_str()).expect("Incorrect JSON response");
let checkpoint_number = v["data"]["epoch"]["checkpoints"]["nodes"][0]["sequenceNumber"]
Copy link
Contributor

Choose a reason for hiding this comment

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

This may be a bit panick-y if one of these fields does not exist for some reason (like if the epoch was pruned). This is fine if we're intending this to be an example application, but if not, in some places we use cynic as a library to provide type-safe GraphQL queries in Rust -- where you will then be compelled to introduce Option<...> in the appropriate places where data might not exist, and check for it.

See this tool, for example, to fetch all packages:

https://github.com/MystenLabs/sui/blob/main/crates/sui-package-dump/src/query.rs

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the great feedback, will look at cynic indeed.

Copy link
Contributor

@stefan-mysten stefan-mysten Aug 21, 2024

Choose a reason for hiding this comment

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

@joyqvq
Copy link
Contributor

joyqvq commented Aug 30, 2024

can we add #[derive(Debug, Serialize, Deserialize)] to struct Proof and TransactionProof ? useful for external caller.

@gdanezis gdanezis merged commit bb93869 into main Sep 11, 2024
49 checks passed
@gdanezis gdanezis deleted the fix-light-client-rpc branch September 11, 2024 11:07
suiwombat pushed a commit that referenced this pull request Sep 16, 2024
## Description 

Modernise the RPC used in the light client:
- Use GraphQL to get the end-of-epoch checkpoint.
- Use the supported Rust SDK to get objects and other info.
- Use a generic object store, by default provided by Mysten, for the
full checkpoint data.
- Add a cache to package loader since we observed the same package
downloaded multiple times.

## Test plan 

Existing unit tests, and manual CLI invocations.
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.

5 participants