diff --git a/Cargo.lock b/Cargo.lock index 48f0a31f5..83bfc9dc6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4607,6 +4607,7 @@ dependencies = [ "asset-hub-polkadot-runtime", "cumulus-pallet-xcm", "cumulus-primitives-core", + "frame-metadata-hash-extension", "frame-support", "frame-system", "itertools 0.11.0", @@ -5864,6 +5865,20 @@ dependencies = [ "hash-db", ] +[[package]] +name = "merkleized-metadata" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f313fcff1d2a4bcaa2deeaa00bf7530d77d5f7bd0467a117dde2e29a75a7a17a" +dependencies = [ + "array-bytes", + "blake3", + "frame-metadata", + "parity-scale-codec", + "scale-decode", + "scale-info", +] + [[package]] name = "merlin" version = "3.0.0" @@ -8784,6 +8799,7 @@ dependencies = [ "cumulus-primitives-utility", "frame-benchmarking", "frame-executive", + "frame-metadata-hash-extension", "frame-support", "frame-system", "frame-system-benchmarking", @@ -12718,6 +12734,29 @@ dependencies = [ "sp-arithmetic", ] +[[package]] +name = "scale-bits" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e57b1e7f6b65ed1f04e79a85a57d755ad56d76fdf1e9bddcc9ae14f71fcdcf54" +dependencies = [ + "parity-scale-codec", + "scale-type-resolver", +] + +[[package]] +name = "scale-decode" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e98f3262c250d90e700bb802eb704e1f841e03331c2eb815e46516c4edbf5b27" +dependencies = [ + "derive_more", + "parity-scale-codec", + "scale-bits", + "scale-type-resolver", + "smallvec", +] + [[package]] name = "scale-info" version = "2.11.3" @@ -12744,6 +12783,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "scale-type-resolver" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0cded6518aa0bd6c1be2b88ac81bf7044992f0f154bfbabd5ad34f43512abcb" + [[package]] name = "schannel" version = "0.1.23" @@ -14700,13 +14745,22 @@ version = "23.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dc993ad871b63fbba60362f3ea86583f5e7e1256e8fdcb3b5b249c9ead354bf" dependencies = [ + "array-bytes", "build-helper", "cargo_metadata", "console", "filetime", + "frame-metadata", + "merkleized-metadata", + "parity-scale-codec", "parity-wasm", "polkavm-linker", + "sc-executor", + "sp-core", + "sp-io", "sp-maybe-compressed-blob", + "sp-tracing", + "sp-version", "strum 0.26.3", "tempfile", "toml 0.8.15", diff --git a/Cargo.toml b/Cargo.toml index 8e93ee393..951f2d8d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -119,6 +119,7 @@ frame-system = { version = "35.0.0", default-features = false } frame-system-rpc-runtime-api = { version = "33.0.0", default-features = false } frame-system-benchmarking = { version = "35.0.0", default-features = false } frame-try-runtime = { version = "0.41.0", default-features = false } +frame-metadata-hash-extension = { version = "0.3.0", default-features = false } sp-api = { version = "33.0.0", default-features = false } sp-debug-derive = { version = "14.0.0", default-features = false } sp-std = { version = "14.0.0", default-features = false } diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 69a8d18b7..1c848f2de 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -74,6 +74,7 @@ itertools.workspace = true pallet-democracy.workspace = true pallet-scheduler.workspace = true pallet-treasury.workspace = true +frame-metadata-hash-extension.workspace = true # Runtimes polkadot-runtime.workspace = true diff --git a/integration-tests/src/tests/credentials.rs b/integration-tests/src/tests/credentials.rs index d4c1c174c..81d9b49a6 100644 --- a/integration-tests/src/tests/credentials.rs +++ b/integration-tests/src/tests/credentials.rs @@ -79,6 +79,7 @@ fn dispenser_signed_extensions_pass_for_new_account() { pallet_dispenser::extensions::CheckNonce::::from(0u32), frame_system::CheckWeight::::new(), pallet_transaction_payment::ChargeTransactionPayment::::from(0u64.into()).into(), + frame_metadata_hash_extension::CheckMetadataHash::::new(true), ); assert_err!( extra.validate(&who, &paid_call, &paid_call.get_dispatch_info(), 0), diff --git a/runtimes/polimec/Cargo.toml b/runtimes/polimec/Cargo.toml index 21477dd59..1cbe3c160 100644 --- a/runtimes/polimec/Cargo.toml +++ b/runtimes/polimec/Cargo.toml @@ -14,7 +14,7 @@ version.workspace = true workspace = true [build-dependencies] -substrate-wasm-builder.workspace = true +substrate-wasm-builder = { workspace = true, optional = true } [dependencies] parity-scale-codec = { workspace= true, default-features = false, features = [ @@ -184,6 +184,8 @@ std = [ "xcm-builder/std", "xcm-executor/std", "xcm/std", + "substrate-wasm-builder", + "frame-metadata-hash-extension/std" ] runtime-benchmarks = [ @@ -277,9 +279,11 @@ try-runtime = [ # A feature that should be enabled when the runtime should be built for on-chain # deployment. This will disable stuff that shouldn't be part of the on-chain wasm # to make it smaller, like logging for example. -on-chain-release-build = [ - "pallet-funding/on-chain-release-build", - "sp-api/disable-logging", -] +on-chain-release-build = [ "sp-api/disable-logging", "pallet-funding/on-chain-release-build", "metadata-hash" ] development-settings = [ "shared-configuration/development-settings" ] + +# Enable the metadata hash generation in the wasm-builder +metadata-hash = [ + "substrate-wasm-builder?/metadata-hash", +] diff --git a/runtimes/polimec/build.rs b/runtimes/polimec/build.rs index fcbbf573c..d8e369ce5 100644 --- a/runtimes/polimec/build.rs +++ b/runtimes/polimec/build.rs @@ -14,8 +14,17 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use substrate_wasm_builder::WasmBuilder; +#[cfg(all(feature = "std", feature = "metadata-hash"))] +fn main() { + substrate_wasm_builder::WasmBuilder::init_with_defaults().enable_metadata_hash("PLMC", 10).build(); +} +#[cfg(all(feature = "std", not(feature = "metadata-hash")))] fn main() { - WasmBuilder::new().with_current_project().export_heap_base().import_memory().build(); + substrate_wasm_builder::WasmBuilder::build_using_defaults(); } + +/// The wasm builder is deactivated when compiling +/// this crate for wasm to speed up the compilation. +#[cfg(not(feature = "std"))] +fn main() {} diff --git a/runtimes/polimec/src/lib.rs b/runtimes/polimec/src/lib.rs index 953c3ed85..db0447098 100644 --- a/runtimes/polimec/src/lib.rs +++ b/runtimes/polimec/src/lib.rs @@ -149,6 +149,7 @@ pub type SignedExtra = ( Runtime, pallet_transaction_payment::ChargeTransactionPayment, >, + frame_metadata_hash_extension::CheckMetadataHash, ); /// Unchecked extrinsic type as expected by this runtime. @@ -901,6 +902,7 @@ where pallet_dispenser::extensions::SkipCheckIfFeeless::from( pallet_transaction_payment::ChargeTransactionPayment::::from(tip), ), + frame_metadata_hash_extension::CheckMetadataHash::::new(true), ); let raw_payload = generic::SignedPayload::new(call, extra) .map_err(|e| {