Skip to content

Commit 805faa7

Browse files
clangenbbrenzi
andauthored
Add CheckMetadataHash signed extension (#373)
* random voting in bot-community * democracy bot fixes * fmt * cosmetics * add cli export-secret and help tester with the mnemonic of an account which will skip voting. randomize turnout too * fix ci * polkadot-v1.13.0; bump api-client and encointer-pallets * [node] fix build after upgrade * fix ci * bump-versions * bump Cargo.lock * [runtime] add `CheckMetaDataHash` extension and bump api-client library * change branch to api-client supporting the check metadata hash extension * bump api client * fix benchmarking build * toml fmt * [runtime] fix fmt --------- Co-authored-by: Alain Brenzikofer <alain@integritee.network>
1 parent b6810fe commit 805faa7

File tree

7 files changed

+102
-24
lines changed

7 files changed

+102
-24
lines changed

Cargo.lock

Lines changed: 81 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pallet-encointer-scheduler = { default-features = false, version = "~12.1.0" }
5151
frame-benchmarking = { version = "35.0.0", default-features = false }
5252
frame-benchmarking-cli = { version = "39.0.0" }
5353
frame-executive = { version = "35.0.0", default-features = false }
54+
frame-metadata-hash-extension = { version = "0.3.0", default-features = false }
5455
frame-support = { version = "35.0.0", default-features = false }
5556
frame-system = { version = "35.0.0", default-features = false }
5657
frame-system-benchmarking = { version = "35.0.0", default-features = false }
@@ -125,11 +126,11 @@ substrate-client-keystore = { version = "0.10.0" }
125126
[patch.crates-io]
126127
## api client
127128
# todo: temporary patch until ^0.17.1 is released
128-
ac-compose-macros = { git = "https://github.com/encointer/substrate-api-client.git", branch = "crates-io-v0.17.0-patch-for-stable-sdk-1.13" }
129-
ac-node-api = { git = "https://github.com/encointer/substrate-api-client.git", branch = "crates-io-v0.17.0-patch-for-stable-sdk-1.13" }
130-
ac-primitives = { git = "https://github.com/encointer/substrate-api-client.git", branch = "crates-io-v0.17.0-patch-for-stable-sdk-1.13" }
131-
substrate-api-client = { git = "https://github.com/encointer/substrate-api-client.git", branch = "crates-io-v0.17.0-patch-for-stable-sdk-1.13" }
132-
substrate-client-keystore = { git = "https://github.com/encointer/substrate-api-client.git", branch = "crates-io-v0.17.0-patch-for-stable-sdk-1.13" }
129+
ac-compose-macros = { git = "https://github.com/encointer/substrate-api-client.git", branch = "crates-io-v0.17.0-patch-for-stable-check-metadata-hash-sdk-1.13" }
130+
ac-node-api = { git = "https://github.com/encointer/substrate-api-client.git", branch = "crates-io-v0.17.0-patch-for-stable-check-metadata-hash-sdk-1.13" }
131+
ac-primitives = { git = "https://github.com/encointer/substrate-api-client.git", branch = "crates-io-v0.17.0-patch-for-stable-check-metadata-hash-sdk-1.13" }
132+
substrate-api-client = { git = "https://github.com/encointer/substrate-api-client.git", branch = "crates-io-v0.17.0-patch-for-stable-check-metadata-hash-sdk-1.13" }
133+
substrate-client-keystore = { git = "https://github.com/encointer/substrate-api-client.git", branch = "crates-io-v0.17.0-patch-for-stable-check-metadata-hash-sdk-1.13" }
133134
#ac-node-api = { path = "../../substrate-api-client/node-api" }
134135
#ac-primitives = { path = "../../substrate-api-client/primitives" }
135136
#substrate-api-client = { path = "../../substrate-api-client" }

node/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ futures = { workspace = true }
2828
log = { workspace = true }
2929
serde_json = { workspace = true }
3030

31+
frame-metadata-hash-extension = { workspace = true, features = ["std"] }
3132
frame-system = { workspace = true, features = ["std"] }
3233
pallet-asset-tx-payment = { workspace = true, features = ["std"] }
3334
sc-cli = { workspace = true }

node/src/benchmarking.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ pub fn create_benchmark_extrinsic(
120120
frame_system::CheckNonce::<runtime::Runtime>::from(nonce),
121121
frame_system::CheckWeight::<runtime::Runtime>::new(),
122122
pallet_asset_tx_payment::ChargeAssetTxPayment::<runtime::Runtime>::from(0, None),
123+
frame_metadata_hash_extension::CheckMetadataHash::<runtime::Runtime>::new(false),
123124
);
124125

125126
let raw_payload = runtime::SignedPayload::from_raw(
@@ -134,6 +135,7 @@ pub fn create_benchmark_extrinsic(
134135
(),
135136
(),
136137
(),
138+
None,
137139
),
138140
);
139141
let signature = raw_payload.using_encoded(|e| sender.sign(e));

runtime/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pallet-encointer-scheduler = { workspace = true }
3232

3333
# substrate deps
3434
frame-executive = { workspace = true }
35+
frame-metadata-hash-extension = { workspace = true }
3536
frame-support = { workspace = true }
3637
frame-system = { workspace = true }
3738
pallet-asset-tx-payment = { workspace = true }
@@ -73,7 +74,7 @@ frame-system-benchmarking = { workspace = true, optional = true }
7374
hex-literal = { workspace = true, optional = true }
7475

7576
[build-dependencies]
76-
substrate-wasm-builder = { workspace = true }
77+
substrate-wasm-builder = { workspace = true, optional = true, features = ["metadata-hash"] }
7778

7879
[features]
7980
default = ["std"]
@@ -83,6 +84,7 @@ std = [
8384
"encointer-primitives/serde_derive",
8485
"encointer-primitives/std",
8586
"frame-executive/std",
87+
"frame-metadata-hash-extension/std",
8688
"frame-support/std",
8789
"frame-system-rpc-runtime-api/std",
8890
"frame-system/std",
@@ -124,6 +126,7 @@ std = [
124126
"sp-std/std",
125127
"sp-transaction-pool/std",
126128
"sp-version/std",
129+
"substrate-wasm-builder",
127130
]
128131
runtime-benchmarks = [
129132
"frame-benchmarking/runtime-benchmarks",

runtime/build.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use substrate_wasm_builder::WasmBuilder;
2-
1+
#[cfg(feature = "std")]
32
fn main() {
4-
WasmBuilder::new()
5-
.with_current_project()
6-
.export_heap_base()
7-
.import_memory()
3+
substrate_wasm_builder::WasmBuilder::init_with_defaults()
4+
.enable_metadata_hash("ERT", 12)
85
.build()
96
}
7+
8+
#[cfg(not(feature = "std"))]
9+
fn main() {}

runtime/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ pub struct NoConversion;
480480
impl ConversionFromAssetBalance<u128, (), u128> for NoConversion {
481481
type Error = ();
482482
fn from_asset_balance(balance: Balance, _asset_id: ()) -> Result<Balance, Self::Error> {
483-
return Ok(balance)
483+
return Ok(balance);
484484
}
485485
#[cfg(feature = "runtime-benchmarks")]
486486
fn ensure_successful(_: ()) {}
@@ -590,6 +590,7 @@ pub type SignedExtra = (
590590
frame_system::CheckNonce<Runtime>,
591591
frame_system::CheckWeight<Runtime>,
592592
pallet_asset_tx_payment::ChargeAssetTxPayment<Runtime>,
593+
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
593594
);
594595
/// Unchecked extrinsic type as expected by this runtime.
595596
pub type UncheckedExtrinsic =

0 commit comments

Comments
 (0)