Releases: paritytech/subxt
v0.39.0
[0.39.0] - 2025-02-04
This release is mostly bug fixes and changes. The only change that should be a breaking change is removing the substrate-compat
feature flag (see #1850), which we'll go into more detail about.
The substrate-compat
feature flag has been removed.
The substrate-compat
feature flag essentially provided:
- An implementation of the
subxt::config::Header
trait for anything implementingsp_runtime::traits::Header
(here). - Same for
subxt::config::Hasher
and anything implementingsp_runtime::traits::Hasher
(here). - A
subxt_core::tx::PairSigner
type which could be given something implementingsp_core::Pair
and then be used to sign transactions (here). - From impls for
sp_runtime::AccountId32
and related forsubxt::utils::AccountId32
(here). - Likewise for
sp_runtime::MultiAddress
andsubxt::utils::MultiAddress
(here). - Likewise for
sp_runtime::MultiSignature
andsubxt::utils::MultiSignature
(here).
While useful, providing these features in Subxt is almost impossible to maintain: we can only support a single version of sp_runtime
/sp_core
at a time, but many versions are in use in the wild. This led to various issues regarding the mismatch between sp_*
crates in use and a given version of Subxt. More generally, the goal of Subxt is to be independent from any specific version of Substrate, and communicate via the exposed RPC APIs in order to work across any compatible Substrate version (or indeed, alternative implementations that follow things like the RPC spec).
As a result, we've taken the decision to remove this compatibility layer from Subxt itself. To migrate away from this feature, we suggest:
- Using the example here to see how to use a Substrate signer to sign Subxt transactions.
- Looking at
subxt_signer
instead, if it's a viable alternative in your case. - Following the "here" links above to see what impls were removed. Impls can generally be recreated as needed using wrapper types which allow converting between Substrate and Subxt types/traits, for instance:
// Wrap a substrate header type in this to impl the subxt Header trait:
struct SubxtHeader<T>(pub T);
// This basically copies the code removed from Subxt, but on a wrapper type:
impl <T> subxt::config::Header for SubxtHeader<T>
where
T: sp_runtime::traits::Header,
<T as sp_runtime::traits::Header>::Number: Into<u64>,
{
type Number = T::Number;
type Hasher = T::Hashing;
fn number(&self) -> Self::Number {
*self.0.number()
}
}
The hope is that this pattern is applicable to any such types that you find useful to share between Substrate and Subxt code. Please raise an issue if you can't find a solution in your case, and we'll endeavour to help!
The result of this is that your code will work against whichever Substrate crate versions you are using, at the cost of this code no longer being included behind the substrate-compat
feature flag.
A full list of relevant changes and fixes (nothing was added in this release) is as follows:
Changed
- remove substrate compat (#1850)
- migrate custom error trait impls to
thiserror
(#1856) - re-export
jsonrpsee
insubxt::ext
(#1843)
Fixed
- don't double hash: use the same hash in ExtrinsicDetails and ExtrinsicDetails (#1917)
- fix and test sr25519 signing in nostd (#1872)
- preserve custom metadata when converting between Subxt metadata and frame_metadata (#1914)
- fix: don't wrap rpc error in DisconnectedWillReconnect in reconnecting rpc client (#1904)
- fix: substrate runner, support new libp2p addr log (#1892)
- update Artifacts (auto-generated) (#1874)
- bump frame-decode and frame-metadata to latest (#1870)
- fix unstable-light-client + ChainHeadBackend tx events (#1865)
- when native feature is enabled, we need polkadot-sdk/std for eg examples to work (#1864)
- load latest metadata version from Wasm blobs. (#1859)
- minor fix - Yew example (#1852)
- update the release notes to work for current releases (#1842)
v0.38.1
[0.38.1] - 2025-01-24
This is a bug-fix release that fixes a bug in the reconnecting-rpc-client
where the error was wrapped in the wrong error variant
which kept retry logic to keep retrying the same error indefinitely.
Fixed
- don't wrap rpc error in DisconnectedWillReconnect in reconnecting rpc client (#1904)
Full Changelog: v0.38.0...v0.38.1
v0.38.0
[0.38.0] - 2024-10-24
This release doesn't introduce any substantial breaking changes and focuses primarily on incremental improvements, testing and bug fixes. A few of the highlights include:
- #1785: Support decoding V5 extrinsics in blocks (currently Subxt will still submit V4 extrinsics). This also unifies our extrinsic decoding logic into one place.
- #1802: Stabilizing the
subxt::backend::unstable::UnstableBackend
(it's now calledsubxt::backend::chain_head::ChainHeadBackend
). This backend can be used to interact with the modernchainHead
RPC methods exposed by Smoldot and compliant RPC nodes. See this example. - #1803: Stabilizing the
reconnecting-rpc-client
. See this example. - #1720: A nice little QoL improvement if you have the raw runtime WASM and would like to generate an interface directly from that (ie with
#[subx(runtime_path = "path/to/runtime.wasm")]
). - #1661: Support loading keys directly from the PolkadotJS JSON to be used in Subxt.
- #1638: Improve support for Eth style chains by defining a 20-byte account ID type directly in
subxt-core
. See this example.
The notable changes in this release are as follows:
Added
- add reconnecting tests for unstable_backend (#1765)
- add support for generating metadata from runtime wasm files (#1720)
- support loading keys from Polkadot-JS accounts (#1661)
- allow tx payloads to be boxed (#1690)
- add hash method to ExtrinsicDetails (#1676)
- expose
secret_key
method forecdsa::Keypair
andeth::Keypair
(#1628) - add 20-byte account id to subxt_core (#1638)
Changed
- make it clearer which extrinsic failed to decode (#1835)
- chore(deps): bump frame-metadata from 16 to 17 (#1836)
- chore(deps): bump
scale family crates
,primitive-types
andimpl-serde
(#1832) - chore(deps): replace
instant
withweb-time
(#1830) - deps: use polkadot-sdk umbrella crate (#1786)
- stabilize reconnecting-rpc-client (#1803)
- stabilize chainhead backend (#1802)
- derive serialize on more types (#1797)
- use frame-decode for core extrinsic decode logic (including v5 support) (#1785)
- reconn-rpc-client: parse URL before connecting (#1789)
- update proc_macro_error to proc_macro_error2 (#1767)
- chore(deps): update Smoldot to the latest version (#1400)
- remove unneeded
?Sized
bound and replace never type with()
(#1758) - improve test coverage for legacy
Backend
impl (#1751) - add integration tests for
unstable-reconnecting-rpc-client
(#1711) - replace
reconnecting-jsonrpsee-ws-client
withsubxt-reconnecting-rpc-client
(#1705) - allow PartialExtrinsic to be held across await points (#1658)
- chore(deps): bump jsonrpsee from 0.22.5 to 0.23.1 (#1656)
Fixed
- fix stripping metadata in the case where enums like RuntimeCall are handed back (#1774)
- fix:
defalt-feature
->default-features
Cargo.toml (#1828) - avoid hang by notifying subscribers when the backend is closed (#1817)
- fix: error message on rpc errors (#1804)
- docs: fix typos (#1776)
- examples: fix reconnecting logging target (#1733)
- docs: fix spelling issues (#1699)
- chore: fix some comments (#1697)
- codegen: Fix decode error by adding
#[codec(dumb_trait_bound)]
(#1630)
v0.37.1
v0.37.0
[0.37.0] - 2024-05-28
This release mainly adds support for the sign extension CheckMetadataHash
and fixes a regression introduced in v0.36.0
where the type de-duplication was too aggressive and lots of the same type such as BoundedVec
was duplicated to
plenty of different types such as BoundedVec1, BoundedVec2, .. BoundedVec.
Added
- Implemented
sign_prehashed
forecdsa::Keypair
andeth::Keypair
(#1598) - Add a basic version of the CheckMetadataHash signed extension (#1590)
Changed
Full Changelog: v0.36.0...v0.37.0
v0.36.1
v0.36.0
[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:
- An RPC client that is capable of reconnecting. This is gated behind the
unstable-reconnecting-rpc-client
feature flag at the moment, and - 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 individualLegacyRpcMethods
andUnstableRpcMethods
are not automatically retried on reconnection. Which leads us to.. - A couple of util helpers (
subxt::backend::retry
andsubxt::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)
v0.35.3
[0.35.3] - 2024-04-11
Another bug-fix release that substitutes BinaryHeap
for Vec
in the same way that we do for BTreeMap/Set to avoid issues with the Ord constraint on the generic type (because this may be a generated type, and we don't automatically apply Ord to generated types).