This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Metadata V15: Add Runtime API metadata #13302
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
lexnv
changed the base branch from
master
to
lexnv/md15_expose_md_at_versions
February 2, 2023 17:55
lexnv
added
B3-apinoteworthy
D2-notlive 💤
PR contains changes in a runtime directory that is not deployed to a chain that requires an audit.
D3-trivial 🧸
PR contains trivial changes in a runtime directory that do not require an audit
C1-low
PR touches the given topic and has a low impact on builders.
and removed
D2-notlive 💤
PR contains changes in a runtime directory that is not deployed to a chain that requires an audit.
labels
Feb 2, 2023
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
bkchr
approved these changes
Mar 30, 2023
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.
Thank you! Nice work! :)
bkchr
reviewed
Mar 30, 2023
bkchr
reviewed
Mar 30, 2023
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Bastian Köcher <git@kchr.de>
This reverts commit 3bafb29.
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
bot rebase |
Rebased |
sam0x17
approved these changes
Apr 10, 2023
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
bot merge |
This was referenced Apr 13, 2023
This pull request has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/april-updates-for-substrate-and-polkadot-devs/2764/1 |
2 tasks
This pull request has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/stablising-v15-metadata/2819/1 |
3 tasks
2 tasks
15 tasks
AurevoirXavier
added a commit
to darwinia-network/darwinia
that referenced
this pull request
Jul 11, 2023
nathanwhit
pushed a commit
to nathanwhit/substrate
that referenced
this pull request
Jul 19, 2023
* impl_runtime_apis: Generate getters for `metadata_at` functions Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * runtime: Implement new `Metadata` runtime trait Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * runtime: Move `metadata_at` functions to construct_runtime macro Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * contruct_runtime: Use `OpaqueMetadata` from hidden imports Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Adjust testing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/tests: Add tests for the new API Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/proc-macro: Helper to extract documentation literals Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/proc-macro: Helper to filter all `cfg` attributes Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/proc-macro: Generate documentation getters for metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/proc-macro: Avoid trait collision with snake case methods Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * proc-macro/tests: Check doc getters Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/proc-macro: Generate metadata for runtime methods Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/api: Export scale-info and frame-metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/proc-macro: Generate metadata for runtime traits Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/runtime: Expose metadata v15 internally Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * test: Use metadata v15 from `lexnv/md_v15_test` branch Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/proc-macro: Generate crate access one module up Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame: Implement `runtime_metadata` for mocks and tests Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/proc-macro: Fix warnings Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/proc-macro: Add no-docs flag Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame: Adjust more tests Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/tests: Check runtime metadata correctness Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/benchmarking: Adjust benchmarks Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/benchmarks: Adjust more benchmarks Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/api: Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/proc-macro: Generate runtime metadata on the `decl_runtime_apis` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame: Abuse Deref to resolve `runtime_metadata` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Revert "frame: Implement `runtime_metadata` for mocks and tests" This reverts commit e4782de. Revert "frame: Adjust more tests" This reverts commit de1352c. Revert "frame/benchmarking: Adjust benchmarks" This reverts commit ae85bbe. Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Revert "frame/benchmarks: Adjust more benchmarks" This reverts commit d37aa22. * primitives/proc-macro: Remove unused imports and function Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/support: Adjust runtime metadata test Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/tests: Remove doc getter test Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/support: Enable `no-metadata-docs` feature from `sp-api` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/tests: Add `TypeInfo` for test::extrinsic Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/api: Expose scale-info and frame-metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update frame-metadata to include v15 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix merge conflicts Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/metadata_ir: Add IR for runtime API metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/metadata_ir: Convert IR to V15 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/api: Collect IR metadata for runtime API Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/api: Move `metadata_ir` from frame/support Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/tests: Adjust testing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/tests: Adjust `metadata_versions` test Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/runtime_metadata: Exclude default type parameters from methods Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update primitives/api/proc-macro/src/runtime_metadata.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/src/metadata_ir/types.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/src/metadata_ir/mod.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/proc-macro/src/utils.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/proc-macro/src/runtime_metadata.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/proc-macro/src/runtime_metadata.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/proc-macro/src/runtime_metadata.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/proc-macro/src/runtime_metadata.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/proc-macro/src/runtime_metadata.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/proc-macro/src/runtime_metadata.rs Co-authored-by: Bastian Köcher <git@kchr.de> * primitives: Fix build Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/metadata-ir: Move IR to dedicated crate Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives: Reexport metadata-ir and frame-metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame: Use apis field instead of runtime Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Better documentation for the `Deref` abstraction Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * ui-tests: Check empty `impl_runtime_apis` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives: Remove unneeded bounds on generic params Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives: Rename `collect_where_bounds` to `get_argument_type_param` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives: Generate crate access per fn call Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Revert "primitives: Remove unneeded bounds on generic params" This reverts commit 5178e38. * metadata-ir: Add no-std Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives: Adjust where bounds Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Change `frame-metadata` branch to "origin/main" Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update to `main` from origin Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update frame-metadata to crates.io v15.1 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Revert "ui-tests: Check empty `impl_runtime_apis`" This reverts commit cf78a71. * Move ui test to primitives/ui Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update frame/support/test/tests/runtime_metadata.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/proc-macro/src/runtime_metadata.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Test already covered by `empty_impl_runtime_apis_call.stderr` This reverts commit 3bafb29. * Retriger CI Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Import `TokenStream` as `TokenStream2` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: parity-processbot <> Co-authored-by: Bastian Köcher <git@kchr.de>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
A0-please_review
Pull request needs code review.
B1-note_worthy
Changes should be noted in the release notes
C1-low
PR touches the given topic and has a low impact on builders.
D3-trivial 🧸
PR contains trivial changes in a runtime directory that do not require an audit
T1-runtime
This PR/Issue is related to the topic “runtime”.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR collects the runtime API information for the metadata V15 and
exposes the metadata under
metadata_at_version(u32::MAX)
.Considering both
sp-api
andframe-support
crates need access to themetadata_ir (an intermediate representation of the metadata that can be converted
into multiple metadata versions), and
frame-support
depends onsp-api
, themetadata_ir has been moved to
sp-api
.Implementation Details
decl_runtime_apis
Collects the runtime metadata of each declared trait using the metadata IR
and exposes the
runtime_metadata
. The collection of the metadata happensat this stage because it preserves trait and method documentation, as well as
method parameter names.
impl_runtime_apis
This is the stage at which we definitely know which runtime traits are implemented for
the given Runtime. The macro collects all the
RuntimeApiMetadataIR
by callingruntime_metadata
of each trait.The
runtime_metadata
function is exposed using theInternalImplRuntimeApis
trait.InternalImplRuntimeApis and InternalConstructRuntime
There are many tests that use independently just the
impl_runtime_apis
or justconstruct_runtime
.However, only the
impl_runtime_apis
has access to the runtime metadata API.To avoid a breaking change, the following behavior is desired:
construct_runtime
is used aruntime_metadata
method should return an empty runtime metadata APIconstruct_runtime
andimpl_runtime_apis
are used together, theruntime_metadata
method should be deduced from theimpl_runtime_apis
macroThis is indeed the behavior exposed by rust unstable specialization: rust-lang/rust#31844 feature.
One way of circumventing this is by introducing 2 traits
impl_runtime_apis
implementsInternalImplRuntimeApis
on theRuntime
itself (strongest pick by the compiler forruntime_metadata()
fn). Whileconstruct_runtime
implementsInternalConstructRuntime
on the& Runtime
.Using the
Deref
guarantees, if we are only usingconstruct_runtime
: the runtime will return an empty runtime metadata (avoid breaking change). Otherwise, when implementing both traits theruntime_metadata
is deduced to be part of theInternalImplRuntimeApis
that contains the complete runtime metadata API.construct_runtime
This macro puts together the metadata IR and implements the
InternalConstructRuntime
for avoiding breaking changes.Part of: #12939.
Testing Done
Frame-metadata PR: paritytech/frame-metadata#48
Subxt PoC branch for generating the runtime interface subxt/lexnv/metadata_v15, example from subxt/lexnv/runtime_calls
Runtime API metadata extracted from substrate for the
Metadata
trait:Next Steps
docs
flag similar to framedecl_runtime_api
(poc commit)cumulus companion: paritytech/cumulus#2357
cc @paritytech/subxt-team