diff --git a/.github/workflows/check-pull-request.yml b/.github/workflows/check-pull-request.yml
index 62b8984..0fa300c 100644
--- a/.github/workflows/check-pull-request.yml
+++ b/.github/workflows/check-pull-request.yml
@@ -19,9 +19,10 @@ on:
# Matches tags containing an arbitrary suffix starting with '-'.
- v[0-9]+.[0-9]+.[0-9]+-*
-# Ensures only one build is run per branch, unless pushing to develop
+# Cancel a currently running workflow from the same PR, branch or tag when a new workflow is
+# triggered (ref https://stackoverflow.com/a/72408109)
concurrency:
- group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/develop' && github.run_number || github.ref }}
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
@@ -105,6 +106,8 @@ jobs:
- name: Build ${{ matrix.runtime }}
id: srtool_build
uses: chevdor/srtool-actions@v0.9.2
+ env:
+ BUILD_OPTS: "--features on-chain-release-build"
with:
image: paritytech/srtool
chain: ${{ matrix.runtime }}
diff --git a/Cargo.lock b/Cargo.lock
index 86f5dde..4fe8c62 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -670,6 +670,7 @@ dependencies = [
"cumulus-relay-chain-interface",
"frame-benchmarking",
"frame-benchmarking-cli",
+ "frame-metadata-hash-extension",
"frame-support",
"frame-system-rpc-runtime-api",
"frame-try-runtime",
@@ -740,6 +741,7 @@ dependencies = [
"cumulus-primitives-utility",
"frame-benchmarking",
"frame-executive",
+ "frame-metadata-hash-extension",
"frame-support",
"frame-system",
"frame-system-benchmarking",
@@ -5485,6 +5487,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"
@@ -11808,6 +11824,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"
@@ -11834,6 +11873,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"
@@ -13555,13 +13600,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.14",
diff --git a/Cargo.toml b/Cargo.toml
index 3944277..39f827f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -35,6 +35,7 @@ scale-info = { version = "2.1.1", default-features = false }
assets-common = { version = "0.14.0", default-features = false }
frame-benchmarking = { version = "35.0.0", default-features = false }
frame-benchmarking-cli = { version = "39.0.0" }
+frame-metadata-hash-extension = { version = "0.3.0", default-features = false }
frame-executive = { version = "35.0.0", default-features = false }
frame-support = { version = "35.0.0", default-features = false }
frame-system = { version = "35.0.0", default-features = false }
diff --git a/node/Cargo.toml b/node/Cargo.toml
index a6db4d6..8d34068 100644
--- a/node/Cargo.toml
+++ b/node/Cargo.toml
@@ -23,6 +23,7 @@ parity-scale-codec = { workspace = true, features = ["std"] }
# Substrate
frame-benchmarking = { workspace = true, features = ["std"] }
frame-benchmarking-cli = { workspace = true }
+frame-metadata-hash-extension = { workspace = true, features = ["std"] }
frame-support = { workspace = true, features = ["std"] }
frame-system-rpc-runtime-api = { workspace = true, features = ["std"] }
frame-try-runtime = { workspace = true, features = ["std"] }
@@ -116,3 +117,4 @@ try-runtime = [
"polkadot-cli/try-runtime",
"sp-runtime/try-runtime",
]
+metadata-hash = ["bajun-runtime/metadata-hash"]
diff --git a/runtime/bajun/Cargo.toml b/runtime/bajun/Cargo.toml
index 76a1828..768627b 100644
--- a/runtime/bajun/Cargo.toml
+++ b/runtime/bajun/Cargo.toml
@@ -8,7 +8,7 @@ repository.workspace = true
version.workspace = true
[build-dependencies]
-substrate-wasm-builder = { workspace = true }
+substrate-wasm-builder = { workspace = true, optional = true }
[dependencies]
# General
@@ -25,6 +25,7 @@ scale-info = { workspace = true, features = [ "derive" ] }
assets-common = { workspace = true }
frame-benchmarking = { workspace = true, optional = true }
frame-executive = { workspace = true }
+frame-metadata-hash-extension = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
frame-system-benchmarking = { workspace = true, optional = true }
@@ -126,6 +127,7 @@ std = [
"cumulus-primitives-utility/std",
"frame-benchmarking/std",
"frame-executive/std",
+ "frame-metadata-hash-extension/std",
"frame-support/std",
"frame-system-benchmarking/std",
"frame-system-rpc-runtime-api/std",
@@ -183,6 +185,7 @@ std = [
"staging-xcm/std",
"staging-xcm-builder/std",
"staging-xcm-executor/std",
+ "substrate-wasm-builder",
# integritee
"pallet-asset-registry/std",
"xcm-primitives/std",
@@ -292,3 +295,13 @@ try-runtime = [
"pallet-ajuna-tournament/try-runtime",
"pallet-ajuna-nft-transfer/try-runtime",
]
+
+# Enable metadata hash generation at compile time for the `CheckMetadataHash` extension.
+# This pulls in some dependencies and add compile time, this is why we only do it for
+# production builds.
+metadata-hash = ["substrate-wasm-builder?/metadata-hash"]
+
+# A feature that should be enabled when the runtime should be built for on-chain
+# deployment. Hence, the CI building the release artifact should always enable this
+# feature.
+on-chain-release-build = ["metadata-hash"]
diff --git a/runtime/bajun/build.rs b/runtime/bajun/build.rs
index aa41dcc..82e6ceb 100644
--- a/runtime/bajun/build.rs
+++ b/runtime/bajun/build.rs
@@ -14,16 +14,17 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-#[cfg(feature = "std")]
+#[cfg(all(feature = "std", not(feature = "metadata-hash")))]
fn main() {
- substrate_wasm_builder::WasmBuilder::new()
- .with_current_project()
- .export_heap_base()
- .import_memory()
+ substrate_wasm_builder::WasmBuilder::build_using_defaults()
+}
+
+#[cfg(all(feature = "std", feature = "metadata-hash"))]
+fn main() {
+ substrate_wasm_builder::WasmBuilder::init_with_defaults()
+ .enable_metadata_hash("BAJU", 12)
.build()
}
-/// 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/runtime/bajun/src/lib.rs b/runtime/bajun/src/lib.rs
index 1d9c892..fc4b590 100644
--- a/runtime/bajun/src/lib.rs
+++ b/runtime/bajun/src/lib.rs
@@ -137,6 +137,7 @@ pub type SignedExtra = (
frame_system::CheckNonce,
frame_system::CheckWeight,
pallet_transaction_payment::ChargeTransactionPayment,
+ frame_metadata_hash_extension::CheckMetadataHash,
);
/// Unchecked extrinsic type as expected by this runtime.