From bdeb4da7738c10a2ed98b7c557f2cd31c0be1422 Mon Sep 17 00:00:00 2001 From: Yang Date: Tue, 1 Oct 2024 19:27:39 +0000 Subject: [PATCH 1/3] add support for metadata hash extention --- parachain/Cargo.lock | 55 +++++++++++++++++++++++++++ parachain/Cargo.toml | 1 + parachain/runtime/litentry/Cargo.toml | 4 +- parachain/runtime/litentry/build.rs | 6 +-- parachain/runtime/litentry/src/lib.rs | 3 +- parachain/runtime/paseo/Cargo.toml | 4 +- parachain/runtime/paseo/build.rs | 6 +-- parachain/runtime/paseo/src/lib.rs | 3 +- parachain/runtime/rococo/Cargo.toml | 4 +- parachain/runtime/rococo/build.rs | 6 +-- parachain/runtime/rococo/src/lib.rs | 3 +- 11 files changed, 74 insertions(+), 21 deletions(-) diff --git a/parachain/Cargo.lock b/parachain/Cargo.lock index 4b7e019a05..6fb64dda77 100644 --- a/parachain/Cargo.lock +++ b/parachain/Cargo.lock @@ -5613,6 +5613,7 @@ dependencies = [ "fp-self-contained", "frame-benchmarking", "frame-executive", + "frame-metadata-hash-extension", "frame-support", "frame-system", "frame-system-benchmarking", @@ -5920,6 +5921,20 @@ dependencies = [ "hash-db 0.16.0", ] +[[package]] +name = "merkleized-metadata" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f313fcff1d2a4bcaa2deeaa00bf7530d77d5f7bd0467a117dde2e29a75a7a17a" +dependencies = [ + "array-bytes", + "blake3", + "frame-metadata", + "parity-scale-codec", + "scale-decode", + "scale-info", +] + [[package]] name = "merlin" version = "2.0.1" @@ -8484,6 +8499,7 @@ dependencies = [ "fp-self-contained", "frame-benchmarking", "frame-executive", + "frame-metadata-hash-extension", "frame-support", "frame-system", "frame-system-benchmarking", @@ -10783,6 +10799,7 @@ dependencies = [ "fp-self-contained", "frame-benchmarking", "frame-executive", + "frame-metadata-hash-extension", "frame-support", "frame-system", "frame-system-benchmarking", @@ -12348,6 +12365,29 @@ dependencies = [ "sp-arithmetic", ] +[[package]] +name = "scale-bits" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e57b1e7f6b65ed1f04e79a85a57d755ad56d76fdf1e9bddcc9ae14f71fcdcf54" +dependencies = [ + "parity-scale-codec", + "scale-type-resolver", +] + +[[package]] +name = "scale-decode" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e98f3262c250d90e700bb802eb704e1f841e03331c2eb815e46516c4edbf5b27" +dependencies = [ + "derive_more", + "parity-scale-codec", + "scale-bits", + "scale-type-resolver", + "smallvec", +] + [[package]] name = "scale-info" version = "2.11.3" @@ -12374,6 +12414,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "scale-type-resolver" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0cded6518aa0bd6c1be2b88ac81bf7044992f0f154bfbabd5ad34f43512abcb" + [[package]] name = "schannel" version = "0.1.23" @@ -14094,11 +14140,20 @@ version = "5.0.0-dev" source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.1.0#e51a91fcac27d2f95ad631989622848aa8043f9e" dependencies = [ "ansi_term", + "array-bytes", "build-helper", "cargo_metadata", "filetime", + "frame-metadata", + "merkleized-metadata", + "parity-scale-codec", "parity-wasm", + "sc-executor", + "sp-core", + "sp-io", "sp-maybe-compressed-blob", + "sp-tracing", + "sp-version", "strum 0.24.1", "tempfile", "toml 0.7.8", diff --git a/parachain/Cargo.toml b/parachain/Cargo.toml index d229cfd2eb..500f645082 100644 --- a/parachain/Cargo.toml +++ b/parachain/Cargo.toml @@ -177,6 +177,7 @@ sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "r sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } sp-version = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } 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-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false } diff --git a/parachain/runtime/litentry/Cargo.toml b/parachain/runtime/litentry/Cargo.toml index 4b3d3f3b52..79ea857f82 100644 --- a/parachain/runtime/litentry/Cargo.toml +++ b/parachain/runtime/litentry/Cargo.toml @@ -27,6 +27,7 @@ sp-transaction-pool = { workspace = true } sp-version = { workspace = true } 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 } @@ -126,7 +127,7 @@ xcm-simulator = { workspace = true } pallet-message-queue = { workspace = true, features = ["std"] } [build-dependencies] -substrate-wasm-builder = { workspace = true } +substrate-wasm-builder = { workspace = true, features = ["metadata-hash"] } [features] default = ["std"] @@ -186,6 +187,7 @@ std = [ "sp-transaction-pool/std", "sp-version/std", "frame-executive/std", + "frame-metadata-hash-extension/std", "frame-support/std", "frame-system/std", "frame-try-runtime?/std", diff --git a/parachain/runtime/litentry/build.rs b/parachain/runtime/litentry/build.rs index 3ccbec6b26..e99ce32258 100644 --- a/parachain/runtime/litentry/build.rs +++ b/parachain/runtime/litentry/build.rs @@ -17,9 +17,5 @@ use substrate_wasm_builder::WasmBuilder; fn main() { - WasmBuilder::new() - .with_current_project() - .export_heap_base() - .import_memory() - .build() + WasmBuilder::init_with_defaults().enable_metadata_hash("LIT", 18).build(); } diff --git a/parachain/runtime/litentry/src/lib.rs b/parachain/runtime/litentry/src/lib.rs index 176f7164d3..7aec25c89d 100644 --- a/parachain/runtime/litentry/src/lib.rs +++ b/parachain/runtime/litentry/src/lib.rs @@ -125,6 +125,7 @@ pub type SignedExtra = ( frame_system::CheckNonce, frame_system::CheckWeight, pallet_transaction_payment::ChargeTransactionPayment, + frame_metadata_hash_extension::CheckMetadataHash, ); /// Unchecked extrinsic type as expected by this runtime. @@ -224,7 +225,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_version: 9201, impl_version: 0, apis: RUNTIME_API_VERSIONS, - transaction_version: 1, + transaction_version: 2, state_version: 0, }; diff --git a/parachain/runtime/paseo/Cargo.toml b/parachain/runtime/paseo/Cargo.toml index 09c035fa95..85c89ace5c 100644 --- a/parachain/runtime/paseo/Cargo.toml +++ b/parachain/runtime/paseo/Cargo.toml @@ -25,6 +25,7 @@ sp-transaction-pool = { workspace = true } sp-version = { workspace = true } 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 } @@ -126,7 +127,7 @@ xcm-simulator = { workspace = true } pallet-message-queue = { workspace = true, features = ["std"] } [build-dependencies] -substrate-wasm-builder = { workspace = true } +substrate-wasm-builder = { workspace = true, features = ["metadata-hash"] } [features] default = ["std"] @@ -191,6 +192,7 @@ std = [ "sp-transaction-pool/std", "sp-version/std", "frame-executive/std", + "frame-metadata-hash-extension/std", "frame-support/std", "frame-system/std", "frame-try-runtime?/std", diff --git a/parachain/runtime/paseo/build.rs b/parachain/runtime/paseo/build.rs index 3ccbec6b26..e99ce32258 100644 --- a/parachain/runtime/paseo/build.rs +++ b/parachain/runtime/paseo/build.rs @@ -17,9 +17,5 @@ use substrate_wasm_builder::WasmBuilder; fn main() { - WasmBuilder::new() - .with_current_project() - .export_heap_base() - .import_memory() - .build() + WasmBuilder::init_with_defaults().enable_metadata_hash("LIT", 18).build(); } diff --git a/parachain/runtime/paseo/src/lib.rs b/parachain/runtime/paseo/src/lib.rs index e18997cdff..60d6b5d8d0 100644 --- a/parachain/runtime/paseo/src/lib.rs +++ b/parachain/runtime/paseo/src/lib.rs @@ -130,6 +130,7 @@ pub type SignedExtra = ( frame_system::CheckNonce, frame_system::CheckWeight, pallet_transaction_payment::ChargeTransactionPayment, + frame_metadata_hash_extension::CheckMetadataHash, ); /// Unchecked extrinsic type as expected by this runtime. @@ -230,7 +231,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_version: 9201, impl_version: 0, apis: RUNTIME_API_VERSIONS, - transaction_version: 1, + transaction_version: 2, state_version: 0, }; diff --git a/parachain/runtime/rococo/Cargo.toml b/parachain/runtime/rococo/Cargo.toml index 0da86e3f28..6867224fa9 100644 --- a/parachain/runtime/rococo/Cargo.toml +++ b/parachain/runtime/rococo/Cargo.toml @@ -25,6 +25,7 @@ sp-transaction-pool = { workspace = true } sp-version = { workspace = true } 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 } @@ -126,7 +127,7 @@ xcm-simulator = { workspace = true } pallet-message-queue = { workspace = true, features = ["std"] } [build-dependencies] -substrate-wasm-builder = { workspace = true } +substrate-wasm-builder = { workspace = true, features = ["metadata-hash"] } [features] default = ["std"] @@ -191,6 +192,7 @@ std = [ "sp-transaction-pool/std", "sp-version/std", "frame-executive/std", + "frame-metadata-hash-extension/std", "frame-support/std", "frame-system/std", "frame-try-runtime?/std", diff --git a/parachain/runtime/rococo/build.rs b/parachain/runtime/rococo/build.rs index 3ccbec6b26..e99ce32258 100644 --- a/parachain/runtime/rococo/build.rs +++ b/parachain/runtime/rococo/build.rs @@ -17,9 +17,5 @@ use substrate_wasm_builder::WasmBuilder; fn main() { - WasmBuilder::new() - .with_current_project() - .export_heap_base() - .import_memory() - .build() + WasmBuilder::init_with_defaults().enable_metadata_hash("LIT", 18).build(); } diff --git a/parachain/runtime/rococo/src/lib.rs b/parachain/runtime/rococo/src/lib.rs index 334234027c..c1fe3544b0 100644 --- a/parachain/runtime/rococo/src/lib.rs +++ b/parachain/runtime/rococo/src/lib.rs @@ -129,6 +129,7 @@ pub type SignedExtra = ( frame_system::CheckNonce, frame_system::CheckWeight, pallet_transaction_payment::ChargeTransactionPayment, + frame_metadata_hash_extension::CheckMetadataHash, ); /// Unchecked extrinsic type as expected by this runtime. @@ -229,7 +230,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_version: 9201, impl_version: 0, apis: RUNTIME_API_VERSIONS, - transaction_version: 1, + transaction_version: 2, state_version: 0, }; From 7dff3fce020095075d5293d49a60d7cc94abb5fc Mon Sep 17 00:00:00 2001 From: Yang Date: Fri, 4 Oct 2024 08:54:41 +0000 Subject: [PATCH 2/3] add support for metadata hash on worker --- tee-worker/Cargo.lock | 10 +++++----- tee-worker/Cargo.toml | 4 ++-- tee-worker/bitacross/enclave-runtime/Cargo.lock | 8 ++++---- tee-worker/identity/enclave-runtime/Cargo.lock | 8 ++++---- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tee-worker/Cargo.lock b/tee-worker/Cargo.lock index 3598a69365..fb920a6832 100644 --- a/tee-worker/Cargo.lock +++ b/tee-worker/Cargo.lock @@ -15,7 +15,7 @@ dependencies = [ [[package]] name = "ac-compose-macros" version = "0.4.2" -source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/encointer/substrate-api-client.git?branch=v0.9.42-tag-v0.14.0-retracted-check-metadata-hash#eddca35c73b5e2e3d0371fa923a0ba605c2f0d61" dependencies = [ "ac-primitives", "log 0.4.20", @@ -25,7 +25,7 @@ dependencies = [ [[package]] name = "ac-node-api" version = "0.5.1" -source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/encointer/substrate-api-client.git?branch=v0.9.42-tag-v0.14.0-retracted-check-metadata-hash#eddca35c73b5e2e3d0371fa923a0ba605c2f0d61" dependencies = [ "ac-primitives", "bitvec", @@ -50,7 +50,7 @@ dependencies = [ [[package]] name = "ac-primitives" version = "0.9.0" -source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/encointer/substrate-api-client.git?branch=v0.9.42-tag-v0.14.0-retracted-check-metadata-hash#eddca35c73b5e2e3d0371fa923a0ba605c2f0d61" dependencies = [ "frame-system", "impl-serde", @@ -9331,7 +9331,7 @@ dependencies = [ [[package]] name = "substrate-api-client" version = "0.14.0" -source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/encointer/substrate-api-client.git?branch=v0.9.42-tag-v0.14.0-retracted-check-metadata-hash#eddca35c73b5e2e3d0371fa923a0ba605c2f0d61" dependencies = [ "ac-compose-macros", "ac-node-api", @@ -9369,7 +9369,7 @@ dependencies = [ [[package]] name = "substrate-client-keystore" version = "0.9.1" -source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/encointer/substrate-api-client.git?branch=v0.9.42-tag-v0.14.0-retracted-check-metadata-hash#eddca35c73b5e2e3d0371fa923a0ba605c2f0d61" dependencies = [ "array-bytes 4.2.0", "async-trait", diff --git a/tee-worker/Cargo.toml b/tee-worker/Cargo.toml index 07f58471b0..14a3e78002 100644 --- a/tee-worker/Cargo.toml +++ b/tee-worker/Cargo.toml @@ -151,8 +151,8 @@ rlp = { version = "0.5", default-features = false } sha3 = { version = "0.10", default-features = false } url = { git = "https://github.com/domenukk/rust-url", branch = "no_std", default-features = false, features = ["alloc", "no_std_net"] } -substrate-api-client = { git = "https://github.com/scs/substrate-api-client", branch = "polkadot-v0.9.42-tag-v0.14.0", default-features = false, features = ["sync-api"] } -substrate-client-keystore = { git = "https://github.com/scs/substrate-api-client.git", branch = "polkadot-v0.9.42-tag-v0.14.0" } +substrate-api-client = { git = "https://github.com/encointer/substrate-api-client.git", branch = "v0.9.42-tag-v0.14.0-retracted-check-metadata-hash", default-features = false, features = ["sync-api"] } +substrate-client-keystore = { git = "https://github.com/encointer/substrate-api-client.git", branch = "v0.9.42-tag-v0.14.0-retracted-check-metadata-hash" } # substrate finality-grandpa = { version = "0.16.0", default-features = false, features = ["derive-codec"] } diff --git a/tee-worker/bitacross/enclave-runtime/Cargo.lock b/tee-worker/bitacross/enclave-runtime/Cargo.lock index 0062a3972d..50ce4b6f54 100644 --- a/tee-worker/bitacross/enclave-runtime/Cargo.lock +++ b/tee-worker/bitacross/enclave-runtime/Cargo.lock @@ -15,7 +15,7 @@ dependencies = [ [[package]] name = "ac-compose-macros" version = "0.4.2" -source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/encointer/substrate-api-client.git?branch=v0.9.42-tag-v0.14.0-retracted-check-metadata-hash#eddca35c73b5e2e3d0371fa923a0ba605c2f0d61" dependencies = [ "ac-primitives", "log 0.4.21", @@ -25,7 +25,7 @@ dependencies = [ [[package]] name = "ac-node-api" version = "0.5.1" -source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/encointer/substrate-api-client.git?branch=v0.9.42-tag-v0.14.0-retracted-check-metadata-hash#eddca35c73b5e2e3d0371fa923a0ba605c2f0d61" dependencies = [ "ac-primitives", "bitvec", @@ -50,7 +50,7 @@ dependencies = [ [[package]] name = "ac-primitives" version = "0.9.0" -source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/encointer/substrate-api-client.git?branch=v0.9.42-tag-v0.14.0-retracted-check-metadata-hash#eddca35c73b5e2e3d0371fa923a0ba605c2f0d61" dependencies = [ "impl-serde", "parity-scale-codec", @@ -4774,7 +4774,7 @@ dependencies = [ [[package]] name = "substrate-api-client" version = "0.14.0" -source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/encointer/substrate-api-client.git?branch=v0.9.42-tag-v0.14.0-retracted-check-metadata-hash#eddca35c73b5e2e3d0371fa923a0ba605c2f0d61" dependencies = [ "ac-compose-macros", "ac-node-api", diff --git a/tee-worker/identity/enclave-runtime/Cargo.lock b/tee-worker/identity/enclave-runtime/Cargo.lock index 34b8f1631d..cbd98122e1 100644 --- a/tee-worker/identity/enclave-runtime/Cargo.lock +++ b/tee-worker/identity/enclave-runtime/Cargo.lock @@ -15,7 +15,7 @@ dependencies = [ [[package]] name = "ac-compose-macros" version = "0.4.2" -source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/encointer/substrate-api-client.git?branch=v0.9.42-tag-v0.14.0-retracted-check-metadata-hash#eddca35c73b5e2e3d0371fa923a0ba605c2f0d61" dependencies = [ "ac-primitives", "log", @@ -25,7 +25,7 @@ dependencies = [ [[package]] name = "ac-node-api" version = "0.5.1" -source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/encointer/substrate-api-client.git?branch=v0.9.42-tag-v0.14.0-retracted-check-metadata-hash#eddca35c73b5e2e3d0371fa923a0ba605c2f0d61" dependencies = [ "ac-primitives", "bitvec", @@ -50,7 +50,7 @@ dependencies = [ [[package]] name = "ac-primitives" version = "0.9.0" -source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/encointer/substrate-api-client.git?branch=v0.9.42-tag-v0.14.0-retracted-check-metadata-hash#eddca35c73b5e2e3d0371fa923a0ba605c2f0d61" dependencies = [ "impl-serde", "parity-scale-codec", @@ -5518,7 +5518,7 @@ dependencies = [ [[package]] name = "substrate-api-client" version = "0.14.0" -source = "git+https://github.com/scs/substrate-api-client?branch=polkadot-v0.9.42-tag-v0.14.0#e4ed74b0fb6c2fd5585f55c2702b97b56d99c7f6" +source = "git+https://github.com/encointer/substrate-api-client.git?branch=v0.9.42-tag-v0.14.0-retracted-check-metadata-hash#eddca35c73b5e2e3d0371fa923a0ba605c2f0d61" dependencies = [ "ac-compose-macros", "ac-node-api", From 6eb1fe76fdf350f89392cfd40d91cc95ed4da089 Mon Sep 17 00:00:00 2001 From: Yang Date: Sat, 5 Oct 2024 21:12:37 +0000 Subject: [PATCH 3/3] add signedExtensions in ApiPromise.create() for ts-test --- parachain/ts-tests/common/utils/integration-setup.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/parachain/ts-tests/common/utils/integration-setup.ts b/parachain/ts-tests/common/utils/integration-setup.ts index 099dc6cd37..4bba5ccdde 100644 --- a/parachain/ts-tests/common/utils/integration-setup.ts +++ b/parachain/ts-tests/common/utils/integration-setup.ts @@ -23,6 +23,16 @@ export async function initApiPromise(config: any): Promise { // Initiate the polkadot API. const api = await ApiPromise.create({ provider: wsProvider, + signedExtensions: { + CheckMetadataHash: { + extrinsic: { + mode: 'u8' + }, + payload: { + metadataHash: 'Option<[u8;32]>' + } + } + } }); console.log(`Initialization done`);