Skip to content
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

v16: Expose the unstable metadata v16 #5732

Merged
merged 87 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
7e8baee
metadata-ir: Introduce PalletAssociatedTypeMetadata
lexnv Aug 7, 2024
1c12f15
frame/config: Add associated types to parsed config
lexnv Aug 7, 2024
20b22d8
frame/expand: Implement associated types expansion
lexnv Aug 7, 2024
350efce
frame/expand: Use provided cfgs for the associated types
lexnv Aug 7, 2024
3e97971
frame/construct_runtime: Extract associated types from pallet config
lexnv Aug 7, 2024
5d8021e
frame/pallet: Introduce `config(without_metadata)`
lexnv Aug 7, 2024
5679244
frame/pallet: Introduce `#[pallet::include_metadata]` for associated
lexnv Aug 7, 2024
958611e
frame/pallet: Include associated type iff bounds contain TypeInfo
lexnv Aug 7, 2024
7f26b67
frame/pallet: Proper flag for metdata collection
lexnv Aug 7, 2024
cc001f3
frame/tests/ui: Fix type in test
lexnv Aug 8, 2024
b2803e2
frame/tests/ui: Check config without metadata
lexnv Aug 8, 2024
94007d8
frame/tests/ui: Check config with multiple attributes
lexnv Aug 8, 2024
75d2697
frame/tests/ui: Add negative test for duplicate attributes in config
lexnv Aug 8, 2024
ebcb4a0
frame/tests/ui: Add negative test for collecting metadata from constants
lexnv Aug 8, 2024
5115021
frame/tests/ui: Add negative test for metadata collection on events
lexnv Aug 8, 2024
aba029a
frame/tests: Check PalletAssociatedTypeMetadataIR collection
lexnv Aug 8, 2024
6502c83
frame/support: Add documentation
lexnv Aug 8, 2024
e9571cb
Add PRdoc
lexnv Aug 8, 2024
31bf284
Merge remote-tracking branch 'origin/master' into lexnv/metadata-v16-…
lexnv Aug 8, 2024
7429eb7
Update prdoc
lexnv Aug 8, 2024
8a0c138
prdoc: Remove unneeded crate
lexnv Aug 8, 2024
c6c1800
prdoc: Include frame-support
lexnv Aug 8, 2024
90c100c
Prupdate
lexnv Aug 8, 2024
fc87031
metadata-ir: Add v16 wrappers in preparation for frame-md release
lexnv Sep 13, 2024
f627476
Merge remote-tracking branch 'origin/master' into lexnv/metadata-v16-…
lexnv Sep 13, 2024
b533f60
metadata-ir: Add conversion methods
lexnv Sep 13, 2024
e298259
metadata-ir: Enable v16 version as unstable
lexnv Sep 13, 2024
d0ff8f4
metadata-ir: Fix into stable conversion
lexnv Sep 13, 2024
4060637
frame-md: Use git dependency instead
lexnv Sep 16, 2024
adf7508
metadata-ir: Adjust for new transaction format
lexnv Sep 16, 2024
2982c59
Merge remote-tracking branch 'origin/master' into lexnv/metadata-v16-…
lexnv Sep 16, 2024
4ee1d7f
Merge branch 'lexnv/metadata-v16-associated-types' into lexnv/metadat…
lexnv Sep 16, 2024
97eb703
cargo: Use frame-metadata 17
lexnv Oct 25, 2024
a95183e
Merge remote-tracking branch 'origin/master' into lexnv/metadata-v16-…
lexnv Oct 25, 2024
6ff6f37
metadata-ir: Adjust metadata
lexnv Oct 25, 2024
fba3502
metadata-ir: Prepare metadataIR for multiple version collection
lexnv Oct 25, 2024
ca2b0f0
Add prdoc
lexnv Oct 25, 2024
daf8dc3
Merge remote-tracking branch 'origin/master' into lexnv/metadata-v16-…
lexnv Oct 25, 2024
379ec83
Update substrate/frame/metadata-hash-extension/Cargo.toml
lexnv Oct 30, 2024
475288c
Update cargo lock with pending branches
lexnv Nov 7, 2024
195e514
Update prdoc
lexnv Nov 7, 2024
332a900
metadata-ir/v14: Populate with lowest supported version
lexnv Nov 7, 2024
f9b635d
metadata-ir/unstable: Adjust for new frame-md version
lexnv Nov 7, 2024
ce42813
extrinsic: Modify ExtrinsicMetadata to return a Vec of versions
lexnv Nov 7, 2024
bdf9e7e
metadata-ir: Use IR versions instead of hardcoding
lexnv Nov 7, 2024
7ed95ff
Update substrate/primitives/metadata-ir/src/v15.rs
lexnv Nov 11, 2024
b81abd8
Update substrate/primitives/runtime/src/traits/mod.rs
lexnv Nov 11, 2024
1384674
metadata-ir: Assume version 0 for transaction_extensions
lexnv Nov 11, 2024
aef4a5c
Update cargo to latest
lexnv Nov 11, 2024
628616e
Update Cargo.toml
lexnv Nov 11, 2024
0c8efe9
Merge remote-tracking branch 'origin/lexnv/metadata-v16-associated-ty…
lexnv Nov 11, 2024
2390a7b
Update cargo lock with unreleased branch
lexnv Nov 11, 2024
b5a45a4
Merge remote-tracking branch 'origin/master' into lexnv/metadata-v16-…
lexnv Nov 11, 2024
eeb7e4a
metadata-ir: Do not specify vec
lexnv Nov 12, 2024
06c0eb3
Update PRdoc
lexnv Nov 12, 2024
e0b9c32
cargo: Update merkleized-metadata to unreleased branch
lexnv Nov 12, 2024
5e7aada
Merge remote-tracking branch 'origin/master' into lexnv/metadata-v16-…
lexnv Nov 12, 2024
d05af73
cargo: Update dependencies
lexnv Nov 15, 2024
3e611b1
Merge branch 'master' into lexnv/metadata-v16-associated-types-enable…
lexnv Nov 15, 2024
0979d1a
benchmark-cli/overhead: Select latest stable version for metadata
lexnv Nov 18, 2024
e378438
Merge remote-tracking branch 'origin/lexnv/metadata-v16-associated-ty…
lexnv Nov 18, 2024
f7dfa0d
Add space to cargo.toml features
lexnv Nov 18, 2024
bb682dd
utils/cli: Use latest stable metadata for tests
lexnv Nov 18, 2024
15b361c
frame/support: Check unstable metadata is propagated
lexnv Nov 18, 2024
8747a92
Update PRdoc
lexnv Nov 18, 2024
e397ca8
Merge branch 'master' into lexnv/metadata-v16-associated-types-enable…
lexnv Nov 18, 2024
75d2f94
Update from lexnv running command 'prdoc --audience node_dev --bump p…
actions-user Nov 18, 2024
cae9c1e
Update PRdoc
lexnv Nov 18, 2024
0de89ed
Merge branch 'master' into lexnv/metadata-v16-associated-types-enable…
lexnv Nov 19, 2024
9b251c4
ci: Check-semver update CI to stable
lexnv Nov 19, 2024
1f4ae8c
ci: Update to nightly as toolchain for semvercheck
lexnv Nov 19, 2024
4a23b69
ci: Use an older nightly version
lexnv Nov 19, 2024
f6b9aa3
ci: Switch to v0.9 instead
lexnv Nov 19, 2024
5a9c623
Merge branch 'master' into lexnv/metadata-v16-associated-types-enable…
lexnv Nov 19, 2024
d64fd33
Revert CI changes for a followup
lexnv Nov 19, 2024
61bf04f
Include semver-fix
lexnv Nov 20, 2024
9293fca
Adjust PRdoc
lexnv Nov 20, 2024
10d6bcb
Bump none for frame tests support crate
lexnv Nov 20, 2024
8da158a
Merge branch 'master' into lexnv/metadata-v16-associated-types-enable…
lexnv Nov 20, 2024
6cf31bc
prdoc: Make frame-support-test a patch again
lexnv Nov 20, 2024
c52b80c
prdoc: Remove frame-support-test
lexnv Nov 20, 2024
3f61d31
prdoc: Add frame-support-test as Minor bump
lexnv Nov 20, 2024
bc98d08
prdoc: Bump as major
lexnv Nov 20, 2024
60cf5fe
Update .github/workflows/check-semver.yml
lexnv Nov 21, 2024
e5bfbcd
Merge remote-tracking branch 'origin/master' into lexnv/metadata-v16-…
lexnv Nov 26, 2024
dc57834
Merge branch 'master' into lexnv/metadata-v16-associated-types-enable…
lexnv Nov 27, 2024
e68ecbd
prdoc: Replace description |- with |
lexnv Nov 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ frame-benchmarking-pallet-pov = { default-features = false, path = "substrate/fr
frame-election-provider-solution-type = { path = "substrate/frame/election-provider-support/solution-type", default-features = false }
frame-election-provider-support = { path = "substrate/frame/election-provider-support", default-features = false }
frame-executive = { path = "substrate/frame/executive", default-features = false }
frame-metadata = { version = "16.0.0", default-features = false }
frame-metadata = { version = "18.0.0", default-features = false }
frame-metadata-hash-extension = { path = "substrate/frame/metadata-hash-extension", default-features = false }
frame-support = { path = "substrate/frame/support", default-features = false }
frame-support-procedural = { path = "substrate/frame/support/procedural", default-features = false }
Expand Down Expand Up @@ -854,7 +854,7 @@ macro_magic = { version = "0.5.1" }
maplit = { version = "1.0.2" }
memmap2 = { version = "0.9.3" }
memory-db = { version = "0.32.0", default-features = false }
merkleized-metadata = { version = "0.1.0" }
merkleized-metadata = { version = "0.1.2" }
merlin = { version = "3.0", default-features = false }
messages-relay = { path = "bridges/relays/messages" }
metered = { version = "0.6.1", default-features = false, package = "prioritized-metered-channel" }
Expand Down
29 changes: 29 additions & 0 deletions prdoc/pr_5732.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
title: Expose the unstable metadata v16
doc:
- audience: Node Dev
description: |
This PR exposes the *unstable* metadata V16. The metadata is exposed under the unstable u32::MAX number.
Developers can start experimenting with the new features of the metadata v16. *Please note that this metadata is under development and expect breaking changes until stabilization.*
The `ExtrinsicMetadata` trait receives a breaking change. Its associated type `VERSION` is rename to `VERSIONS` and now supports a constant static list of metadata versions.
The versions implemented for `UncheckedExtrinsic` are v4 (legacy version) and v5 (new version).
For metadata collection, it is assumed that all `TransactionExtensions` are under version 0.

crates:
- name: sp-metadata-ir
bump: major
- name: frame-support-procedural
bump: patch
- name: frame-support
bump: minor
- name: frame-support-test
bump: major
- name: frame-metadata-hash-extension
bump: patch
- name: substrate-wasm-builder
bump: minor
- name: pallet-revive
bump: minor
- name: sp-runtime
bump: major
- name: frame-benchmarking-cli
bump: patch
lexnv marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion substrate/frame/metadata-hash-extension/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ substrate-test-runtime-client = { workspace = true }
sp-api = { workspace = true, default-features = true }
sp-transaction-pool = { workspace = true, default-features = true }
merkleized-metadata = { workspace = true }
frame-metadata = { features = ["current"], workspace = true, default-features = true }
frame-metadata = { features = ["current", "unstable"], workspace = true, default-features = true }
sp-tracing = { workspace = true, default-features = true }

[features]
Expand Down
8 changes: 6 additions & 2 deletions substrate/frame/revive/src/evm/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ impl<Address: TypeInfo, Signature: TypeInfo, E: EthExtra> ExtrinsicLike
impl<Address, Signature, E: EthExtra> ExtrinsicMetadata
for UncheckedExtrinsic<Address, Signature, E>
{
const VERSION: u8 =
generic::UncheckedExtrinsic::<Address, CallOf<E::Config>, Signature, E::Extension>::VERSION;
const VERSIONS: &'static [u8] = generic::UncheckedExtrinsic::<
Address,
CallOf<E::Config>,
Signature,
E::Extension,
>::VERSIONS;
type TransactionExtensions = E::Extension;
}

Expand Down
1 change: 1 addition & 0 deletions substrate/frame/support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ scale-info = { features = [
], workspace = true }
frame-metadata = { features = [
"current",
"unstable",
], workspace = true }
sp-api = { features = [
"frame-metadata",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub fn expand_runtime_metadata(
pallets: #scrate::__private::vec![ #(#pallets),* ],
extrinsic: #scrate::__private::metadata_ir::ExtrinsicMetadataIR {
ty,
version: <#extrinsic as #scrate::sp_runtime::traits::ExtrinsicMetadata>::VERSION,
versions: <#extrinsic as #scrate::sp_runtime::traits::ExtrinsicMetadata>::VERSIONS.into_iter().map(|ref_version| *ref_version).collect(),
address_ty,
call_ty,
signature_ty,
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/support/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static_assertions = { workspace = true, default-features = true }
serde = { features = ["derive"], workspace = true }
codec = { features = ["derive"], workspace = true }
scale-info = { features = ["derive"], workspace = true }
frame-metadata = { features = ["current"], workspace = true }
frame-metadata = { features = ["current", "unstable"], workspace = true }
sp-api = { workspace = true }
sp-arithmetic = { workspace = true }
sp-io = { workspace = true }
Expand Down
8 changes: 7 additions & 1 deletion substrate/frame/support/test/tests/pallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ parameter_types! {
/// Latest stable metadata version used for testing.
const LATEST_METADATA_VERSION: u32 = 15;

/// Unstable metadata version.
const UNSTABLE_METADATA_VERSION: u32 = u32::MAX;

pub struct SomeType1;
impl From<SomeType1> for u64 {
fn from(_t: SomeType1) -> Self {
Expand Down Expand Up @@ -1977,7 +1980,10 @@ fn metadata_at_version() {

#[test]
fn metadata_versions() {
assert_eq!(vec![14, LATEST_METADATA_VERSION], Runtime::metadata_versions());
assert_eq!(
vec![14, LATEST_METADATA_VERSION, UNSTABLE_METADATA_VERSION],
Runtime::metadata_versions()
);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion substrate/primitives/metadata-ir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { workspace = true }
frame-metadata = { features = ["current"], workspace = true }
frame-metadata = { features = ["current", "unstable"], workspace = true }
scale-info = { features = ["derive"], workspace = true }

[features]
Expand Down
25 changes: 21 additions & 4 deletions substrate/primitives/metadata-ir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ mod types;
use frame_metadata::RuntimeMetadataPrefixed;
pub use types::*;

mod unstable;
mod v14;
mod v15;

Expand All @@ -39,23 +40,33 @@ const V14: u32 = 14;
/// Metadata V15.
const V15: u32 = 15;

/// Unstable metadata V16.
const UNSTABLE_V16: u32 = u32::MAX;

/// Transform the IR to the specified version.
///
/// Use [`supported_versions`] to find supported versions.
pub fn into_version(metadata: MetadataIR, version: u32) -> Option<RuntimeMetadataPrefixed> {
// Note: Unstable metadata version is `u32::MAX` until stabilized.
match version {
// Latest stable version.
// Version V14. This needs to be around until the
// deprecation of the `Metadata_metadata` runtime call in favor of
// `Metadata_metadata_at_version.
V14 => Some(into_v14(metadata)),
// Unstable metadata.

// Version V15 - latest stable.
V15 => Some(into_latest(metadata)),

// Unstable metadata under `u32::MAX`.
UNSTABLE_V16 => Some(into_unstable(metadata)),

_ => None,
}
}

/// Returns the supported metadata versions.
pub fn supported_versions() -> alloc::vec::Vec<u32> {
alloc::vec![V14, V15]
alloc::vec![V14, V15, UNSTABLE_V16]
}

/// Transform the IR to the latest stable metadata version.
Expand All @@ -70,6 +81,12 @@ pub fn into_v14(metadata: MetadataIR) -> RuntimeMetadataPrefixed {
latest.into()
}

/// Transform the IR to unstable metadata version 16.
pub fn into_unstable(metadata: MetadataIR) -> RuntimeMetadataPrefixed {
let latest: frame_metadata::v16::RuntimeMetadataV16 = metadata.into();
latest.into()
}

#[cfg(test)]
mod test {
use super::*;
Expand All @@ -81,7 +98,7 @@ mod test {
pallets: vec![],
extrinsic: ExtrinsicMetadataIR {
ty: meta_type::<()>(),
version: 0,
versions: vec![0],
address_ty: meta_type::<()>(),
call_ty: meta_type::<()>(),
signature_ty: meta_type::<()>(),
Expand Down
6 changes: 3 additions & 3 deletions substrate/primitives/metadata-ir/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ pub struct ExtrinsicMetadataIR<T: Form = MetaForm> {
///
/// Note: Field used for metadata V14 only.
pub ty: T::Type,
/// Extrinsic version.
pub version: u8,
lexnv marked this conversation as resolved.
Show resolved Hide resolved
/// Extrinsic versions.
pub versions: Vec<u8>,
/// The type of the address that signs the extrinsic
pub address_ty: T::Type,
/// The type of the outermost Call enum.
Expand All @@ -191,7 +191,7 @@ impl IntoPortable for ExtrinsicMetadataIR {
fn into_portable(self, registry: &mut Registry) -> Self::Output {
ExtrinsicMetadataIR {
ty: registry.register_type(&self.ty),
version: self.version,
versions: self.versions,
address_ty: registry.register_type(&self.address_ty),
call_ty: registry.register_type(&self.call_ty),
signature_ty: registry.register_type(&self.signature_ty),
Expand Down
Loading
Loading