mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 14:31:02 +00:00
Bump Substrate/Polkadot/Cumulus refs (aka Weights v1.5) (#1597)
* update Substrate + Polkadot + Cumulus refs * Origin -> RuntimeOrigin * weights v1.5 * update refs once again + `cargo test -p pallet-bridge-grandpa` works * started work on `cargo test -p pallet-bridge-messages` * cargo test -p pallet-bridge-relayers * cargo test -p pallet-bridge-parachains * cargo test -p millau-runtime * cargo test -p bridge-runtime-common * cargo test -p rialto-runtime * cargo test -p rialto-parachain-runtime * cargo test -p millau-bridge-node * cargo test -p rialto-bridge-node * cargo test -p rialto-parachain-collator * cargo test -p messages-relay * cargo test -p parachains-relay * cargo test -p substrate-relay * cargo test --all * cargo check -p millau-runtime --locked --features runtime-benchmarks * fix remaining test * fmt * try to allow clippy failure temporarily * Revert "try to allow clippy failure temporarily" This reverts commit d1b6593580f07e0dbeecb7ab0aa92cee98888ed3. * use min_by * Revert "use min_by" This reverts commit 33042f49ed37e8dd0505370289e17f03bf1a56ee. * Revert "Revert "use min_by"" This reverts commit 1d2204f0b14dc81e5650bb574dedb5fa78c7097d. * trigger CI * Revert "trigger CI" This reverts commit 259d91b5606743bba9d043c69f07eac6c8700ef5. * new day, new clippy warning * more clippy issues
This commit is contained in:
committed by
Bastian Köcher
parent
9e1847d12a
commit
a3dc2d2748
@@ -554,7 +554,7 @@ mod tests {
|
||||
run_test(|| {
|
||||
let mut lane = inbound_lane::<TestRuntime, _>(TEST_LANE_ID);
|
||||
let mut payload = REGULAR_PAYLOAD;
|
||||
payload.dispatch_result.unspent_weight = 1;
|
||||
*payload.dispatch_result.unspent_weight.ref_time_mut() = 1;
|
||||
assert_eq!(
|
||||
lane.receive_message::<TestMessageDispatch, _>(
|
||||
&TEST_RELAYER_A,
|
||||
|
||||
+137
-105
@@ -65,11 +65,7 @@ use bp_messages::{
|
||||
};
|
||||
use bp_runtime::{BasicOperatingMode, ChainId, OwnedBridgeModule, Size};
|
||||
use codec::{Decode, Encode, MaxEncodedLen};
|
||||
use frame_support::{
|
||||
ensure, fail,
|
||||
traits::Get,
|
||||
weights::{Pays, PostDispatchInfo},
|
||||
};
|
||||
use frame_support::{dispatch::PostDispatchInfo, ensure, fail, traits::Get};
|
||||
use num_traits::{SaturatingAdd, Zero};
|
||||
use sp_std::{
|
||||
cell::RefCell, cmp::PartialOrd, collections::vec_deque::VecDeque, marker::PhantomData,
|
||||
@@ -104,7 +100,8 @@ pub mod pallet {
|
||||
// General types
|
||||
|
||||
/// The overarching event type.
|
||||
type Event: From<Event<Self, I>> + IsType<<Self as frame_system::Config>::Event>;
|
||||
type RuntimeEvent: From<Event<Self, I>>
|
||||
+ IsType<<Self as frame_system::Config>::RuntimeEvent>;
|
||||
/// Benchmarks results from runtime we're plugged into.
|
||||
type WeightInfo: WeightInfoExt;
|
||||
|
||||
@@ -174,13 +171,13 @@ pub mod pallet {
|
||||
type TargetHeaderChain: TargetHeaderChain<Self::OutboundPayload, Self::AccountId>;
|
||||
/// Message payload verifier.
|
||||
type LaneMessageVerifier: LaneMessageVerifier<
|
||||
Self::Origin,
|
||||
Self::RuntimeOrigin,
|
||||
Self::OutboundPayload,
|
||||
Self::OutboundMessageFee,
|
||||
>;
|
||||
/// Message delivery payment.
|
||||
type MessageDeliveryAndDispatchPayment: MessageDeliveryAndDispatchPayment<
|
||||
Self::Origin,
|
||||
Self::RuntimeOrigin,
|
||||
Self::AccountId,
|
||||
Self::OutboundMessageFee,
|
||||
>;
|
||||
@@ -333,9 +330,10 @@ pub mod pallet {
|
||||
});
|
||||
|
||||
// compute actual dispatch weight that depends on the stored message size
|
||||
let actual_weight = sp_std::cmp::min(
|
||||
let actual_weight = sp_std::cmp::min_by(
|
||||
T::WeightInfo::maximal_increase_message_fee(),
|
||||
T::WeightInfo::increase_message_fee(message_size as _),
|
||||
|w1, w2| w1.ref_time().cmp(&w2.ref_time()),
|
||||
);
|
||||
|
||||
Ok(PostDispatchInfo { actual_weight: Some(actual_weight), pays_fee: Pays::Yes })
|
||||
@@ -418,7 +416,7 @@ pub mod pallet {
|
||||
// on this lane. We can't dispatch lane messages out-of-order, so if declared
|
||||
// weight is not enough, let's move to next lane
|
||||
let dispatch_weight = T::MessageDispatch::dispatch_weight(&mut message);
|
||||
if dispatch_weight > dispatch_weight_left {
|
||||
if dispatch_weight.ref_time() > dispatch_weight_left.ref_time() {
|
||||
log::trace!(
|
||||
target: LOG_TARGET,
|
||||
"Cannot dispatch any more messages on lane {:?}. Weight: declared={}, left={}",
|
||||
@@ -456,7 +454,10 @@ pub mod pallet {
|
||||
ReceivalResult::TooManyUnconfirmedMessages => (dispatch_weight, true),
|
||||
};
|
||||
|
||||
let unspent_weight = sp_std::cmp::min(unspent_weight, dispatch_weight);
|
||||
let unspent_weight =
|
||||
sp_std::cmp::min_by(unspent_weight, dispatch_weight, |w1, w2| {
|
||||
w1.ref_time().cmp(&w2.ref_time())
|
||||
});
|
||||
dispatch_weight_left -= dispatch_weight - unspent_weight;
|
||||
actual_weight = actual_weight.saturating_sub(unspent_weight).saturating_sub(
|
||||
// delivery call weight formula assumes that the fee is paid at
|
||||
@@ -465,7 +466,7 @@ pub mod pallet {
|
||||
if refund_pay_dispatch_fee {
|
||||
T::WeightInfo::pay_inbound_dispatch_fee_overhead()
|
||||
} else {
|
||||
0
|
||||
Weight::from_ref_time(0)
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -580,11 +581,11 @@ pub mod pallet {
|
||||
if let Some(confirmed_messages) = confirmed_messages {
|
||||
// handle messages delivery confirmation
|
||||
let preliminary_callback_overhead =
|
||||
relayers_state.total_messages.saturating_mul(single_message_callback_overhead);
|
||||
single_message_callback_overhead.saturating_mul(relayers_state.total_messages);
|
||||
let actual_callback_weight =
|
||||
T::OnDeliveryConfirmed::on_messages_delivered(&lane_id, &confirmed_messages);
|
||||
match preliminary_callback_overhead.checked_sub(actual_callback_weight) {
|
||||
Some(difference) if difference == 0 => (),
|
||||
match preliminary_callback_overhead.checked_sub(&actual_callback_weight) {
|
||||
Some(difference) if difference.ref_time() == 0 => (),
|
||||
Some(difference) => {
|
||||
log::trace!(
|
||||
target: LOG_TARGET,
|
||||
@@ -775,8 +776,11 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
impl<T, I>
|
||||
bp_messages::source_chain::MessagesBridge<T::Origin, T::OutboundMessageFee, T::OutboundPayload>
|
||||
for Pallet<T, I>
|
||||
bp_messages::source_chain::MessagesBridge<
|
||||
T::RuntimeOrigin,
|
||||
T::OutboundMessageFee,
|
||||
T::OutboundPayload,
|
||||
> for Pallet<T, I>
|
||||
where
|
||||
T: Config<I>,
|
||||
I: 'static,
|
||||
@@ -784,7 +788,7 @@ where
|
||||
type Error = sp_runtime::DispatchErrorWithPostInfo<PostDispatchInfo>;
|
||||
|
||||
fn send_message(
|
||||
sender: T::Origin,
|
||||
sender: T::RuntimeOrigin,
|
||||
lane: LaneId,
|
||||
message: T::OutboundPayload,
|
||||
delivery_and_dispatch_fee: T::OutboundMessageFee,
|
||||
@@ -795,7 +799,7 @@ where
|
||||
|
||||
/// Function that actually sends message.
|
||||
fn send_message<T: Config<I>, I: 'static>(
|
||||
submitter: T::Origin,
|
||||
submitter: T::RuntimeOrigin,
|
||||
lane_id: LaneId,
|
||||
payload: T::OutboundPayload,
|
||||
delivery_and_dispatch_fee: T::OutboundMessageFee,
|
||||
@@ -875,8 +879,8 @@ fn send_message<T: Config<I>, I: 'static>(
|
||||
let single_message_callback_overhead =
|
||||
T::WeightInfo::single_message_callback_overhead(T::DbWeight::get());
|
||||
let actual_callback_weight = T::OnMessageAccepted::on_messages_accepted(&lane_id, &nonce);
|
||||
match single_message_callback_overhead.checked_sub(actual_callback_weight) {
|
||||
Some(difference) if difference == 0 => (),
|
||||
match single_message_callback_overhead.checked_sub(&actual_callback_weight) {
|
||||
Some(difference) if difference.ref_time() == 0 => (),
|
||||
Some(difference) => {
|
||||
log::trace!(
|
||||
target: LOG_TARGET,
|
||||
@@ -1104,8 +1108,8 @@ fn verify_and_decode_messages_proof<Chain: SourceHeaderChain<Fee>, Fee, Dispatch
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::mock::{
|
||||
message, message_payload, run_test, unrewarded_relayer, Balance, Event as TestEvent,
|
||||
Origin, TestMessageDeliveryAndDispatchPayment, TestMessagesDeliveryProof,
|
||||
message, message_payload, run_test, unrewarded_relayer, Balance, RuntimeEvent as TestEvent,
|
||||
RuntimeOrigin, TestMessageDeliveryAndDispatchPayment, TestMessagesDeliveryProof,
|
||||
TestMessagesParameter, TestMessagesProof, TestOnDeliveryConfirmed1,
|
||||
TestOnDeliveryConfirmed2, TestOnMessageAccepted, TestRuntime, TokenConversionRate,
|
||||
MAX_OUTBOUND_PAYLOAD_SIZE, PAYLOAD_REJECTED_BY_TARGET_CHAIN, REGULAR_PAYLOAD, TEST_LANE_ID,
|
||||
@@ -1149,10 +1153,10 @@ mod tests {
|
||||
let message_nonce =
|
||||
outbound_lane::<TestRuntime, ()>(TEST_LANE_ID).data().latest_generated_nonce + 1;
|
||||
let weight = Pallet::<TestRuntime>::send_message(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_LANE_ID,
|
||||
REGULAR_PAYLOAD,
|
||||
REGULAR_PAYLOAD.declared_weight,
|
||||
REGULAR_PAYLOAD.declared_weight.ref_time(),
|
||||
)
|
||||
.expect("send_message has failed")
|
||||
.actual_weight
|
||||
@@ -1174,7 +1178,7 @@ mod tests {
|
||||
// check that fee has been withdrawn from submitter
|
||||
assert!(TestMessageDeliveryAndDispatchPayment::is_fee_paid(
|
||||
1,
|
||||
REGULAR_PAYLOAD.declared_weight
|
||||
REGULAR_PAYLOAD.declared_weight.ref_time()
|
||||
));
|
||||
|
||||
weight
|
||||
@@ -1185,7 +1189,7 @@ mod tests {
|
||||
System::<TestRuntime>::reset_events();
|
||||
|
||||
assert_ok!(Pallet::<TestRuntime>::receive_messages_delivery_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TestMessagesDeliveryProof(Ok((
|
||||
TEST_LANE_ID,
|
||||
InboundLaneData {
|
||||
@@ -1226,7 +1230,7 @@ mod tests {
|
||||
|
||||
let parameter = TestMessagesParameter::TokenConversionRate(10.into());
|
||||
assert_ok!(Pallet::<TestRuntime>::update_pallet_parameter(
|
||||
Origin::root(),
|
||||
RuntimeOrigin::root(),
|
||||
parameter.clone(),
|
||||
));
|
||||
|
||||
@@ -1250,7 +1254,7 @@ mod tests {
|
||||
|
||||
let parameter = TestMessagesParameter::TokenConversionRate(10.into());
|
||||
assert_ok!(Pallet::<TestRuntime>::update_pallet_parameter(
|
||||
Origin::signed(2),
|
||||
RuntimeOrigin::signed(2),
|
||||
parameter.clone(),
|
||||
));
|
||||
|
||||
@@ -1271,7 +1275,7 @@ mod tests {
|
||||
run_test(|| {
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime>::update_pallet_parameter(
|
||||
Origin::signed(2),
|
||||
RuntimeOrigin::signed(2),
|
||||
TestMessagesParameter::TokenConversionRate(10.into()),
|
||||
),
|
||||
DispatchError::BadOrigin,
|
||||
@@ -1281,7 +1285,7 @@ mod tests {
|
||||
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime>::update_pallet_parameter(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TestMessagesParameter::TokenConversionRate(10.into()),
|
||||
),
|
||||
DispatchError::BadOrigin,
|
||||
@@ -1327,22 +1331,27 @@ mod tests {
|
||||
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime>::send_message(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_LANE_ID,
|
||||
REGULAR_PAYLOAD,
|
||||
REGULAR_PAYLOAD.declared_weight,
|
||||
REGULAR_PAYLOAD.declared_weight.ref_time(),
|
||||
),
|
||||
Error::<TestRuntime, ()>::NotOperatingNormally,
|
||||
);
|
||||
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime>::increase_message_fee(Origin::signed(1), TEST_LANE_ID, 1, 1,),
|
||||
Pallet::<TestRuntime>::increase_message_fee(
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_LANE_ID,
|
||||
1,
|
||||
1,
|
||||
),
|
||||
Error::<TestRuntime, ()>::BridgeModule(bp_runtime::OwnedBridgeModuleError::Halted),
|
||||
);
|
||||
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime>::receive_messages_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_RELAYER_A,
|
||||
Ok(vec![message(2, REGULAR_PAYLOAD)]).into(),
|
||||
1,
|
||||
@@ -1353,7 +1362,7 @@ mod tests {
|
||||
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime>::receive_messages_delivery_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TestMessagesDeliveryProof(Ok((
|
||||
TEST_LANE_ID,
|
||||
InboundLaneData {
|
||||
@@ -1387,23 +1396,23 @@ mod tests {
|
||||
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime>::send_message(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_LANE_ID,
|
||||
REGULAR_PAYLOAD,
|
||||
REGULAR_PAYLOAD.declared_weight,
|
||||
REGULAR_PAYLOAD.declared_weight.ref_time(),
|
||||
),
|
||||
Error::<TestRuntime, ()>::NotOperatingNormally,
|
||||
);
|
||||
|
||||
assert_ok!(Pallet::<TestRuntime>::increase_message_fee(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_LANE_ID,
|
||||
1,
|
||||
1,
|
||||
));
|
||||
|
||||
assert_ok!(Pallet::<TestRuntime>::receive_messages_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_RELAYER_A,
|
||||
Ok(vec![message(1, REGULAR_PAYLOAD)]).into(),
|
||||
1,
|
||||
@@ -1411,7 +1420,7 @@ mod tests {
|
||||
),);
|
||||
|
||||
assert_ok!(Pallet::<TestRuntime>::receive_messages_delivery_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TestMessagesDeliveryProof(Ok((
|
||||
TEST_LANE_ID,
|
||||
InboundLaneData {
|
||||
@@ -1449,7 +1458,7 @@ mod tests {
|
||||
.extend_from_slice(&[0u8; MAX_OUTBOUND_PAYLOAD_SIZE as usize]);
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime>::send_message(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_LANE_ID,
|
||||
message_payload.clone(),
|
||||
Balance::MAX,
|
||||
@@ -1463,7 +1472,7 @@ mod tests {
|
||||
}
|
||||
assert_eq!(message_payload.size(), MAX_OUTBOUND_PAYLOAD_SIZE);
|
||||
assert_ok!(Pallet::<TestRuntime>::send_message(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_LANE_ID,
|
||||
message_payload,
|
||||
Balance::MAX,
|
||||
@@ -1477,10 +1486,10 @@ mod tests {
|
||||
// messages with this payload are rejected by target chain verifier
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime>::send_message(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_LANE_ID,
|
||||
PAYLOAD_REJECTED_BY_TARGET_CHAIN,
|
||||
PAYLOAD_REJECTED_BY_TARGET_CHAIN.declared_weight
|
||||
PAYLOAD_REJECTED_BY_TARGET_CHAIN.declared_weight.ref_time(),
|
||||
),
|
||||
Error::<TestRuntime, ()>::MessageRejectedByChainVerifier,
|
||||
);
|
||||
@@ -1493,7 +1502,7 @@ mod tests {
|
||||
// messages with zero fee are rejected by lane verifier
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime>::send_message(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_LANE_ID,
|
||||
REGULAR_PAYLOAD,
|
||||
0
|
||||
@@ -1509,10 +1518,10 @@ mod tests {
|
||||
TestMessageDeliveryAndDispatchPayment::reject_payments();
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime>::send_message(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_LANE_ID,
|
||||
REGULAR_PAYLOAD,
|
||||
REGULAR_PAYLOAD.declared_weight
|
||||
REGULAR_PAYLOAD.declared_weight.ref_time(),
|
||||
),
|
||||
Error::<TestRuntime, ()>::FailedToWithdrawMessageFee,
|
||||
);
|
||||
@@ -1523,7 +1532,7 @@ mod tests {
|
||||
fn receive_messages_proof_works() {
|
||||
run_test(|| {
|
||||
assert_ok!(Pallet::<TestRuntime>::receive_messages_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_RELAYER_A,
|
||||
Ok(vec![message(1, REGULAR_PAYLOAD)]).into(),
|
||||
1,
|
||||
@@ -1567,7 +1576,7 @@ mod tests {
|
||||
Some(OutboundLaneData { latest_received_nonce: 9, ..Default::default() });
|
||||
|
||||
assert_ok!(Pallet::<TestRuntime>::receive_messages_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_RELAYER_A,
|
||||
message_proof,
|
||||
1,
|
||||
@@ -1601,12 +1610,14 @@ mod tests {
|
||||
#[test]
|
||||
fn receive_messages_proof_does_not_accept_message_if_dispatch_weight_is_not_enough() {
|
||||
run_test(|| {
|
||||
let mut declared_weight = REGULAR_PAYLOAD.declared_weight;
|
||||
*declared_weight.ref_time_mut() -= 1;
|
||||
assert_ok!(Pallet::<TestRuntime>::receive_messages_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_RELAYER_A,
|
||||
Ok(vec![message(1, REGULAR_PAYLOAD)]).into(),
|
||||
1,
|
||||
REGULAR_PAYLOAD.declared_weight - 1,
|
||||
declared_weight,
|
||||
));
|
||||
assert_eq!(InboundLanes::<TestRuntime>::get(TEST_LANE_ID).last_delivered_nonce(), 0);
|
||||
});
|
||||
@@ -1617,11 +1628,11 @@ mod tests {
|
||||
run_test(|| {
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime, ()>::receive_messages_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_RELAYER_A,
|
||||
Err(()).into(),
|
||||
1,
|
||||
0,
|
||||
Weight::from_ref_time(0),
|
||||
),
|
||||
Error::<TestRuntime, ()>::InvalidMessagesProof,
|
||||
);
|
||||
@@ -1633,11 +1644,11 @@ mod tests {
|
||||
run_test(|| {
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime, ()>::receive_messages_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_RELAYER_A,
|
||||
Ok(vec![message(1, REGULAR_PAYLOAD)]).into(),
|
||||
u32::MAX,
|
||||
0,
|
||||
Weight::from_ref_time(0),
|
||||
),
|
||||
Error::<TestRuntime, ()>::TooManyMessagesInTheProof,
|
||||
);
|
||||
@@ -1661,13 +1672,13 @@ mod tests {
|
||||
fn receive_messages_delivery_proof_rewards_relayers() {
|
||||
run_test(|| {
|
||||
assert_ok!(Pallet::<TestRuntime>::send_message(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_LANE_ID,
|
||||
REGULAR_PAYLOAD,
|
||||
1000,
|
||||
));
|
||||
assert_ok!(Pallet::<TestRuntime>::send_message(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_LANE_ID,
|
||||
REGULAR_PAYLOAD,
|
||||
2000,
|
||||
@@ -1675,7 +1686,7 @@ mod tests {
|
||||
|
||||
// this reports delivery of message 1 => reward is paid to TEST_RELAYER_A
|
||||
assert_ok!(Pallet::<TestRuntime>::receive_messages_delivery_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TestMessagesDeliveryProof(Ok((
|
||||
TEST_LANE_ID,
|
||||
InboundLaneData {
|
||||
@@ -1698,7 +1709,7 @@ mod tests {
|
||||
// this reports delivery of both message 1 and message 2 => reward is paid only to
|
||||
// TEST_RELAYER_B
|
||||
assert_ok!(Pallet::<TestRuntime>::receive_messages_delivery_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TestMessagesDeliveryProof(Ok((
|
||||
TEST_LANE_ID,
|
||||
InboundLaneData {
|
||||
@@ -1728,7 +1739,7 @@ mod tests {
|
||||
run_test(|| {
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime>::receive_messages_delivery_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TestMessagesDeliveryProof(Err(())),
|
||||
Default::default(),
|
||||
),
|
||||
@@ -1743,7 +1754,7 @@ mod tests {
|
||||
// when number of relayers entries is invalid
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime>::receive_messages_delivery_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TestMessagesDeliveryProof(Ok((
|
||||
TEST_LANE_ID,
|
||||
InboundLaneData {
|
||||
@@ -1769,7 +1780,7 @@ mod tests {
|
||||
// when number of messages is invalid
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime>::receive_messages_delivery_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TestMessagesDeliveryProof(Ok((
|
||||
TEST_LANE_ID,
|
||||
InboundLaneData {
|
||||
@@ -1795,7 +1806,7 @@ mod tests {
|
||||
// when last delivered nonce is invalid
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime>::receive_messages_delivery_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TestMessagesDeliveryProof(Ok((
|
||||
TEST_LANE_ID,
|
||||
InboundLaneData {
|
||||
@@ -1827,11 +1838,12 @@ mod tests {
|
||||
invalid_message.data.payload = Vec::new();
|
||||
|
||||
assert_ok!(Pallet::<TestRuntime, ()>::receive_messages_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_RELAYER_A,
|
||||
Ok(vec![invalid_message]).into(),
|
||||
1,
|
||||
0, // weight may be zero in this case (all messages are improperly encoded)
|
||||
Weight::from_ref_time(0), /* weight may be zero in this case (all messages are
|
||||
* improperly encoded) */
|
||||
),);
|
||||
|
||||
assert_eq!(InboundLanes::<TestRuntime>::get(TEST_LANE_ID).last_delivered_nonce(), 1,);
|
||||
@@ -1845,7 +1857,7 @@ mod tests {
|
||||
invalid_message.data.payload = Vec::new();
|
||||
|
||||
assert_ok!(Pallet::<TestRuntime, ()>::receive_messages_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_RELAYER_A,
|
||||
Ok(
|
||||
vec![message(1, REGULAR_PAYLOAD), invalid_message, message(3, REGULAR_PAYLOAD),]
|
||||
@@ -1862,12 +1874,12 @@ mod tests {
|
||||
#[test]
|
||||
fn actual_dispatch_weight_does_not_overlow() {
|
||||
run_test(|| {
|
||||
let message1 = message(1, message_payload(0, Weight::MAX / 2));
|
||||
let message2 = message(2, message_payload(0, Weight::MAX / 2));
|
||||
let message3 = message(3, message_payload(0, Weight::MAX / 2));
|
||||
let message1 = message(1, message_payload(0, u64::MAX / 2));
|
||||
let message2 = message(2, message_payload(0, u64::MAX / 2));
|
||||
let message3 = message(3, message_payload(0, u64::MAX / 2));
|
||||
|
||||
assert_ok!(Pallet::<TestRuntime, ()>::receive_messages_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_RELAYER_A,
|
||||
// this may cause overflow if source chain storage is invalid
|
||||
Ok(vec![message1, message2, message3]).into(),
|
||||
@@ -1886,7 +1898,7 @@ mod tests {
|
||||
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime, ()>::increase_message_fee(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_LANE_ID,
|
||||
1,
|
||||
100,
|
||||
@@ -1901,7 +1913,7 @@ mod tests {
|
||||
run_test(|| {
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime, ()>::increase_message_fee(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_LANE_ID,
|
||||
1,
|
||||
100,
|
||||
@@ -1920,7 +1932,7 @@ mod tests {
|
||||
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime, ()>::increase_message_fee(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_LANE_ID,
|
||||
1,
|
||||
100,
|
||||
@@ -1936,7 +1948,7 @@ mod tests {
|
||||
send_regular_message();
|
||||
|
||||
assert_ok!(Pallet::<TestRuntime, ()>::increase_message_fee(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_LANE_ID,
|
||||
1,
|
||||
100,
|
||||
@@ -1950,11 +1962,11 @@ mod tests {
|
||||
run_test(|| {
|
||||
fn submit_with_unspent_weight(
|
||||
nonce: MessageNonce,
|
||||
unspent_weight: Weight,
|
||||
unspent_weight: u64,
|
||||
is_prepaid: bool,
|
||||
) -> (Weight, Weight) {
|
||||
let mut payload = REGULAR_PAYLOAD;
|
||||
payload.dispatch_result.unspent_weight = unspent_weight;
|
||||
*payload.dispatch_result.unspent_weight.ref_time_mut() = unspent_weight;
|
||||
payload.dispatch_result.dispatch_fee_paid_during_dispatch = !is_prepaid;
|
||||
let proof = Ok(vec![message(nonce, payload)]).into();
|
||||
let messages_count = 1;
|
||||
@@ -1965,7 +1977,7 @@ mod tests {
|
||||
REGULAR_PAYLOAD.declared_weight,
|
||||
);
|
||||
let post_dispatch_weight = Pallet::<TestRuntime>::receive_messages_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_RELAYER_A,
|
||||
proof,
|
||||
messages_count,
|
||||
@@ -1980,16 +1992,26 @@ mod tests {
|
||||
|
||||
// when dispatch is returning `unspent_weight < declared_weight`
|
||||
let (pre, post) = submit_with_unspent_weight(1, 1, false);
|
||||
assert_eq!(post, pre - 1);
|
||||
assert_eq!(post.ref_time(), pre.ref_time() - 1);
|
||||
|
||||
// when dispatch is returning `unspent_weight = declared_weight`
|
||||
let (pre, post) = submit_with_unspent_weight(2, REGULAR_PAYLOAD.declared_weight, false);
|
||||
assert_eq!(post, pre - REGULAR_PAYLOAD.declared_weight);
|
||||
let (pre, post) =
|
||||
submit_with_unspent_weight(2, REGULAR_PAYLOAD.declared_weight.ref_time(), false);
|
||||
assert_eq!(
|
||||
post.ref_time(),
|
||||
pre.ref_time() - REGULAR_PAYLOAD.declared_weight.ref_time()
|
||||
);
|
||||
|
||||
// when dispatch is returning `unspent_weight > declared_weight`
|
||||
let (pre, post) =
|
||||
submit_with_unspent_weight(3, REGULAR_PAYLOAD.declared_weight + 1, false);
|
||||
assert_eq!(post, pre - REGULAR_PAYLOAD.declared_weight);
|
||||
let (pre, post) = submit_with_unspent_weight(
|
||||
3,
|
||||
REGULAR_PAYLOAD.declared_weight.ref_time() + 1,
|
||||
false,
|
||||
);
|
||||
assert_eq!(
|
||||
post.ref_time(),
|
||||
pre.ref_time() - REGULAR_PAYLOAD.declared_weight.ref_time()
|
||||
);
|
||||
|
||||
// when there's no unspent weight
|
||||
let (pre, post) = submit_with_unspent_weight(4, 0, false);
|
||||
@@ -1998,8 +2020,10 @@ mod tests {
|
||||
// when dispatch is returning `unspent_weight < declared_weight` AND message is prepaid
|
||||
let (pre, post) = submit_with_unspent_weight(5, 1, true);
|
||||
assert_eq!(
|
||||
post,
|
||||
pre - 1 - <TestRuntime as Config>::WeightInfo::pay_inbound_dispatch_fee_overhead()
|
||||
post.ref_time(),
|
||||
pre.ref_time() -
|
||||
1 - <TestRuntime as Config>::WeightInfo::pay_inbound_dispatch_fee_overhead()
|
||||
.ref_time()
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -2043,7 +2067,7 @@ mod tests {
|
||||
|
||||
// first tx with messages 1+2
|
||||
assert_ok!(Pallet::<TestRuntime>::receive_messages_delivery_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TestMessagesDeliveryProof(messages_1_and_2_proof),
|
||||
UnrewardedRelayersState {
|
||||
unrewarded_relayer_entries: 1,
|
||||
@@ -2054,7 +2078,7 @@ mod tests {
|
||||
));
|
||||
// second tx with message 3
|
||||
assert_ok!(Pallet::<TestRuntime>::receive_messages_delivery_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TestMessagesDeliveryProof(messages_3_proof),
|
||||
UnrewardedRelayersState {
|
||||
unrewarded_relayer_entries: 1,
|
||||
@@ -2097,7 +2121,7 @@ mod tests {
|
||||
crate::mock::DbWeight::get(),
|
||||
);
|
||||
let post_dispatch_weight = Pallet::<TestRuntime>::receive_messages_delivery_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
proof,
|
||||
relayers_state,
|
||||
)
|
||||
@@ -2157,7 +2181,7 @@ mod tests {
|
||||
// numer of actually confirmed messages is `1`.
|
||||
assert_noop!(
|
||||
Pallet::<TestRuntime>::receive_messages_delivery_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TestMessagesDeliveryProof(Ok((
|
||||
TEST_LANE_ID,
|
||||
InboundLaneData { last_confirmed_nonce: 1, relayers: Default::default() },
|
||||
@@ -2178,32 +2202,40 @@ mod tests {
|
||||
large_payload.extra = vec![2; MAX_OUTBOUND_PAYLOAD_SIZE as usize / 5];
|
||||
|
||||
assert_ok!(Pallet::<TestRuntime>::send_message(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_LANE_ID,
|
||||
small_payload,
|
||||
100,
|
||||
));
|
||||
assert_ok!(Pallet::<TestRuntime>::send_message(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_LANE_ID,
|
||||
large_payload,
|
||||
100,
|
||||
));
|
||||
|
||||
let small_weight =
|
||||
Pallet::<TestRuntime>::increase_message_fee(Origin::signed(1), TEST_LANE_ID, 1, 1)
|
||||
.expect("increase_message_fee has failed")
|
||||
.actual_weight
|
||||
.expect("increase_message_fee always returns Some");
|
||||
let small_weight = Pallet::<TestRuntime>::increase_message_fee(
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_LANE_ID,
|
||||
1,
|
||||
1,
|
||||
)
|
||||
.expect("increase_message_fee has failed")
|
||||
.actual_weight
|
||||
.expect("increase_message_fee always returns Some");
|
||||
|
||||
let large_weight =
|
||||
Pallet::<TestRuntime>::increase_message_fee(Origin::signed(1), TEST_LANE_ID, 2, 1)
|
||||
.expect("increase_message_fee has failed")
|
||||
.actual_weight
|
||||
.expect("increase_message_fee always returns Some");
|
||||
let large_weight = Pallet::<TestRuntime>::increase_message_fee(
|
||||
RuntimeOrigin::signed(1),
|
||||
TEST_LANE_ID,
|
||||
2,
|
||||
1,
|
||||
)
|
||||
.expect("increase_message_fee has failed")
|
||||
.actual_weight
|
||||
.expect("increase_message_fee always returns Some");
|
||||
|
||||
assert!(
|
||||
large_weight > small_weight,
|
||||
large_weight.ref_time() > small_weight.ref_time(),
|
||||
"Actual post-dispatch weigth for larger message {} must be larger than {} for small message",
|
||||
large_weight,
|
||||
small_weight,
|
||||
@@ -2225,7 +2257,7 @@ mod tests {
|
||||
|
||||
// confirm delivery of all sent messages
|
||||
assert_ok!(Pallet::<TestRuntime>::receive_messages_delivery_proof(
|
||||
Origin::signed(1),
|
||||
RuntimeOrigin::signed(1),
|
||||
TestMessagesDeliveryProof(Ok((
|
||||
TEST_LANE_ID,
|
||||
InboundLaneData {
|
||||
@@ -2332,7 +2364,7 @@ mod tests {
|
||||
REGULAR_PAYLOAD.encode(),
|
||||
OutboundMessageDetails {
|
||||
nonce: 0,
|
||||
dispatch_weight: 0,
|
||||
dispatch_weight: Weight::from_ref_time(0),
|
||||
size: 0,
|
||||
delivery_and_dispatch_fee: 0,
|
||||
dispatch_fee_payment:
|
||||
|
||||
@@ -87,23 +87,23 @@ frame_support::construct_runtime! {
|
||||
|
||||
parameter_types! {
|
||||
pub const BlockHashCount: u64 = 250;
|
||||
pub const MaximumBlockWeight: Weight = 1024;
|
||||
pub const MaximumBlockWeight: Weight = Weight::from_ref_time(1024);
|
||||
pub const MaximumBlockLength: u32 = 2 * 1024;
|
||||
pub const AvailableBlockRatio: Perbill = Perbill::one();
|
||||
pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight { read: 1, write: 2 };
|
||||
}
|
||||
|
||||
impl frame_system::Config for TestRuntime {
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type Call = Call;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type BlockNumber = u64;
|
||||
type Hash = H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type AccountId = AccountId;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Header = SubstrateHeader;
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type Version = ();
|
||||
type PalletInfo = PalletInfo;
|
||||
@@ -128,7 +128,7 @@ impl pallet_balances::Config for TestRuntime {
|
||||
type MaxLocks = ();
|
||||
type Balance = Balance;
|
||||
type DustRemoval = ();
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type ExistentialDeposit = ExistentialDeposit;
|
||||
type AccountStore = frame_system::Pallet<TestRuntime>;
|
||||
type WeightInfo = ();
|
||||
@@ -159,7 +159,7 @@ impl MessagesParameter for TestMessagesParameter {
|
||||
}
|
||||
|
||||
impl Config for TestRuntime {
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type WeightInfo = ();
|
||||
type Parameter = TestMessagesParameter;
|
||||
type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce;
|
||||
@@ -185,7 +185,7 @@ impl Config for TestRuntime {
|
||||
type BridgedChainId = TestBridgedChainId;
|
||||
}
|
||||
|
||||
impl SenderOrigin<AccountId> for Origin {
|
||||
impl SenderOrigin<AccountId> for RuntimeOrigin {
|
||||
fn linked_account(&self) -> Option<AccountId> {
|
||||
match self.caller {
|
||||
OriginCaller::system(frame_system::RawOrigin::Signed(ref submitter)) =>
|
||||
@@ -298,11 +298,11 @@ impl TargetHeaderChain<TestPayload, TestRelayer> for TestTargetHeaderChain {
|
||||
#[derive(Debug, Default)]
|
||||
pub struct TestLaneMessageVerifier;
|
||||
|
||||
impl LaneMessageVerifier<Origin, TestPayload, TestMessageFee> for TestLaneMessageVerifier {
|
||||
impl LaneMessageVerifier<RuntimeOrigin, TestPayload, TestMessageFee> for TestLaneMessageVerifier {
|
||||
type Error = &'static str;
|
||||
|
||||
fn verify_message(
|
||||
_submitter: &Origin,
|
||||
_submitter: &RuntimeOrigin,
|
||||
delivery_and_dispatch_fee: &TestMessageFee,
|
||||
_lane: &LaneId,
|
||||
_lane_outbound_data: &OutboundLaneData,
|
||||
@@ -328,7 +328,8 @@ impl TestMessageDeliveryAndDispatchPayment {
|
||||
|
||||
/// Returns true if given fee has been paid by given submitter.
|
||||
pub fn is_fee_paid(submitter: AccountId, fee: TestMessageFee) -> bool {
|
||||
let raw_origin: Result<frame_system::RawOrigin<_>, _> = Origin::signed(submitter).into();
|
||||
let raw_origin: Result<frame_system::RawOrigin<_>, _> =
|
||||
RuntimeOrigin::signed(submitter).into();
|
||||
frame_support::storage::unhashed::get(b":message-fee:") == Some((raw_origin.unwrap(), fee))
|
||||
}
|
||||
|
||||
@@ -340,13 +341,13 @@ impl TestMessageDeliveryAndDispatchPayment {
|
||||
}
|
||||
}
|
||||
|
||||
impl MessageDeliveryAndDispatchPayment<Origin, AccountId, TestMessageFee>
|
||||
impl MessageDeliveryAndDispatchPayment<RuntimeOrigin, AccountId, TestMessageFee>
|
||||
for TestMessageDeliveryAndDispatchPayment
|
||||
{
|
||||
type Error = &'static str;
|
||||
|
||||
fn pay_delivery_and_dispatch_fee(
|
||||
submitter: &Origin,
|
||||
submitter: &RuntimeOrigin,
|
||||
fee: &TestMessageFee,
|
||||
) -> Result<(), Self::Error> {
|
||||
if frame_support::storage::unhashed::get(b":reject-message-fee:") == Some(true) {
|
||||
@@ -451,7 +452,7 @@ impl OnDeliveryConfirmed for TestOnDeliveryConfirmed2 {
|
||||
fn on_messages_delivered(lane: &LaneId, messages: &DeliveredMessages) -> Weight {
|
||||
let key = (b"TestOnDeliveryConfirmed2", lane, messages).encode();
|
||||
frame_support::storage::unhashed::put(&key, &true);
|
||||
0
|
||||
Weight::from_ref_time(0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -482,7 +483,7 @@ impl MessageDispatch<AccountId, TestMessageFee> for TestMessageDispatch {
|
||||
fn dispatch_weight(message: &mut DispatchMessage<TestPayload, TestMessageFee>) -> Weight {
|
||||
match message.data.payload.as_ref() {
|
||||
Ok(payload) => payload.declared_weight,
|
||||
Err(_) => 0,
|
||||
Err(_) => Weight::from_ref_time(0),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -503,8 +504,13 @@ pub fn message(nonce: MessageNonce, payload: TestPayload) -> Message<TestMessage
|
||||
}
|
||||
|
||||
/// Constructs message payload using given arguments and zero unspent weight.
|
||||
pub const fn message_payload(id: u64, declared_weight: Weight) -> TestPayload {
|
||||
TestPayload { id, declared_weight, dispatch_result: dispatch_result(0), extra: Vec::new() }
|
||||
pub const fn message_payload(id: u64, declared_weight: u64) -> TestPayload {
|
||||
TestPayload {
|
||||
id,
|
||||
declared_weight: Weight::from_ref_time(declared_weight),
|
||||
dispatch_result: dispatch_result(0),
|
||||
extra: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Return message data with valid fee for given payload.
|
||||
@@ -513,10 +519,10 @@ pub fn message_data(payload: TestPayload) -> MessageData<TestMessageFee> {
|
||||
}
|
||||
|
||||
/// Returns message dispatch result with given unspent weight.
|
||||
pub const fn dispatch_result(unspent_weight: Weight) -> MessageDispatchResult {
|
||||
pub const fn dispatch_result(unspent_weight: u64) -> MessageDispatchResult {
|
||||
MessageDispatchResult {
|
||||
dispatch_result: true,
|
||||
unspent_weight,
|
||||
unspent_weight: Weight::from_ref_time(unspent_weight),
|
||||
dispatch_fee_paid_during_dispatch: true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//! Autogenerated weights for `pallet_bridge_messages`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-10-04, STEPS: 50, REPEAT: 20
|
||||
//! DATE: 2022-10-17, STEPS: 50, REPEAT: 20
|
||||
//! LOW RANGE: [], HIGH RANGE: []
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled
|
||||
//! CHAIN: Some("dev"), DB CACHE: 1024
|
||||
@@ -72,149 +72,149 @@ pub trait WeightInfo {
|
||||
pub struct BridgeWeight<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo for BridgeWeight<T> {
|
||||
fn send_minimal_message_worst_case() -> Weight {
|
||||
(62_300_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(10 as Weight))
|
||||
Weight::from_ref_time(61_807_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(10 as u64))
|
||||
}
|
||||
fn send_1_kb_message_worst_case() -> Weight {
|
||||
(63_176_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(10 as Weight))
|
||||
Weight::from_ref_time(65_074_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(10 as u64))
|
||||
}
|
||||
fn send_16_kb_message_worst_case() -> Weight {
|
||||
(73_472_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(10 as Weight))
|
||||
Weight::from_ref_time(73_584_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(10 as u64))
|
||||
}
|
||||
fn maximal_increase_message_fee() -> Weight {
|
||||
(2_539_209_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
Weight::from_ref_time(2_522_629_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(3 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
fn increase_message_fee(i: u32) -> Weight {
|
||||
(0 as Weight)
|
||||
.saturating_add((1_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
Weight::from_ref_time(27_072_000 as u64)
|
||||
.saturating_add(Weight::from_ref_time(892 as u64).saturating_mul(i as u64))
|
||||
.saturating_add(T::DbWeight::get().reads(3 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
fn receive_single_message_proof() -> Weight {
|
||||
(49_205_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(4 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
Weight::from_ref_time(49_628_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(4 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
fn receive_two_messages_proof() -> Weight {
|
||||
(62_182_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(4 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
Weight::from_ref_time(61_514_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(4 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
fn receive_single_message_proof_with_outbound_lane_state() -> Weight {
|
||||
(55_928_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(4 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
Weight::from_ref_time(65_960_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(4 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
fn receive_single_message_proof_1_kb() -> Weight {
|
||||
(47_298_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
Weight::from_ref_time(48_009_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(3 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
fn receive_single_message_proof_16_kb() -> Weight {
|
||||
(105_016_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
Weight::from_ref_time(100_439_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(3 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as u64))
|
||||
}
|
||||
fn receive_single_prepaid_message_proof() -> Weight {
|
||||
(49_067_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(4 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
Weight::from_ref_time(50_463_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(4 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
fn receive_delivery_proof_for_single_message() -> Weight {
|
||||
(58_520_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
Weight::from_ref_time(57_383_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight {
|
||||
(61_563_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
Weight::from_ref_time(62_003_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as u64))
|
||||
}
|
||||
fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight {
|
||||
(63_197_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(7 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
Weight::from_ref_time(64_401_000 as u64)
|
||||
.saturating_add(T::DbWeight::get().reads(7 as u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as u64))
|
||||
}
|
||||
}
|
||||
|
||||
// For backwards compatibility and tests
|
||||
impl WeightInfo for () {
|
||||
fn send_minimal_message_worst_case() -> Weight {
|
||||
(62_300_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(10 as Weight))
|
||||
Weight::from_ref_time(61_807_000 as u64)
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(10 as u64))
|
||||
}
|
||||
fn send_1_kb_message_worst_case() -> Weight {
|
||||
(63_176_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(10 as Weight))
|
||||
Weight::from_ref_time(65_074_000 as u64)
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(10 as u64))
|
||||
}
|
||||
fn send_16_kb_message_worst_case() -> Weight {
|
||||
(73_472_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(10 as Weight))
|
||||
Weight::from_ref_time(73_584_000 as u64)
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(10 as u64))
|
||||
}
|
||||
fn maximal_increase_message_fee() -> Weight {
|
||||
(2_539_209_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
Weight::from_ref_time(2_522_629_000 as u64)
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
}
|
||||
fn increase_message_fee(i: u32) -> Weight {
|
||||
(0 as Weight)
|
||||
.saturating_add((1_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
Weight::from_ref_time(27_072_000 as u64)
|
||||
.saturating_add(Weight::from_ref_time(892 as u64).saturating_mul(i as u64))
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
}
|
||||
fn receive_single_message_proof() -> Weight {
|
||||
(49_205_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(4 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
Weight::from_ref_time(49_628_000 as u64)
|
||||
.saturating_add(RocksDbWeight::get().reads(4 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as u64))
|
||||
}
|
||||
fn receive_two_messages_proof() -> Weight {
|
||||
(62_182_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(4 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
Weight::from_ref_time(61_514_000 as u64)
|
||||
.saturating_add(RocksDbWeight::get().reads(4 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as u64))
|
||||
}
|
||||
fn receive_single_message_proof_with_outbound_lane_state() -> Weight {
|
||||
(55_928_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(4 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
Weight::from_ref_time(65_960_000 as u64)
|
||||
.saturating_add(RocksDbWeight::get().reads(4 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as u64))
|
||||
}
|
||||
fn receive_single_message_proof_1_kb() -> Weight {
|
||||
(47_298_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
Weight::from_ref_time(48_009_000 as u64)
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
}
|
||||
fn receive_single_message_proof_16_kb() -> Weight {
|
||||
(105_016_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
Weight::from_ref_time(100_439_000 as u64)
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as u64))
|
||||
}
|
||||
fn receive_single_prepaid_message_proof() -> Weight {
|
||||
(49_067_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(4 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
Weight::from_ref_time(50_463_000 as u64)
|
||||
.saturating_add(RocksDbWeight::get().reads(4 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as u64))
|
||||
}
|
||||
fn receive_delivery_proof_for_single_message() -> Weight {
|
||||
(58_520_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
Weight::from_ref_time(57_383_000 as u64)
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as u64))
|
||||
}
|
||||
fn receive_delivery_proof_for_two_messages_by_single_relayer() -> Weight {
|
||||
(61_563_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(6 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
Weight::from_ref_time(62_003_000 as u64)
|
||||
.saturating_add(RocksDbWeight::get().reads(6 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as u64))
|
||||
}
|
||||
fn receive_delivery_proof_for_two_messages_by_two_relayers() -> Weight {
|
||||
(63_197_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(7 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
Weight::from_ref_time(64_401_000 as u64)
|
||||
.saturating_add(RocksDbWeight::get().reads(7 as u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as u64))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,14 +43,14 @@ pub fn ensure_weights_are_correct<W: WeightInfoExt>(
|
||||
db_weight: RuntimeDbWeight,
|
||||
) {
|
||||
// verify `send_message` weight components
|
||||
assert_ne!(W::send_message_overhead(), 0);
|
||||
assert_ne!(W::send_message_size_overhead(0), 0);
|
||||
assert_ne!(W::send_message_overhead(), Weight::from_ref_time(0));
|
||||
assert_ne!(W::send_message_size_overhead(0), Weight::from_ref_time(0));
|
||||
|
||||
// verify `receive_messages_proof` weight components
|
||||
assert_ne!(W::receive_messages_proof_overhead(), 0);
|
||||
assert_ne!(W::receive_messages_proof_messages_overhead(1), 0);
|
||||
assert_ne!(W::receive_messages_proof_outbound_lane_state_overhead(), 0);
|
||||
assert_ne!(W::storage_proof_size_overhead(1), 0);
|
||||
assert_ne!(W::receive_messages_proof_overhead(), Weight::from_ref_time(0));
|
||||
assert_ne!(W::receive_messages_proof_messages_overhead(1), Weight::from_ref_time(0));
|
||||
assert_ne!(W::receive_messages_proof_outbound_lane_state_overhead(), Weight::from_ref_time(0));
|
||||
assert_ne!(W::storage_proof_size_overhead(1), Weight::from_ref_time(0));
|
||||
|
||||
// verify that the hardcoded value covers `receive_messages_proof` weight
|
||||
let actual_single_regular_message_delivery_tx_weight = W::receive_messages_proof_weight(
|
||||
@@ -58,11 +58,11 @@ pub fn ensure_weights_are_correct<W: WeightInfoExt>(
|
||||
(EXPECTED_DEFAULT_MESSAGE_LENGTH + W::expected_extra_storage_proof_size()) as usize,
|
||||
),
|
||||
1,
|
||||
0,
|
||||
Weight::from_ref_time(0),
|
||||
);
|
||||
assert!(
|
||||
actual_single_regular_message_delivery_tx_weight <=
|
||||
expected_default_message_delivery_tx_weight,
|
||||
actual_single_regular_message_delivery_tx_weight.ref_time() <=
|
||||
expected_default_message_delivery_tx_weight.ref_time(),
|
||||
"Default message delivery transaction weight {} is larger than expected weight {}",
|
||||
actual_single_regular_message_delivery_tx_weight,
|
||||
expected_default_message_delivery_tx_weight,
|
||||
@@ -71,15 +71,16 @@ pub fn ensure_weights_are_correct<W: WeightInfoExt>(
|
||||
// verify that hardcoded value covers additional byte length of `receive_messages_proof` weight
|
||||
let actual_additional_byte_delivery_weight = W::storage_proof_size_overhead(1);
|
||||
assert!(
|
||||
actual_additional_byte_delivery_weight <= expected_additional_byte_delivery_weight,
|
||||
actual_additional_byte_delivery_weight.ref_time() <=
|
||||
expected_additional_byte_delivery_weight.ref_time(),
|
||||
"Single additional byte delivery weight {} is larger than expected weight {}",
|
||||
actual_additional_byte_delivery_weight,
|
||||
expected_additional_byte_delivery_weight,
|
||||
);
|
||||
|
||||
// verify `receive_messages_delivery_proof` weight components
|
||||
assert_ne!(W::receive_messages_delivery_proof_overhead(), 0);
|
||||
assert_ne!(W::storage_proof_size_overhead(1), 0);
|
||||
assert_ne!(W::receive_messages_delivery_proof_overhead(), Weight::from_ref_time(0));
|
||||
assert_ne!(W::storage_proof_size_overhead(1), Weight::from_ref_time(0));
|
||||
|
||||
// `receive_messages_delivery_proof_messages_overhead` and
|
||||
// `receive_messages_delivery_proof_relayers_overhead` may return zero if rewards are not paid
|
||||
@@ -96,8 +97,8 @@ pub fn ensure_weights_are_correct<W: WeightInfoExt>(
|
||||
db_weight,
|
||||
);
|
||||
assert!(
|
||||
actual_messages_delivery_confirmation_tx_weight <=
|
||||
expected_messages_delivery_confirmation_tx_weight,
|
||||
actual_messages_delivery_confirmation_tx_weight.ref_time() <=
|
||||
expected_messages_delivery_confirmation_tx_weight.ref_time(),
|
||||
"Messages delivery confirmation transaction weight {} is larger than expected weight {}",
|
||||
actual_messages_delivery_confirmation_tx_weight,
|
||||
expected_messages_delivery_confirmation_tx_weight,
|
||||
@@ -106,7 +107,7 @@ pub fn ensure_weights_are_correct<W: WeightInfoExt>(
|
||||
// verify pay-dispatch-fee overhead for inbound messages
|
||||
let actual_pay_inbound_dispatch_fee_weight = W::pay_inbound_dispatch_fee_overhead();
|
||||
assert!(
|
||||
actual_pay_inbound_dispatch_fee_weight <= expected_pay_inbound_dispatch_fee_weight,
|
||||
actual_pay_inbound_dispatch_fee_weight.ref_time() <= expected_pay_inbound_dispatch_fee_weight.ref_time(),
|
||||
"Weight {} of pay-dispatch-fee overhead for inbound messages is larger than expected weight {}",
|
||||
actual_pay_inbound_dispatch_fee_weight,
|
||||
expected_pay_inbound_dispatch_fee_weight,
|
||||
@@ -140,7 +141,7 @@ pub fn ensure_able_to_receive_message<W: WeightInfoExt>(
|
||||
max_incoming_message_dispatch_weight,
|
||||
);
|
||||
assert!(
|
||||
max_delivery_transaction_dispatch_weight <= max_extrinsic_weight,
|
||||
max_delivery_transaction_dispatch_weight.ref_time() <= max_extrinsic_weight.ref_time(),
|
||||
"Weight of maximal message delivery transaction + {} is larger than maximal possible transaction weight {}",
|
||||
max_delivery_transaction_dispatch_weight,
|
||||
max_extrinsic_weight,
|
||||
@@ -179,7 +180,7 @@ pub fn ensure_able_to_receive_confirmation<W: WeightInfoExt>(
|
||||
db_weight,
|
||||
);
|
||||
assert!(
|
||||
max_confirmation_transaction_dispatch_weight <= max_extrinsic_weight,
|
||||
max_confirmation_transaction_dispatch_weight.ref_time() <= max_extrinsic_weight.ref_time(),
|
||||
"Weight of maximal confirmation transaction {} is larger than maximal possible transaction weight {}",
|
||||
max_confirmation_transaction_dispatch_weight,
|
||||
max_extrinsic_weight,
|
||||
@@ -264,13 +265,13 @@ pub trait WeightInfoExt: WeightInfo {
|
||||
// message
|
||||
let callback_overhead = relayers_state
|
||||
.total_messages
|
||||
.saturating_mul(Self::single_message_callback_overhead(db_weight));
|
||||
.saturating_mul(Self::single_message_callback_overhead(db_weight).ref_time());
|
||||
|
||||
transaction_overhead
|
||||
.saturating_add(messages_overhead)
|
||||
.saturating_add(relayers_overhead)
|
||||
.saturating_add(proof_size_overhead)
|
||||
.saturating_add(callback_overhead)
|
||||
.saturating_add(Weight::from_ref_time(callback_overhead))
|
||||
}
|
||||
|
||||
// Functions that are used by extrinsics weights formulas.
|
||||
@@ -305,7 +306,7 @@ pub trait WeightInfoExt: WeightInfo {
|
||||
let weight_of_single_message_and_single_tx_overhead = Self::receive_single_message_proof();
|
||||
weight_of_two_messages_and_single_tx_overhead
|
||||
.saturating_sub(weight_of_single_message_and_single_tx_overhead)
|
||||
.saturating_mul(messages as Weight)
|
||||
.saturating_mul(messages as _)
|
||||
}
|
||||
|
||||
/// Returns weight that needs to be accounted when message delivery transaction
|
||||
@@ -336,7 +337,7 @@ pub trait WeightInfoExt: WeightInfo {
|
||||
let weight_of_single_message = Self::receive_delivery_proof_for_single_message();
|
||||
weight_of_two_messages
|
||||
.saturating_sub(weight_of_single_message)
|
||||
.saturating_mul(messages as Weight)
|
||||
.saturating_mul(messages as _)
|
||||
}
|
||||
|
||||
/// Returns weight that needs to be accounted when receiving confirmations for given a number of
|
||||
@@ -348,7 +349,7 @@ pub trait WeightInfoExt: WeightInfo {
|
||||
Self::receive_delivery_proof_for_two_messages_by_single_relayer();
|
||||
weight_of_two_messages_by_two_relayers
|
||||
.saturating_sub(weight_of_two_messages_by_single_relayer)
|
||||
.saturating_mul(relayers as Weight)
|
||||
.saturating_mul(relayers as _)
|
||||
}
|
||||
|
||||
/// Returns weight that needs to be accounted when storage proof of given size is received
|
||||
@@ -360,7 +361,7 @@ pub trait WeightInfoExt: WeightInfo {
|
||||
/// relayer must pay when it relays proof of given size (even if cost based on other parameters
|
||||
/// is less than that cost).
|
||||
fn storage_proof_size_overhead(proof_size: u32) -> Weight {
|
||||
let proof_size_in_bytes = proof_size as Weight;
|
||||
let proof_size_in_bytes = proof_size;
|
||||
let byte_weight = (Self::receive_single_message_proof_16_kb() -
|
||||
Self::receive_single_message_proof_1_kb()) /
|
||||
(15 * 1024);
|
||||
|
||||
Reference in New Issue
Block a user