From 01cede212063714a295c9748494b36de0aef73e1 Mon Sep 17 00:00:00 2001 From: fewensa <37804932+fewensa@users.noreply.github.com> Date: Fri, 30 Apr 2021 03:11:33 +0800 Subject: [PATCH] Message dispatch support multiple instances (#942) * message dispatch support multiple instances * format code * define millau grandpa instance in rialto --- .../bin/millau/runtime/src/rialto_messages.rs | 9 +++++++-- bridges/bin/rialto/runtime/src/lib.rs | 1 + .../bin/rialto/runtime/src/millau_messages.rs | 9 +++++++-- bridges/bin/runtime-common/src/messages.rs | 18 ++++++++++-------- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/bridges/bin/millau/runtime/src/rialto_messages.rs b/bridges/bin/millau/runtime/src/rialto_messages.rs index 736301016f..a61d7cce29 100644 --- a/bridges/bin/millau/runtime/src/rialto_messages.rs +++ b/bridges/bin/millau/runtime/src/rialto_messages.rs @@ -214,7 +214,9 @@ impl TargetHeaderChain for Rialto fn verify_messages_delivery_proof( proof: Self::MessagesDeliveryProof, ) -> Result<(LaneId, InboundLaneData), Self::Error> { - messages::source::verify_messages_delivery_proof::(proof) + messages::source::verify_messages_delivery_proof::( + proof, + ) } } @@ -231,7 +233,10 @@ impl SourceHeaderChain for Rialto { proof: Self::MessagesProof, messages_count: u32, ) -> Result>, Self::Error> { - messages::target::verify_messages_proof::(proof, messages_count) + messages::target::verify_messages_proof::( + proof, + messages_count, + ) } } diff --git a/bridges/bin/rialto/runtime/src/lib.rs b/bridges/bin/rialto/runtime/src/lib.rs index 69fff6b10c..70f7703882 100644 --- a/bridges/bin/rialto/runtime/src/lib.rs +++ b/bridges/bin/rialto/runtime/src/lib.rs @@ -436,6 +436,7 @@ parameter_types! { pub const HeadersToKeep: u32 = 7 * bp_rialto::DAYS as u32; } +pub type MillauGrandpaInstance = (); impl pallet_bridge_grandpa::Config for Runtime { type BridgedChain = bp_millau::Millau; type MaxRequests = MaxRequests; diff --git a/bridges/bin/rialto/runtime/src/millau_messages.rs b/bridges/bin/rialto/runtime/src/millau_messages.rs index 77b73c0785..30a34b9276 100644 --- a/bridges/bin/rialto/runtime/src/millau_messages.rs +++ b/bridges/bin/rialto/runtime/src/millau_messages.rs @@ -214,7 +214,9 @@ impl TargetHeaderChain for Millau fn verify_messages_delivery_proof( proof: Self::MessagesDeliveryProof, ) -> Result<(LaneId, InboundLaneData), Self::Error> { - messages::source::verify_messages_delivery_proof::(proof) + messages::source::verify_messages_delivery_proof::( + proof, + ) } } @@ -231,7 +233,10 @@ impl SourceHeaderChain for Millau { proof: Self::MessagesProof, messages_count: u32, ) -> Result>, Self::Error> { - messages::target::verify_messages_proof::(proof, messages_count) + messages::target::verify_messages_proof::( + proof, + messages_count, + ) } } diff --git a/bridges/bin/runtime-common/src/messages.rs b/bridges/bin/runtime-common/src/messages.rs index 54e8b30031..9f25039dc4 100644 --- a/bridges/bin/runtime-common/src/messages.rs +++ b/bridges/bin/runtime-common/src/messages.rs @@ -352,20 +352,21 @@ pub mod source { } /// Verify proof of This -> Bridged chain messages delivery. - pub fn verify_messages_delivery_proof( + pub fn verify_messages_delivery_proof( proof: FromBridgedChainMessagesDeliveryProof>>, ) -> Result, &'static str> where - ThisRuntime: pallet_bridge_grandpa::Config, + ThisRuntime: pallet_bridge_grandpa::Config, ThisRuntime: pallet_bridge_messages::Config>>, - HashOf>: Into::BridgedChain>>, + HashOf>: + Into>::BridgedChain>>, { let FromBridgedChainMessagesDeliveryProof { bridged_header_hash, storage_proof, lane, } = proof; - pallet_bridge_grandpa::Pallet::::parse_finalized_storage_proof( + pallet_bridge_grandpa::Pallet::::parse_finalized_storage_proof( bridged_header_hash.into(), StorageProof::new(storage_proof), |storage| { @@ -504,20 +505,21 @@ pub mod target { /// The `messages_count` argument verification (sane limits) is supposed to be made /// outside of this function. This function only verifies that the proof declares exactly /// `messages_count` messages. - pub fn verify_messages_proof( + pub fn verify_messages_proof( proof: FromBridgedChainMessagesProof>>, messages_count: u32, ) -> Result>>>, &'static str> where - ThisRuntime: pallet_bridge_grandpa::Config, + ThisRuntime: pallet_bridge_grandpa::Config, ThisRuntime: pallet_bridge_messages::Config>>, - HashOf>: Into::BridgedChain>>, + HashOf>: + Into>::BridgedChain>>, { verify_messages_proof_with_parser::( proof, messages_count, |bridged_header_hash, bridged_storage_proof| { - pallet_bridge_grandpa::Pallet::::parse_finalized_storage_proof( + pallet_bridge_grandpa::Pallet::::parse_finalized_storage_proof( bridged_header_hash.into(), StorageProof::new(bridged_storage_proof), |storage_adapter| storage_adapter,