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

shim: refactor the sugondat rpc client #76

Merged
merged 1 commit into from
Nov 30, 2023
Merged

shim: refactor the sugondat rpc client #76

merged 1 commit into from
Nov 30, 2023

Conversation

pepyakin
Copy link
Contributor

@pepyakin pepyakin commented Nov 30, 2023

shim: refactor the sugondat rpc client

This changeset makes a couple of fixes and changes:

  1. Now the client strives to provide a peristent connection. See persistent connection #68.
  2. Fix the greedy polling (See shim/sovereign: remove greedy polling #37). Now, only a single task polls for the
    finalized header.
  3. Extracts the timestamp from the extrinsics instead of getting it from the storage.
  4. Also sprinkles more documentation, clarifies some assumptions.
  5. Now checks whether the subxt codegen matches the runtime metadata. If not, then
    we assume that the node is still useable, but still warn the user.
  6. If the RPC node is not available, instead of bailing out, we
    keep reconnecting. I imagine this should be useful in cases where we spin up
    a local network and the shim started up before the sugondat node (plausible IMO).

Closes #68
Closes #56
Closes #37

There is a follow-up in #77 that performs extraction of mod conn { } into a separate file.

Copy link
Contributor Author

pepyakin commented Nov 30, 2023

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

This changeset makes a couple of fixes and changes:

1. Now the client strives to provide a peristent connection. See #68.
1. Fix the greedy polling (See #37). Now, only a single task polls for the
finalized header.
1. Extracts the timestamp from the extrinsics instead of getting it from the storage.
1. Also sprinkles more documentation, clarifies some assumptions.
1. Now checks whether the subxt codegen matches the runtime metadata. If not, then
we assume that the node is still useable, but still warn the user.
1. If the RPC node is not available, instead of bailing out, we
keep reconnecting. I imagine this should be useful in cases where we spin up
a local network and the shim started up before the sugondat node (plausible IMO).

Closes #68
Closes #56
Closes #37
let subxt = sugondat_subxt::Client::from_rpc_client(raw.clone()).await?;
check_if_compatible(&subxt)?;
if !is_codegen_valid_for(&subxt.metadata()) {
const WARN_WRONG_VERSION: &str = "connected to a sugondat node with a newer runtime than the one this shim was compiled against. Update the shim lest you run into problems. https://github.com/thrumdev/sugondat";
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 excessive if we ever commit to a stable interface.

@rphmeier rphmeier merged commit 5c17e86 into main Nov 30, 2023
@rphmeier rphmeier deleted the pep-get-block-fix branch November 30, 2023 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants