Skip to content
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

Add CheckMetadataHash signed extension #373

Merged
merged 19 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
92 changes: 81 additions & 11 deletions Cargo.lock

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

11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pallet-encointer-scheduler = { default-features = false, version = "~12.1.0" }
frame-benchmarking = { version = "35.0.0", default-features = false }
frame-benchmarking-cli = { version = "39.0.0" }
frame-executive = { version = "35.0.0", default-features = false }
frame-metadata-hash-extension = { version = "0.3.0", default-features = false }
frame-support = { version = "35.0.0", default-features = false }
frame-system = { version = "35.0.0", default-features = false }
frame-system-benchmarking = { version = "35.0.0", default-features = false }
Expand Down Expand Up @@ -125,11 +126,11 @@ substrate-client-keystore = { version = "0.10.0" }
[patch.crates-io]
## api client
# todo: temporary patch until ^0.17.1 is released
ac-compose-macros = { git = "https://github.com/encointer/substrate-api-client.git", branch = "crates-io-v0.17.0-patch-for-stable-sdk-1.13" }
ac-node-api = { git = "https://github.com/encointer/substrate-api-client.git", branch = "crates-io-v0.17.0-patch-for-stable-sdk-1.13" }
ac-primitives = { git = "https://github.com/encointer/substrate-api-client.git", branch = "crates-io-v0.17.0-patch-for-stable-sdk-1.13" }
substrate-api-client = { git = "https://github.com/encointer/substrate-api-client.git", branch = "crates-io-v0.17.0-patch-for-stable-sdk-1.13" }
substrate-client-keystore = { git = "https://github.com/encointer/substrate-api-client.git", branch = "crates-io-v0.17.0-patch-for-stable-sdk-1.13" }
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" }
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" }
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" }
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" }
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" }
#ac-node-api = { path = "../../substrate-api-client/node-api" }
#ac-primitives = { path = "../../substrate-api-client/primitives" }
#substrate-api-client = { path = "../../substrate-api-client" }
Expand Down
1 change: 1 addition & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ futures = { workspace = true }
log = { workspace = true }
serde_json = { workspace = true }

frame-metadata-hash-extension = { workspace = true, features = ["std"] }
frame-system = { workspace = true, features = ["std"] }
pallet-asset-tx-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 @@ -120,6 +120,7 @@ pub fn create_benchmark_extrinsic(
frame_system::CheckNonce::<runtime::Runtime>::from(nonce),
frame_system::CheckWeight::<runtime::Runtime>::new(),
pallet_asset_tx_payment::ChargeAssetTxPayment::<runtime::Runtime>::from(0, None),
frame_metadata_hash_extension::CheckMetadataHash::<runtime::Runtime>::new(false),
);

let raw_payload = runtime::SignedPayload::from_raw(
Expand All @@ -134,6 +135,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 @@ -32,6 +32,7 @@ pallet-encointer-scheduler = { workspace = true }

# substrate deps
frame-executive = { workspace = true }
frame-metadata-hash-extension = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-asset-tx-payment = { workspace = true }
Expand Down Expand Up @@ -73,7 +74,7 @@ frame-system-benchmarking = { workspace = true, optional = 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 @@ -83,6 +84,7 @@ std = [
"encointer-primitives/serde_derive",
"encointer-primitives/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 @@ -124,6 +126,7 @@ std = [
"sp-std/std",
"sp-transaction-pool/std",
"sp-version/std",
"substrate-wasm-builder",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
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() {}
3 changes: 2 additions & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ pub struct NoConversion;
impl ConversionFromAssetBalance<u128, (), u128> for NoConversion {
type Error = ();
fn from_asset_balance(balance: Balance, _asset_id: ()) -> Result<Balance, Self::Error> {
return Ok(balance)
return Ok(balance);
}
#[cfg(feature = "runtime-benchmarks")]
fn ensure_successful(_: ()) {}
Expand Down Expand Up @@ -590,6 +590,7 @@ pub type SignedExtra = (
frame_system::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
pallet_asset_tx_payment::ChargeAssetTxPayment<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic =
Expand Down
Loading