1515// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
1616
1717use crate :: cli:: CliChain ;
18- use relay_substrate_client:: { AccountKeyPairOf , Chain , TransactionSignScheme } ;
18+ use messages_relay:: relay_strategy:: MixStrategy ;
19+ use pallet_bridge_parachains:: { RelayBlockHash , RelayBlockHasher , RelayBlockNumber } ;
20+ use parachains_relay:: ParachainsPipeline ;
21+ use relay_substrate_client:: { AccountKeyPairOf , Chain , RelayChain , TransactionSignScheme } ;
1922use strum:: { EnumString , EnumVariantNames } ;
2023use substrate_relay_helper:: {
2124 finality:: SubstrateFinalitySyncPipeline , messages_lane:: SubstrateMessageLane ,
25+ parachains:: SubstrateParachainsPipeline ,
2226} ;
2327
2428#[ derive( Debug , PartialEq , Eq , EnumString , EnumVariantNames ) ]
@@ -59,8 +63,9 @@ pub trait CliBridgeBase: Sized {
5963 + CliChain < KeyPair = AccountKeyPairOf < Self :: Target > > ;
6064}
6165
62- /// Bridge representation that can be used from the CLI for relaying headers.
63- pub trait HeadersCliBridge : CliBridgeBase {
66+ /// Bridge representation that can be used from the CLI for relaying headers
67+ /// from a relay chain to a relay chain.
68+ pub trait RelayToRelayHeadersCliBridge : CliBridgeBase {
6469 /// Finality proofs synchronization pipeline.
6570 type Finality : SubstrateFinalitySyncPipeline <
6671 SourceChain = Self :: Source ,
@@ -69,6 +74,29 @@ pub trait HeadersCliBridge: CliBridgeBase {
6974 > ;
7075}
7176
77+ /// Bridge representation that can be used from the CLI for relaying headers
78+ /// from a parachain to a relay chain.
79+ pub trait ParachainToRelayHeadersCliBridge : CliBridgeBase {
80+ // The `CliBridgeBase` type represents the parachain in this situation.
81+ // We need to add an extra type for the relay chain.
82+ type SourceRelay : Chain < BlockNumber = RelayBlockNumber , Hash = RelayBlockHash , Hasher = RelayBlockHasher >
83+ + CliChain
84+ + RelayChain ;
85+ /// Finality proofs synchronization pipeline (source parachain -> target).
86+ type ParachainFinality : SubstrateParachainsPipeline <
87+ SourceRelayChain = Self :: SourceRelay ,
88+ SourceParachain = Self :: Source ,
89+ TargetChain = Self :: Target ,
90+ TransactionSignScheme = Self :: Target ,
91+ > + ParachainsPipeline < SourceChain = Self :: SourceRelay , TargetChain = Self :: Target > ;
92+ /// Finality proofs synchronization pipeline (source relay chain -> target).
93+ type RelayFinality : SubstrateFinalitySyncPipeline <
94+ SourceChain = Self :: SourceRelay ,
95+ TargetChain = Self :: Target ,
96+ TransactionSignScheme = Self :: Target ,
97+ > ;
98+ }
99+
72100/// Bridge representation that can be used from the CLI for relaying messages.
73101pub trait MessagesCliBridge : CliBridgeBase {
74102 /// Name of the runtime method used to estimate the message dispatch and delivery fee for the
@@ -80,6 +108,7 @@ pub trait MessagesCliBridge: CliBridgeBase {
80108 TargetChain = Self :: Target ,
81109 SourceTransactionSignScheme = Self :: Source ,
82110 TargetTransactionSignScheme = Self :: Target ,
111+ RelayStrategy = MixStrategy ,
83112 > ;
84113}
85114
@@ -91,7 +120,7 @@ impl CliBridgeBase for MillauToRialtoCliBridge {
91120 type Target = relay_rialto_client:: Rialto ;
92121}
93122
94- impl HeadersCliBridge for MillauToRialtoCliBridge {
123+ impl RelayToRelayHeadersCliBridge for MillauToRialtoCliBridge {
95124 type Finality = crate :: chains:: millau_headers_to_rialto:: MillauFinalityToRialto ;
96125}
97126
@@ -109,7 +138,7 @@ impl CliBridgeBase for RialtoToMillauCliBridge {
109138 type Target = relay_millau_client:: Millau ;
110139}
111140
112- impl HeadersCliBridge for RialtoToMillauCliBridge {
141+ impl RelayToRelayHeadersCliBridge for RialtoToMillauCliBridge {
113142 type Finality = crate :: chains:: rialto_headers_to_millau:: RialtoFinalityToMillau ;
114143}
115144
@@ -127,7 +156,7 @@ impl CliBridgeBase for WestendToMillauCliBridge {
127156 type Target = relay_millau_client:: Millau ;
128157}
129158
130- impl HeadersCliBridge for WestendToMillauCliBridge {
159+ impl RelayToRelayHeadersCliBridge for WestendToMillauCliBridge {
131160 type Finality = crate :: chains:: westend_headers_to_millau:: WestendFinalityToMillau ;
132161}
133162
@@ -139,7 +168,7 @@ impl CliBridgeBase for MillauToRialtoParachainCliBridge {
139168 type Target = relay_rialto_parachain_client:: RialtoParachain ;
140169}
141170
142- impl HeadersCliBridge for MillauToRialtoParachainCliBridge {
171+ impl RelayToRelayHeadersCliBridge for MillauToRialtoParachainCliBridge {
143172 type Finality =
144173 crate :: chains:: millau_headers_to_rialto_parachain:: MillauFinalityToRialtoParachain ;
145174}
@@ -159,6 +188,12 @@ impl CliBridgeBase for RialtoParachainToMillauCliBridge {
159188 type Target = relay_millau_client:: Millau ;
160189}
161190
191+ impl ParachainToRelayHeadersCliBridge for RialtoParachainToMillauCliBridge {
192+ type SourceRelay = relay_rialto_client:: Rialto ;
193+ type ParachainFinality = crate :: chains:: rialto_parachains_to_millau:: RialtoParachainsToMillau ;
194+ type RelayFinality = crate :: chains:: rialto_headers_to_millau:: RialtoFinalityToMillau ;
195+ }
196+
162197impl MessagesCliBridge for RialtoParachainToMillauCliBridge {
163198 const ESTIMATE_MESSAGE_FEE_METHOD : & ' static str =
164199 bp_millau:: TO_MILLAU_ESTIMATE_MESSAGE_FEE_METHOD ;
@@ -169,6 +204,12 @@ impl MessagesCliBridge for RialtoParachainToMillauCliBridge {
169204//// `WestendParachain` to `Millau` bridge definition.
170205pub struct WestmintToMillauCliBridge { }
171206
207+ impl ParachainToRelayHeadersCliBridge for WestmintToMillauCliBridge {
208+ type SourceRelay = relay_westend_client:: Westend ;
209+ type ParachainFinality = crate :: chains:: westend_parachains_to_millau:: WestendParachainsToMillau ;
210+ type RelayFinality = crate :: chains:: westend_headers_to_millau:: WestendFinalityToMillau ;
211+ }
212+
172213impl CliBridgeBase for WestmintToMillauCliBridge {
173214 type Source = relay_westend_client:: Westmint ;
174215 type Target = relay_millau_client:: Millau ;
0 commit comments