Skip to content

Commit 4903b79

Browse files
authored
refund_pay_dispatch_fee removed (#1695)
1 parent 61c3b22 commit 4903b79

File tree

11 files changed

+14
-105
lines changed

11 files changed

+14
-105
lines changed

bin/millau/runtime/src/xcm_config.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ mod tests {
314314
dispatch_result,
315315
MessageDispatchResult {
316316
unspent_weight: frame_support::weights::Weight::from_ref_time(0),
317-
dispatch_fee_paid_during_dispatch: false,
318317
dispatch_level_result: (),
319318
}
320319
);

bin/rialto-parachain/runtime/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,6 @@ mod tests {
892892
dispatch_result,
893893
MessageDispatchResult {
894894
unspent_weight: frame_support::weights::Weight::from_ref_time(0),
895-
dispatch_fee_paid_during_dispatch: false,
896895
dispatch_level_result: (),
897896
}
898897
);

bin/rialto/runtime/src/xcm_config.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ mod tests {
273273
dispatch_result,
274274
MessageDispatchResult {
275275
unspent_weight: frame_support::weights::Weight::from_ref_time(0),
276-
dispatch_fee_paid_during_dispatch: false,
277276
dispatch_level_result: (),
278277
}
279278
);

bin/runtime-common/src/messages.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -542,11 +542,7 @@ pub mod target {
542542
},
543543
}
544544

545-
MessageDispatchResult {
546-
unspent_weight: Weight::zero(),
547-
dispatch_fee_paid_during_dispatch: false,
548-
dispatch_level_result: (),
549-
}
545+
MessageDispatchResult { unspent_weight: Weight::zero(), dispatch_level_result: () }
550546
}
551547
}
552548

modules/messages/src/benchmarking.rs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -256,39 +256,6 @@ benchmarks_instance_pallet! {
256256
assert!(T::is_message_dispatched(21));
257257
}
258258

259-
// Benchmark `receive_messages_proof` extrinsic with single minimal-weight message and following conditions:
260-
// * proof does not include outbound lane state proof;
261-
// * inbound lane already has state, so it needs to be read and decoded;
262-
// * message is successfully dispatched;
263-
// * message requires all heavy checks done by dispatcher;
264-
// * message dispatch fee is paid at source (bridged) chain.
265-
//
266-
// This benchmark is used to compute extra weight spent at target chain when fee is paid there. Then we use
267-
// this information in two places: (1) to reduce weight of delivery tx if sender pays fee at the source chain
268-
// and (2) to refund relayer with this weight if fee has been paid at the source chain.
269-
receive_single_prepaid_message_proof {
270-
let relayer_id_on_source = T::bridged_relayer_id();
271-
let relayer_id_on_target = account("relayer", 0, SEED);
272-
T::endow_account(&relayer_id_on_target);
273-
274-
// mark messages 1..=20 as delivered
275-
receive_messages::<T, I>(20);
276-
277-
let (proof, dispatch_weight) = T::prepare_message_proof(MessageProofParams {
278-
lane: T::bench_lane_id(),
279-
message_nonces: 21..=21,
280-
outbound_lane_data: None,
281-
size: StorageProofSize::Minimal(EXPECTED_DEFAULT_MESSAGE_LENGTH),
282-
});
283-
}: receive_messages_proof(RawOrigin::Signed(relayer_id_on_target), relayer_id_on_source, proof, 1, dispatch_weight)
284-
verify {
285-
assert_eq!(
286-
crate::InboundLanes::<T, I>::get(&T::bench_lane_id()).last_delivered_nonce(),
287-
21,
288-
);
289-
assert!(T::is_message_dispatched(21));
290-
}
291-
292259
// Benchmark `receive_messages_delivery_proof` extrinsic with following conditions:
293260
// * single relayer is rewarded for relaying single message;
294261
// * relayer account does not exist (in practice it needs to exist in production environment).

modules/messages/src/lib.rs

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -361,32 +361,20 @@ pub mod pallet {
361361
// losing funds for messages dispatch. But keep in mind that relayer pays base
362362
// delivery transaction cost anyway. And base cost covers everything except
363363
// dispatch, so we have a balance here.
364-
let (unspent_weight, refund_pay_dispatch_fee) = match &receival_result {
364+
let unspent_weight = match &receival_result {
365365
ReceivalResult::Dispatched(dispatch_result) => {
366366
valid_messages += 1;
367-
(
368-
dispatch_result.unspent_weight,
369-
!dispatch_result.dispatch_fee_paid_during_dispatch,
370-
)
367+
dispatch_result.unspent_weight
371368
},
372369
ReceivalResult::InvalidNonce |
373370
ReceivalResult::TooManyUnrewardedRelayers |
374-
ReceivalResult::TooManyUnconfirmedMessages => (message_dispatch_weight, true),
371+
ReceivalResult::TooManyUnconfirmedMessages => message_dispatch_weight,
375372
};
376373
lane_messages_received_status.push(message.key.nonce, receival_result);
377374

378375
let unspent_weight = unspent_weight.min(message_dispatch_weight);
379376
dispatch_weight_left -= message_dispatch_weight - unspent_weight;
380-
actual_weight = actual_weight.saturating_sub(unspent_weight).saturating_sub(
381-
// delivery call weight formula assumes that the fee is paid at
382-
// this (target) chain. If the message is prepaid at the source
383-
// chain, let's refund relayer with this extra cost.
384-
if refund_pay_dispatch_fee {
385-
T::WeightInfo::pay_inbound_dispatch_fee_overhead()
386-
} else {
387-
Weight::zero()
388-
},
389-
);
377+
actual_weight = actual_weight.saturating_sub(unspent_weight);
390378
}
391379

392380
messages_received_status.push(lane_messages_received_status);
@@ -1554,11 +1542,9 @@ mod tests {
15541542
fn submit_with_unspent_weight(
15551543
nonce: MessageNonce,
15561544
unspent_weight: u64,
1557-
is_prepaid: bool,
15581545
) -> (Weight, Weight) {
15591546
let mut payload = REGULAR_PAYLOAD;
15601547
*payload.dispatch_result.unspent_weight.ref_time_mut() = unspent_weight;
1561-
payload.dispatch_result.dispatch_fee_paid_during_dispatch = !is_prepaid;
15621548
let proof = Ok(vec![message(nonce, payload)]).into();
15631549
let messages_count = 1;
15641550
let pre_dispatch_weight =
@@ -1582,40 +1568,32 @@ mod tests {
15821568
}
15831569

15841570
// when dispatch is returning `unspent_weight < declared_weight`
1585-
let (pre, post) = submit_with_unspent_weight(1, 1, false);
1571+
let (pre, post) = submit_with_unspent_weight(1, 1);
15861572
assert_eq!(post.ref_time(), pre.ref_time() - 1);
15871573

15881574
// when dispatch is returning `unspent_weight = declared_weight`
15891575
let (pre, post) =
1590-
submit_with_unspent_weight(2, REGULAR_PAYLOAD.declared_weight.ref_time(), false);
1576+
submit_with_unspent_weight(2, REGULAR_PAYLOAD.declared_weight.ref_time());
15911577
assert_eq!(
15921578
post.ref_time(),
15931579
pre.ref_time() - REGULAR_PAYLOAD.declared_weight.ref_time()
15941580
);
15951581

15961582
// when dispatch is returning `unspent_weight > declared_weight`
1597-
let (pre, post) = submit_with_unspent_weight(
1598-
3,
1599-
REGULAR_PAYLOAD.declared_weight.ref_time() + 1,
1600-
false,
1601-
);
1583+
let (pre, post) =
1584+
submit_with_unspent_weight(3, REGULAR_PAYLOAD.declared_weight.ref_time() + 1);
16021585
assert_eq!(
16031586
post.ref_time(),
16041587
pre.ref_time() - REGULAR_PAYLOAD.declared_weight.ref_time()
16051588
);
16061589

16071590
// when there's no unspent weight
1608-
let (pre, post) = submit_with_unspent_weight(4, 0, false);
1591+
let (pre, post) = submit_with_unspent_weight(4, 0);
16091592
assert_eq!(post, pre);
16101593

1611-
// when dispatch is returning `unspent_weight < declared_weight` AND message is prepaid
1612-
let (pre, post) = submit_with_unspent_weight(5, 1, true);
1613-
assert_eq!(
1614-
post.ref_time(),
1615-
pre.ref_time() -
1616-
1 - <TestRuntime as Config>::WeightInfo::pay_inbound_dispatch_fee_overhead()
1617-
.ref_time()
1618-
);
1594+
// when dispatch is returning `unspent_weight < declared_weight`
1595+
let (pre, post) = submit_with_unspent_weight(5, 1);
1596+
assert_eq!(post.ref_time(), pre.ref_time() - 1);
16191597
});
16201598
}
16211599

modules/messages/src/mock.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,6 @@ pub const fn dispatch_result(
395395
) -> MessageDispatchResult<TestDispatchLevelResult> {
396396
MessageDispatchResult {
397397
unspent_weight: Weight::from_ref_time(unspent_weight),
398-
dispatch_fee_paid_during_dispatch: true,
399398
dispatch_level_result: (),
400399
}
401400
}

modules/messages/src/weights.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ pub trait WeightInfo {
5555
fn receive_single_message_proof_with_outbound_lane_state() -> Weight;
5656
fn receive_single_message_proof_1_kb() -> Weight;
5757
fn receive_single_message_proof_16_kb() -> Weight;
58-
fn receive_single_prepaid_message_proof() -> Weight;
5958
fn receive_delivery_proof_for_single_message() -> Weight;
6059
fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight;
6160
fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight;
@@ -91,11 +90,6 @@ impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
9190
.saturating_add(T::DbWeight::get().reads(3 as u64))
9291
.saturating_add(T::DbWeight::get().writes(1 as u64))
9392
}
94-
fn receive_single_prepaid_message_proof() -> Weight {
95-
Weight::from_ref_time(49_646_000 as u64)
96-
.saturating_add(T::DbWeight::get().reads(4 as u64))
97-
.saturating_add(T::DbWeight::get().writes(2 as u64))
98-
}
9993
fn receive_delivery_proof_for_single_message() -> Weight {
10094
Weight::from_ref_time(55_108_000 as u64)
10195
.saturating_add(T::DbWeight::get().reads(4 as u64))
@@ -140,11 +134,6 @@ impl WeightInfo for () {
140134
.saturating_add(RocksDbWeight::get().reads(3 as u64))
141135
.saturating_add(RocksDbWeight::get().writes(1 as u64))
142136
}
143-
fn receive_single_prepaid_message_proof() -> Weight {
144-
Weight::from_ref_time(49_646_000 as u64)
145-
.saturating_add(RocksDbWeight::get().reads(4 as u64))
146-
.saturating_add(RocksDbWeight::get().writes(2 as u64))
147-
}
148137
fn receive_delivery_proof_for_single_message() -> Weight {
149138
Weight::from_ref_time(55_108_000 as u64)
150139
.saturating_add(RocksDbWeight::get().reads(4 as u64))

modules/messages/src/weights_ext.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -265,15 +265,6 @@ pub trait WeightInfoExt: WeightInfo {
265265
(15 * 1024);
266266
proof_size_in_bytes * byte_weight
267267
}
268-
269-
/// Returns weight of the pay-dispatch-fee operation for inbound messages.
270-
///
271-
/// This function may return zero if runtime doesn't support pay-dispatch-fee-at-target-chain
272-
/// option.
273-
fn pay_inbound_dispatch_fee_overhead() -> Weight {
274-
Self::receive_single_message_proof()
275-
.saturating_sub(Self::receive_single_prepaid_message_proof())
276-
}
277268
}
278269

279270
impl WeightInfoExt for () {

primitives/messages/src/target_chain.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,6 @@ impl<AccountId> MessageDispatch<AccountId> for ForbidInboundMessages {
162162
_: &AccountId,
163163
_: DispatchMessage<Self::DispatchPayload>,
164164
) -> MessageDispatchResult<Self::DispatchLevelResult> {
165-
MessageDispatchResult {
166-
unspent_weight: Weight::zero(),
167-
dispatch_fee_paid_during_dispatch: false,
168-
dispatch_level_result: (),
169-
}
165+
MessageDispatchResult { unspent_weight: Weight::zero(), dispatch_level_result: () }
170166
}
171167
}

primitives/runtime/src/messages.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ pub struct MessageDispatchResult<DispatchLevelResult> {
3030
/// the weight, declared by the message sender;
3131
/// 2) if message has not been dispatched at all.
3232
pub unspent_weight: Weight,
33-
/// Whether the message dispatch fee has been paid during dispatch. This will be true if your
34-
/// configuration supports pay-dispatch-fee-at-target-chain option and message sender has
35-
/// enabled this option.
36-
pub dispatch_fee_paid_during_dispatch: bool,
3733
/// Fine-grained result of single message dispatch (for better diagnostic purposes)
3834
pub dispatch_level_result: DispatchLevelResult,
3935
}

0 commit comments

Comments
 (0)