Skip to content

Commit

Permalink
add CheckMetadataHash signed extension (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
clangenb authored Jun 27, 2024
1 parent 550fe53 commit 73a0944
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 9 deletions.
74 changes: 72 additions & 2 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 node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ hex = { workspace = true }
hex-literal = { workspace = true }
serde_json = { workspace = true }

frame-metadata-hash-extension = { workspace = true, features = ["std"] }
frame-system = { workspace = true, features = ["std"] }
pallet-transaction-payment = { workspace = true, features = ["std"] }
sc-cli = { workspace = true }
Expand Down
2 changes: 2 additions & 0 deletions node/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ pub fn create_benchmark_extrinsic(
frame_system::CheckNonce::<runtime::Runtime>::from(nonce),
frame_system::CheckWeight::<runtime::Runtime>::new(),
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
frame_metadata_hash_extension::CheckMetadataHash::<runtime::Runtime>::new(false),
);

let raw_payload = runtime::SignedPayload::from_raw(
Expand All @@ -135,6 +136,7 @@ pub fn create_benchmark_extrinsic(
(),
(),
(),
None,
),
);
let signature = raw_payload.using_encoded(|e| sender.sign(e));
Expand Down
5 changes: 4 additions & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ sp-version = { workspace = true }

# frame
frame-executive = { workspace = true }
frame-metadata-hash-extension = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }

Expand All @@ -67,7 +68,7 @@ frame-system-benchmarking = { optional = true, workspace = true }
hex-literal = { workspace = true, optional = true }

[build-dependencies]
substrate-wasm-builder = { workspace = true }
substrate-wasm-builder = { workspace = true, optional = true, features = ["metadata-hash"] }

[features]
default = ["std"]
Expand All @@ -76,6 +77,7 @@ std = [
"parity-scale-codec/std",
"scale-info/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 @@ -106,6 +108,7 @@ std = [
"sp-storage/std",
"sp-transaction-pool/std",
"sp-version/std",
"substrate-wasm-builder",
"pallet-teerex/std",
"pallet-claims/std",
"pallet-enclave-bridge/std",
Expand Down
12 changes: 6 additions & 6 deletions runtime/build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use substrate_wasm_builder::WasmBuilder;

#[cfg(feature = "std")]
fn main() {
WasmBuilder::new()
.with_current_project()
.export_heap_base()
.import_memory()
substrate_wasm_builder::WasmBuilder::init_with_defaults()
.enable_metadata_hash("ERT", 12)
.build()
}

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

/// All migrations of the runtime, aside from the ones declared in the pallets.
Expand Down

0 comments on commit 73a0944

Please sign in to comment.