Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Metadata V15: Expose types for the overarching Call, Event, Error enu…
Browse files Browse the repository at this point in the history
…ms (#14143)

* frame-metadata: Point to unreleased branch

Signed-off-by: Alexandru Vasile <[email protected]>

* frame: Generalize outer enum generation for events and errors

Signed-off-by: Alexandru Vasile <[email protected]>

* frame: Remove individual generation of outer enum events

Signed-off-by: Alexandru Vasile <[email protected]>

* primitives/traits: Add marker trait for outer runtime enums

Signed-off-by: Alexandru Vasile <[email protected]>

* frame: Derive Clone, PartialEq, Eq for RuntimeEvents only

Signed-off-by: Alexandru Vasile <[email protected]>

* frame/pallet: Include `#[pallet::error]` enum into pallet parts

Signed-off-by: Alexandru Vasile <[email protected]>

* metadata-ir: Include call, event, error types

Signed-off-by: Alexandru Vasile <[email protected]>

* frame/metadata: Include outer enum types in V15 metadata

Signed-off-by: Alexandru Vasile <[email protected]>

* frame/tests: Ensure `RuntimeError` includes `#[pallet::error]` parts

Signed-off-by: Alexandru Vasile <[email protected]>

* frame/support: Document the reserved name for `RuntimeError`

Signed-off-by: Alexandru Vasile <[email protected]>

* frame: Use self-generated `RuntimeEvent` for `GetRuntimeOuterEnumTypes`

Signed-off-by: Alexandru Vasile <[email protected]>

* frame/ui: Fix UI tests

Signed-off-by: Alexandru Vasile <[email protected]>

* frame/support: Remove unused system path

Signed-off-by: Alexandru Vasile <[email protected]>

* frame/ui: Unexpected field and reintroduce frame_system::Config for RuntimeCall

Signed-off-by: Alexandru Vasile <[email protected]>

* frame/support: Remove `GetRuntimeOuterEnumTypes` marker trait

Signed-off-by: Alexandru Vasile <[email protected]>

* frame/support: Remove `;` from macro

Signed-off-by: Alexandru Vasile <[email protected]>

* Update frame-metadata to point to unreleased branch

Signed-off-by: Alexandru Vasile <[email protected]>

* Rename error_enum_ty to module_error_enum_ty

Signed-off-by: Alexandru Vasile <[email protected]>

* Update module_error_ty documentation

Signed-off-by: Alexandru Vasile <[email protected]>

* frame: Implement from_dispatch_error

Signed-off-by: Alexandru Vasile <[email protected]>

* frame/support: Adjust test to ModuleErrorType

Signed-off-by: Alexandru Vasile <[email protected]>

* Fix clippy

Signed-off-by: Alexandru Vasile <[email protected]>

* Improve documentation

Signed-off-by: Alexandru Vasile <[email protected]>

* frame/tests: Check `from_dispatch_error` impl

Signed-off-by: Alexandru Vasile <[email protected]>

* Update frame-metadata

Signed-off-by: Alexandru Vasile <[email protected]>

* Remove the module_error_ty

Signed-off-by: Alexandru Vasile <[email protected]>

* Apply fmt

Signed-off-by: Alexandru Vasile <[email protected]>

* Revert unneeded parts

Signed-off-by: Alexandru Vasile <[email protected]>

* Revert "Revert unneeded parts"

This reverts commit b94bbd1.

Revert "Apply fmt"

This reverts commit 9b1c3e7.

Revert "Remove the module_error_ty"

This reverts commit 98de5b2.

* Update frame-metadata to origin/master

Signed-off-by: Alexandru Vasile <[email protected]>

* Add outerEnums to the metadata

Signed-off-by: Alexandru Vasile <[email protected]>

* Add tests

Signed-off-by: Alexandru Vasile <[email protected]>

* Keep backwards compatibility for explicit pallet parts

Signed-off-by: Alexandru Vasile <[email protected]>

* Rename tt_error_part to be more generic

Signed-off-by: Alexandru Vasile <[email protected]>

* Increase recursion_limit to 1k

Signed-off-by: Alexandru Vasile <[email protected]>

* Rename `fully_expanded` to `expanded`

Signed-off-by: Alexandru Vasile <[email protected]>

* Improve documentation

Signed-off-by: Alexandru Vasile <[email protected]>

* Adjust UI tests

Signed-off-by: Alexandru Vasile <[email protected]>

* Update UI tests

Signed-off-by: Alexandru Vasile <[email protected]>

* Update undefined_validate_unsigned_part.stderr UI test

Signed-off-by: Alexandru Vasile <[email protected]>

* Adjust yet again

Signed-off-by: Alexandru Vasile <[email protected]>

* Optimise macro expansions

Signed-off-by: Alexandru Vasile <[email protected]>

* Use latest frame-metadata and rename `moduleErrorType` to `RuntimeError`

Signed-off-by: Alexandru Vasile <[email protected]>

* Fix comment

Signed-off-by: Alexandru Vasile <[email protected]>

* Apply fmt

Signed-off-by: Alexandru Vasile <[email protected]>

* Update frame/support/procedural/src/construct_runtime/parse.rs

Co-authored-by: Bastian Köcher <[email protected]>

* Update frame/support/procedural/src/construct_runtime/parse.rs

Co-authored-by: Bastian Köcher <[email protected]>

* Update frame-metadata PR

Signed-off-by: Alexandru Vasile <[email protected]>

* Remove `expanded` from error messages and fix typo

Signed-off-by: Alexandru Vasile <[email protected]>

* Move docs to the function

Signed-off-by: Alexandru Vasile <[email protected]>

* ui: Use the intermed syntax for pallet parts

Signed-off-by: Alexandru Vasile <[email protected]>

* Update frame-metadata with latest release

Signed-off-by: Alexandru Vasile <[email protected]>

* frame: Address feedback for `from_dispatch_error`

Signed-off-by: Alexandru Vasile <[email protected]>

---------

Signed-off-by: Alexandru Vasile <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
  • Loading branch information
lexnv and bkchr authored Jun 28, 2023
1 parent a84f0af commit 9f6fecf
Show file tree
Hide file tree
Showing 33 changed files with 1,143 additions and 337 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
//! The Substrate runtime. This can be compiled with `#[no_std]`, ready for Wasm.
#![cfg_attr(not(feature = "std"), no_std)]
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 512.
#![recursion_limit = "512"]
// `construct_runtime!` does a lot of recursion and requires us to increase the limits.
#![recursion_limit = "1024"]

use codec::{Decode, Encode, MaxEncodedLen};
use frame_election_provider_support::{
Expand Down
2 changes: 1 addition & 1 deletion frame/support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
serde = { version = "1.0.163", default-features = false, features = ["alloc", "derive"] }
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
frame-metadata = { version = "15.1.0", default-features = false, features = ["v14", "v15-unstable"] }
frame-metadata = { version = "15.2.0", default-features = false, features = ["unstable"] }
sp-api = { version = "4.0.0-dev", default-features = false, path = "../../primitives/api" }
sp-std = { version = "8.0.0", default-features = false, path = "../../primitives/std" }
sp-io = { version = "23.0.0", default-features = false, path = "../../primitives/io" }
Expand Down
168 changes: 0 additions & 168 deletions frame/support/procedural/src/construct_runtime/expand/event.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License

use crate::construct_runtime::Pallet;
use crate::construct_runtime::{parse::PalletPath, Pallet};
use proc_macro2::TokenStream;
use quote::quote;
use std::str::FromStr;
Expand All @@ -26,6 +26,7 @@ pub fn expand_runtime_metadata(
pallet_declarations: &[Pallet],
scrate: &TokenStream,
extrinsic: &TypePath,
system_path: &PalletPath,
) -> TokenStream {
let pallets = pallet_declarations
.iter()
Expand Down Expand Up @@ -115,6 +116,13 @@ pub fn expand_runtime_metadata(
},
ty: #scrate::scale_info::meta_type::<#runtime>(),
apis: (&rt).runtime_metadata(),
outer_enums: #scrate::metadata_ir::OuterEnumsIR {
call_enum_ty: #scrate::scale_info::meta_type::<
<#runtime as #system_path::Config>::RuntimeCall
>(),
event_enum_ty: #scrate::scale_info::meta_type::<RuntimeEvent>(),
error_enum_ty: #scrate::scale_info::meta_type::<RuntimeError>(),
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions frame/support/procedural/src/construct_runtime/expand/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@

mod call;
mod config;
mod event;
mod freeze_reason;
mod hold_reason;
mod inherent;
mod lock_id;
mod metadata;
mod origin;
mod outer_enums;
mod slash_reason;
mod unsigned;

pub use call::expand_outer_dispatch;
pub use config::expand_outer_config;
pub use event::expand_outer_event;
pub use freeze_reason::expand_outer_freeze_reason;
pub use hold_reason::expand_outer_hold_reason;
pub use inherent::expand_outer_inherent;
pub use lock_id::expand_outer_lock_id;
pub use metadata::expand_runtime_metadata;
pub use origin::expand_outer_origin;
pub use outer_enums::{expand_outer_enum, OuterEnumType};
pub use slash_reason::expand_outer_slash_reason;
pub use unsigned::expand_outer_validate_unsigned;
Loading

0 comments on commit 9f6fecf

Please sign in to comment.