-
Notifications
You must be signed in to change notification settings - Fork 255
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
Metadata V15: Generate Runtime APIs #918
Conversation
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
cli/src/utils.rs
Outdated
u32::MAX => CodegenMetadataVersion::Unstable, | ||
_ => panic!("MetadataVersion and CodegenMetadataVersion are not in sync!"), | ||
14 => CodegenMetadataVersion::Latest, |
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.
Nit: maybe just manually have an into_codegen_metadata_version(metadata_version: Option<MetadataVersion>) -> CodegenMetadataVersion
so we don't have to hardcode the 14 here (I'm trying to get away from assuming anything about what the node has in terms of metadata versions :))?
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.
Or clap has default_value = <str>
which we could use so that MetadataVersion
could have a Latest
variant and clap will default to using that. (maybe we can just use CodegenMetadataVersion
directly in that case?)
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.
That makes sense! Have ended up using just the CodegenMetadataVersion
here :D Thanks!
codegen/src/utils/fetch_metadata.rs
Outdated
let versions: Vec<u32> = Decode::decode(&mut &raw_bytes[..])?; | ||
Ok::<Vec<u32>, FetchMetadataError>(versions) | ||
}) | ||
.transpose()?; |
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.
Does the ?
here lead to us exiting early if this call fails due to "Metadata_metadata_versions" not existing?
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.
The code here seems a bit complex after another look, I'll take a note to go back and do a plain-old match to make it easier to follow:
- we initially do a
.ok()
which throws away theResult<String, Error>
from the client and wraps into aOption<String>
- we transpose an Option<Result<..>>, out of which the Result can only be part of the closure: hex decoding or coded::decod failed
I believe we should be safe here, I'll be a bit more explicit with a simple match and such :D
Signed-off-by: Alexandru Vasile <[email protected]>
…v/add_runtime_api Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
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.
Looks awesome; good job on this!
Signed-off-by: Alexandru Vasile <[email protected]>
* Update frame-metadata to v15.1.0 Signed-off-by: Alexandru Vasile <[email protected]> * Enable V15 unstable metadata in frame-metadata Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Move validation hashing to dedicated file Signed-off-by: Alexandru Vasile <[email protected]> * Use sp-metadata-ir from substrate to work with metadata Signed-off-by: Alexandru Vasile <[email protected]> * Revert using sp-metadata-ir in favor of conversion to v15 Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Convert v14 to v15 Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Use v15 for validation Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Use v15 for codegen Signed-off-by: Alexandru Vasile <[email protected]> * metadata/bench: Use v15 Signed-off-by: Alexandru Vasile <[email protected]> * Adjust to v15 metadata Signed-off-by: Alexandru Vasile <[email protected]> * Adjust testing Signed-off-by: Alexandru Vasile <[email protected]> * Improve documentation Signed-off-by: Alexandru Vasile <[email protected]> * force CI Signed-off-by: Alexandru Vasile <[email protected]> * rpc: Fetch metadata at version Signed-off-by: Alexandru Vasile <[email protected]> * artifacts: Update polkadot.scale from commit 6dc9e84dde2 Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Fetch V15 using the new API Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Add runtime API interface Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Hash runtime API metadata for validation Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Extract runtime API metadata wrapper from subxt::Metadata Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Adjust hashing cache to reflect root+item keys Signed-off-by: Alexandru Vasile <[email protected]> * rpc: Add raw state_call API method Signed-off-by: Alexandru Vasile <[email protected]> * runtime_api: Add payload with static and dynamic variants Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Allow payloads to call into the runtime Signed-off-by: Alexandru Vasile <[email protected]> * examples: Add example to make a runtime API call both static and dynamic Signed-off-by: Alexandru Vasile <[email protected]> * Update polkadot.rs Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Simplify client fetching Signed-off-by: Alexandru Vasile <[email protected]> * Address feedback and fallback to old API if needed Signed-off-by: Alexandru Vasile <[email protected]> * runtime_api: Make mutability conditional on input params Signed-off-by: Alexandru Vasile <[email protected]> * Regenerate polkadot.rs Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Retain only pallets without runtime API info Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Retry via `Metadata_metadata` without conversion Signed-off-by: Alexandru Vasile <[email protected]> * payload: Remove `Decode` and change validation fn Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Retain runtime API types Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Runtime APIs documentation based on flag Signed-off-by: Alexandru Vasile <[email protected]> * Update examples/examples/custom_metadata_url.rs Co-authored-by: James Wilson <[email protected]> * Update artifacts from polkadot-a6cfdb16e9 Signed-off-by: Alexandru Vasile <[email protected]> * Update polkadot.rs with polkadot-a6cfdb16e9 Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Generate input structures for runtime API Signed-off-by: Alexandru Vasile <[email protected]> * runtime_api: Remove the static paylaod and use single impl Signed-off-by: Alexandru Vasile <[email protected]> * examples: Fetch account nonce Signed-off-by: Alexandru Vasile <[email protected]> * testing: Adjust build script to fetch latest metadata Signed-off-by: Alexandru Vasile <[email protected]> * testing: Check account nonce from runtime API Signed-off-by: Alexandru Vasile <[email protected]> * Update cargo.lock Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Fix doc generation for runtime types Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Rename `inputs` runtime calls module to `types` Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Generate Calls structs inside the types module Signed-off-by: Alexandru Vasile <[email protected]> * testing: Check Alice account nonce before submitting the tx Signed-off-by: Alexandru Vasile <[email protected]> * cli: Add metadata version option flag supporting v14 and unstable Signed-off-by: Alexandru Vasile <[email protected]> * cli: Specify version to fetch Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Fallback to fetching latest stable metadata Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Add unstable-metadata feature to fetch the latest Signed-off-by: Alexandru Vasile <[email protected]> * RuntimeVersion with Latest and Version(u32) Signed-off-by: Alexandru Vasile <[email protected]> * Update polkadot.rs Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Adjust fetch_metadata to inspect version list Signed-off-by: Alexandru Vasile <[email protected]> * testing: Adjust metadata to metadata_legacy Signed-off-by: Alexandru Vasile <[email protected]> * events: Adjust docs to use metadata_legacy Signed-off-by: Alexandru Vasile <[email protected]> * have a pass over fetch_metadata * cargo fmt * Option<String> when fetch metadata via latest API * clippy * fmt * cli: Use the MetadataVersion from codegen Signed-off-by: Alexandru Vasile <[email protected]> * cli: Specify latest as default for MetadataVersion Signed-off-by: Alexandru Vasile <[email protected]> * cli: Remove version from metadata and use the one from file_or_url Signed-off-by: Alexandru Vasile <[email protected]> * Fix clippy Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Decode metadata independently for different RPC calls Signed-off-by: Alexandru Vasile <[email protected]> --------- Signed-off-by: Alexandru Vasile <[email protected]> Co-authored-by: James Wilson <[email protected]>
* Update frame-metadata to v15.1.0 Signed-off-by: Alexandru Vasile <[email protected]> * Enable V15 unstable metadata in frame-metadata Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Move validation hashing to dedicated file Signed-off-by: Alexandru Vasile <[email protected]> * Use sp-metadata-ir from substrate to work with metadata Signed-off-by: Alexandru Vasile <[email protected]> * Revert using sp-metadata-ir in favor of conversion to v15 Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Convert v14 to v15 Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Use v15 for validation Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Use v15 for codegen Signed-off-by: Alexandru Vasile <[email protected]> * metadata/bench: Use v15 Signed-off-by: Alexandru Vasile <[email protected]> * Adjust to v15 metadata Signed-off-by: Alexandru Vasile <[email protected]> * Adjust testing Signed-off-by: Alexandru Vasile <[email protected]> * Improve documentation Signed-off-by: Alexandru Vasile <[email protected]> * force CI Signed-off-by: Alexandru Vasile <[email protected]> * rpc: Fetch metadata at version Signed-off-by: Alexandru Vasile <[email protected]> * artifacts: Update polkadot.scale from commit 6dc9e84dde2 Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Fetch V15 using the new API Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Add runtime API interface Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Hash runtime API metadata for validation Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Extract runtime API metadata wrapper from subxt::Metadata Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Adjust hashing cache to reflect root+item keys Signed-off-by: Alexandru Vasile <[email protected]> * rpc: Add raw state_call API method Signed-off-by: Alexandru Vasile <[email protected]> * runtime_api: Add payload with static and dynamic variants Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Allow payloads to call into the runtime Signed-off-by: Alexandru Vasile <[email protected]> * examples: Add example to make a runtime API call both static and dynamic Signed-off-by: Alexandru Vasile <[email protected]> * Update polkadot.rs Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Simplify client fetching Signed-off-by: Alexandru Vasile <[email protected]> * Address feedback and fallback to old API if needed Signed-off-by: Alexandru Vasile <[email protected]> * runtime_api: Make mutability conditional on input params Signed-off-by: Alexandru Vasile <[email protected]> * Regenerate polkadot.rs Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Retain only pallets without runtime API info Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Retry via `Metadata_metadata` without conversion Signed-off-by: Alexandru Vasile <[email protected]> * payload: Remove `Decode` and change validation fn Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Retain runtime API types Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Runtime APIs documentation based on flag Signed-off-by: Alexandru Vasile <[email protected]> * Update examples/examples/custom_metadata_url.rs Co-authored-by: James Wilson <[email protected]> * Update artifacts from polkadot-a6cfdb16e9 Signed-off-by: Alexandru Vasile <[email protected]> * Update polkadot.rs with polkadot-a6cfdb16e9 Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Generate input structures for runtime API Signed-off-by: Alexandru Vasile <[email protected]> * runtime_api: Remove the static paylaod and use single impl Signed-off-by: Alexandru Vasile <[email protected]> * examples: Fetch account nonce Signed-off-by: Alexandru Vasile <[email protected]> * testing: Adjust build script to fetch latest metadata Signed-off-by: Alexandru Vasile <[email protected]> * testing: Check account nonce from runtime API Signed-off-by: Alexandru Vasile <[email protected]> * Update cargo.lock Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Fix doc generation for runtime types Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Rename `inputs` runtime calls module to `types` Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Generate Calls structs inside the types module Signed-off-by: Alexandru Vasile <[email protected]> * testing: Check Alice account nonce before submitting the tx Signed-off-by: Alexandru Vasile <[email protected]> * cli: Add metadata version option flag supporting v14 and unstable Signed-off-by: Alexandru Vasile <[email protected]> * cli: Specify version to fetch Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Fallback to fetching latest stable metadata Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Add unstable-metadata feature to fetch the latest Signed-off-by: Alexandru Vasile <[email protected]> * RuntimeVersion with Latest and Version(u32) Signed-off-by: Alexandru Vasile <[email protected]> * Update polkadot.rs Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Adjust fetch_metadata to inspect version list Signed-off-by: Alexandru Vasile <[email protected]> * testing: Adjust metadata to metadata_legacy Signed-off-by: Alexandru Vasile <[email protected]> * events: Adjust docs to use metadata_legacy Signed-off-by: Alexandru Vasile <[email protected]> * have a pass over fetch_metadata * cargo fmt * Option<String> when fetch metadata via latest API * clippy * fmt * cli: Use the MetadataVersion from codegen Signed-off-by: Alexandru Vasile <[email protected]> * cli: Specify latest as default for MetadataVersion Signed-off-by: Alexandru Vasile <[email protected]> * cli: Remove version from metadata and use the one from file_or_url Signed-off-by: Alexandru Vasile <[email protected]> * Fix clippy Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Decode metadata independently for different RPC calls Signed-off-by: Alexandru Vasile <[email protected]> --------- Signed-off-by: Alexandru Vasile <[email protected]> Co-authored-by: James Wilson <[email protected]>
* Update frame-metadata to v15.1.0 Signed-off-by: Alexandru Vasile <[email protected]> * Enable V15 unstable metadata in frame-metadata Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Move validation hashing to dedicated file Signed-off-by: Alexandru Vasile <[email protected]> * Use sp-metadata-ir from substrate to work with metadata Signed-off-by: Alexandru Vasile <[email protected]> * Revert using sp-metadata-ir in favor of conversion to v15 Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Convert v14 to v15 Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Use v15 for validation Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Use v15 for codegen Signed-off-by: Alexandru Vasile <[email protected]> * metadata/bench: Use v15 Signed-off-by: Alexandru Vasile <[email protected]> * Adjust to v15 metadata Signed-off-by: Alexandru Vasile <[email protected]> * Adjust testing Signed-off-by: Alexandru Vasile <[email protected]> * Improve documentation Signed-off-by: Alexandru Vasile <[email protected]> * force CI Signed-off-by: Alexandru Vasile <[email protected]> * rpc: Fetch metadata at version Signed-off-by: Alexandru Vasile <[email protected]> * artifacts: Update polkadot.scale from commit 6dc9e84dde2 Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Fetch V15 using the new API Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Add runtime API interface Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Hash runtime API metadata for validation Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Extract runtime API metadata wrapper from subxt::Metadata Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Adjust hashing cache to reflect root+item keys Signed-off-by: Alexandru Vasile <[email protected]> * rpc: Add raw state_call API method Signed-off-by: Alexandru Vasile <[email protected]> * runtime_api: Add payload with static and dynamic variants Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Allow payloads to call into the runtime Signed-off-by: Alexandru Vasile <[email protected]> * examples: Add example to make a runtime API call both static and dynamic Signed-off-by: Alexandru Vasile <[email protected]> * Update polkadot.rs Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Simplify client fetching Signed-off-by: Alexandru Vasile <[email protected]> * Address feedback and fallback to old API if needed Signed-off-by: Alexandru Vasile <[email protected]> * runtime_api: Make mutability conditional on input params Signed-off-by: Alexandru Vasile <[email protected]> * Regenerate polkadot.rs Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Retain only pallets without runtime API info Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Retry via `Metadata_metadata` without conversion Signed-off-by: Alexandru Vasile <[email protected]> * payload: Remove `Decode` and change validation fn Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Retain runtime API types Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Runtime APIs documentation based on flag Signed-off-by: Alexandru Vasile <[email protected]> * Update examples/examples/custom_metadata_url.rs Co-authored-by: James Wilson <[email protected]> * Update artifacts from polkadot-a6cfdb16e9 Signed-off-by: Alexandru Vasile <[email protected]> * Update polkadot.rs with polkadot-a6cfdb16e9 Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Generate input structures for runtime API Signed-off-by: Alexandru Vasile <[email protected]> * runtime_api: Remove the static paylaod and use single impl Signed-off-by: Alexandru Vasile <[email protected]> * examples: Fetch account nonce Signed-off-by: Alexandru Vasile <[email protected]> * testing: Adjust build script to fetch latest metadata Signed-off-by: Alexandru Vasile <[email protected]> * testing: Check account nonce from runtime API Signed-off-by: Alexandru Vasile <[email protected]> * Update cargo.lock Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Fix doc generation for runtime types Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Rename `inputs` runtime calls module to `types` Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Generate Calls structs inside the types module Signed-off-by: Alexandru Vasile <[email protected]> * testing: Check Alice account nonce before submitting the tx Signed-off-by: Alexandru Vasile <[email protected]> * cli: Add metadata version option flag supporting v14 and unstable Signed-off-by: Alexandru Vasile <[email protected]> * cli: Specify version to fetch Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Fallback to fetching latest stable metadata Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Add unstable-metadata feature to fetch the latest Signed-off-by: Alexandru Vasile <[email protected]> * RuntimeVersion with Latest and Version(u32) Signed-off-by: Alexandru Vasile <[email protected]> * Update polkadot.rs Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Adjust fetch_metadata to inspect version list Signed-off-by: Alexandru Vasile <[email protected]> * testing: Adjust metadata to metadata_legacy Signed-off-by: Alexandru Vasile <[email protected]> * events: Adjust docs to use metadata_legacy Signed-off-by: Alexandru Vasile <[email protected]> * have a pass over fetch_metadata * cargo fmt * Option<String> when fetch metadata via latest API * clippy * fmt * cli: Use the MetadataVersion from codegen Signed-off-by: Alexandru Vasile <[email protected]> * cli: Specify latest as default for MetadataVersion Signed-off-by: Alexandru Vasile <[email protected]> * cli: Remove version from metadata and use the one from file_or_url Signed-off-by: Alexandru Vasile <[email protected]> * Fix clippy Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Decode metadata independently for different RPC calls Signed-off-by: Alexandru Vasile <[email protected]> --------- Signed-off-by: Alexandru Vasile <[email protected]> Co-authored-by: James Wilson <[email protected]>
* Update frame-metadata to v15.1.0 Signed-off-by: Alexandru Vasile <[email protected]> * Enable V15 unstable metadata in frame-metadata Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Move validation hashing to dedicated file Signed-off-by: Alexandru Vasile <[email protected]> * Use sp-metadata-ir from substrate to work with metadata Signed-off-by: Alexandru Vasile <[email protected]> * Revert using sp-metadata-ir in favor of conversion to v15 Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Convert v14 to v15 Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Use v15 for validation Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Use v15 for codegen Signed-off-by: Alexandru Vasile <[email protected]> * metadata/bench: Use v15 Signed-off-by: Alexandru Vasile <[email protected]> * Adjust to v15 metadata Signed-off-by: Alexandru Vasile <[email protected]> * Adjust testing Signed-off-by: Alexandru Vasile <[email protected]> * Improve documentation Signed-off-by: Alexandru Vasile <[email protected]> * force CI Signed-off-by: Alexandru Vasile <[email protected]> * rpc: Fetch metadata at version Signed-off-by: Alexandru Vasile <[email protected]> * artifacts: Update polkadot.scale from commit 6dc9e84dde2 Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Fetch V15 using the new API Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Add runtime API interface Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Hash runtime API metadata for validation Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Extract runtime API metadata wrapper from subxt::Metadata Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Adjust hashing cache to reflect root+item keys Signed-off-by: Alexandru Vasile <[email protected]> * rpc: Add raw state_call API method Signed-off-by: Alexandru Vasile <[email protected]> * runtime_api: Add payload with static and dynamic variants Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Allow payloads to call into the runtime Signed-off-by: Alexandru Vasile <[email protected]> * examples: Add example to make a runtime API call both static and dynamic Signed-off-by: Alexandru Vasile <[email protected]> * Update polkadot.rs Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Simplify client fetching Signed-off-by: Alexandru Vasile <[email protected]> * Address feedback and fallback to old API if needed Signed-off-by: Alexandru Vasile <[email protected]> * runtime_api: Make mutability conditional on input params Signed-off-by: Alexandru Vasile <[email protected]> * Regenerate polkadot.rs Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Retain only pallets without runtime API info Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Retry via `Metadata_metadata` without conversion Signed-off-by: Alexandru Vasile <[email protected]> * payload: Remove `Decode` and change validation fn Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Retain runtime API types Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Runtime APIs documentation based on flag Signed-off-by: Alexandru Vasile <[email protected]> * Update examples/examples/custom_metadata_url.rs Co-authored-by: James Wilson <[email protected]> * Update artifacts from polkadot-a6cfdb16e9 Signed-off-by: Alexandru Vasile <[email protected]> * Update polkadot.rs with polkadot-a6cfdb16e9 Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Generate input structures for runtime API Signed-off-by: Alexandru Vasile <[email protected]> * runtime_api: Remove the static paylaod and use single impl Signed-off-by: Alexandru Vasile <[email protected]> * examples: Fetch account nonce Signed-off-by: Alexandru Vasile <[email protected]> * testing: Adjust build script to fetch latest metadata Signed-off-by: Alexandru Vasile <[email protected]> * testing: Check account nonce from runtime API Signed-off-by: Alexandru Vasile <[email protected]> * Update cargo.lock Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Fix doc generation for runtime types Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Rename `inputs` runtime calls module to `types` Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Generate Calls structs inside the types module Signed-off-by: Alexandru Vasile <[email protected]> * testing: Check Alice account nonce before submitting the tx Signed-off-by: Alexandru Vasile <[email protected]> * cli: Add metadata version option flag supporting v14 and unstable Signed-off-by: Alexandru Vasile <[email protected]> * cli: Specify version to fetch Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Fallback to fetching latest stable metadata Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Add unstable-metadata feature to fetch the latest Signed-off-by: Alexandru Vasile <[email protected]> * RuntimeVersion with Latest and Version(u32) Signed-off-by: Alexandru Vasile <[email protected]> * Update polkadot.rs Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Adjust fetch_metadata to inspect version list Signed-off-by: Alexandru Vasile <[email protected]> * testing: Adjust metadata to metadata_legacy Signed-off-by: Alexandru Vasile <[email protected]> * events: Adjust docs to use metadata_legacy Signed-off-by: Alexandru Vasile <[email protected]> * have a pass over fetch_metadata * cargo fmt * Option<String> when fetch metadata via latest API * clippy * fmt * cli: Use the MetadataVersion from codegen Signed-off-by: Alexandru Vasile <[email protected]> * cli: Specify latest as default for MetadataVersion Signed-off-by: Alexandru Vasile <[email protected]> * cli: Remove version from metadata and use the one from file_or_url Signed-off-by: Alexandru Vasile <[email protected]> * Fix clippy Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Decode metadata independently for different RPC calls Signed-off-by: Alexandru Vasile <[email protected]> --------- Signed-off-by: Alexandru Vasile <[email protected]> Co-authored-by: James Wilson <[email protected]>
* Update frame-metadata to v15.1.0 Signed-off-by: Alexandru Vasile <[email protected]> * Enable V15 unstable metadata in frame-metadata Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Move validation hashing to dedicated file Signed-off-by: Alexandru Vasile <[email protected]> * Use sp-metadata-ir from substrate to work with metadata Signed-off-by: Alexandru Vasile <[email protected]> * Revert using sp-metadata-ir in favor of conversion to v15 Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Convert v14 to v15 Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Use v15 for validation Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Use v15 for codegen Signed-off-by: Alexandru Vasile <[email protected]> * metadata/bench: Use v15 Signed-off-by: Alexandru Vasile <[email protected]> * Adjust to v15 metadata Signed-off-by: Alexandru Vasile <[email protected]> * Adjust testing Signed-off-by: Alexandru Vasile <[email protected]> * Improve documentation Signed-off-by: Alexandru Vasile <[email protected]> * force CI Signed-off-by: Alexandru Vasile <[email protected]> * rpc: Fetch metadata at version Signed-off-by: Alexandru Vasile <[email protected]> * artifacts: Update polkadot.scale from commit 6dc9e84dde2 Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Fetch V15 using the new API Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Add runtime API interface Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Hash runtime API metadata for validation Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Extract runtime API metadata wrapper from subxt::Metadata Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Adjust hashing cache to reflect root+item keys Signed-off-by: Alexandru Vasile <[email protected]> * rpc: Add raw state_call API method Signed-off-by: Alexandru Vasile <[email protected]> * runtime_api: Add payload with static and dynamic variants Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Allow payloads to call into the runtime Signed-off-by: Alexandru Vasile <[email protected]> * examples: Add example to make a runtime API call both static and dynamic Signed-off-by: Alexandru Vasile <[email protected]> * Update polkadot.rs Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Simplify client fetching Signed-off-by: Alexandru Vasile <[email protected]> * Address feedback and fallback to old API if needed Signed-off-by: Alexandru Vasile <[email protected]> * runtime_api: Make mutability conditional on input params Signed-off-by: Alexandru Vasile <[email protected]> * Regenerate polkadot.rs Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Retain only pallets without runtime API info Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Retry via `Metadata_metadata` without conversion Signed-off-by: Alexandru Vasile <[email protected]> * payload: Remove `Decode` and change validation fn Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Retain runtime API types Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Runtime APIs documentation based on flag Signed-off-by: Alexandru Vasile <[email protected]> * Update examples/examples/custom_metadata_url.rs Co-authored-by: James Wilson <[email protected]> * Update artifacts from polkadot-a6cfdb16e9 Signed-off-by: Alexandru Vasile <[email protected]> * Update polkadot.rs with polkadot-a6cfdb16e9 Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Generate input structures for runtime API Signed-off-by: Alexandru Vasile <[email protected]> * runtime_api: Remove the static paylaod and use single impl Signed-off-by: Alexandru Vasile <[email protected]> * examples: Fetch account nonce Signed-off-by: Alexandru Vasile <[email protected]> * testing: Adjust build script to fetch latest metadata Signed-off-by: Alexandru Vasile <[email protected]> * testing: Check account nonce from runtime API Signed-off-by: Alexandru Vasile <[email protected]> * Update cargo.lock Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Fix doc generation for runtime types Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Rename `inputs` runtime calls module to `types` Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Generate Calls structs inside the types module Signed-off-by: Alexandru Vasile <[email protected]> * testing: Check Alice account nonce before submitting the tx Signed-off-by: Alexandru Vasile <[email protected]> * cli: Add metadata version option flag supporting v14 and unstable Signed-off-by: Alexandru Vasile <[email protected]> * cli: Specify version to fetch Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Fallback to fetching latest stable metadata Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Add unstable-metadata feature to fetch the latest Signed-off-by: Alexandru Vasile <[email protected]> * RuntimeVersion with Latest and Version(u32) Signed-off-by: Alexandru Vasile <[email protected]> * Update polkadot.rs Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Adjust fetch_metadata to inspect version list Signed-off-by: Alexandru Vasile <[email protected]> * testing: Adjust metadata to metadata_legacy Signed-off-by: Alexandru Vasile <[email protected]> * events: Adjust docs to use metadata_legacy Signed-off-by: Alexandru Vasile <[email protected]> * have a pass over fetch_metadata * cargo fmt * Option<String> when fetch metadata via latest API * clippy * fmt * cli: Use the MetadataVersion from codegen Signed-off-by: Alexandru Vasile <[email protected]> * cli: Specify latest as default for MetadataVersion Signed-off-by: Alexandru Vasile <[email protected]> * cli: Remove version from metadata and use the one from file_or_url Signed-off-by: Alexandru Vasile <[email protected]> * Fix clippy Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Decode metadata independently for different RPC calls Signed-off-by: Alexandru Vasile <[email protected]> --------- Signed-off-by: Alexandru Vasile <[email protected]> Co-authored-by: James Wilson <[email protected]>
* speed up ui tests by reducing number of pallets * add small and tiny versions of polkadot metadata * change drop implementation fix test * rust yml add nextest and merge tests * 2 * 3 * 4 * 5 * 6 * add script for generating files * Upgrade to `syn 2.0` (#875) * WIP updating to syn 2.0.0 * WIP darling compat * Update darling and syn workspace deps * NestedMeta::parse_meta_list * Rename attribute keyword type property to path * Fmt * Update more type to path * Unused darling * Cargo.lock * Add missing syn features * Metadata V15: Generate Runtime APIs (#918) * Update frame-metadata to v15.1.0 Signed-off-by: Alexandru Vasile <[email protected]> * Enable V15 unstable metadata in frame-metadata Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Move validation hashing to dedicated file Signed-off-by: Alexandru Vasile <[email protected]> * Use sp-metadata-ir from substrate to work with metadata Signed-off-by: Alexandru Vasile <[email protected]> * Revert using sp-metadata-ir in favor of conversion to v15 Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Convert v14 to v15 Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Use v15 for validation Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Use v15 for codegen Signed-off-by: Alexandru Vasile <[email protected]> * metadata/bench: Use v15 Signed-off-by: Alexandru Vasile <[email protected]> * Adjust to v15 metadata Signed-off-by: Alexandru Vasile <[email protected]> * Adjust testing Signed-off-by: Alexandru Vasile <[email protected]> * Improve documentation Signed-off-by: Alexandru Vasile <[email protected]> * force CI Signed-off-by: Alexandru Vasile <[email protected]> * rpc: Fetch metadata at version Signed-off-by: Alexandru Vasile <[email protected]> * artifacts: Update polkadot.scale from commit 6dc9e84dde2 Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Fetch V15 using the new API Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Add runtime API interface Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Hash runtime API metadata for validation Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Extract runtime API metadata wrapper from subxt::Metadata Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Adjust hashing cache to reflect root+item keys Signed-off-by: Alexandru Vasile <[email protected]> * rpc: Add raw state_call API method Signed-off-by: Alexandru Vasile <[email protected]> * runtime_api: Add payload with static and dynamic variants Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Allow payloads to call into the runtime Signed-off-by: Alexandru Vasile <[email protected]> * examples: Add example to make a runtime API call both static and dynamic Signed-off-by: Alexandru Vasile <[email protected]> * Update polkadot.rs Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Simplify client fetching Signed-off-by: Alexandru Vasile <[email protected]> * Address feedback and fallback to old API if needed Signed-off-by: Alexandru Vasile <[email protected]> * runtime_api: Make mutability conditional on input params Signed-off-by: Alexandru Vasile <[email protected]> * Regenerate polkadot.rs Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Retain only pallets without runtime API info Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Retry via `Metadata_metadata` without conversion Signed-off-by: Alexandru Vasile <[email protected]> * payload: Remove `Decode` and change validation fn Signed-off-by: Alexandru Vasile <[email protected]> * metadata: Retain runtime API types Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Runtime APIs documentation based on flag Signed-off-by: Alexandru Vasile <[email protected]> * Update examples/examples/custom_metadata_url.rs Co-authored-by: James Wilson <[email protected]> * Update artifacts from polkadot-a6cfdb16e9 Signed-off-by: Alexandru Vasile <[email protected]> * Update polkadot.rs with polkadot-a6cfdb16e9 Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Generate input structures for runtime API Signed-off-by: Alexandru Vasile <[email protected]> * runtime_api: Remove the static paylaod and use single impl Signed-off-by: Alexandru Vasile <[email protected]> * examples: Fetch account nonce Signed-off-by: Alexandru Vasile <[email protected]> * testing: Adjust build script to fetch latest metadata Signed-off-by: Alexandru Vasile <[email protected]> * testing: Check account nonce from runtime API Signed-off-by: Alexandru Vasile <[email protected]> * Update cargo.lock Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Fix doc generation for runtime types Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Rename `inputs` runtime calls module to `types` Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Generate Calls structs inside the types module Signed-off-by: Alexandru Vasile <[email protected]> * testing: Check Alice account nonce before submitting the tx Signed-off-by: Alexandru Vasile <[email protected]> * cli: Add metadata version option flag supporting v14 and unstable Signed-off-by: Alexandru Vasile <[email protected]> * cli: Specify version to fetch Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Fallback to fetching latest stable metadata Signed-off-by: Alexandru Vasile <[email protected]> * subxt: Add unstable-metadata feature to fetch the latest Signed-off-by: Alexandru Vasile <[email protected]> * RuntimeVersion with Latest and Version(u32) Signed-off-by: Alexandru Vasile <[email protected]> * Update polkadot.rs Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Adjust fetch_metadata to inspect version list Signed-off-by: Alexandru Vasile <[email protected]> * testing: Adjust metadata to metadata_legacy Signed-off-by: Alexandru Vasile <[email protected]> * events: Adjust docs to use metadata_legacy Signed-off-by: Alexandru Vasile <[email protected]> * have a pass over fetch_metadata * cargo fmt * Option<String> when fetch metadata via latest API * clippy * fmt * cli: Use the MetadataVersion from codegen Signed-off-by: Alexandru Vasile <[email protected]> * cli: Specify latest as default for MetadataVersion Signed-off-by: Alexandru Vasile <[email protected]> * cli: Remove version from metadata and use the one from file_or_url Signed-off-by: Alexandru Vasile <[email protected]> * Fix clippy Signed-off-by: Alexandru Vasile <[email protected]> * codegen: Decode metadata independently for different RPC calls Signed-off-by: Alexandru Vasile <[email protected]> --------- Signed-off-by: Alexandru Vasile <[email protected]> Co-authored-by: James Wilson <[email protected]> * add small and tiny versions of polkadot metadata * add script for generating files * new metadata * Runtime APIs; don't ask for validation hash anywhere except new_static (#947) * remove validation hash where not wanted * .into() * fix example * cargo fmt * Subxt Guide (#890) * WIP Starting to write book; extrinsics first pass done * cargo fmt * Ongoing work; events, constants, wip blocks * at_latest() and wip blocks * remove need to import parity-scale-codec crate with Subxt for macro to work * More docs; expanding on setup guide and finish pass of main sections * Tidy and remove example section for now * format book lines to 100chars * Fix example code * cargo fmt * cargo fmt * fix example * Fix typos * fix broken doc links, pub mods * Update Subxt macro docs * can't link to Subxt here * move macro docs to Subxt to make linking better and fix example code * note on macro about docs * cargo fmt * document the no_default_derives macro feature * Address feedback and remove redundant text * address review comments; minor tweaks * WIP add Runtime calls to book * Improve Runtime API docs * expose thing we forgot to expose and doc link fixes * use new metadata files in book * use mtadata full in docs * regenerate polkadot.rs * use small metadata in a couple of places * Update scripts/artifacts.sh Co-authored-by: Niklas Adolfsson <[email protected]> --------- Signed-off-by: Alexandru Vasile <[email protected]> Co-authored-by: Andrew Jones <[email protected]> Co-authored-by: Alexandru Vasile <[email protected]> Co-authored-by: James Wilson <[email protected]> Co-authored-by: Niklas Adolfsson <[email protected]>
This PR adds support for the runtime API using the metadata exposed by substrate in paritytech/substrate#13302.
API Design
runtime_apis.rs generates a new runtime API interface that allows users to call directly into the runtime of substrate-based chains
The
Metadata_metadata
runtime function call is accessible viametadata().metadata()
. This preserves two indirections: one for the runtime API trait (identified by the firstmetadata()
) and one for the concrete function to call from the runtime trait. This follows the design decisions in subxt to utilize empty struct objects instead of paths for improved ergonomics and formatting.Arguments can be passed to the runtime functions that accept them. The provided arguments to the runtime function call are scale-encoded in the codegen directly.
codegen API using the
subxt
macroRuntime API Payload
This PR introduces two types of payloads:
StaticRuntimeApiPayload
andDynamicRuntimeApiPayload
.The payload that these types are built around takes in two generic parameters:
Each payload must implement the following trait:
The associated
ReturnType
is used for decoding the result of the function back to a provided type (either by codegen or "dynamically" by the user).StaticRuntimeApiPayload
This payload leverages the API exposed by the codegen and is strongly typed.
The arguments are provided by the codegen as scale-encoded bytes, which makes the generic argument data
Vec<u8>
. In this caseencode_args_to
ignores theMetadata
parameters and passes through the bytesobtained from the codegen directly.
Validation is enabled by default for these payloads, users can opt-out however using the
unvalidated()
method.DynamicRuntimeApiPayload
This offers users more control when it comes to making dynamic calls. Similar to transactions,
users can construct a dynamic runtime API payload from various objects and the subxt
will do its best to encode those objects to the shape of the runtime metadata.
Build on top of #912.
Closes paritytech/subxt-team-milestones#21.