From b7ae392ca62923ba748f0cb9dde49b3274f70240 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Fri, 28 Jun 2024 09:40:25 +0200 Subject: [PATCH 1/3] New codegen for bridge-hub-polkadot 1.2.5 --- Cargo.lock | 2 +- .../src/codegen_runtime.rs | 16 +++++++++++++++- .../client-bridge-hub-polkadot/src/lib.rs | 2 +- substrate-relay/Cargo.toml | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 105a6dd7ad..b65fe75390 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9415,7 +9415,7 @@ dependencies = [ [[package]] name = "substrate-relay" -version = "1.6.4" +version = "1.6.5" dependencies = [ "anyhow", "async-std", diff --git a/relay-clients/client-bridge-hub-polkadot/src/codegen_runtime.rs b/relay-clients/client-bridge-hub-polkadot/src/codegen_runtime.rs index 2b4e85876f..83f6b1e4e5 100644 --- a/relay-clients/client-bridge-hub-polkadot/src/codegen_runtime.rs +++ b/relay-clients/client-bridge-hub-polkadot/src/codegen_runtime.rs @@ -17,7 +17,7 @@ //! Autogenerated runtime API //! THIS FILE WAS AUTOGENERATED USING parity-bridges-common::runtime-codegen //! EXECUTED COMMAND: target/debug/runtime-codegen --from-wasm-file -//! bridge-hub-polkadot_runtime-v1002004.compact.compressed.wasm +//! bridge-hub-polkadot_runtime-v1002005.compact.compressed.wasm #[allow(dead_code, unused_imports, non_camel_case_types)] #[allow(clippy::all)] @@ -708,6 +708,20 @@ pub mod api { pub id: _3, } } + pub mod frame_metadata_hash_extension { + use super::runtime_types; + #[derive(::codec::Decode, ::codec::Encode, Clone, Debug, PartialEq)] + pub struct CheckMetadataHash { + pub mode: runtime_types::frame_metadata_hash_extension::Mode, + } + #[derive(::codec::Decode, ::codec::Encode, Clone, Debug, PartialEq)] + pub enum Mode { + #[codec(index = 0)] + Disabled, + #[codec(index = 1)] + Enabled, + } + } pub mod frame_support { use super::runtime_types; pub mod dispatch { diff --git a/relay-clients/client-bridge-hub-polkadot/src/lib.rs b/relay-clients/client-bridge-hub-polkadot/src/lib.rs index c29ff7569f..e4bf8f9ebd 100644 --- a/relay-clients/client-bridge-hub-polkadot/src/lib.rs +++ b/relay-clients/client-bridge-hub-polkadot/src/lib.rs @@ -129,5 +129,5 @@ impl ChainWithMessages for BridgeHubPolkadot { impl ChainWithRuntimeVersion for BridgeHubPolkadot { const RUNTIME_VERSION: Option = - Some(SimpleRuntimeVersion { spec_version: 1_002_004, transaction_version: 3 }); + Some(SimpleRuntimeVersion { spec_version: 1_002_005, transaction_version: 4 }); } diff --git a/substrate-relay/Cargo.toml b/substrate-relay/Cargo.toml index 3bf8adb8df..68ceebb286 100644 --- a/substrate-relay/Cargo.toml +++ b/substrate-relay/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "substrate-relay" -version = "1.6.4" +version = "1.6.5" authors.workspace = true edition.workspace = true license = "GPL-3.0-or-later WITH Classpath-exception-2.0" From 0b50322c2894aec8d98255393e3d74f307ac1d2f Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Fri, 28 Jun 2024 10:21:08 +0200 Subject: [PATCH 2/3] Fix `CheckMetadataHash` for BHP --- Cargo.lock | 1 - .../client-bridge-hub-kusama/Cargo.toml | 1 - .../client-bridge-hub-kusama/src/lib.rs | 3 +-- .../src/codegen_runtime.rs | 11 +++++++++- .../client-bridge-hub-polkadot/src/lib.rs | 20 ++++++++++++++++--- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b65fe75390..8c7f62d200 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6831,7 +6831,6 @@ dependencies = [ "bp-header-chain", "bp-messages", "bp-parachains", - "bp-polkadot", "bp-polkadot-core", "bp-runtime", "bridge-runtime-common", diff --git a/relay-clients/client-bridge-hub-kusama/Cargo.toml b/relay-clients/client-bridge-hub-kusama/Cargo.toml index f2fdeeed40..2ee82f97f0 100644 --- a/relay-clients/client-bridge-hub-kusama/Cargo.toml +++ b/relay-clients/client-bridge-hub-kusama/Cargo.toml @@ -20,7 +20,6 @@ bp-bridge-hub-kusama = { git = "https://github.com/paritytech/polkadot-sdk", bra bp-header-chain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } bp-messages = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } bp-parachains = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } -bp-polkadot = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } bp-polkadot-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } bp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } bridge-runtime-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master" } diff --git a/relay-clients/client-bridge-hub-kusama/src/lib.rs b/relay-clients/client-bridge-hub-kusama/src/lib.rs index a8d47fdead..a78557629b 100644 --- a/relay-clients/client-bridge-hub-kusama/src/lib.rs +++ b/relay-clients/client-bridge-hub-kusama/src/lib.rs @@ -19,8 +19,7 @@ pub mod codegen_runtime; use bp_bridge_hub_kusama::AVERAGE_BLOCK_INTERVAL; -use bp_polkadot::SuffixedCommonSignedExtensionExt; -use bp_polkadot_core::SuffixedCommonSignedExtension; +use bp_polkadot_core::{SuffixedCommonSignedExtension, SuffixedCommonSignedExtensionExt}; use codec::Encode; use relay_substrate_client::{ calls::UtilityCall as MockUtilityCall, Chain, ChainWithBalances, ChainWithMessages, diff --git a/relay-clients/client-bridge-hub-polkadot/src/codegen_runtime.rs b/relay-clients/client-bridge-hub-polkadot/src/codegen_runtime.rs index 83f6b1e4e5..1b18885add 100644 --- a/relay-clients/client-bridge-hub-polkadot/src/codegen_runtime.rs +++ b/relay-clients/client-bridge-hub-polkadot/src/codegen_runtime.rs @@ -714,7 +714,16 @@ pub mod api { pub struct CheckMetadataHash { pub mode: runtime_types::frame_metadata_hash_extension::Mode, } - #[derive(::codec::Decode, ::codec::Encode, Clone, Debug, PartialEq)] + #[derive( + ::codec::Decode, + ::codec::Encode, + Clone, + Debug, + Eq, + PartialEq, + scale_info::TypeInfo, + Copy, + )] pub enum Mode { #[codec(index = 0)] Disabled, diff --git a/relay-clients/client-bridge-hub-polkadot/src/lib.rs b/relay-clients/client-bridge-hub-polkadot/src/lib.rs index e4bf8f9ebd..0f4d2eb57e 100644 --- a/relay-clients/client-bridge-hub-polkadot/src/lib.rs +++ b/relay-clients/client-bridge-hub-polkadot/src/lib.rs @@ -18,8 +18,8 @@ pub mod codegen_runtime; -use bp_bridge_hub_polkadot::{SignedExtension, AVERAGE_BLOCK_INTERVAL}; -use bp_polkadot_core::SuffixedCommonSignedExtensionExt; +use bp_bridge_hub_polkadot::AVERAGE_BLOCK_INTERVAL; +use bp_polkadot_core::{SuffixedCommonSignedExtension, SuffixedCommonSignedExtensionExt}; use codec::Encode; use relay_substrate_client::{ calls::UtilityCall as MockUtilityCall, Chain, ChainWithBalances, ChainWithMessages, @@ -32,6 +32,20 @@ use sp_runtime::{generic::SignedPayload, traits::IdentifyAccount}; use std::time::Duration; pub use codegen_runtime::api::runtime_types; +use runtime_types::frame_metadata_hash_extension::Mode; + +use bp_runtime::extensions::{ + BridgeRejectObsoleteHeadersAndMessages, GenericSignedExtensionSchema, + RefundBridgedParachainMessagesSchema, +}; + +pub type CheckMetadataHash = GenericSignedExtensionSchema>; + +pub type SignedExtension = SuffixedCommonSignedExtension<( + BridgeRejectObsoleteHeadersAndMessages, + RefundBridgedParachainMessagesSchema, + CheckMetadataHash, +)>; pub type RuntimeCall = runtime_types::bridge_hub_polkadot_runtime::RuntimeCall; // TODO: https://github.com/paritytech/parity-bridges-common/issues/2547 - regenerate when ready @@ -100,7 +114,7 @@ impl ChainWithTransactions for BridgeHubPolkadot { param.genesis_hash, unsigned.nonce, unsigned.tip, - (((), ()), ((), ())), + (((), (), Mode::Disabled), ((), (), None)), ), )?; From b9361f51af8108f3a5837262ca760e0458c34b21 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Fri, 28 Jun 2024 12:10:07 +0200 Subject: [PATCH 3/3] Fix codegen for `Meta` - add `::scale_info::TypeInfo` --- .../client-bridge-hub-kusama/src/codegen_runtime.rs | 9 +-------- .../client-bridge-hub-polkadot/src/codegen_runtime.rs | 9 +-------- tools/runtime-codegen/src/main.rs | 8 ++++++++ 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/relay-clients/client-bridge-hub-kusama/src/codegen_runtime.rs b/relay-clients/client-bridge-hub-kusama/src/codegen_runtime.rs index 06496b3482..925d56c87d 100644 --- a/relay-clients/client-bridge-hub-kusama/src/codegen_runtime.rs +++ b/relay-clients/client-bridge-hub-kusama/src/codegen_runtime.rs @@ -715,14 +715,7 @@ pub mod api { pub mode: runtime_types::frame_metadata_hash_extension::Mode, } #[derive( - ::codec::Decode, - ::codec::Encode, - Clone, - Debug, - Eq, - PartialEq, - scale_info::TypeInfo, - Copy, + ::codec::Decode, ::codec::Encode, Clone, Debug, Eq, PartialEq, scale_info::TypeInfo, )] pub enum Mode { #[codec(index = 0)] diff --git a/relay-clients/client-bridge-hub-polkadot/src/codegen_runtime.rs b/relay-clients/client-bridge-hub-polkadot/src/codegen_runtime.rs index 1b18885add..6f3ac60a44 100644 --- a/relay-clients/client-bridge-hub-polkadot/src/codegen_runtime.rs +++ b/relay-clients/client-bridge-hub-polkadot/src/codegen_runtime.rs @@ -715,14 +715,7 @@ pub mod api { pub mode: runtime_types::frame_metadata_hash_extension::Mode, } #[derive( - ::codec::Decode, - ::codec::Encode, - Clone, - Debug, - Eq, - PartialEq, - scale_info::TypeInfo, - Copy, + ::codec::Decode, ::codec::Encode, Clone, Debug, Eq, PartialEq, scale_info::TypeInfo, )] pub enum Mode { #[codec(index = 0)] diff --git a/tools/runtime-codegen/src/main.rs b/tools/runtime-codegen/src/main.rs index 6458c86759..b966576f41 100644 --- a/tools/runtime-codegen/src/main.rs +++ b/tools/runtime-codegen/src/main.rs @@ -124,6 +124,14 @@ fn main() -> color_eyre::Result<()> { syn::parse_quote!(PartialEq), ]); + // Add `TypeInfo` just for `frame_metadata_hash_extension::Meta` to be usable for + // `SignedExtension`. + codegen_builder.add_derives_for_type( + syn::parse_str("frame_metadata_hash_extension::Mode").expect("valid type"), + vec![syn::parse_quote!(Eq), syn::parse_quote!(scale_info::TypeInfo)], + false, + ); + // Type substitutes let type_substitutes = vec![ TypeSubstitute::simple("sp_core::crypto::AccountId32"),