-
Notifications
You must be signed in to change notification settings - Fork 529
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
Add support for querying protocol state by state hash or height #15893
Add support for querying protocol state by state hash or height #15893
Conversation
…hash or height The `protocolState` GraphQL query has been updated to allow users to retrieve the protocol state for a specific block by providing either the state hash or the height of the desired block. This enhances the flexibility and usability of the API. Changes include: - Added `stateHash` argument to specify the state hash of the desired block - Added `height` argument to specify the height of the desired block in the best chain - Updated the resolver to handle the new arguments and retrieve the protocol state based on the provided state hash or height - If neither state hash nor height is provided, the protocol state of the current best tip is returned (previous behavior) - Improved error handling and validation to ensure that exactly one of state hash or height is provided - Updated documentation to reflect the new functionality This feature allows users to query historical protocol states and retrieve information about specific blocks, enabling more granular analysis and exploration of the Mina protocol's history.
The protocolState query now accepts two new optional arguments: - height: to specify the height of the desired block in the best chain - stateHash: to specify the state hash of the desired block This allows querying the protocol state for a specific block, instead of only the current state. The description of the query was updated to reflect this change.
!ci-build-me |
pr looks good, i will run the container once it builds in CI to just manually check if this is backwards compatible with the old api. For the most part i think it is because of the way you are handling optional arguments, but testing will just seal the deal. |
okay the end point seems to be backwards compatible
|
src/lib/mina_graphql/mina_graphql.ml
Outdated
~resolve:(fun { ctx = mina; _ } () state_hash_base58_opt height_opt | ||
encoding_opt -> | ||
let open Deferred.Result.Let_syntax in | ||
let%bind breadcrumb = |
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.
let%bind breadcrumb = | |
let%map breadcrumb = |
NIT, but this would allow to remove Deferred.Result.return
below and make the whole code a bit less multilayered.
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.
done! 882f94e
The protocol state encoding logic has been simplified: - Instead of using Deferred.Result.return to wrap the encoding result, the encoding is now performed directly in the match expression. - The match expression now directly returns the encoded protocol state string based on the selected encoding option. This refactoring improves code readability and eliminates the need for an extra Deferred.Result layer, as the encoding operation itself does not involve any asynchronous or fallible computations.
!ci-build-me |
Context
This pull request enhances the
protocolState
GraphQL query to allow users to retrieve the protocol state for a specific block by providing either the state hash or the height of the desired block. This improvement increases the flexibility and usability of the API, enabling more granular analysis and exploration of the Mina protocol's history. This was a specific ask from Lambda for their Mina -> ETH bridge work.Description
The changes include:
stateHash
andheight
arguments to theprotocolState
queryChanges made
src/lib/mina_graphql/mina_graphql.ml
:stateHash
andheight
arguments to theprotocolState
querygraphql_schema.json
:height
andstateHash
arguments to theprotocolState
query schema