Skip to content

Prep to release v0.42.0 #2003

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

Merged
merged 4 commits into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ jobs:
name: Check documentation and run doc tests
runs-on: parity-large
needs: [fmt, machete]
timeout-minutes: 30
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incase doc tests hang again!

steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand Down
94 changes: 94 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,100 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.42.0] - 2025-05-09

The primary benefit of this release is introducing support for the [_about-to-be-stabilised-in-polkadot-sdk_](https://github.com/paritytech/polkadot-sdk/pull/8443) V16 metadata, and with that, support for calling Pallet View Functions on runtimes which will support this. Pallet View Functions are used much like Runtime APIs, except that they are declared in specific pallets and not declared at the runtime-wide level, allowing pallets to carry their own APIs with them.

### Pallet View Functions

Calling a Pallet View Function in this Subxt release will look like:

```rust
use runtime::proxy::view_functions::check_permissions::{Call, ProxyType};

// Construct the call, providing the two arguments.
let view_function_call = runtime::view_functions()
.proxy()
.check_permissions(
Call::System(runtime::system::Call::remark { remark: b"hi".to_vec() }),
ProxyType::Any
);

// Submit the call and get back a result.
let _is_call_allowed = api
.view_functions()
.at_latest()
.await?
.call(view_function_call)
.await?;
```

Like Runtime APIs and others, the dynamic API can also be used to call into Pallet View Functions, which has the advantage of not needing the statically generated interface, but the downside of not being strongly typed. This looks like the following:

```rust
use scale_value::value;

let metadata = api.metadata();

// Look up the query ID for the View Function in the node metadata:
let query_id = metadata
.pallet_by_name("Proxy")
.unwrap()
.view_function_by_name("check_permissions")
.unwrap()
.query_id();

// Construct the call, providing the two arguments.
let view_function_call = subxt::dynamic::view_function_call(
*query_id,
vec![
value!(System(remark(b"hi".to_vec()))),
value!(Any())
],
);

// Submit the call and get back a result.
let _is_call_allowed = api
.view_functions()
.at_latest()
.await?
.call(view_function_call)
.await?;
```

### Updated `Config` trait

Another change to be aware of is that [our `Config` trait has been tweaked](https://github.com/paritytech/subxt/pull/1974). The `Hash` associated type is no longer needed, as it can be obtained via the `Hasher` associated type already, and `PolkadotConfig`/`SubstrateConfig` now set the hasher by default to be `DynamicHasher256`, which will (when V16 metadata is available for a runtime) automatically select between Keccak256 and BlakeTwo256 hashers depending on what the chain requires.

### Other changes

We also [solidify our support for V1 archive RPCs](https://github.com/paritytech/subxt/pull/1977), [upgrade the codebase to Rust 2024 edition](https://github.com/paritytech/subxt/pull/2001), and a bunch of other changes, the full list of which is here:

### Added

- Support v16 metadata and use it by default if it's available ([#1999](https://github.com/paritytech/subxt/pull/1999))
- Metadata V16: Implement support for Pallet View Functions ([#1981](https://github.com/paritytech/subxt/pull/1981))
- Metadata V16: Be more dynamic over which hasher is used. ([#1974](https://github.com/paritytech/subxt/pull/1974))

### Changed

- Update to 2024 edition ([#2001](https://github.com/paritytech/subxt/pull/2001))
- Update Smoldot to latest version ([#1991](https://github.com/paritytech/subxt/pull/1991))
- Update native test timeout to 45 mins ([#2002](https://github.com/paritytech/subxt/pull/2002))
- chore(deps): tokio ^1.44.2 ([#1989](https://github.com/paritytech/subxt/pull/1989))
- Add DefaultParams to allow more transaction extensions to be used when calling _default() methods ([#1979](https://github.com/paritytech/subxt/pull/1979))
- Use wat instead of wabt to avoid CI cmake error (and use supported dep) ([#1980](https://github.com/paritytech/subxt/pull/1980))
- Support v1 archive RPCs ([#1977](https://github.com/paritytech/subxt/pull/1977))
- Support V16 metadata and refactor metadata code ([#1967](https://github.com/paritytech/subxt/pull/1967))
- Allow submitting transactions ignoring follow events ([#1962](https://github.com/paritytech/subxt/pull/1962))
- Improve error message regarding failure to extract metadata from WASM runtime ([#1961](https://github.com/paritytech/subxt/pull/1961))
- Add docs for subxt-rpcs and fix example ([#1954](https://github.com/paritytech/subxt/pull/1954))

### Fixed

- Fix CLI storage diff ([#1958](https://github.com/paritytech/subxt/pull/1958))
- chore: fix some typos ([#1997](https://github.com/paritytech/subxt/pull/1997))

## [0.41.0] - 2025-03-10

This release makes two main changes:
Expand Down
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/src/commands/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use subxt_metadata::{
/// Explore the differences between two nodes
///
/// # Example
/// ```
/// ```text
/// subxt diff ./artifacts/polkadot_metadata_small.scale ./artifacts/polkadot_metadata_tiny.scale
/// subxt diff ./artifacts/polkadot_metadata_small.scale wss://rpc.polkadot.io:443
/// ```
Expand Down
1 change: 1 addition & 0 deletions cli/src/commands/explore/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ mod runtime_apis;
/// # Example
///
/// Show the pallets and runtime apis that are available:
///
/// ```text
/// subxt explore --file=polkadot_metadata.scale
/// ```
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/explore/runtime_apis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use subxt_metadata::RuntimeApiMetadata;

/// Runs for a specified runtime API trait.
/// Cases to consider:
/// ```txt
/// ```text
/// method is:
/// None => Show pallet docs + available methods
/// Some (invalid) => Show Error + available methods
Expand Down
2 changes: 1 addition & 1 deletion codegen/src/api/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use super::CodegenError;
/// Generate constants from the provided pallet's metadata.
///
/// The function creates a new module named `constants` under the pallet's module.
/// ```ignore
/// ```rust,ignore
/// pub mod PalletName {
/// pub mod constants {
/// ...
Expand Down
4 changes: 2 additions & 2 deletions codegen/src/api/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use subxt_metadata::PalletMetadata;
///
/// The function creates a new module named `events` under the pallet's module.
///
/// ```ignore
/// ```rust,ignore
/// pub mod PalletName {
/// pub mod events {
/// ...
Expand All @@ -24,7 +24,7 @@ use subxt_metadata::PalletMetadata;
/// The function generates the events as rust structs that implement the `subxt::event::StaticEvent` trait
/// to uniquely identify the event's identity when creating the extrinsic.
///
/// ```ignore
/// ```rust,ignore
/// pub struct EventName {
/// pub event_param: type,
/// }
Expand Down
11 changes: 8 additions & 3 deletions codegen/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,19 +410,24 @@ pub struct StructFromVariant {
/// Returns the TokenStream of the type alias module.
///
/// E.g a struct like this:
/// ```ignore
///
/// ```rust,ignore
/// pub struct SetMaxCodeSize {
/// pub new: ::core::primitive::u32,
/// }
/// ```
///
/// will be made into this:
/// ```ignore
///
/// ```rust,ignore
/// pub struct SetMaxCodeSize {
/// pub new: set_max_code_size::New,
/// }
/// ```
///
/// And the type alias module will look like this:
/// ```ignore
///
/// ```rust,ignore
/// pub mod set_max_code_size {
/// use super::runtime_types;
/// pub type New = ::core::primitive::u32;
Expand Down
2 changes: 1 addition & 1 deletion codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub use syn;
///
/// Generating an interface using all of the defaults:
///
/// ```rust
/// ```rust,standalone_crate
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc tests have been hanging in CI, and even locally, I think since I enabled Rust 2024. Rust 2024 changes how doc tests run and compiles them into a single binary ratehr than 1 per test.

Since many of our doc tests generate a load of code via the subxt macro, I suspect that this was eating up too much memory during compilation and causing the CI machine to hang (locally it went well over 4GB offhand).

Either way, adding standalone_crate to them all reverted to the previous behaviour which seems to work much better for us!

/// use codec::Decode;
/// use subxt_codegen::{ Metadata, CodegenBuilder };
///
Expand Down
4 changes: 2 additions & 2 deletions rpcs/src/client/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl std::ops::Deref for RpcClient {
///
/// # Example
///
/// ```rust
/// ```rust,standalone_crate
/// use subxt_rpcs::client::{ rpc_params, RpcParams };
///
/// // If you provide no params you get `None` back
Expand Down Expand Up @@ -138,7 +138,7 @@ pub use rpc_params;
///
/// # Example
///
/// ```rust
/// ```rust,standalone_crate
/// use subxt_rpcs::client::RpcParams;
///
/// let mut params = RpcParams::new();
Expand Down
8 changes: 4 additions & 4 deletions signer/src/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Keypair {
///
/// # Example
///
/// ```rust
/// ```rust,standalone_crate
/// use subxt_signer::{ SecretUri, ecdsa::Keypair };
/// use std::str::FromStr;
///
Expand Down Expand Up @@ -84,7 +84,7 @@ impl Keypair {
///
/// # Example
///
/// ```rust
/// ```rust,standalone_crate
/// use subxt_signer::{ bip39::Mnemonic, ecdsa::Keypair };
///
/// let phrase = "bottom drive obey lake curtain smoke basket hold race lonely fit walk";
Expand Down Expand Up @@ -122,7 +122,7 @@ impl Keypair {
///
/// # Example
///
/// ```rust
/// ```rust,standalone_crate
/// use subxt_signer::{ bip39::Mnemonic, ecdsa::Keypair, DeriveJunction };
///
/// let phrase = "bottom drive obey lake curtain smoke basket hold race lonely fit walk";
Expand Down Expand Up @@ -178,7 +178,7 @@ impl Keypair {

/// Verify that some signature for a message was created by the owner of the [`PublicKey`].
///
/// ```rust
/// ```rust,standalone_crate
/// use subxt_signer::{ bip39::Mnemonic, ecdsa };
///
/// let keypair = ecdsa::dev::alice();
Expand Down
4 changes: 2 additions & 2 deletions signer/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Keypair {
///
/// # Example
///
/// ```rust
/// ```rust,standalone_crate
/// use subxt_signer::{ bip39::Mnemonic, eth::{ Keypair, DerivationPath } };
///
/// let phrase = "bottom drive obey lake curtain smoke basket hold race lonely fit walk";
Expand Down Expand Up @@ -175,7 +175,7 @@ impl AsRef<[u8; 65]> for Signature {

/// Verify that some signature for a message was created by the owner of the [`PublicKey`].
///
/// ```rust
/// ```rust,standalone_crate
/// use subxt_signer::{ bip39::Mnemonic, eth };
///
/// let keypair = eth::dev::alith();
Expand Down
8 changes: 4 additions & 4 deletions signer/src/sr25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl Keypair {
///
/// # Example
///
/// ```rust
/// ```rust,standalone_crate
/// use subxt_signer::{ SecretUri, sr25519::Keypair };
/// use std::str::FromStr;
///
Expand Down Expand Up @@ -94,7 +94,7 @@ impl Keypair {
///
/// # Example
///
/// ```rust
/// ```rust,standalone_crate
/// use subxt_signer::{ bip39::Mnemonic, sr25519::Keypair };
///
/// let phrase = "bottom drive obey lake curtain smoke basket hold race lonely fit walk";
Expand Down Expand Up @@ -144,7 +144,7 @@ impl Keypair {
///
/// # Example
///
/// ```rust
/// ```rust,standalone_crate
/// use subxt_signer::{ bip39::Mnemonic, sr25519::Keypair, DeriveJunction };
///
/// let phrase = "bottom drive obey lake curtain smoke basket hold race lonely fit walk";
Expand Down Expand Up @@ -186,7 +186,7 @@ impl Keypair {

/// Verify that some signature for a message was created by the owner of the [`PublicKey`].
///
/// ```rust
/// ```rust,standalone_crate
/// use subxt_signer::{ bip39::Mnemonic, sr25519 };
///
/// let keypair = sr25519::dev::alice();
Expand Down
6 changes: 3 additions & 3 deletions subxt/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub mod rpc {
///
/// # Example
///
/// ```rust,no_run
/// ```rust,no_run,standalone_crate
/// use std::time::Duration;
/// use futures::StreamExt;
/// use subxt::backend::rpc::reconnecting_rpc_client::{RpcClient, ExponentialBackoff};
Expand Down Expand Up @@ -541,7 +541,7 @@ mod test {
/// - `current_runtime_version`
/// - `call`
/// The test covers them because they follow the simple pattern of:
/// ```no_run
/// ```rust,no_run,standalone_crate
/// async fn THE_THING(&self) -> Result<HashFor<T>, Error> {
/// retry(|| <DO THE THING> ).await
/// }
Expand Down Expand Up @@ -572,7 +572,7 @@ mod test {
/// - `stream_all_block_headers`
/// - `stream_best_block_headers`
/// The test covers them because they follow the simple pattern of:
/// ```no_run
/// ```rust,no_run,standalone_crate
/// async fn stream_the_thing(
/// &self,
/// ) -> Result<StreamOfResults<(T::Header, BlockRef<HashFor<T>>)>, Error> {
Expand Down
Loading
Loading