Skip to content

Commit

Permalink
Relay v1.6.5: added support for bridge-hub-polkadot/1002005 (#3015)
Browse files Browse the repository at this point in the history
* New codegen for bridge-hub-polkadot 1.2.5

* Fix `CheckMetadataHash` for BHP

* Fix codegen for `Meta` - add `::scale_info::TypeInfo`
  • Loading branch information
bkontur authored Jun 28, 2024
1 parent 98a0c88 commit 4e011c3
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 19 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion relay-clients/client-bridge-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
3 changes: 1 addition & 2 deletions relay-clients/client-bridge-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 17 additions & 1 deletion relay-clients/client-bridge-hub-polkadot/src/codegen_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -708,6 +708,22 @@ 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, Eq, PartialEq, scale_info::TypeInfo,
)]
pub enum Mode {
#[codec(index = 0)]
Disabled,
#[codec(index = 1)]
Enabled,
}
}
pub mod frame_support {
use super::runtime_types;
pub mod dispatch {
Expand Down
22 changes: 18 additions & 4 deletions relay-clients/client-bridge-hub-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<Mode, Option<[u8; 32]>>;

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
Expand Down Expand Up @@ -100,7 +114,7 @@ impl ChainWithTransactions for BridgeHubPolkadot {
param.genesis_hash,
unsigned.nonce,
unsigned.tip,
(((), ()), ((), ())),
(((), (), Mode::Disabled), ((), (), None)),
),
)?;

Expand Down Expand Up @@ -129,5 +143,5 @@ impl ChainWithMessages for BridgeHubPolkadot {

impl ChainWithRuntimeVersion for BridgeHubPolkadot {
const RUNTIME_VERSION: Option<SimpleRuntimeVersion> =
Some(SimpleRuntimeVersion { spec_version: 1_002_004, transaction_version: 3 });
Some(SimpleRuntimeVersion { spec_version: 1_002_005, transaction_version: 4 });
}
2 changes: 1 addition & 1 deletion substrate-relay/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
8 changes: 8 additions & 0 deletions tools/runtime-codegen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit 4e011c3

Please sign in to comment.