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

Prep for 0.36.0 release #1587

Merged
merged 4 commits into from
May 16, 2024
Merged

Prep for 0.36.0 release #1587

merged 4 commits into from
May 16, 2024

Conversation

jsdw
Copy link
Collaborator

@jsdw jsdw commented May 16, 2024

[0.36.0] - 2024-05-16

This release adds a few new features, which I'll go over below in more detail.

subxt-core

We now have a brand new subxt-core crate, which is #[no-std] compatible, and contains a lot of the core logic that is needed in Subxt. Using this crate, you can do things in a no-std environment like:

  • blocks: decode and explore block bodies.
  • constants: access and validate the constant addresses in some metadata.
  • custom_values: access and validate the custom value addresses in some metadata.
  • metadata: decode bytes into the metadata used throughout this library.
  • storage: construct storage request payloads and decode the results you'd get back.
  • tx: construct and sign transactions (extrinsics).
  • runtime_api: construct runtime API request payloads and decode the results you'd get back.
  • events: decode and explore events.

Check out the docs for more, including examples of each case.

A breaking change that comes from migrating a bunch of logic to this new crate is that the ExtrinsicParams trait is now handed &ClientState<T> rather than a Client. ClientState is just a concrete struct containing the state that one needs for things like signed extensions.

Support for reconnecting

We've baked in a bunch of support for automatically reconnecting after a connection loss into Subxt. This comes in three parts:

  1. An RPC client that is capable of reconnecting. This is gated behind the unstable-reconnecting-rpc-client feature flag at the moment, and
  2. Handling in the subxt Backends such that when the RPC client notifies it that it is reconnecting, the backend will transparently handle this behind the scenes, or else pass on a DisconnectedWillReconnect error to the user where it cannot. Note that the individual LegacyRpcMethods and UnstableRpcMethods are not automatically retried on reconnection. Which leads us to..
  3. A couple of util helpers (subxt::backend::retry and subxt::backend::retry_stream) which can be used in conjunction with a reconnecting RPC client to make it easy to automatically retry RPC method calls where needed.

We'd love feedback on this reconnecting work! To try it out, enable the unstable-reconnecting-rpc-client feature flag and then you can make use of this like so:

use std::time::Duration;
use futures::StreamExt;
use subxt::backend::rpc::reconnecting_rpc_client::{Client, ExponentialBackoff};
use subxt::{OnlineClient, PolkadotConfig};

// Generate an interface that we can use from the node's metadata.
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
pub mod polkadot {}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a new client with with a reconnecting RPC client.
    let rpc = Client::builder()
        // We can configure the retry policy; here to an exponential backoff.
        // This API accepts an iterator of retry delays, and here we use `take`
        // to limit the number of retries.
        .retry_policy(
            ExponentialBackoff::from_millis(100)
                .max_delay(Duration::from_secs(10))
                .take(3),
        )
        .build("ws://localhost:9944".to_string())
        .await?;

    // Use this reconnecting client when instantiating a Subxt client:
    let api: OnlineClient<PolkadotConfig> = OnlineClient::from_rpc_client(rpc.clone()).await?;

Check out the full example here.

Better Ethereum support

We've added built-in support for Ethereum style chains (eg Frontier and Moonbeam) in subxt-signer, making it easier to sign transactions for these chains now.

Check out a full example here.

We plan to improve on this in the future, baking in better Ethereum support if possible so that it's as seamless to use AccountId20 as it is AccountId32.

Stabilizing the new V2 RPCs (#1540, #1539, #1538)

A bunch of the new RPCs are now stable in the spec, and have consequently been stabilized here, bringing the unstable-backend a step closer to being stabilized itself! We'll probably first remove the feature flag and next make it the default backend, in upcoming releases.

All of the notable changes in this release are as follows:

Added

  • Add frontier/ethereum example (#1557)
  • Rpc: add full support reconnecting rpc client (#1505)
  • Signer: ethereum implementation (#1501)
  • subxt-core crate (#1466)

Changed

  • Bump scale-decode and related deps to latest (#1583)
  • Update Artifacts (auto-generated) (#1577)
  • Update deps to use scale-type-resolver 0.2 (#1565)
  • Stabilize transactionBroadcast methods (#1540)
  • Stabilize transactionWatch methods (#1539)
  • Stabilize chainHead methods (#1538)
  • Rename traits to remove T suffix (#1535)
  • Add Debug/Clone/etc for common Configs for convenience (#1542)
  • Unstable_rpc: Add transactionBroadcast and transactionStop (#1497)

Fixed

  • metadata: Fix cargo clippy (#1574)
  • Fixed import in subxt-signer::eth (#1553)
  • chore: fix typos and link broken (#1541)
  • Make subxt-core ready for publishing (#1508)
  • Remove dupe storage item if we get one back, to be compatible with Smoldot + legacy RPCs (#1534)
  • fix: substrate runner libp2p port (#1533)
  • Swap BinaryHeap for Vec to avoid Ord constraint issue (#1523)
  • storage_type: Strip key proper hash and entry bytes (32 instead of 16) (#1522)
  • testing: Prepare light client testing with substrate binary and add subxt-test macro (#1507)

@jsdw jsdw requested a review from a team as a code owner May 16, 2024 11:51
CHANGELOG.md Outdated Show resolved Hide resolved
@jsdw jsdw merged commit 8c6452e into master May 16, 2024
13 checks passed
@jsdw jsdw deleted the release-v0.36.0 branch May 16, 2024 15:37
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