Skip to content

feat: add support for metadata hash checks #835

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

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ build-production-wasm:
- export AUTHORIZE_UPGRADE_PREFIX=0x02
- export AUTHORIZE_UPGRADE_CHECK_VERSION=true
- export VERBOSE=true
- export DEFAULT_FEATURES="--features metadata-hash"
- cp -r * /build
- /srtool/build build
- subwasm meta --format=json+scale /out/${RUNTIME}_runtime.compact.wasm > /out/${RUNTIME}-metadata.json
Expand Down
54 changes: 54 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ xcm-emulator = { git = "https://github.com/paritytech/polka
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" }
frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" }
frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" }
frame-metadata-hash-extension = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" }
Expand Down
53 changes: 28 additions & 25 deletions runtimes/peregrine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,31 +70,32 @@ sp-transaction-pool = { workspace = true }
sp-version = { workspace = true }
sp-weights = { workspace = true }

frame-executive = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-assets = { workspace = true }
pallet-aura = { workspace = true }
pallet-authorship = { workspace = true }
pallet-balances = { workspace = true }
pallet-collective = { workspace = true }
pallet-democracy = { workspace = true }
pallet-indices = { workspace = true }
pallet-membership = { workspace = true }
pallet-message-queue = { workspace = true }
pallet-multisig = { workspace = true }
pallet-preimage = { workspace = true }
pallet-proxy = { workspace = true }
pallet-scheduler = { workspace = true }
pallet-session = { workspace = true }
pallet-sudo = { workspace = true }
pallet-timestamp = { workspace = true }
pallet-tips = { workspace = true }
pallet-transaction-payment = { workspace = true }
pallet-treasury = { workspace = true }
pallet-utility = { workspace = true }
pallet-vesting = { workspace = true }
sp-genesis-builder = { workspace = true }
frame-executive = { workspace = true }
frame-metadata-hash-extension = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-assets = { workspace = true }
pallet-aura = { workspace = true }
pallet-authorship = { workspace = true }
pallet-balances = { workspace = true }
pallet-collective = { workspace = true }
pallet-democracy = { workspace = true }
pallet-indices = { workspace = true }
pallet-membership = { workspace = true }
pallet-message-queue = { workspace = true }
pallet-multisig = { workspace = true }
pallet-preimage = { workspace = true }
pallet-proxy = { workspace = true }
pallet-scheduler = { workspace = true }
pallet-session = { workspace = true }
pallet-sudo = { workspace = true }
pallet-timestamp = { workspace = true }
pallet-tips = { workspace = true }
pallet-transaction-payment = { workspace = true }
pallet-treasury = { workspace = true }
pallet-utility = { workspace = true }
pallet-vesting = { workspace = true }
sp-genesis-builder = { workspace = true }

# Cumulus dependencies
cumulus-pallet-aura-ext = { workspace = true }
Expand Down Expand Up @@ -126,6 +127,7 @@ frame-try-runtime = { workspace = true, optional = true }
[features]
default = ["std"]
fast-gov = ["runtime-common/fast-gov"]
metadata-hash = ["substrate-wasm-builder/metadata-hash"]
runtime-benchmarks = [
"attestation/runtime-benchmarks",
"ctype/runtime-benchmarks",
Expand Down Expand Up @@ -190,6 +192,7 @@ std = [
"did/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",
Expand Down
11 changes: 8 additions & 3 deletions runtimes/peregrine/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@
use substrate_wasm_builder::WasmBuilder;

fn main() {
WasmBuilder::new()
let builder = WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build()
.import_memory();

#[cfg(feature = "metadata-hash")]
// TODO: Can we re-use some consts?
let builder = builder.enable_metadata_hash("PILT", 15);

builder.build()
}
2 changes: 2 additions & 0 deletions runtimes/peregrine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use core::str;

// Polkadot-sdk crates
use cumulus_pallet_parachain_system::register_validate_block;
use frame_metadata_hash_extension::CheckMetadataHash;
use frame_support::construct_runtime;
use frame_system::{
ChainContext, CheckEra, CheckGenesis, CheckNonZeroSender, CheckNonce, CheckSpecVersion, CheckTxVersion, CheckWeight,
Expand Down Expand Up @@ -217,4 +218,5 @@ pub type SignedExtra = (
CheckNonce<Runtime>,
CheckWeight<Runtime>,
ChargeTransactionPayment<Runtime>,
CheckMetadataHash<Runtime>,
);
49 changes: 26 additions & 23 deletions runtimes/spiritnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,29 +68,30 @@ sp-transaction-pool = { workspace = true }
sp-version = { workspace = true }
sp-weights = { workspace = true }

frame-executive = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-assets = { workspace = true }
pallet-aura = { workspace = true }
pallet-authorship = { workspace = true }
pallet-balances = { workspace = true }
pallet-collective = { workspace = true }
pallet-democracy = { workspace = true }
pallet-indices = { workspace = true }
pallet-membership = { workspace = true }
pallet-message-queue = { workspace = true }
pallet-multisig = { workspace = true }
pallet-preimage = { workspace = true }
pallet-proxy = { workspace = true }
pallet-scheduler = { workspace = true }
pallet-session = { workspace = true }
pallet-timestamp = { workspace = true }
pallet-tips = { workspace = true }
pallet-transaction-payment = { workspace = true }
pallet-treasury = { workspace = true }
pallet-utility = { workspace = true }
pallet-vesting = { workspace = true }
frame-executive = { workspace = true }
frame-metadata-hash-extension = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-assets = { workspace = true }
pallet-aura = { workspace = true }
pallet-authorship = { workspace = true }
pallet-balances = { workspace = true }
pallet-collective = { workspace = true }
pallet-democracy = { workspace = true }
pallet-indices = { workspace = true }
pallet-membership = { workspace = true }
pallet-message-queue = { workspace = true }
pallet-multisig = { workspace = true }
pallet-preimage = { workspace = true }
pallet-proxy = { workspace = true }
pallet-scheduler = { workspace = true }
pallet-session = { workspace = true }
pallet-timestamp = { workspace = true }
pallet-tips = { workspace = true }
pallet-transaction-payment = { workspace = true }
pallet-treasury = { workspace = true }
pallet-utility = { workspace = true }
pallet-vesting = { workspace = true }

# Cumulus dependencies
cumulus-pallet-aura-ext = { workspace = true }
Expand Down Expand Up @@ -123,6 +124,7 @@ frame-try-runtime = { workspace = true, optional = true }
[features]
default = ["std"]
fast-gov = ["runtime-common/fast-gov"]
metadata-hash = ["substrate-wasm-builder/metadata-hash"]
runtime-benchmarks = [
"attestation/runtime-benchmarks",
"ctype/runtime-benchmarks",
Expand Down Expand Up @@ -187,6 +189,7 @@ std = [
"did/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",
Expand Down
11 changes: 8 additions & 3 deletions runtimes/spiritnet/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@
use substrate_wasm_builder::WasmBuilder;

fn main() {
WasmBuilder::new()
let builder = WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build()
.import_memory();

#[cfg(feature = "metadata-hash")]
// TODO: Can we re-use some consts?
let builder = builder.enable_metadata_hash("PILT", 15);

builder.build()
}
2 changes: 2 additions & 0 deletions runtimes/spiritnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use core::str;

// Polkadot-sdk crates
use cumulus_pallet_parachain_system::register_validate_block;
use frame_metadata_hash_extension::CheckMetadataHash;
use frame_support::construct_runtime;
use frame_system::{
ChainContext, CheckEra, CheckGenesis, CheckNonZeroSender, CheckNonce, CheckSpecVersion, CheckTxVersion, CheckWeight,
Expand Down Expand Up @@ -212,4 +213,5 @@ pub type SignedExtra = (
CheckNonce<Runtime>,
CheckWeight<Runtime>,
ChargeTransactionPayment<Runtime>,
CheckMetadataHash<Runtime>,
);
Loading