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

Add chainHead RPC methods #766

Merged
merged 8 commits into from
Jan 19, 2023
Merged

Add chainHead RPC methods #766

merged 8 commits into from
Jan 19, 2023

Conversation

lexnv
Copy link
Collaborator

@lexnv lexnv commented Jan 10, 2023

This PR adds support for the low level chainHead interface exposed by the substrate nodes.

The chianHead family of functions is added to subxt's RPC methods, together with the corresponding events required for interpreting the data of the RPC methods.

This PR takes the essential parts of #762 PR to aim towards a mergeable form.

Part of #732.

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
subxt/src/rpc/rpc.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@jsdw jsdw left a comment

Choose a reason for hiding this comment

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

This looks great to me offhand!

One thing I'd suggest I think is to add a few integration tests to call these methods and ensure that they actually work: given that they may be around a while until we are fully using them, it'd be good to ensure that they keep working incase anything changes in the (unstable) API in the meantime :)

Co-authored-by: James Wilson <james@jsdw.me>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Copy link
Collaborator

@jsdw jsdw left a comment

Choose a reason for hiding this comment

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

Love the tests too; great work!

subxt/src/rpc/rpc.rs Outdated Show resolved Hide resolved
/// When the user is no longer interested in a block, the user is responsible
/// for calling the [`chainhead_unstable_unpin`](Rpc::chainhead_unstable_unpin) method on each.
/// Failure to do so will result in the subscription being dropped by the chain.
pub async fn chainhead_unstable_follow(
Copy link
Member

Choose a reason for hiding this comment

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

could be nice to have a separate module or something for the v2 impls but perhaps _unstable is sufficient

Copy link
Collaborator

Choose a reason for hiding this comment

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

In the longer run, hopefully we will be able to remove all of the "old" methods and only have these new ones on this Rpc type :)

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
@lexnv lexnv merged commit 0750ccd into master Jan 19, 2023
@lexnv lexnv deleted the lexnv/rpc_chainhead branch January 19, 2023 11:53
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.

3 participants