Skip to content

Commit 9810406

Browse files
jsdwniklasad1
andauthored
Prep to release 0.35 (#1489)
* Prep to release 0.35 * Remove newline Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> * Fix a couple of small nits --------- Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
1 parent 852dab6 commit 9810406

File tree

9 files changed

+155
-43
lines changed

9 files changed

+155
-43
lines changed

CHANGELOG.md

Lines changed: 111 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,115 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.35.0] - 2024-03-21
8+
9+
This release contains several fixes, adds `no_std` support to a couple of crates (`subxt-signer` and `subxt-metadata`) and introduces a few quality of life improvements, which I'll quickly cover:
10+
11+
### Reworked light client ([#1475](https://github.com/paritytech/subxt/pull/1475))
12+
13+
This PR reworks the light client interface. The "basic" usage of connecting to a parachain now looks like this:
14+
15+
```rust
16+
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
17+
pub mod polkadot {}
18+
19+
use subxt::lightclient::LightClient;
20+
21+
// Instantiate a light client with the Polkadot relay chain given its chain spec.
22+
let (lightclient, polkadot_rpc) = LightClient::relay_chain(POLKADOT_SPEC)?;
23+
// Connect the light client to some parachain by giving a chain spec for it.
24+
let asset_hub_rpc = lightclient.parachain(ASSET_HUB_SPEC)?;
25+
26+
// Now, we can create Subxt clients from these Smoldot backed RPC clients:
27+
let polkadot_api = OnlineClient::<PolkadotConfig>::from_rpc_client(polkadot_rpc).await?;
28+
let asset_hub_api = OnlineClient::<PolkadotConfig>::from_rpc_client(asset_hub_rpc).await?;
29+
```
30+
31+
This interface mirrors the requirement that we must connect to a relay chain before we can connect to a parachain. It also moves the light client specific logic into an `RpcClientT` implementation, rather than exposing it as a `subxt::client::LightClient`.
32+
33+
### Typed Storage Keys ([#1419](https://github.com/paritytech/subxt/pull/1419))
34+
35+
This PR changes the storage interface so that, where possible, we now also decode the storage keys as well as the values when iterating over storage entries:
36+
37+
```rust
38+
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
39+
pub mod polkadot {}
40+
41+
// Create a new API client, configured to talk to Polkadot nodes.
42+
let api = OnlineClient::<PolkadotConfig>::new().await?;
43+
44+
// Build a storage query to iterate over account information.
45+
let storage_query = polkadot::storage().system().account_iter();
46+
47+
// Get back an iterator of results (here, we are fetching 10 items at
48+
// a time from the node, but we always iterate over one at a time).
49+
let mut results = api.storage().at_latest().await?.iter(storage_query).await?;
50+
51+
while let Some(Ok(kv)) = results.next().await {
52+
// We used to get a tuple of key bytes + value. Now we get back a
53+
// `kv` struct containing the bytes and value as well as the actual
54+
// decoded keys:
55+
println!("Decoded key(s): {:?}", kv.keys);
56+
println!("Key bytes: 0x{}", hex::encode(&kv.key_bytes));
57+
println!("Value: {:?}", kv.value);
58+
}
59+
```
60+
61+
When using the static interface, keys come back as a tuple of values corresponding to the different hashers used in constructing the key. When using a dynamic interface, keys will be encoded/decoded from the type given so long as it implements `subxt::storage::StorageKey`, eg `Vec<scale_value::Value>`.
62+
63+
### Extrinsic Params Refinement ([#1439](https://github.com/paritytech/subxt/pull/1439))
64+
65+
Prior to this PR, one could configure extrinsic signed extensions by providing some params like so:
66+
67+
```rust
68+
// Configure the transaction parameters; we give a small tip and set the
69+
// transaction to live for 32 blocks from the `latest_block` above:
70+
let tx_params = Params::new()
71+
.tip(1_000)
72+
.mortal(latest_block.header(), 32)
73+
.build();
74+
75+
let hash = api.tx().sign_and_submit(&tx, &from, tx_params).await?;
76+
```
77+
78+
If you want to customize the account nonce, you'd use a different call like `create_signed_with_nonce` instead.
79+
80+
One of the downsides of the above approach is that, if you don't provide any explicit params, transactions will be immortal by default (because the signed extensions didn't have the information to do any better).
81+
82+
Now, with the help of a `RefineParams` trait, transactions will default to being mortal and living for 32 blocks unless an explicit mortality is provided as above.
83+
84+
One notable change is that the offline-only `create_signed_with_nonce` and `create_partial_signed_with_nonce` functions have lost the `_with_nonce` suffix. Since we can't discover nonce/mortality settings offline, you should now provide `Params` and set an explicit nonce (and mortality, if you like) when using these calls, otherwise the nonce will be set to 0 and the mortality to `Immortal`.
85+
86+
For a full list of changes, please see the following:
87+
88+
### Added
89+
90+
- Reworked light client ([#1475](https://github.com/paritytech/subxt/pull/1475))
91+
- `no_std` compatibility for `subxt-signer` ([#1477](https://github.com/paritytech/subxt/pull/1477))
92+
- Typed Storage Keys ([#1419](https://github.com/paritytech/subxt/pull/1419))
93+
- Extrinsic Params Refinement ([#1439](https://github.com/paritytech/subxt/pull/1439))
94+
- Make storage_page_size for the LegacyBackend configurable ([#1458](https://github.com/paritytech/subxt/pull/1458))
95+
- `no_std` compatibility for `subxt-metadata` ([#1401](https://github.com/paritytech/subxt/pull/1401))
96+
- Experimental `reconnecting-rpc-client` ([#1396](https://github.com/paritytech/subxt/pull/1396))
97+
98+
### Changed
99+
100+
- `scale-type-resolver` integration ([#1460](https://github.com/paritytech/subxt/pull/1460))
101+
- subxt: Derive `std::cmp` traits for subxt payloads and addresses ([#1429](https://github.com/paritytech/subxt/pull/1429))
102+
- CLI: Return error on wrongly specified type paths ([#1397](https://github.com/paritytech/subxt/pull/1397))
103+
- rpc v2: chainhead support multiple finalized block hashes in `FollowEvent::Initialized` ([#1476](https://github.com/paritytech/subxt/pull/1476))
104+
- rpc v2: rename transaction to transactionWatch ([#1399](https://github.com/paritytech/subxt/pull/1399))
105+
106+
### Fixed
107+
108+
- Avoid a panic in case we try decoding naff bytes ([#1444](https://github.com/paritytech/subxt/pull/1444))
109+
- Fix error mapping to wrong transaction status ([#1445](https://github.com/paritytech/subxt/pull/1445))
110+
- Update DispatchError to match latest in polkadot-sdk ([#1442](https://github.com/paritytech/subxt/pull/1442))
111+
- Handle errors when fetching storage keys from Unstablebackend ([#1440](https://github.com/paritytech/subxt/pull/1440))
112+
- Swap type aliases around to be semantically correct ([#1441](https://github.com/paritytech/subxt/pull/1441))
113+
7114
## [0.34.0] - 2024-01-23
8-
115+
9116
This release introduces a bunch of features that make subxt easier to use. Let's look at a few of them.
10117

11118
### Codegen - Integrating [`scale-typegen`](https://github.com/paritytech/scale-typegen) and adding type aliases ([#1249](https://github.com/paritytech/subxt/pull/1249))
@@ -23,7 +130,7 @@ If you provide an invalid type path, the macro will tell you so. It also suggest
23130

24131
```rust
25132
#[subxt::subxt(
26-
runtime_metadata_path = "metadata.scale",
133+
runtime_metadata_path = "metadata.scale",
27134
derive_for_type(path = "Junctions", derive = "Clone")
28135
)]
29136
pub mod polkadot {}
@@ -34,7 +141,7 @@ This gives you a compile-time error like this:
34141
```md
35142
Type `Junctions` does not exist at path `Junctions`
36143

37-
A type with the same name is present at:
144+
A type with the same name is present at:
38145
xcm::v3::junctions::Junctions
39146
xcm::v2::multilocation::Junctions
40147
```
@@ -78,7 +185,7 @@ Our CLI tool now allows you to explore runtime APIs and events ([#1290](https://
78185
# Show details about a runtime API call:
79186
subxt explore --url wss://westend-rpc.polkadot.io api StakingAPI nominations_quota
80187
# Execute a runtime API call from the CLI:
81-
subxt explore --url wss://westend-rpc.polkadot.io api core version -e
188+
subxt explore --url wss://westend-rpc.polkadot.io api core version -e
82189
# Discover what events a pallet can emit:
83190
subxt explore --url wss://westend-rpc.polkadot.io pallet Balances events
84191
```

Cargo.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ resolver = "2"
3131
[workspace.package]
3232
authors = ["Parity Technologies <admin@parity.io>"]
3333
edition = "2021"
34-
version = "0.34.0"
34+
version = "0.35.0"
3535
rust-version = "1.74.0"
3636
license = "Apache-2.0 OR GPL-3.0"
3737
repository = "https://github.com/paritytech/subxt"
@@ -135,12 +135,12 @@ sp-runtime = "34.0.0"
135135
sp-keyring = "34.0.0"
136136

137137
# Subxt workspace crates:
138-
subxt = { version = "0.34.0", path = "subxt", default-features = false }
139-
subxt-macro = { version = "0.34.0", path = "macro" }
140-
subxt-metadata = { version = "0.34.0", path = "metadata", default-features = false }
141-
subxt-codegen = { version = "0.34.0", path = "codegen" }
142-
subxt-signer = { version = "0.34.0", path = "signer", default-features = false }
143-
subxt-lightclient = { version = "0.34.0", path = "lightclient", default-features = false }
138+
subxt = { version = "0.35.0", path = "subxt", default-features = false }
139+
subxt-macro = { version = "0.35.0", path = "macro" }
140+
subxt-metadata = { version = "0.35.0", path = "metadata", default-features = false }
141+
subxt-codegen = { version = "0.35.0", path = "codegen" }
142+
subxt-signer = { version = "0.35.0", path = "signer", default-features = false }
143+
subxt-lightclient = { version = "0.35.0", path = "lightclient", default-features = false }
144144
test-runtime = { path = "testing/test-runtime" }
145145
substrate-runner = { path = "testing/substrate-runner" }
146146

examples/parachain-example/Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/wasm-example/Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)