Skip to content

Commit 841a43b

Browse files
authored
Prepare for 0.43.0 release (#2041)
1 parent 0a20e74 commit 841a43b

File tree

4 files changed

+135
-38
lines changed

4 files changed

+135
-38
lines changed

CHANGELOG.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,103 @@ 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.43.0] - 2025-07-17
8+
9+
This is a reasonably small release which is mainly bug fixing, but has a couple of changes I'd like to elaborate on:
10+
11+
### Remove `codec::Encode` and `codec::Decode` derives from generated APIs by default ([#2008](https://github.com/paritytech/subxt/pull/2008))
12+
13+
When generating an API using the `#[subxt::subxt(...)]` macro (or programatically via `subxt-codegen`), we had always previously added `parity_scale_codec::Encode` and `parity_scale_codec::Decode` derives to all of the generated types. Most places in Subxt have not made use of these for a long time (relying instead on `scale_encode::EncodeAsType` and `scale_decode::DecodeAsType`, since they allow encoding and encoding which takes the type information into account and can more gracefully handle incompatibilities).
14+
15+
We eventually [hit an issue](https://github.com/paritytech/subxt/issues/2006) to which the most appropriate fix was just to remove these derives.
16+
17+
If you still need the `parity_scale_codec::Encode` or `parity_scale_codec::Decode` derives on certain types, you have two options:
18+
19+
1. Use the [`derive_for_type`](https://docs.rs/subxt/latest/subxt/attr.subxt.html#derive_for_typepath---derive--) attr to add them back where needed, eg:
20+
```rust
21+
#[subxt::subxt(
22+
...
23+
derive_for_type(
24+
path = "staging_xcm::v3::multilocation::MultiLocation",
25+
derive = "parity_scale_codec::Encode, parity_scale_codec::Decode",
26+
recursive
27+
)
28+
)]
29+
```
30+
2. Use the [`derive_for_all_types`](https://docs.rs/subxt/latest/subxt/attr.subxt.html#derive_for_all_types--) attr to add them back everywhere, eg:
31+
```
32+
#[subxt::subxt(
33+
...
34+
derive_for_all_types = "parity_scale_codec::Encode, parity_scale_codec::Decode"
35+
)]
36+
```
37+
38+
Prefer (1) where possible to reduce the amount of generated code, and reduce the likelihood of running into [issues](https://github.com/paritytech/subxt/issues/2006) around those derives in certain edge cases.
39+
40+
This PR changes some things around storage keys to remove one last requirement for `Encode` and `Decode` derives, and also as a side effect changes `api.storage().call_raw()` slightly to no longer also try to decode the resulting type via `Decode`, leaving this to the user (and also meaning it's much easier now for the user to obtain the raw bytes for some storage entry).
41+
42+
In other words, instead of doing something like:
43+
44+
```rust
45+
let (compact_len, metadata) = rt
46+
.call_raw::<(Compact<u32>, frame_metadata::RuntimeMetadataPrefixed)>(
47+
"Metadata_metadata",
48+
None,
49+
)
50+
.await?;
51+
```
52+
53+
You would now do:
54+
55+
```rust
56+
let meta_bytes = rt.call_raw("Metadata_metadata", None).await?;
57+
let (compact_len, metadata): (Compact<u32>, frame_metadata::RuntimeMetadataPrefixed) =
58+
Decode::decode(&mut &*meta_bytes)?;
59+
```
60+
61+
### Address some issues around tx mortality ([#2025](https://github.com/paritytech/subxt/pull/2025))
62+
63+
Prior to this change, the intended behavior was that any transaction submitted via an `OnlineClient` would have a mortality of 32 blocks by default, and any transaction submitted via an `OfflineClient` would be immortal by default. A couple of issues were present or cropped up however:
64+
- If you explicitly configure the mortality via setting params like `PolkadotExtrinsicParamsBuilder::new().mortal(32).build()`, the `OfflineClient` transaction would _still_ be immortal, because it didn't have enough information to properly configure the mortality as asked for (by virtue of being offline and unable to fetch it).
65+
- The intended behaviour turned out to have been broken, and transactions were being submitted as immortal even via the `OnlineClient` by default, unless mortality was explicitly configured.
66+
- There was no easy way to actually set the mortality for an `OfflineClient` transaction; you'd have to do something like this:
67+
```rust
68+
let params = DefaultExtrinsicParamsBuilder::new();
69+
params.5 = CheckMortalityParams::mortal_from_unchecked(for_n_blocks, from_block_n, from_block_hash);
70+
```
71+
72+
With this PR, transactions _are_ now mortal by default using the `OnlineClient`, we now return an error if you try to construct a transaction with the `OfflineClient` and try to use `params.mortal(..)` when configuring it, and we expose `params.mortal_from_unchecked(..)` to allow configuration for offline transactions without the ugly code above.
73+
74+
In this PR, we also discovered an issue decoding `Eras` and fixed this, so that decoding the mortality of a transaction when it is mortal should now work.
75+
76+
### Add FFI example ([#2037](https://github.com/paritytech/subxt/pull/2037))
77+
78+
I'd like to do a quick shoutout to @wassimans, who submitted an excellent example for how to interact with Subxt via the C FFI in Python and Node.JS. This is something I've wanted to add for a while, so it's lovely to see this new example which highlights one of the strengths of Subxt over Javascript based compatitors in the space.
79+
80+
All of the non-trivial changes in this release are listed below:
81+
82+
### Added
83+
84+
- Add FFI example ([#2037](https://github.com/paritytech/subxt/pull/2037))
85+
86+
### Changed
87+
88+
- Remove `codec::Encode` and `codec::Decode` derives from generated APIs by default ([#2008](https://github.com/paritytech/subxt/pull/2008))
89+
- Address some issues around tx mortality ([#2025](https://github.com/paritytech/subxt/pull/2025))
90+
91+
### Fixed
92+
93+
- Fix 'subxt explore storage': don't turn keys to bytes ([#2038](https://github.com/paritytech/subxt/pull/2038))
94+
- Refactor: improve nonce and block injection in extrinsic params ([#2032](https://github.com/paritytech/subxt/pull/2032))
95+
- Improve docs for `at_latest` ([#2035](https://github.com/paritytech/subxt/pull/2035))
96+
- Clippy fixes for latest Rustc ([#2033](https://github.com/paritytech/subxt/pull/2033))
97+
- docs: fix minor comment typos ([#2027](https://github.com/paritytech/subxt/pull/2027))
98+
- chore: remove redundant backtick in comment ([#2020](https://github.com/paritytech/subxt/pull/2020))
99+
- Keep codec attrs even when Encode/Decode not used ([#2023](https://github.com/paritytech/subxt/pull/2023))
100+
- Run CI on v0.N.x branches or PRs to them for ease of backporting ([#2017](https://github.com/paritytech/subxt/pull/2017))
101+
- De-dup types early in CLI/macro so that derives/substitutes work for de-duped types ([#2015](https://github.com/paritytech/subxt/pull/2015))
102+
- If only one hasher, always treat any key as a single and not NMap key, even if it's a tuple. ([#2010](https://github.com/paritytech/subxt/pull/2010))
103+
7104
## [0.42.1] - 2025-05-12
8105

9106
This patch release reduces the rust-version to 1.85.0, given that we don't use any features newer than this at the moment.

Cargo.lock

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

Cargo.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ resolver = "2"
3737
[workspace.package]
3838
authors = ["Parity Technologies <[email protected]>"]
3939
edition = "2024"
40-
version = "0.42.1"
40+
version = "0.43.0"
4141
rust-version = "1.85.0"
4242
license = "Apache-2.0 OR GPL-3.0"
4343
repository = "https://github.com/paritytech/subxt"
@@ -153,16 +153,16 @@ sp-state-machine = { version = "0.45.0", default-features = false }
153153
sp-runtime = { version = "41.1.0", default-features = false }
154154

155155
# Subxt workspace crates:
156-
subxt = { version = "0.42.1", path = "subxt", default-features = false }
157-
subxt-core = { version = "0.42.1", path = "core", default-features = false }
158-
subxt-macro = { version = "0.42.1", path = "macro" }
159-
subxt-metadata = { version = "0.42.1", path = "metadata", default-features = false }
160-
subxt-codegen = { version = "0.42.1", path = "codegen" }
161-
subxt-signer = { version = "0.42.1", path = "signer", default-features = false }
162-
subxt-rpcs = { version = "0.42.1", path = "rpcs", default-features = false }
163-
subxt-lightclient = { version = "0.42.1", path = "lightclient", default-features = false }
164-
subxt-utils-fetchmetadata = { version = "0.42.1", path = "utils/fetch-metadata", default-features = false }
165-
subxt-utils-stripmetadata = { version = "0.42.1", path = "utils/strip-metadata", default-features = false }
156+
subxt = { version = "0.43.0", path = "subxt", default-features = false }
157+
subxt-core = { version = "0.43.0", path = "core", default-features = false }
158+
subxt-macro = { version = "0.43.0", path = "macro" }
159+
subxt-metadata = { version = "0.43.0", path = "metadata", default-features = false }
160+
subxt-codegen = { version = "0.43.0", path = "codegen" }
161+
subxt-signer = { version = "0.43.0", path = "signer", default-features = false }
162+
subxt-rpcs = { version = "0.43.0", path = "rpcs", default-features = false }
163+
subxt-lightclient = { version = "0.43.0", path = "lightclient", default-features = false }
164+
subxt-utils-fetchmetadata = { version = "0.43.0", path = "utils/fetch-metadata", default-features = false }
165+
subxt-utils-stripmetadata = { version = "0.43.0", path = "utils/strip-metadata", default-features = false }
166166
test-runtime = { path = "testing/test-runtime" }
167167
substrate-runner = { path = "testing/substrate-runner" }
168168

examples/ffi-example/Cargo.lock

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

0 commit comments

Comments
 (0)