Skip to content

Support v16 metadata and use it by default if it's available #1999

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 10 commits into from
May 8, 2025

Conversation

jsdw
Copy link
Collaborator

@jsdw jsdw commented May 7, 2025

This PR updates subxt to support V16 metadata (from [email protected]) and ensures it's downloaded and used by default when available.

It also:

  • Updates frame-decode so that it aligns on the frame-metadata in use (see this)
  • Updates scale-typegen because a new Duration prelude type was spotted, breaking tests.
  • Updates the Substrate dependencies.
  • Fixes other changes in the Substrate node that broke tests.

@jsdw jsdw requested a review from a team as a code owner May 7, 2025 10:54
Comment on lines -290 to -308
let tx = node_runtime::tx().staking().bond(
100_000_000_000_000,
runtime_types::pallet_staking::RewardDestination::Stash,
);

let signed_extrinsic = api
.tx()
.create_signed(&tx, &bob_signer, Default::default())
.await?;

signed_extrinsic
.submit_and_watch()
.await
.unwrap()
.wait_for_finalized_success()
.await?
.find_first::<system::events::ExtrinsicSuccess>()?
.expect("No ExtrinsicSuccess Event found");

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is already a hold now so no need to artifically create one.

Comment on lines +174 to 188
match fetch_available_versions(&client).await {
Ok(supported_versions) => {
fetch_inner(&client, version, supported_versions).await
},
Err(e) => {
// The "new" interface failed. if the user is asking for V14 or the "latest"
// metadata then try the legacy interface instead. Else, just return the
// reason for failure.
if matches!(version, MetadataVersion::Version(14) | MetadataVersion::Latest) {
fetch_inner_legacy(&client).await
} else {
Err(e)
}
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tidied this up because previously it was returning only the error from fetch_inner_legacy (ie "The node can only return version 14 metadata using the legacy API..") which wasn't very helpful!

/// The metadata versions that we support converting into [`crate::Metadata`].
/// These are ordest from highest to lowest, so that the metadata we'd want to
/// pick first is first in the array.
pub const SUPPORTED_METADATA_VERSIONS: [u32; 3] = [16, 15, 14];
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I moved this here so that we have only one array of supported versions that's used anywhere we need it

@jsdw jsdw requested a review from Copilot May 8, 2025 13:25
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates subxt to support V16 metadata from [email protected] and ensures that it is used by default when available. Key changes include updated handling of deprecation_info fields in metadata stripping, refactored metadata fetching logic with enhanced version checks and error messages, and adjustments to tests and dependency versions for compatibility with the new metadata format.

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
utils/strip-metadata/src/lib.rs Updated deprecation field usage to new V16 types.
utils/fetch-metadata/src/url.rs Refactored metadata fetching to support version discovery and fallback.
testing/test-runtime/build.rs Updated metadata download logic and error handling for V16 support.
testing/no-std-tests/src/main.rs Removed #[no_mangle] attribute from rust_eh_personality.
testing/integration-tests/src/full_client/pallet_view_functions.rs Temporarily commented out view function tests pending V16 stability.
testing/integration-tests/src/full_client/frame/balances.rs Updated test expectation for balance lock amount.
testing/integration-tests/src/full_client/blocks.rs Added a new expected transaction extension "AuthorizeCall".
subxt/src/client/online_client.rs Modified metadata fetching by looping through supported versions.
metadata/src/from/mod.rs Adjusted conversion to allow V16 metadata instead of erroring out.
macro/src/wasm_loader.rs and Cargo.toml (macro/) Updated SUPPORTED_METADATA_VERSIONS usage and dependency configuration.
core/src/utils/account_id.rs Changed keyring import to use a more specific module path.
Cargo.toml Bumped dependency versions for compatibility with new metadata support.
Comments suppressed due to low confidence (3)

testing/integration-tests/src/full_client/frame/balances.rs:301

  • The expected locked balance value was updated from 100_000_000_000_000 to 327_000_000_000_000. Please ensure this change is intentional and aligns with the new V16 metadata behavior.
assert_eq!(holds[0].amount, 327_000_000_000_000);

testing/no-std-tests/src/main.rs:15

  • The #[no_mangle] attribute was removed from the rust_eh_personality function. Verify that this removal is intentional and will not cause linking issues on the targeted no-std platforms.
#[no_mangle]

testing/integration-tests/src/full_client/blocks.rs:336

  • A new transaction extension 'AuthorizeCall' was added to the expected list. Confirm that this addition matches the updated node behavior and is reflected in the metadata changes.
"AuthorizeCall",

@jsdw
Copy link
Collaborator Author

jsdw commented May 8, 2025

The only failing test is failing because of some cache cleanup error at the end that cropped up before for a bit. All of the actual tests pass, so I'll ignore this failure.

Once the polkadot-sdk PR merges, we'll have a Substrate nightly binary that supports V16 and can transition Subxt to using it by default in tests, un-comment-out view function tests and add corresponding view function examples / docs.

@jsdw jsdw merged commit 9ba89e3 into master May 8, 2025
12 of 13 checks passed
@jsdw jsdw deleted the jsdw-stabilize-metadata-v16 branch May 8, 2025 13:44
@jsdw jsdw mentioned this pull request May 9, 2025
github-merge-queue bot pushed a commit to paritytech/polkadot-sdk that referenced this pull request May 14, 2025
This PR bumps frame-metadata 23.0.0, which stabilizes V16 metadata. This
was previously available as the "unstable" metadata.

The main additions provided by V16 metadata are:
- Information about the Pallet View Functions exposed by pallets.
- Information about the Config associated types used by each pallet.
- Support for V5 transactions, including support for a chain providing
multiple transaction extension versions and multiple supported
transaciton versions.
- Support for deprecation information, so that mostly anything defined
in a runtime can be marked as deprecated in order for runtime/pallet
authors to communicate to consumers about deprecated items.

To sanity check this, I've built a polkadot node with this change and
checked that using Subxt (this PR
paritytech/subxt#1999), v16 metadata is indeed
available, downloads and decodes correctly.

<!--
✄
-----------------------------------------------------------------------------

Thank you for your Pull Request! 🙏 Please make sure it follows the
contribution guidelines outlined in [this

document](https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CONTRIBUTING.md)
and fill out the
sections below. Once you're ready to submit your PR for review, please
delete this section and leave only the text under
the "Description" heading.

# Description

*A concise description of what your PR is doing, and what potential
issue it is solving. Use [Github semantic

linking](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword)
to link the PR to an issue that must be closed once this is merged.*

## Integration

*In depth notes about how this PR should be integrated by downstream
projects. This part is mandatory, and should be
reviewed by reviewers, if the PR does NOT have the `R0-Silent` label. In
case of a `R0-Silent`, it can be ignored.*

## Review Notes

*In depth notes about the **implementation** details of your PR. This
should be the main guide for reviewers to
understand your approach and effectively review it. If too long, use

[`<details>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details)*.

*Imagine that someone who is depending on the old code wants to
integrate your new code and the only information that
they get is this section. It helps to include example usage and default
value here, with a `diff` code-block to show
possibly integration.*

*Include your leftover TODOs, if any, here.*

# Checklist

* [ ] My PR includes a detailed description as outlined in the
"Description" and its two subsections above.
* [ ] My PR follows the [labeling requirements](

https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CONTRIBUTING.md#Process
) of this project (at minimum one label for `T` required)
* External contributors: ask maintainers to put the right label on your
PR.
* [ ] I have made corresponding changes to the documentation (if
applicable)
* [ ] I have added tests that prove my fix is effective or that my
feature works (if applicable)

You can remove the "Checklist" section once all have been checked. Thank
you for your contribution!

✄
-----------------------------------------------------------------------------
--.

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

1 participant