Skip to content

Commit

Permalink
enable metadata hash (#2786)
Browse files Browse the repository at this point in the history
* wip

* Update runtime/acala/src/lib.rs

Co-authored-by: zjb0807 <zjb0807@qq.com>

* fix

* fix

* revert

* enable metadata hash

* fix

---------

Co-authored-by: zjb0807 <zjb0807@qq.com>
  • Loading branch information
xlc and zjb0807 authored Aug 26, 2024
1 parent 33b2fee commit a8b1230
Show file tree
Hide file tree
Showing 8 changed files with 212 additions and 118 deletions.
291 changes: 190 additions & 101 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,14 @@ cumulus-pallet-xcm = { version = "0.16.0", default-features = false }
cumulus-pallet-xcmp-queue = { version = "0.16.0", default-features = false }
cumulus-primitives-core = { version = "0.15.0", default-features = false }
cumulus-primitives-parachain-inherent = { version = "0.15.0", default-features = false }
cumulus-primitives-timestamp = { version = "0.15.0", default-features = false }
cumulus-primitives-timestamp = { version = "0.15.1", default-features = false }
cumulus-primitives-utility = { version = "0.16.0", default-features = false }
cumulus-test-relay-sproof-builder = { version = "0.15.0", default-features = false }
frame-benchmarking = { version = "37.0.0", default-features = false }
frame-executive = { version = "37.0.0", default-features = false }
frame-metadata-hash-extension = { version = "0.5.0", default-features = false }
frame-support = { version = "37.0.0", default-features = false }
frame-system = { version = "37.0.0", default-features = false }
frame-system = { version = "37.1.0", default-features = false }
frame-system-rpc-runtime-api = { version = "34.0.0", default-features = false }
frame-try-runtime = { version = "0.43.0", default-features = false }
pallet-aura = { version = "36.0.0", default-features = false }
Expand Down Expand Up @@ -260,12 +261,12 @@ polkadot-core-primitives = { version = "15.0.0", default-features = false }
polkadot-parachain-primitives = { version = "14.0.0", default-features = false }
polkadot-primitives = { version = "15.0.0", default-features = false }
polkadot-runtime-common = { version = "16.0.0", default-features = false }
polkadot-runtime-parachains = { version = "16.0.0", default-features = false }
polkadot-runtime-parachains = { version = "16.0.1", default-features = false }
sp-api = { version = "34.0.0", default-features = false }
sp-application-crypto = { version = "38.0.0", default-features = false }
sp-arithmetic = { version = "26.0.0", default-features = false }
sp-block-builder = { version = "34.0.0", default-features = false }
sp-blockchain = { version = "37.0.0", default-features = false }
sp-blockchain = { version = "37.0.1", default-features = false }
sp-consensus = { version = "0.40.0", default-features = false }
sp-consensus-aura = { version = "0.40.0", default-features = false }
sp-consensus-slots = { version = "0.40.0", default-features = false }
Expand Down Expand Up @@ -297,5 +298,5 @@ xcm-builder = { version = "16.0.0", package = "staging-xcm-builder", default-fea
xcm-executor = { version = "16.0.0", package = "staging-xcm-executor", default-features = false }

# polkadot-sdk (client)
substrate-wasm-builder = { version = "24.0.0" }
substrate-wasm-builder = { version = "24.0.0", features = ["metadata-hash"] }
xcm-simulator = { version = "16.0.0" }
2 changes: 2 additions & 0 deletions runtime/acala/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ hex-literal = { workspace = true }

# substrate
frame-executive = { workspace = true }
frame-metadata-hash-extension = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
frame-system-rpc-runtime-api = { workspace = true }
Expand Down Expand Up @@ -156,6 +157,7 @@ std = [
"serde_json/std",

"frame-benchmarking/std",
"frame-metadata-hash-extension/std",
"frame-executive/std",
"frame-support/std",
"frame-system-rpc-runtime-api/std",
Expand Down
6 changes: 2 additions & 4 deletions runtime/acala/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@

#[cfg(feature = "std")]
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("ACA", 12)
.build()
}

Expand Down
6 changes: 4 additions & 2 deletions runtime/acala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,7 @@ where
frame_system::CheckEra::<Runtime>::from(generic::Era::mortal(period, current_block)),
runtime_common::CheckNonce::<Runtime>::from(nonce),
frame_system::CheckWeight::<Runtime>::new(),
frame_metadata_hash_extension::CheckMetadataHash::new(true),
module_evm::SetEvmOrigin::<Runtime>::new(),
module_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
);
Expand Down Expand Up @@ -1960,6 +1961,7 @@ pub type SignedExtra = (
frame_system::CheckEra<Runtime>,
runtime_common::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
// `SetEvmOrigin` needs ahead of `ChargeTransactionPayment`, we set origin in `SetEvmOrigin::validate()`, then
// `ChargeTransactionPayment::validate()` can process erc20 token transfer successfully in the case of using erc20
// as fee token.
Expand Down Expand Up @@ -2525,7 +2527,7 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig
}
}

let (_, _, _, _, mortality, check_nonce, _, _, charge) = extra.clone();
let (_, _, _, _, mortality, check_nonce, _, _, _, charge) = extra.clone();

if mortality != frame_system::CheckEra::from(sp_runtime::generic::Era::Immortal) {
// require immortal
Expand Down Expand Up @@ -2574,7 +2576,7 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig
}
}

let (_, _, _, _, mortality, check_nonce, _, _, charge) = extra.clone();
let (_, _, _, _, mortality, check_nonce, _, _, _, charge) = extra.clone();

if mortality != frame_system::CheckEra::from(sp_runtime::generic::Era::Immortal) {
// require immortal
Expand Down
2 changes: 2 additions & 0 deletions runtime/karura/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ hex-literal = { workspace = true }

# substrate
frame-executive = { workspace = true }
frame-metadata-hash-extension = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
frame-system-rpc-runtime-api = { workspace = true }
Expand Down Expand Up @@ -158,6 +159,7 @@ std = [
"serde_json/std",

"frame-benchmarking/std",
"frame-metadata-hash-extension/std",
"frame-executive/std",
"frame-support/std",
"frame-system-rpc-runtime-api/std",
Expand Down
6 changes: 2 additions & 4 deletions runtime/karura/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@

#[cfg(feature = "std")]
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("KAR", 12)
.build()
}

Expand Down
6 changes: 4 additions & 2 deletions runtime/karura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,7 @@ where
frame_system::CheckEra::<Runtime>::from(generic::Era::mortal(period, current_block)),
runtime_common::CheckNonce::<Runtime>::from(nonce),
frame_system::CheckWeight::<Runtime>::new(),
frame_metadata_hash_extension::CheckMetadataHash::<Runtime>::new(true),
module_evm::SetEvmOrigin::<Runtime>::new(),
module_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
);
Expand Down Expand Up @@ -1992,6 +1993,7 @@ pub type SignedExtra = (
frame_system::CheckEra<Runtime>,
runtime_common::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
// `SetEvmOrigin` needs ahead of `ChargeTransactionPayment`, we set origin in `SetEvmOrigin::validate()`, then
// `ChargeTransactionPayment::validate()` can process erc20 token transfer successfully in the case of using erc20
// as fee token.
Expand Down Expand Up @@ -2555,7 +2557,7 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig
}
}

let (_, _, _, _, mortality, check_nonce, _, _, charge) = extra.clone();
let (_, _, _, _, mortality, check_nonce, _, _, _, charge) = extra.clone();

if mortality != frame_system::CheckEra::from(sp_runtime::generic::Era::Immortal) {
// require immortal
Expand Down Expand Up @@ -2604,7 +2606,7 @@ impl Convert<(RuntimeCall, SignedExtra), Result<(EthereumTransactionMessage, Sig
}
}

let (_, _, _, _, mortality, check_nonce, _, _, charge) = extra.clone();
let (_, _, _, _, mortality, check_nonce, _, _, _, charge) = extra.clone();

if mortality != frame_system::CheckEra::from(sp_runtime::generic::Era::Immortal) {
// require immortal
Expand Down

0 comments on commit a8b1230

Please sign in to comment.