@@ -52,11 +52,11 @@ use crate::{
5252
5353use bp_messages:: {
5454 source_chain:: {
55- LaneMessageVerifier , MessageDeliveryAndDispatchPayment , SendMessageArtifacts ,
56- TargetHeaderChain ,
55+ DeliveryConfirmationPayments , LaneMessageVerifier , SendMessageArtifacts , TargetHeaderChain ,
5756 } ,
5857 target_chain:: {
59- DispatchMessage , MessageDispatch , ProvedLaneMessages , ProvedMessages , SourceHeaderChain ,
58+ DeliveryPayments , DispatchMessage , MessageDispatch , ProvedLaneMessages , ProvedMessages ,
59+ SourceHeaderChain ,
6060 } ,
6161 total_unrewarded_messages, DeliveredMessages , InboundLaneData , InboundMessageDetails , LaneId ,
6262 MessageKey , MessageNonce , MessagePayload , MessagesOperatingMode , OutboundLaneData ,
@@ -143,18 +143,17 @@ pub mod pallet {
143143 /// Identifier of relayer that deliver messages to this chain. Relayer reward is paid on the
144144 /// bridged chain.
145145 type InboundRelayer : Parameter + MaxEncodedLen ;
146+ /// Delivery payments.
147+ type DeliveryPayments : DeliveryPayments < Self :: AccountId > ;
146148
147149 // Types that are used by outbound_lane (on source chain).
148150
149151 /// Target header chain.
150152 type TargetHeaderChain : TargetHeaderChain < Self :: OutboundPayload , Self :: AccountId > ;
151153 /// Message payload verifier.
152154 type LaneMessageVerifier : LaneMessageVerifier < Self :: RuntimeOrigin , Self :: OutboundPayload > ;
153- /// Message delivery payment.
154- type MessageDeliveryAndDispatchPayment : MessageDeliveryAndDispatchPayment <
155- Self :: RuntimeOrigin ,
156- Self :: AccountId ,
157- > ;
155+ /// Delivery confirmation payments.
156+ type DeliveryConfirmationPayments : DeliveryConfirmationPayments < Self :: AccountId > ;
158157
159158 // Types that are used by inbound_lane (on target chain).
160159
@@ -377,9 +376,17 @@ pub mod pallet {
377376 messages_received_status. push ( lane_messages_received_status) ;
378377 }
379378
379+ // let's now deal with relayer payments
380+ T :: DeliveryPayments :: pay_reward (
381+ relayer_id_at_this_chain,
382+ total_messages,
383+ valid_messages,
384+ actual_weight,
385+ ) ;
386+
380387 log:: debug!(
381388 target: LOG_TARGET ,
382- "Received messages: total={}, valid={}. Weight used: {}/{}" ,
389+ "Received messages: total={}, valid={}. Weight used: {}/{}. " ,
383390 total_messages,
384391 valid_messages,
385392 actual_weight,
@@ -388,7 +395,7 @@ pub mod pallet {
388395
389396 Self :: deposit_event ( Event :: MessagesReceived ( messages_received_status) ) ;
390397
391- Ok ( PostDispatchInfo { actual_weight : Some ( actual_weight) , pays_fee : Pays :: Yes } )
398+ Ok ( PostDispatchInfo { actual_weight : Some ( actual_weight) , pays_fee : Pays :: No } )
392399 }
393400
394401 /// Receive messages delivery proof from bridged chain.
@@ -475,7 +482,7 @@ pub mod pallet {
475482 } ) ;
476483
477484 // if some new messages have been confirmed, reward relayers
478- < T as Config < I > > :: MessageDeliveryAndDispatchPayment :: pay_relayers_rewards (
485+ T :: DeliveryConfirmationPayments :: pay_reward (
479486 lane_id,
480487 lane_data. relayers ,
481488 & confirmation_relayer,
@@ -879,10 +886,10 @@ mod tests {
879886 use super :: * ;
880887 use crate :: mock:: {
881888 message, message_payload, run_test, unrewarded_relayer, DbWeight ,
882- RuntimeEvent as TestEvent , RuntimeOrigin , TestMessageDeliveryAndDispatchPayment ,
883- TestMessagesDeliveryProof , TestMessagesProof , TestRuntime , MAX_OUTBOUND_PAYLOAD_SIZE ,
884- PAYLOAD_REJECTED_BY_TARGET_CHAIN , REGULAR_PAYLOAD , TEST_LANE_ID , TEST_LANE_ID_2 ,
885- TEST_LANE_ID_3 , TEST_RELAYER_A , TEST_RELAYER_B ,
889+ RuntimeEvent as TestEvent , RuntimeOrigin , TestDeliveryConfirmationPayments ,
890+ TestDeliveryPayments , TestMessagesDeliveryProof , TestMessagesProof , TestRuntime ,
891+ MAX_OUTBOUND_PAYLOAD_SIZE , PAYLOAD_REJECTED_BY_TARGET_CHAIN , REGULAR_PAYLOAD , TEST_LANE_ID ,
892+ TEST_LANE_ID_2 , TEST_LANE_ID_3 , TEST_RELAYER_A , TEST_RELAYER_B ,
886893 } ;
887894 use bp_messages:: { UnrewardedRelayer , UnrewardedRelayersState } ;
888895 use bp_test_utils:: generate_owned_bridge_module_tests;
@@ -1165,6 +1172,8 @@ mod tests {
11651172 ) ) ;
11661173
11671174 assert_eq ! ( InboundLanes :: <TestRuntime >:: get( TEST_LANE_ID ) . 0 . last_delivered_nonce( ) , 1 ) ;
1175+
1176+ assert ! ( TestDeliveryPayments :: is_reward_paid( 1 ) ) ;
11681177 } ) ;
11691178 }
11701179
@@ -1326,8 +1335,8 @@ mod tests {
13261335 ..Default :: default ( )
13271336 } ,
13281337 ) ) ;
1329- assert ! ( TestMessageDeliveryAndDispatchPayment :: is_reward_paid( TEST_RELAYER_A , 1 ) ) ;
1330- assert ! ( !TestMessageDeliveryAndDispatchPayment :: is_reward_paid( TEST_RELAYER_B , 1 ) ) ;
1338+ assert ! ( TestDeliveryConfirmationPayments :: is_reward_paid( TEST_RELAYER_A , 1 ) ) ;
1339+ assert ! ( !TestDeliveryConfirmationPayments :: is_reward_paid( TEST_RELAYER_B , 1 ) ) ;
13311340
13321341 // this reports delivery of both message 1 and message 2 => reward is paid only to
13331342 // TEST_RELAYER_B
@@ -1352,8 +1361,8 @@ mod tests {
13521361 ..Default :: default ( )
13531362 } ,
13541363 ) ) ;
1355- assert ! ( !TestMessageDeliveryAndDispatchPayment :: is_reward_paid( TEST_RELAYER_A , 1 ) ) ;
1356- assert ! ( TestMessageDeliveryAndDispatchPayment :: is_reward_paid( TEST_RELAYER_B , 1 ) ) ;
1364+ assert ! ( !TestDeliveryConfirmationPayments :: is_reward_paid( TEST_RELAYER_A , 1 ) ) ;
1365+ assert ! ( TestDeliveryConfirmationPayments :: is_reward_paid( TEST_RELAYER_B , 1 ) ) ;
13571366 } ) ;
13581367 }
13591368
0 commit comments