diff --git a/.github/workflows/build-deterministic-runtime.yml b/.github/workflows/build-deterministic-runtime.yml index 5f192f34..eb6136bd 100644 --- a/.github/workflows/build-deterministic-runtime.yml +++ b/.github/workflows/build-deterministic-runtime.yml @@ -32,6 +32,9 @@ jobs: - name: Build ${{ matrix.runtime }} runtime id: srtool_build uses: chevdor/srtool-actions@v0.9.2 + env: + # Includes metadata hash for production chains. + BUILD_OPTS: "--features on-chain-release-build" with: chain: ${{ matrix.runtime }} diff --git a/Cargo.lock b/Cargo.lock index 4cde9e06..43e9b23e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5270,9 +5270,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "lru" @@ -5391,6 +5391,7 @@ dependencies = [ "fp-self-contained", "frame-benchmarking", "frame-executive", + "frame-metadata-hash-extension", "frame-support", "frame-system", "frame-system-benchmarking", @@ -5530,6 +5531,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" @@ -11505,6 +11520,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" @@ -11531,6 +11569,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" @@ -13184,13 +13228,22 @@ name = "substrate-wasm-builder" version = "24.0.0" source = "git+https://github.com/paritytech/polkadot-sdk?tag=polkadot-stable2407-2#d6f482d5593c3e791d7b3e92e95aa3c734e23794" 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.2", "tempfile", "toml 0.8.12", @@ -13347,6 +13400,7 @@ dependencies = [ "fp-self-contained", "frame-benchmarking", "frame-executive", + "frame-metadata-hash-extension", "frame-support", "frame-system", "frame-system-benchmarking", diff --git a/Cargo.toml b/Cargo.toml index d79fa0ac..a5e27bda 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,6 +56,7 @@ pallet-myth-proxy = { path = "pallets/myth-proxy", default-features = false } frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2407-2", default-features = false } frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2407-2" } frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2407-2", default-features = false } +frame-metadata-hash-extension = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2407-2", default-features = false } frame-support = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2407-2", default-features = false } frame-system = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2407-2", default-features = false } frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-stable2407-2", default-features = false } diff --git a/primitives/xcm/src/lib.rs b/primitives/xcm/src/lib.rs index 7d40f29e..5f9f47d6 100644 --- a/primitives/xcm/src/lib.rs +++ b/primitives/xcm/src/lib.rs @@ -10,7 +10,8 @@ pub struct SignedToAccountId20( sp_std::marker::PhantomData<(Origin, AccountId, Network)>, ); impl, Network: Get> - sp_runtime::traits::TryConvert for SignedToAccountId20 + sp_runtime::traits::TryConvert + for SignedToAccountId20 where Origin::PalletsOrigin: From> + TryInto, Error = Origin::PalletsOrigin>, diff --git a/runtime/mainnet/Cargo.toml b/runtime/mainnet/Cargo.toml index 2c7cc362..c6561f66 100644 --- a/runtime/mainnet/Cargo.toml +++ b/runtime/mainnet/Cargo.toml @@ -35,6 +35,7 @@ pallet-escrow = {workspace = true, default-features = false} # Substrate frame-benchmarking = { workspace = true, default-features = false, optional = true } frame-executive = { workspace = true, default-features = false } +frame-metadata-hash-extension = { workspace = true, default-features = false } frame-support = { workspace = true, default-features = false } frame-system = { workspace = true, default-features = false } frame-system-benchmarking = { workspace = true, default-features = false, optional = true } @@ -226,3 +227,16 @@ try-runtime = [ "parachain-info/try-runtime", "pallet-escrow/try-runtime", ] + +# Enable the metadata hash generation. +# +# This is hidden behind a feature because it increases the compile time. +# The wasm binary needs to be compiled twice, once to fetch the metadata, +# generate the metadata hash and then a second time with the +# `RUNTIME_METADATA_HASH` environment variable set for the `CheckMetadataHash` +# extension. +metadata-hash = ["substrate-wasm-builder/metadata-hash"] + +# A convenience feature for enabling things when doing a build +# for an on-chain release. +on-chain-release-build = ["metadata-hash"] diff --git a/runtime/mainnet/build.rs b/runtime/mainnet/build.rs index 02d6973f..525a0b6a 100644 --- a/runtime/mainnet/build.rs +++ b/runtime/mainnet/build.rs @@ -1,12 +1,15 @@ -#[cfg(feature = "std")] +#[cfg(all(feature = "std", feature = "metadata-hash"))] fn main() { - substrate_wasm_builder::WasmBuilder::new() - .with_current_project() - .export_heap_base() - .import_memory() + substrate_wasm_builder::WasmBuilder::init_with_defaults() + .enable_metadata_hash("MYTH", 18) .build() } +#[cfg(all(feature = "std", not(feature = "metadata-hash")))] +fn main() { + substrate_wasm_builder::WasmBuilder::init_with_defaults().build() +} + /// The wasm builder is deactivated when compiling /// this crate for wasm to speed up the compilation. #[cfg(not(feature = "std"))] diff --git a/runtime/mainnet/src/lib.rs b/runtime/mainnet/src/lib.rs index b448bab6..b4475f9c 100644 --- a/runtime/mainnet/src/lib.rs +++ b/runtime/mainnet/src/lib.rs @@ -94,6 +94,7 @@ pub type SignedExtra = ( frame_system::CheckWeight, pallet_transaction_payment::ChargeTransactionPayment, cumulus_primitives_storage_weight_reclaim::StorageWeightReclaim, + frame_metadata_hash_extension::CheckMetadataHash, ); /// Unchecked extrinsic type as expected by this runtime. diff --git a/runtime/testnet/Cargo.toml b/runtime/testnet/Cargo.toml index a141ae14..b59125e4 100644 --- a/runtime/testnet/Cargo.toml +++ b/runtime/testnet/Cargo.toml @@ -33,6 +33,7 @@ pallet-myth-proxy = { workspace = true, default-features = false } # Substrate frame-benchmarking = { workspace = true, default-features = false, optional = true } frame-executive = { workspace = true, default-features = false } +frame-metadata-hash-extension = { workspace = true, default-features = false } frame-support = { workspace = true, default-features = false } frame-system = { workspace = true, default-features = false } frame-system-benchmarking = { workspace = true, default-features = false, optional = true } @@ -223,3 +224,16 @@ try-runtime = [ "pallet-escrow/try-runtime", "pallet-myth-proxy/try-runtime", ] + +# Enable the metadata hash generation. +# +# This is hidden behind a feature because it increases the compile time. +# The wasm binary needs to be compiled twice, once to fetch the metadata, +# generate the metadata hash and then a second time with the +# `RUNTIME_METADATA_HASH` environment variable set for the `CheckMetadataHash` +# extension. +metadata-hash = ["substrate-wasm-builder/metadata-hash"] + +# A convenience feature for enabling things when doing a build +# for an on-chain release. +on-chain-release-build = ["metadata-hash"] diff --git a/runtime/testnet/build.rs b/runtime/testnet/build.rs index 02d6973f..401b6741 100644 --- a/runtime/testnet/build.rs +++ b/runtime/testnet/build.rs @@ -1,12 +1,15 @@ -#[cfg(feature = "std")] +#[cfg(all(feature = "std", feature = "metadata-hash"))] fn main() { - substrate_wasm_builder::WasmBuilder::new() - .with_current_project() - .export_heap_base() - .import_memory() + substrate_wasm_builder::WasmBuilder::init_with_defaults() + .enable_metadata_hash("MUSE", 18) .build() } +#[cfg(all(feature = "std", not(feature = "metadata-hash")))] +fn main() { + substrate_wasm_builder::WasmBuilder::init_with_defaults().build() +} + /// The wasm builder is deactivated when compiling /// this crate for wasm to speed up the compilation. #[cfg(not(feature = "std"))] diff --git a/runtime/testnet/src/lib.rs b/runtime/testnet/src/lib.rs index 3cc18e07..0f7aee99 100644 --- a/runtime/testnet/src/lib.rs +++ b/runtime/testnet/src/lib.rs @@ -94,6 +94,7 @@ pub type SignedExtra = ( frame_system::CheckWeight, pallet_transaction_payment::ChargeTransactionPayment, cumulus_primitives_storage_weight_reclaim::StorageWeightReclaim, + frame_metadata_hash_extension::CheckMetadataHash, ); /// Unchecked extrinsic type as expected by this runtime.