-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Skipped Deployments
|
e90bf87
to
61e3489
Compare
a95c6fe
to
07c910c
Compare
61e3489
to
806bc7f
Compare
|
||
// 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"] |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to also peek here: https://github.com/MystenLabs/sui-rust-sdk/tree/stefan/graphql_client_cynic/crates/sui-graphql-client
Docs on custom queries with cynic:
https://github.com/MystenLabs/sui-rust-sdk/tree/stefan/graphql_client_cynic/crates/sui-graphql-client#custom-queries
can we add |
531a402
to
d727fab
Compare
060dd04
to
4b9d020
Compare
4b9d020
to
c2c78d8
Compare
## 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.
Description
Modernise the RPC used in the light client:
Test plan
Existing unit tests, and manual CLI invocations.