-
Notifications
You must be signed in to change notification settings - Fork 264
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
Conversation
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"); | ||
|
There was a problem hiding this comment.
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.
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) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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
There was a problem hiding this 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",
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. |
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>
This PR updates subxt to support V16 metadata (from
[email protected]
) and ensures it's downloaded and used by default when available.It also:
frame-decode
so that it aligns on theframe-metadata
in use (see this)scale-typegen
because a newDuration
prelude type was spotted, breaking tests.