Skip to content

Commit

Permalink
remove invalid weight, returned by send_message (paritytech#1984)
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik authored Mar 22, 2023
1 parent 9f1cd40 commit 1fdf576
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 23 deletions.
23 changes: 4 additions & 19 deletions bridges/modules/messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,15 +749,7 @@ fn send_message<T: Config<I>, I: 'static>(

Pallet::<T, I>::deposit_event(Event::MessageAccepted { lane_id, nonce });

// we may introduce benchmarks for that, but no heavy ops planned here apart from
// db reads and writes. There are currently 2 db reads and 2 db writes:
// - one db read for operation mode check (`ensure_normal_operating_mode`);
// - one db read for outbound lane state (`outbound_lane`);
// - one db write for outbound lane state (`send_message`);
// - one db write for the message (`send_message`);
let actual_weight = T::DbWeight::get().reads_writes(2, 2);

Ok(SendMessageArtifacts { nonce, weight: actual_weight })
Ok(SendMessageArtifacts { nonce })
}

/// Ensure that the pallet is in normal operational mode.
Expand Down Expand Up @@ -970,18 +962,13 @@ mod tests {
}
}

fn send_regular_message() -> Weight {
fn send_regular_message() {
get_ready_for_events();

let message_nonce =
outbound_lane::<TestRuntime, ()>(TEST_LANE_ID).data().latest_generated_nonce + 1;
let weight = send_message::<TestRuntime, ()>(
RuntimeOrigin::signed(1),
TEST_LANE_ID,
REGULAR_PAYLOAD,
)
.expect("send_message has failed")
.weight;
send_message::<TestRuntime, ()>(RuntimeOrigin::signed(1), TEST_LANE_ID, REGULAR_PAYLOAD)
.expect("send_message has failed");

// check event with assigned nonce
assert_eq!(
Expand All @@ -995,8 +982,6 @@ mod tests {
topics: vec![],
}],
);

weight
}

fn receive_messages_delivery_proof() {
Expand Down
6 changes: 2 additions & 4 deletions bridges/primitives/messages/src/source_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{InboundLaneData, LaneId, MessageNonce, OutboundLaneData};

use crate::UnrewardedRelayer;
use bp_runtime::Size;
use frame_support::{weights::Weight, Parameter, RuntimeDebug};
use frame_support::{Parameter, RuntimeDebug};
use sp_std::{
collections::{btree_map::BTreeMap, vec_deque::VecDeque},
fmt::Debug,
Expand Down Expand Up @@ -124,8 +124,6 @@ impl<AccountId> DeliveryConfirmationPayments<AccountId> for () {
pub struct SendMessageArtifacts {
/// Nonce of the message.
pub nonce: MessageNonce,
/// Actual weight of send message call.
pub weight: Weight,
}

/// Messages bridge API to be used from other pallets.
Expand Down Expand Up @@ -155,7 +153,7 @@ impl<SenderOrigin, Payload> MessagesBridge<SenderOrigin, Payload> for NoopMessag
_lane: LaneId,
_message: Payload,
) -> Result<SendMessageArtifacts, Self::Error> {
Ok(SendMessageArtifacts { nonce: 0, weight: Weight::zero() })
Ok(SendMessageArtifacts { nonce: 0 })
}
}

Expand Down

0 comments on commit 1fdf576

Please sign in to comment.