From f63f5ee2fd811aedd4f7ce29ad23ff9edce6f4bf Mon Sep 17 00:00:00 2001 From: Santiago Balaguer Date: Fri, 7 Jun 2024 18:40:37 +0200 Subject: [PATCH 1/7] added checkMetadata SignedExtension to coretime parachains on Rococo and Westend --- .../coretime/coretime-rococo/Cargo.toml | 10 ++++ .../coretime/coretime-rococo/build.rs | 9 +++- .../coretime/coretime-rococo/src/lib.rs | 3 +- .../coretime/coretime-westend/Cargo.toml | 10 ++++ .../coretime/coretime-westend/build.rs | 9 +++- .../coretime/coretime-westend/src/lib.rs | 3 +- .../coretime_rococo_local_network.toml | 46 +++++++++++++++++++ .../coretime_westend_local_network.toml | 46 +++++++++++++++++++ 8 files changed, 132 insertions(+), 4 deletions(-) create mode 100644 cumulus/zombienet/examples/coretime_rococo_local_network.toml create mode 100644 cumulus/zombienet/examples/coretime_westend_local_network.toml diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/Cargo.toml b/cumulus/parachains/runtimes/coretime/coretime-rococo/Cargo.toml index dc99fe331f78..88328cd42926 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/Cargo.toml +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/Cargo.toml @@ -22,6 +22,7 @@ serde = { optional = true, features = ["derive"], workspace = true, default-feat # Substrate frame-benchmarking = { path = "../../../../../substrate/frame/benchmarking", default-features = false, optional = true } frame-executive = { path = "../../../../../substrate/frame/executive", default-features = false } +frame-metadata-hash-extension = { path = "../../../../../substrate/frame/metadata-hash-extension", default-features = false } frame-support = { path = "../../../../../substrate/frame/support", default-features = false } frame-system = { path = "../../../../../substrate/frame/system", default-features = false } frame-system-benchmarking = { path = "../../../../../substrate/frame/system/benchmarking", default-features = false, optional = true } @@ -94,6 +95,7 @@ std = [ "cumulus-primitives-utility/std", "frame-benchmarking?/std", "frame-executive/std", + "frame-metadata-hash-extension/std", "frame-support/std", "frame-system-benchmarking?/std", "frame-system-rpc-runtime-api/std", @@ -200,3 +202,11 @@ try-runtime = [ ] fast-runtime = [] + +# Enable the metadata hash generation in the wasm builder. +metadata-hash = ["substrate-wasm-builder/metadata-hash"] + +# A feature that should be enabled when the runtime should be built for on-chain +# deployment. This will disable stuff that shouldn't be part of the on-chain wasm +# to make it smaller, like logging for example. +on-chain-release-build = ["metadata-hash", "sp-api/disable-logging"] \ No newline at end of file diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/build.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/build.rs index 28dacd20cf30..3fb5f5677438 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/build.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/build.rs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#[cfg(feature = "std")] +#[cfg(all(not(feature = "metadata-hash"), feature = "std"))] fn main() { substrate_wasm_builder::WasmBuilder::new() .with_current_project() @@ -30,5 +30,12 @@ fn main() { .build(); } +#[cfg(all(feature = "metadata-hash", feature = "std"))] +fn main() { + substrate_wasm_builder::WasmBuilder::init_with_defaults() + .enable_metadata_hash("ROC", 12) + .build(); +} + #[cfg(not(feature = "std"))] fn main() {} diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs index b3eaf3d127a2..f10eb30578be 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs @@ -104,6 +104,7 @@ pub type SignedExtra = ( frame_system::CheckWeight, pallet_transaction_payment::ChargeTransactionPayment, cumulus_primitives_storage_weight_reclaim::StorageWeightReclaim, + frame_metadata_hash_extension::CheckMetadataHash, ); /// Unchecked extrinsic type as expected by this runtime. @@ -145,7 +146,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_version: 1_012_000, impl_version: 0, apis: RUNTIME_API_VERSIONS, - transaction_version: 1, + transaction_version: 2, state_version: 1, }; diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/Cargo.toml b/cumulus/parachains/runtimes/coretime/coretime-westend/Cargo.toml index 78018537f5d3..f483968aee80 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/Cargo.toml +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/Cargo.toml @@ -22,6 +22,7 @@ serde = { optional = true, features = ["derive"], workspace = true, default-feat # Substrate frame-benchmarking = { path = "../../../../../substrate/frame/benchmarking", default-features = false, optional = true } frame-executive = { path = "../../../../../substrate/frame/executive", default-features = false } +frame-metadata-hash-extension = { path = "../../../../../substrate/frame/metadata-hash-extension", default-features = false } frame-support = { path = "../../../../../substrate/frame/support", default-features = false } frame-system = { path = "../../../../../substrate/frame/system", default-features = false } frame-system-benchmarking = { path = "../../../../../substrate/frame/system/benchmarking", default-features = false, optional = true } @@ -94,6 +95,7 @@ std = [ "cumulus-primitives-utility/std", "frame-benchmarking?/std", "frame-executive/std", + "frame-metadata-hash-extension/std", "frame-support/std", "frame-system-benchmarking?/std", "frame-system-rpc-runtime-api/std", @@ -197,3 +199,11 @@ try-runtime = [ ] fast-runtime = [] + +# Enable the metadata hash generation in the wasm builder. +metadata-hash = ["substrate-wasm-builder/metadata-hash"] + +# A feature that should be enabled when the runtime should be built for on-chain +# deployment. This will disable stuff that shouldn't be part of the on-chain wasm +# to make it smaller, like logging for example. +on-chain-release-build = ["metadata-hash", "sp-api/disable-logging"] \ No newline at end of file diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/build.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/build.rs index 28dacd20cf30..168edc8a211e 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/build.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/build.rs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#[cfg(feature = "std")] +#[cfg(all(not(feature = "metadata-hash"), feature = "std"))] fn main() { substrate_wasm_builder::WasmBuilder::new() .with_current_project() @@ -30,5 +30,12 @@ fn main() { .build(); } +#[cfg(all(feature = "metadata-hash", feature = "std"))] +fn main() { + substrate_wasm_builder::WasmBuilder::init_with_defaults() + .enable_metadata_hash("WND", 12) + .build(); +} + #[cfg(not(feature = "std"))] fn main() {} diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs index 6c22702ce872..4bb66b887380 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs @@ -104,6 +104,7 @@ pub type SignedExtra = ( frame_system::CheckWeight, pallet_transaction_payment::ChargeTransactionPayment, cumulus_primitives_storage_weight_reclaim::StorageWeightReclaim, + frame_metadata_hash_extension::CheckMetadataHash, ); /// Unchecked extrinsic type as expected by this runtime. @@ -144,7 +145,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_version: 1_012_000, impl_version: 0, apis: RUNTIME_API_VERSIONS, - transaction_version: 1, + transaction_version: 2, state_version: 1, }; diff --git a/cumulus/zombienet/examples/coretime_rococo_local_network.toml b/cumulus/zombienet/examples/coretime_rococo_local_network.toml new file mode 100644 index 000000000000..cd813962a08b --- /dev/null +++ b/cumulus/zombienet/examples/coretime_rococo_local_network.toml @@ -0,0 +1,46 @@ +[relaychain] +default_command = "../polkadot/target/release/polkadot" +default_args = [ "-lparachain=debug" ] +chain = "rococo-local" + + [[relaychain.nodes]] + name = "alice" + validator = true + + [[relaychain.nodes]] + name = "bob" + validator = true + + [[relaychain.nodes]] + name = "charlie" + validator = true + + [[relaychain.nodes]] + name = "dave" + validator = true + +[[parachains]] +id = 1005 +chain = "coretime-local" +cumulus_based = true + + # run alice as parachain collator + [[parachains.collators]] + name = "alice" + validator = true + command = "./target/release/polkadot-parachain" + args = ["-lparachain=debug"] + + # run bob as parachain collator + [[parachains.collators]] + name = "bob" + validator = true + command = "./target/release/polkadot-parachain" + args = ["-lparachain=debug"] + + # run charlie as parachain collator + [[parachains.collators]] + name = "charlie" + validator = true + command = "./target/release/polkadot-parachain" + args = ["-lparachain=debug"] diff --git a/cumulus/zombienet/examples/coretime_westend_local_network.toml b/cumulus/zombienet/examples/coretime_westend_local_network.toml new file mode 100644 index 000000000000..4e75d3d384b8 --- /dev/null +++ b/cumulus/zombienet/examples/coretime_westend_local_network.toml @@ -0,0 +1,46 @@ +[relaychain] +default_command = "../../target/release/polkadot" +default_args = [ "-lparachain=debug" ] +chain = "westend-local" + + [[relaychain.nodes]] + name = "alice" + validator = true + + [[relaychain.nodes]] + name = "bob" + validator = true + + [[relaychain.nodes]] + name = "charlie" + validator = true + + [[relaychain.nodes]] + name = "dave" + validator = true + +[[parachains]] +id = 1005 +chain = "coretime-local" +cumulus_based = true + + # run alice as parachain collator + [[parachains.collators]] + name = "alice" + validator = true + command = "../../target/release/polkadot-parachain" + args = ["-lparachain=debug"] + + # run bob as parachain collator + [[parachains.collators]] + name = "bob" + validator = true + command = "../../target/release/polkadot-parachain" + args = ["-lparachain=debug"] + + # run charlie as parachain collator + [[parachains.collators]] + name = "charlie" + validator = true + command = "../../target/release/polkadot-parachain" + args = ["-lparachain=debug"] \ No newline at end of file From f3e78c11e63b5b9f1676636e26d5a74fa4eb4b5e Mon Sep 17 00:00:00 2001 From: Santiago Balaguer Date: Fri, 7 Jun 2024 18:44:40 +0200 Subject: [PATCH 2/7] remove zombienet config for coretime chains --- .../coretime_rococo_local_network.toml | 46 ------------------- .../coretime_westend_local_network.toml | 46 ------------------- 2 files changed, 92 deletions(-) delete mode 100644 cumulus/zombienet/examples/coretime_rococo_local_network.toml delete mode 100644 cumulus/zombienet/examples/coretime_westend_local_network.toml diff --git a/cumulus/zombienet/examples/coretime_rococo_local_network.toml b/cumulus/zombienet/examples/coretime_rococo_local_network.toml deleted file mode 100644 index cd813962a08b..000000000000 --- a/cumulus/zombienet/examples/coretime_rococo_local_network.toml +++ /dev/null @@ -1,46 +0,0 @@ -[relaychain] -default_command = "../polkadot/target/release/polkadot" -default_args = [ "-lparachain=debug" ] -chain = "rococo-local" - - [[relaychain.nodes]] - name = "alice" - validator = true - - [[relaychain.nodes]] - name = "bob" - validator = true - - [[relaychain.nodes]] - name = "charlie" - validator = true - - [[relaychain.nodes]] - name = "dave" - validator = true - -[[parachains]] -id = 1005 -chain = "coretime-local" -cumulus_based = true - - # run alice as parachain collator - [[parachains.collators]] - name = "alice" - validator = true - command = "./target/release/polkadot-parachain" - args = ["-lparachain=debug"] - - # run bob as parachain collator - [[parachains.collators]] - name = "bob" - validator = true - command = "./target/release/polkadot-parachain" - args = ["-lparachain=debug"] - - # run charlie as parachain collator - [[parachains.collators]] - name = "charlie" - validator = true - command = "./target/release/polkadot-parachain" - args = ["-lparachain=debug"] diff --git a/cumulus/zombienet/examples/coretime_westend_local_network.toml b/cumulus/zombienet/examples/coretime_westend_local_network.toml deleted file mode 100644 index 4e75d3d384b8..000000000000 --- a/cumulus/zombienet/examples/coretime_westend_local_network.toml +++ /dev/null @@ -1,46 +0,0 @@ -[relaychain] -default_command = "../../target/release/polkadot" -default_args = [ "-lparachain=debug" ] -chain = "westend-local" - - [[relaychain.nodes]] - name = "alice" - validator = true - - [[relaychain.nodes]] - name = "bob" - validator = true - - [[relaychain.nodes]] - name = "charlie" - validator = true - - [[relaychain.nodes]] - name = "dave" - validator = true - -[[parachains]] -id = 1005 -chain = "coretime-local" -cumulus_based = true - - # run alice as parachain collator - [[parachains.collators]] - name = "alice" - validator = true - command = "../../target/release/polkadot-parachain" - args = ["-lparachain=debug"] - - # run bob as parachain collator - [[parachains.collators]] - name = "bob" - validator = true - command = "../../target/release/polkadot-parachain" - args = ["-lparachain=debug"] - - # run charlie as parachain collator - [[parachains.collators]] - name = "charlie" - validator = true - command = "../../target/release/polkadot-parachain" - args = ["-lparachain=debug"] \ No newline at end of file From 99a5081c54fa008e2a87b982c6c8f5149395c7d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=B3nal=20Murray?= Date: Fri, 28 Jun 2024 11:44:40 +0200 Subject: [PATCH 3/7] Update lock file --- Cargo.lock | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 8af41e3eae58..91d604d6fa3c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3297,6 +3297,7 @@ dependencies = [ "cumulus-primitives-utility", "frame-benchmarking", "frame-executive", + "frame-metadata-hash-extension", "frame-support", "frame-system", "frame-system-benchmarking", @@ -3363,6 +3364,7 @@ dependencies = [ "cumulus-primitives-utility", "frame-benchmarking", "frame-executive", + "frame-metadata-hash-extension", "frame-support", "frame-system", "frame-system-benchmarking", From 1434dbb4794eda4d46c842a1656f3bdbd17958e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=B3nal=20Murray?= Date: Fri, 28 Jun 2024 11:50:00 +0200 Subject: [PATCH 4/7] Add prdoc --- prdoc/pr_4738.prdoc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 prdoc/pr_4738.prdoc diff --git a/prdoc/pr_4738.prdoc b/prdoc/pr_4738.prdoc new file mode 100644 index 000000000000..d3a115b35422 --- /dev/null +++ b/prdoc/pr_4738.prdoc @@ -0,0 +1,17 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: Add CheckMetadata SignedExtension to Rococo and Westend Coretime chains + +doc: + - audience: Runtime User + This brings support for the new Ledger app and similar hardware wallets to the Coretime + Chain on Rococo and Westend. These hardware wallets will be able to decode the transaction + using the metadata. The runtime will ensure that the metadata used for this decoding process + is correct and that the online wallet did not try to trick you. + +crates: | + - name: coretime-rococo-runtime + bump: major + - name: coretime-westend-runtime + bump: major From 2536a911b5cb462d31225620714e7dc444f7dc33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=B3nal=20Murray?= Date: Fri, 28 Jun 2024 11:52:58 +0200 Subject: [PATCH 5/7] Fix prdoc --- prdoc/pr_4738.prdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prdoc/pr_4738.prdoc b/prdoc/pr_4738.prdoc index d3a115b35422..c8f7c54cc45c 100644 --- a/prdoc/pr_4738.prdoc +++ b/prdoc/pr_4738.prdoc @@ -10,7 +10,7 @@ doc: using the metadata. The runtime will ensure that the metadata used for this decoding process is correct and that the online wallet did not try to trick you. -crates: | +crates: - name: coretime-rococo-runtime bump: major - name: coretime-westend-runtime From 504d8d5af02ffbd0a8de70c32c82e4329a6db25c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=B3nal=20Murray?= Date: Fri, 28 Jun 2024 11:56:24 +0200 Subject: [PATCH 6/7] fix harder --- prdoc/pr_4738.prdoc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/prdoc/pr_4738.prdoc b/prdoc/pr_4738.prdoc index c8f7c54cc45c..751f318e64f3 100644 --- a/prdoc/pr_4738.prdoc +++ b/prdoc/pr_4738.prdoc @@ -5,10 +5,11 @@ title: Add CheckMetadata SignedExtension to Rococo and Westend Coretime chains doc: - audience: Runtime User - This brings support for the new Ledger app and similar hardware wallets to the Coretime - Chain on Rococo and Westend. These hardware wallets will be able to decode the transaction - using the metadata. The runtime will ensure that the metadata used for this decoding process - is correct and that the online wallet did not try to trick you. + description: | + This brings support for the new Ledger app and similar hardware wallets to the Coretime + Chain on Rococo and Westend. These hardware wallets will be able to decode the transaction + using the metadata. The runtime will ensure that the metadata used for this decoding process + is correct and that the online wallet did not try to trick you. crates: - name: coretime-rococo-runtime From c03d113ba3ab29756b5fabbda99151a0a1d6d160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=B3nal=20Murray?= Date: Fri, 28 Jun 2024 12:15:03 +0200 Subject: [PATCH 7/7] Fix build scripts --- .../runtimes/coretime/coretime-rococo/build.rs | 17 ++++++++--------- .../runtimes/coretime/coretime-westend/build.rs | 17 ++++++++--------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/build.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/build.rs index 3fb5f5677438..368a1e427aaa 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/build.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/build.rs @@ -15,18 +15,11 @@ #[cfg(all(not(feature = "metadata-hash"), feature = "std"))] fn main() { - substrate_wasm_builder::WasmBuilder::new() - .with_current_project() - .export_heap_base() - .import_memory() - .build(); + substrate_wasm_builder::WasmBuilder::build_using_defaults(); - substrate_wasm_builder::WasmBuilder::new() - .with_current_project() + substrate_wasm_builder::WasmBuilder::init_with_defaults() .set_file_name("fast_runtime_binary.rs") .enable_feature("fast-runtime") - .import_memory() - .export_heap_base() .build(); } @@ -35,6 +28,12 @@ fn main() { substrate_wasm_builder::WasmBuilder::init_with_defaults() .enable_metadata_hash("ROC", 12) .build(); + + substrate_wasm_builder::WasmBuilder::init_with_defaults() + .set_file_name("fast_runtime_binary.rs") + .enable_feature("fast-runtime") + .enable_metadata_hash("ROC", 12) + .build(); } #[cfg(not(feature = "std"))] diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/build.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/build.rs index 168edc8a211e..2f10a39d1b2e 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/build.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/build.rs @@ -15,18 +15,11 @@ #[cfg(all(not(feature = "metadata-hash"), feature = "std"))] fn main() { - substrate_wasm_builder::WasmBuilder::new() - .with_current_project() - .export_heap_base() - .import_memory() - .build(); + substrate_wasm_builder::WasmBuilder::build_using_defaults(); - substrate_wasm_builder::WasmBuilder::new() - .with_current_project() + substrate_wasm_builder::WasmBuilder::init_with_defaults() .set_file_name("fast_runtime_binary.rs") .enable_feature("fast-runtime") - .import_memory() - .export_heap_base() .build(); } @@ -35,6 +28,12 @@ fn main() { substrate_wasm_builder::WasmBuilder::init_with_defaults() .enable_metadata_hash("WND", 12) .build(); + + substrate_wasm_builder::WasmBuilder::init_with_defaults() + .set_file_name("fast_runtime_binary.rs") + .enable_feature("fast-runtime") + .enable_metadata_hash("WND", 12) + .build(); } #[cfg(not(feature = "std"))]