Skip to content

Commit

Permalink
Add support for metadata hash verification. (#494)
Browse files Browse the repository at this point in the history
* add frame metadata hash signed extra

* unrelated, add foucoco paseo genesis spec and wasm

* Add `metadata-hash` feature to pendulum-node

* Revert "Add `metadata-hash` feature to pendulum-node"

This reverts commit d87aa44.

---------

Co-authored-by: Marcel Ebert <mail@marcel-ebert.de>
  • Loading branch information
gianfra-t and ebma authored Sep 25, 2024
1 parent 3b64b39 commit bb3543c
Show file tree
Hide file tree
Showing 13 changed files with 4,153 additions and 1 deletion.
26 changes: 26 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cargo +nightly test
To build the project, execute

```
cargo build --release
cargo build --release --features metadata-hash
```

A successful build will create a binary under `./target/release/pendulum-node`.
Expand Down
1 change: 1 addition & 0 deletions res/foucoco-paseo-genesis-wasm.txt

Large diffs are not rendered by default.

4,068 changes: 4,068 additions & 0 deletions res/foucoco-paseo-spec-raw.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions runtime/amplitude/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ reward-distribution = { git = "https://github.com/pendulum-chain/spacewalk", def
# Substrate
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false, optional = true }
frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
frame-metadata-hash-extension = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false, optional = true }
Expand Down Expand Up @@ -169,6 +170,7 @@ std = [
"dia-oracle-runtime-api/std",
"frame-benchmarking/std",
"frame-executive/std",
"frame-metadata-hash-extension/std",
"frame-support/std",
"frame-system-rpc-runtime-api/std",
"frame-system/std",
Expand Down Expand Up @@ -347,3 +349,5 @@ try-runtime = [
"bifrost-farming/try-runtime",
"zenlink-protocol/try-runtime",
]

metadata-hash = ["substrate-wasm-builder/metadata-hash"]
13 changes: 13 additions & 0 deletions runtime/amplitude/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
use substrate_wasm_builder::WasmBuilder;

#[cfg(all(feature = "std", not(feature = "metadata-hash")))]
fn main() {
WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build()
}
#[cfg(all(feature = "std", feature = "metadata-hash"))]
fn main() {
WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.enable_metadata_hash("AMPE", 12)
.build();
}

#[cfg(not(feature = "std"))]
fn main() {}
2 changes: 2 additions & 0 deletions runtime/amplitude/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ pub type SignedExtra = (
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
treasury_buyout_extension::CheckBuyout<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);

type EventRecord = frame_system::EventRecord<
Expand Down Expand Up @@ -1111,6 +1112,7 @@ where
frame_system::CheckWeight::<Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
treasury_buyout_extension::CheckBuyout::<Runtime>::new(),
frame_metadata_hash_extension::CheckMetadataHash::new(true),
);

let raw_payload = SignedPayload::new(call, extra).ok()?;
Expand Down
4 changes: 4 additions & 0 deletions runtime/foucoco/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ module-pallet-staking-rpc-runtime-api = { path = "../../pallets/parachain-stakin
# Substrate
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, optional = true, branch = "release-polkadot-v1.1.0" }
frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
frame-metadata-hash-extension = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, optional = true, branch = "release-polkadot-v1.1.0" }
Expand Down Expand Up @@ -166,6 +167,7 @@ std = [
"dia-oracle/std",
'dia-oracle-runtime-api/std',
"frame-executive/std",
"frame-metadata-hash-extension/std",
"frame-support/std",
"frame-system-rpc-runtime-api/std",
"frame-system/std",
Expand Down Expand Up @@ -342,3 +344,5 @@ try-runtime = [
"bifrost-farming/try-runtime",
"zenlink-protocol/try-runtime",
]

metadata-hash = ["substrate-wasm-builder/metadata-hash"]
13 changes: 13 additions & 0 deletions runtime/foucoco/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
use substrate_wasm_builder::WasmBuilder;

#[cfg(all(feature = "std", not(feature = "metadata-hash")))]
fn main() {
WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build()
}
#[cfg(all(feature = "std", feature = "metadata-hash"))]
fn main() {
WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.enable_metadata_hash("AMPE", 12)
.build();
}

#[cfg(not(feature = "std"))]
fn main() {}
2 changes: 2 additions & 0 deletions runtime/foucoco/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ pub type SignedExtra = (
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
treasury_buyout_extension::CheckBuyout<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);

type EventRecord = frame_system::EventRecord<
Expand Down Expand Up @@ -1157,6 +1158,7 @@ where
frame_system::CheckWeight::<Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
treasury_buyout_extension::CheckBuyout::<Runtime>::new(),
frame_metadata_hash_extension::CheckMetadataHash::new(true),
);

let raw_payload = SignedPayload::new(call, extra).ok()?;
Expand Down
4 changes: 4 additions & 0 deletions runtime/pendulum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ reward-distribution = { git = "https://github.com/pendulum-chain/spacewalk", def
# Substrate
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, optional = true, branch = "release-polkadot-v1.1.0" }
frame-executive = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
frame-metadata-hash-extension = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
frame-support = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
frame-system = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, optional = true, branch = "release-polkadot-v1.1.0" }
Expand Down Expand Up @@ -166,6 +167,7 @@ std = [
"dia-oracle/std",
"dia-oracle-runtime-api/std",
"frame-executive/std",
"frame-metadata-hash-extension/std",
"frame-support/std",
"frame-system-rpc-runtime-api/std",
"frame-system/std",
Expand Down Expand Up @@ -340,3 +342,5 @@ try-runtime = [
"zenlink-protocol/try-runtime",
"treasury-buyout-extension/try-runtime",
]

metadata-hash = ["substrate-wasm-builder/metadata-hash"]
13 changes: 13 additions & 0 deletions runtime/pendulum/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
use substrate_wasm_builder::WasmBuilder;

#[cfg(all(feature = "std", not(feature = "metadata-hash")))]
fn main() {
WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.build()
}
#[cfg(all(feature = "std", feature = "metadata-hash"))]
fn main() {
WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
.enable_metadata_hash("PEN", 12)
.build();
}

#[cfg(not(feature = "std"))]
fn main() {}
2 changes: 2 additions & 0 deletions runtime/pendulum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ pub type SignedExtra = (
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
treasury_buyout_extension::CheckBuyout<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);

type EventRecord = frame_system::EventRecord<
Expand Down Expand Up @@ -1134,6 +1135,7 @@ where
frame_system::CheckWeight::<Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
treasury_buyout_extension::CheckBuyout::<Runtime>::new(),
frame_metadata_hash_extension::CheckMetadataHash::new(true),
);

let raw_payload = SignedPayload::new(call, extra).ok()?;
Expand Down

0 comments on commit bb3543c

Please sign in to comment.