diff --git a/bridges/bin/runtime-common/src/mock.rs b/bridges/bin/runtime-common/src/mock.rs index a07bd8cc892d..1c42894baed9 100644 --- a/bridges/bin/runtime-common/src/mock.rs +++ b/bridges/bin/runtime-common/src/mock.rs @@ -200,6 +200,7 @@ impl pallet_bridge_messages::Config for TestRuntime { TestRuntime, (), ConstU64<100_000>, + ConstU64<100_000>, >; type OnMessagesDelivered = (); diff --git a/bridges/modules/messages/src/benchmarking.rs b/bridges/modules/messages/src/benchmarking.rs index 51a1c53e787d..5fcf37fccbd1 100644 --- a/bridges/modules/messages/src/benchmarking.rs +++ b/bridges/modules/messages/src/benchmarking.rs @@ -131,7 +131,7 @@ fn receive_messages, I: 'static>(nonce: MessageNonce) { state: LaneState::Opened, relayers: vec![UnrewardedRelayer { relayer: T::bridged_relayer_id(), - messages: DeliveredMessages::new(nonce, 1), + messages: DeliveredMessages::new(nonce, Some(1)), }] .into(), last_confirmed_nonce: 0, @@ -368,7 +368,7 @@ mod benchmarks { state: LaneState::Opened, relayers: vec![UnrewardedRelayer { relayer: relayer_id.clone(), - messages: DeliveredMessages::new(1, 1), + messages: DeliveredMessages::new(1, Some(1)), }] .into_iter() .collect(), @@ -412,7 +412,7 @@ mod benchmarks { total_messages: 2, last_delivered_nonce: 2, }; - let mut delivered_messages = DeliveredMessages::new(1, 1); + let mut delivered_messages = DeliveredMessages::new(1, Some(1)); delivered_messages.note_dispatched_message(); let proof = T::prepare_message_delivery_proof(MessageDeliveryProofParams { lane: T::bench_lane_id(), @@ -472,11 +472,11 @@ mod benchmarks { relayers: vec![ UnrewardedRelayer { relayer: relayer1_id.clone(), - messages: DeliveredMessages::new(1, 1), + messages: DeliveredMessages::new(1, Some(1)), }, UnrewardedRelayer { relayer: relayer2_id.clone(), - messages: DeliveredMessages::new(2, 1), + messages: DeliveredMessages::new(2, Some(1)), }, ] .into_iter() diff --git a/bridges/modules/messages/src/call_ext.rs b/bridges/modules/messages/src/call_ext.rs index dfaca2bb2d43..ff7ce169edf0 100644 --- a/bridges/modules/messages/src/call_ext.rs +++ b/bridges/modules/messages/src/call_ext.rs @@ -263,7 +263,7 @@ mod tests { messages: DeliveredMessages { begin: n + 1, end: n + 1, - relayer_reward_per_message: 0, + relayer_reward_per_message: None, }, }); } @@ -277,7 +277,7 @@ mod tests { messages: DeliveredMessages { begin: 1, end: BridgedChain::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX, - relayer_reward_per_message: 0, + relayer_reward_per_message: None, }, }); InboundLanes::::insert(test_lane_id(), inbound_lane_state); diff --git a/bridges/modules/messages/src/inbound_lane.rs b/bridges/modules/messages/src/inbound_lane.rs index 169864313453..f3b5afd2beca 100644 --- a/bridges/modules/messages/src/inbound_lane.rs +++ b/bridges/modules/messages/src/inbound_lane.rs @@ -186,7 +186,7 @@ impl InboundLane { relayer_at_bridged_chain: &S::Relayer, nonce: MessageNonce, message_data: DispatchMessageData, - relayer_reward_per_message: RelayerRewardAtSource, + relayer_reward_per_message: Option, ) -> ReceptionResult { let mut data = self.storage.data(); if Some(nonce) != data.last_delivered_nonce().checked_add(1) { @@ -251,7 +251,7 @@ mod tests { &TEST_RELAYER_A, nonce, inbound_message_data(REGULAR_PAYLOAD), - RELAYER_REWARD_PER_MESSAGE, + Some(RELAYER_REWARD_PER_MESSAGE), ), ReceptionResult::Dispatched(dispatch_result(0)) ); @@ -379,7 +379,7 @@ mod tests { &TEST_RELAYER_A, 10, inbound_message_data(REGULAR_PAYLOAD), - RELAYER_REWARD_PER_MESSAGE, + Some(RELAYER_REWARD_PER_MESSAGE), ), ReceptionResult::InvalidNonce ); @@ -398,7 +398,7 @@ mod tests { &(TEST_RELAYER_A + current_nonce), current_nonce, inbound_message_data(REGULAR_PAYLOAD), - RELAYER_REWARD_PER_MESSAGE, + Some(RELAYER_REWARD_PER_MESSAGE), ), ReceptionResult::Dispatched(dispatch_result(0)) ); @@ -409,7 +409,7 @@ mod tests { &(TEST_RELAYER_A + max_nonce + 1), max_nonce + 1, inbound_message_data(REGULAR_PAYLOAD), - RELAYER_REWARD_PER_MESSAGE, + Some(RELAYER_REWARD_PER_MESSAGE), ), ReceptionResult::TooManyUnrewardedRelayers, ); @@ -419,7 +419,7 @@ mod tests { &(TEST_RELAYER_A + max_nonce), max_nonce + 1, inbound_message_data(REGULAR_PAYLOAD), - RELAYER_REWARD_PER_MESSAGE, + Some(RELAYER_REWARD_PER_MESSAGE), ), ReceptionResult::TooManyUnrewardedRelayers, ); @@ -437,7 +437,7 @@ mod tests { &TEST_RELAYER_A, current_nonce, inbound_message_data(REGULAR_PAYLOAD), - RELAYER_REWARD_PER_MESSAGE, + Some(RELAYER_REWARD_PER_MESSAGE), ), ReceptionResult::Dispatched(dispatch_result(0)) ); @@ -448,7 +448,7 @@ mod tests { &TEST_RELAYER_B, max_nonce + 1, inbound_message_data(REGULAR_PAYLOAD), - RELAYER_REWARD_PER_MESSAGE, + Some(RELAYER_REWARD_PER_MESSAGE), ), ReceptionResult::TooManyUnconfirmedMessages, ); @@ -458,7 +458,7 @@ mod tests { &TEST_RELAYER_A, max_nonce + 1, inbound_message_data(REGULAR_PAYLOAD), - RELAYER_REWARD_PER_MESSAGE, + Some(RELAYER_REWARD_PER_MESSAGE), ), ReceptionResult::TooManyUnconfirmedMessages, ); @@ -474,7 +474,7 @@ mod tests { &TEST_RELAYER_A, 1, inbound_message_data(REGULAR_PAYLOAD), - RELAYER_REWARD_PER_MESSAGE, + Some(RELAYER_REWARD_PER_MESSAGE), ), ReceptionResult::Dispatched(dispatch_result(0)) ); @@ -483,7 +483,7 @@ mod tests { &TEST_RELAYER_B, 2, inbound_message_data(REGULAR_PAYLOAD), - RELAYER_REWARD_PER_MESSAGE, + Some(RELAYER_REWARD_PER_MESSAGE), ), ReceptionResult::Dispatched(dispatch_result(0)) ); @@ -492,7 +492,7 @@ mod tests { &TEST_RELAYER_A, 3, inbound_message_data(REGULAR_PAYLOAD), - RELAYER_REWARD_PER_MESSAGE, + Some(RELAYER_REWARD_PER_MESSAGE), ), ReceptionResult::Dispatched(dispatch_result(0)) ); @@ -516,7 +516,7 @@ mod tests { &TEST_RELAYER_A, 1, inbound_message_data(REGULAR_PAYLOAD), - RELAYER_REWARD_PER_MESSAGE, + Some(RELAYER_REWARD_PER_MESSAGE), ), ReceptionResult::Dispatched(dispatch_result(0)) ); @@ -525,7 +525,7 @@ mod tests { &TEST_RELAYER_A, 2, inbound_message_data(REGULAR_PAYLOAD), - RELAYER_REWARD_PER_MESSAGE + 1, + Some(RELAYER_REWARD_PER_MESSAGE + 1), ), ReceptionResult::Dispatched(dispatch_result(0)) ); @@ -534,7 +534,7 @@ mod tests { &TEST_RELAYER_A, 3, inbound_message_data(REGULAR_PAYLOAD), - RELAYER_REWARD_PER_MESSAGE + 1, + Some(RELAYER_REWARD_PER_MESSAGE + 1), ), ReceptionResult::Dispatched(dispatch_result(0)) ); @@ -542,7 +542,7 @@ mod tests { let mut unrewarded_relayer_with_larger_reward = unrewarded_relayer(2, 3, TEST_RELAYER_A); unrewarded_relayer_with_larger_reward.messages.relayer_reward_per_message = - RELAYER_REWARD_PER_MESSAGE + 1; + Some(RELAYER_REWARD_PER_MESSAGE + 1); assert_eq!( lane.storage.data().relayers, vec![ @@ -562,7 +562,7 @@ mod tests { &TEST_RELAYER_A, 1, inbound_message_data(REGULAR_PAYLOAD), - RELAYER_REWARD_PER_MESSAGE, + Some(RELAYER_REWARD_PER_MESSAGE), ), ReceptionResult::Dispatched(dispatch_result(0)) ); @@ -571,7 +571,7 @@ mod tests { &TEST_RELAYER_B, 1, inbound_message_data(REGULAR_PAYLOAD), - RELAYER_REWARD_PER_MESSAGE, + Some(RELAYER_REWARD_PER_MESSAGE), ), ReceptionResult::InvalidNonce, ); @@ -598,7 +598,7 @@ mod tests { &TEST_RELAYER_A, 1, inbound_message_data(payload), - RELAYER_REWARD_PER_MESSAGE, + Some(RELAYER_REWARD_PER_MESSAGE), ), ReceptionResult::Dispatched(dispatch_result(1)) ); diff --git a/bridges/modules/messages/src/tests/mock.rs b/bridges/modules/messages/src/tests/mock.rs index c969f09e4072..3cb9765c9f04 100644 --- a/bridges/modules/messages/src/tests/mock.rs +++ b/bridges/modules/messages/src/tests/mock.rs @@ -296,8 +296,11 @@ impl TestDeliveryPayments { impl DeliveryPayments for TestDeliveryPayments { type Error = &'static str; - fn relayer_reward_per_message(_lane_id: LaneId, _relayer: &AccountId) -> RelayerRewardAtSource { - RELAYER_REWARD_PER_MESSAGE + fn relayer_reward_per_message( + _lane_id: LaneId, + _relayer: &AccountId, + ) -> Option { + Some(RELAYER_REWARD_PER_MESSAGE) } fn pay_reward( @@ -337,7 +340,9 @@ impl DeliveryConfirmationPayments for TestDeliveryConfirmationPayment let relayers_rewards = calc_relayers_rewards_at_source::( messages_relayers, received_range, - |messages, relayer_reward_per_message| messages * relayer_reward_per_message, + |messages, relayer_reward_per_message| { + messages * relayer_reward_per_message.unwrap_or(0) + }, ); let rewarded_relayers = relayers_rewards.len(); for (relayer, reward) in &relayers_rewards { @@ -463,7 +468,7 @@ pub fn unrewarded_relayer( messages: DeliveredMessages { begin, end, - relayer_reward_per_message: RELAYER_REWARD_PER_MESSAGE, + relayer_reward_per_message: Some(RELAYER_REWARD_PER_MESSAGE), }, } } diff --git a/bridges/modules/messages/src/tests/pallet_tests.rs b/bridges/modules/messages/src/tests/pallet_tests.rs index 2d6b39aead38..2a2d5889a149 100644 --- a/bridges/modules/messages/src/tests/pallet_tests.rs +++ b/bridges/modules/messages/src/tests/pallet_tests.rs @@ -86,7 +86,7 @@ fn receive_messages_delivery_proof() { last_confirmed_nonce: 1, relayers: vec![UnrewardedRelayer { relayer: 0, - messages: DeliveredMessages::new(1, 0), + messages: DeliveredMessages::new(1, None), }] .into(), }, @@ -287,7 +287,7 @@ fn receive_messages_proof_works() { .0 .relayers .front() - .map(|r| r.messages.relayer_reward_per_message), + .and_then(|r| r.messages.relayer_reward_per_message), Some(RELAYER_REWARD_PER_MESSAGE), ); @@ -901,7 +901,7 @@ fn proof_size_refund_from_receive_messages_proof_works() { messages: DeliveredMessages { begin: 0, end: 100, - relayer_reward_per_message: 0 + relayer_reward_per_message: None, } }; max_entries @@ -934,7 +934,7 @@ fn proof_size_refund_from_receive_messages_proof_works() { messages: DeliveredMessages { begin: 0, end: 100, - relayer_reward_per_message: 0 + relayer_reward_per_message: None, } }; max_entries - 1 @@ -1048,7 +1048,7 @@ fn test_bridge_messages_call_is_correctly_defined() { last_confirmed_nonce: 1, relayers: vec![UnrewardedRelayer { relayer: 0, - messages: DeliveredMessages::new(1, 0), + messages: DeliveredMessages::new(1, None), }] .into(), }, @@ -1111,7 +1111,11 @@ fn inbound_storage_extra_proof_size_bytes_works() { fn relayer_entry() -> UnrewardedRelayer { UnrewardedRelayer { relayer: 42u64, - messages: DeliveredMessages { begin: 0, end: 100, relayer_reward_per_message: 0 }, + messages: DeliveredMessages { + begin: 0, + end: 100, + relayer_reward_per_message: Some(42), + }, } } @@ -1207,7 +1211,7 @@ fn receive_messages_delivery_proof_fails_if_outbound_lane_is_unknown() { last_confirmed_nonce: 1, relayers: vec![UnrewardedRelayer { relayer: 0, - messages: DeliveredMessages::new(1, 0), + messages: DeliveredMessages::new(1, None), }] .into(), }, diff --git a/bridges/modules/relayers/src/extension/mod.rs b/bridges/modules/relayers/src/extension/mod.rs index 2b2a267c1e66..aec0bcd51eaa 100644 --- a/bridges/modules/relayers/src/extension/mod.rs +++ b/bridges/modules/relayers/src/extension/mod.rs @@ -2329,7 +2329,7 @@ mod tests { messages: DeliveredMessages { begin: 1, end: best_delivered_message, - relayer_reward_per_message: 0, + relayer_reward_per_message: None, }, }] .into(), diff --git a/bridges/modules/relayers/src/mock.rs b/bridges/modules/relayers/src/mock.rs index 4947e38f8ea7..a0799c1f07d9 100644 --- a/bridges/modules/relayers/src/mock.rs +++ b/bridges/modules/relayers/src/mock.rs @@ -76,6 +76,8 @@ pub const TEST_BRIDGED_CHAIN_ID: ChainId = *b"brdg"; /// Maximal extrinsic size at the `BridgedChain`. pub const BRIDGED_CHAIN_MAX_EXTRINSIC_SIZE: u32 = 1024; +/// Default reward that is paid to relayer for delivering a single message. +pub const DEFAULT_REWARD_PER_MESSAGE: ThisChainBalance = 100_000; /// Maximal reward that may be paid to relayer for delivering a single message. pub const MAX_REWARD_PER_MESSAGE: ThisChainBalance = 100_000; @@ -256,6 +258,7 @@ pub type TestDeliveryConfirmationPaymentsAdapter = pallet_bridge_relayers::DeliveryConfirmationPaymentsAdapter< TestRuntime, (), + ConstU64, ConstU64, >; diff --git a/bridges/modules/relayers/src/payment_adapter.rs b/bridges/modules/relayers/src/payment_adapter.rs index 9f069edc9473..55ed1622f23c 100644 --- a/bridges/modules/relayers/src/payment_adapter.rs +++ b/bridges/modules/relayers/src/payment_adapter.rs @@ -33,19 +33,21 @@ use sp_std::{collections::vec_deque::VecDeque, marker::PhantomData, ops::RangeIn /// for the messages pallet. /// /// This adapter assumes 1:1 mapping of `RelayerRewardAtSource` to `T::Reward`. The reward for -/// delivering a single message, will never be larger than the `MaxRewardPerMessage`. +/// delivering a single message, will never be larger than the `MaxRewardPerMessage`. If relayer +/// has not specified expected reward, it gets the `DefaultRewardPerMessage` for every message. /// /// We assume that the confirmation transaction cost is refunded by the signed extension, /// implemented by the pallet. So we do not reward confirmation relayer additionally here. -pub struct DeliveryConfirmationPaymentsAdapter( - PhantomData<(T, MI, MaxRewardPerMessage)>, +pub struct DeliveryConfirmationPaymentsAdapter( + PhantomData<(T, MI, DefaultRewardPerMessage, MaxRewardPerMessage)>, ); -impl DeliveryConfirmationPayments - for DeliveryConfirmationPaymentsAdapter +impl DeliveryConfirmationPayments + for DeliveryConfirmationPaymentsAdapter where T: Config + pallet_bridge_messages::Config, MI: 'static, + DefaultRewardPerMessage: Get, MaxRewardPerMessage: Get, { type Error = &'static str; @@ -63,7 +65,9 @@ where |messages, relayer_reward_per_message| { let relayer_reward_per_message = sp_std::cmp::min( MaxRewardPerMessage::get(), - relayer_reward_per_message.unique_saturated_into(), + relayer_reward_per_message + .map(|x| x.unique_saturated_into()) + .unwrap_or_else(|| DefaultRewardPerMessage::get()), ); T::Reward::unique_saturated_from(messages) @@ -131,11 +135,34 @@ mod tests { }); } + #[test] + fn reward_per_message_is_default_if_not_specified() { + run_test(|| { + let mut delivered_messages = bp_messages::DeliveredMessages::new(1, None); + delivered_messages.note_dispatched_message(); + + >::pay_reward( + test_lane_id(), + vec![bp_messages::UnrewardedRelayer { relayer: 42, messages: delivered_messages }] + .into(), + &43, + &(1..=2), + ); + + assert_eq!( + RelayerRewards::::get(42, test_reward_account_param()), + Some(DEFAULT_REWARD_PER_MESSAGE * 2), + ); + }); + } + #[test] fn reward_per_message_is_never_larger_than_max_reward_per_message() { run_test(|| { let mut delivered_messages = - bp_messages::DeliveredMessages::new(1, MAX_REWARD_PER_MESSAGE + 1); + bp_messages::DeliveredMessages::new(1, Some(MAX_REWARD_PER_MESSAGE + 1)); delivered_messages.note_dispatched_message(); TestDeliveryConfirmationPaymentsAdapter::pay_reward( diff --git a/bridges/primitives/messages/src/lib.rs b/bridges/primitives/messages/src/lib.rs index c5b581d07107..f4f063758d91 100644 --- a/bridges/primitives/messages/src/lib.rs +++ b/bridges/primitives/messages/src/lib.rs @@ -507,13 +507,20 @@ pub struct DeliveredMessages { /// Reward that needs to be paid at the source chain (during confirmation transaction) /// for **every delivered message** in the `begin..=end` range. If reward has been paid /// at the target chain or if no rewards assumed, it may be zero. - pub relayer_reward_per_message: RelayerRewardAtSource, + /// + /// If it is `None`, then the relayer has not specified expected reward at the target chain. + /// The reward will be determined by the `DeliveryConfirmationPayments` algorithm at + /// the source chain. + pub relayer_reward_per_message: Option, } impl DeliveredMessages { /// Create new `DeliveredMessages` struct that confirms delivery of single nonce with given /// dispatch result. - pub fn new(nonce: MessageNonce, relayer_reward_per_message: RelayerRewardAtSource) -> Self { + pub fn new( + nonce: MessageNonce, + relayer_reward_per_message: Option, + ) -> Self { DeliveredMessages { begin: nonce, end: nonce, relayer_reward_per_message } } @@ -625,7 +632,7 @@ impl OutboundLaneData { pub fn calc_relayers_rewards_at_source( messages_relayers: VecDeque>, received_range: &RangeInclusive, - compute_reward: impl Fn(MessageNonce, RelayerRewardAtSource) -> Reward, + compute_reward: impl Fn(MessageNonce, Option) -> Reward, ) -> RelayersRewards where AccountId: sp_std::cmp::Ord, @@ -635,11 +642,6 @@ where // this loop is bounded by `T::MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX` on the bridged chain let mut relayers_rewards: RelayersRewards<_, Reward> = RelayersRewards::new(); for entry in messages_relayers { - // if relayer does not expect any reward, do nothing - if entry.messages.relayer_reward_per_message == 0 { - continue - } - // if we have already paid reward for delivering those messages, do nothing let nonce_begin = sp_std::cmp::max(entry.messages.begin, *received_range.start()); let nonce_end = sp_std::cmp::min(entry.messages.end, *received_range.end()); @@ -652,6 +654,12 @@ where // compute and update reward in the rewards map let new_reward = compute_reward(new_confirmations_count, entry.messages.relayer_reward_per_message); + + // if relayer does not expect any reward, do nothing + if new_reward.is_zero() { + continue + } + let total_relayer_reward = relayers_rewards.entry(entry.relayer).or_insert_with(Zero::zero); *total_relayer_reward = total_relayer_reward.saturating_add(new_reward); } @@ -698,10 +706,10 @@ mod tests { let lane_data = InboundLaneData { state: LaneState::Opened, relayers: vec![ - UnrewardedRelayer { relayer: 1, messages: DeliveredMessages::new(0, 0) }, + UnrewardedRelayer { relayer: 1, messages: DeliveredMessages::new(0, None) }, UnrewardedRelayer { relayer: 2, - messages: DeliveredMessages::new(MessageNonce::MAX, 0), + messages: DeliveredMessages::new(MessageNonce::MAX, None), }, ] .into_iter() @@ -728,7 +736,7 @@ mod tests { relayers: (1u8..=relayer_entries) .map(|i| UnrewardedRelayer { relayer: i, - messages: DeliveredMessages::new(i as _, 0u64), + messages: DeliveredMessages::new(i as _, Some(42)), }) .collect(), last_confirmed_nonce: messages_count as _, @@ -746,7 +754,7 @@ mod tests { #[test] fn contains_result_works() { let delivered_messages = - DeliveredMessages { begin: 100, end: 150, relayer_reward_per_message: 0 }; + DeliveredMessages { begin: 100, end: 150, relayer_reward_per_message: None }; assert!(!delivered_messages.contains_message(99)); assert!(delivered_messages.contains_message(100)); @@ -808,20 +816,21 @@ mod tests { calc_relayers_rewards_at_source::( vec![ // relayer that wants zero reward => no payments expected - UnrewardedRelayer { relayer: 1, messages: DeliveredMessages::new(1, 0) }, + UnrewardedRelayer { relayer: 1, messages: DeliveredMessages::new(1, Some(0)) }, + UnrewardedRelayer { relayer: 1, messages: DeliveredMessages::new(1, None) }, // relayer wants reward => payment is expected - UnrewardedRelayer { relayer: 2, messages: DeliveredMessages::new(2, 77) }, + UnrewardedRelayer { relayer: 2, messages: DeliveredMessages::new(2, Some(77)) }, // relayer that we met before and he wants reward => payment is expected - UnrewardedRelayer { relayer: 1, messages: DeliveredMessages::new(3, 42) }, + UnrewardedRelayer { relayer: 1, messages: DeliveredMessages::new(3, Some(42)) }, // relayer that we met before and he wants reward => payment is expected - UnrewardedRelayer { relayer: 2, messages: DeliveredMessages::new(4, 33) }, + UnrewardedRelayer { relayer: 2, messages: DeliveredMessages::new(4, Some(33)) }, // relayers that deliver messages out of range - UnrewardedRelayer { relayer: 2, messages: DeliveredMessages::new(0, 33) }, - UnrewardedRelayer { relayer: 2, messages: DeliveredMessages::new(5, 33) }, + UnrewardedRelayer { relayer: 2, messages: DeliveredMessages::new(0, Some(33)) }, + UnrewardedRelayer { relayer: 2, messages: DeliveredMessages::new(5, Some(33)) }, ] .into(), &(1..=4), - |_, relayer_reward_per_message| relayer_reward_per_message, + |_, relayer_reward_per_message| relayer_reward_per_message.unwrap_or(0), ), vec![(1, 42), (2, 110)].into_iter().collect(), ); diff --git a/bridges/primitives/messages/src/target_chain.rs b/bridges/primitives/messages/src/target_chain.rs index 40c514a92ec6..b337e9097a98 100644 --- a/bridges/primitives/messages/src/target_chain.rs +++ b/bridges/primitives/messages/src/target_chain.rs @@ -135,7 +135,14 @@ pub trait DeliveryPayments { /// /// Keep in mind that it is not necessary a real reward that will be paid. See /// [`crate::RelayerRewardAtSource`] for more details. - fn relayer_reward_per_message(lane: LaneId, relayer: &AccountId) -> RelayerRewardAtSource; + /// + /// If method returns `None`, it means that the relayer has not specified its expected reward + /// at the target chain and it is up to the source chain `DeliveryConfirmationPayments` to + /// compute the reward amount. + fn relayer_reward_per_message( + lane: LaneId, + relayer: &AccountId, + ) -> Option; /// Pay rewards for delivering messages to the given relayer. /// @@ -173,8 +180,11 @@ impl From for DispatchMessageData DeliveryPayments for () { type Error = &'static str; - fn relayer_reward_per_message(_lane: LaneId, _relayer: &AccountId) -> RelayerRewardAtSource { - 0 + fn relayer_reward_per_message( + _lane: LaneId, + _relayer: &AccountId, + ) -> Option { + None } fn pay_reward(