Skip to content

Commit

Permalink
pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair-singh committed Nov 9, 2023
1 parent 28955c1 commit 5c03ad8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion parachain/pallets/outbound-queue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ pub mod pallet {
fee_per_gas.saturating_mul(max_gas_required.into()).saturating_add(reward)
}

/// Calculate fee in native currency for processing a message locally
/// The local component of the message processing fees in native currency
pub(crate) fn calculate_local_fee() -> T::Balance {
T::WeightToFee::weight_to_fee(
&T::WeightInfo::do_process_message().saturating_add(T::WeightInfo::commit_single()),
Expand Down
11 changes: 6 additions & 5 deletions parachain/pallets/outbound-queue/src/send_message_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use frame_support::{
};
use snowbridge_core::outbound::{
AggregateMessageOrigin, ExportOrigin, Fee, Message, QueuedMessage, SendError, SendMessage,
SendMessageFee, VersionedQueuedMessage,
SendMessageFeeProvider, VersionedQueuedMessage,
};
use sp_core::H256;
use sp_runtime::BoundedVec;
Expand All @@ -26,9 +26,10 @@ pub struct Ticket<MaxMessageSize: Get<u32>> {

impl<T: Config> SendMessage for Pallet<T> {
type Ticket = Ticket<MaxEnqueuedMessageSizeOf<T>>;
type Balance = T::Balance;

fn validate(message: &Message) -> Result<(Self::Ticket, Fee<Self::Balance>), SendError> {
fn validate(
message: &Message,
) -> Result<(Self::Ticket, Fee<<Self as SendMessageFeeProvider>::Balance>), SendError> {
// The inner payload should not be too large
let payload = message.command.abi_encode();

Expand Down Expand Up @@ -84,10 +85,10 @@ impl<T: Config> SendMessage for Pallet<T> {
}
}

impl<T: Config> SendMessageFee for Pallet<T> {
impl<T: Config> SendMessageFeeProvider for Pallet<T> {
type Balance = T::Balance;

/// Calculate fee in native currency for processing a message locally
/// The local component of the message processing fees in native currency
fn local_fee() -> Self::Balance {
Self::calculate_local_fee()
}
Expand Down
11 changes: 6 additions & 5 deletions parachain/primitives/core/src/outbound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,24 +278,25 @@ where
}

/// A trait for sending messages to Ethereum
pub trait SendMessage {
pub trait SendMessage: SendMessageFeeProvider {
type Ticket: Clone + Encode + Decode;
type Balance: BaseArithmetic + Unsigned + Copy;

/// Validate an outbound message and return a tuple:
/// 1. Ticket for submitting the message
/// 2. Delivery fee
fn validate(message: &Message) -> Result<(Self::Ticket, Fee<Self::Balance>), SendError>;
fn validate(
message: &Message,
) -> Result<(Self::Ticket, Fee<<Self as SendMessageFeeProvider>::Balance>), SendError>;

/// Submit the message ticket for eventual delivery to Ethereum
fn deliver(ticket: Self::Ticket) -> Result<H256, SendError>;
}

/// A trait for getting the local costs associated with sending a message.
pub trait SendMessageFee {
pub trait SendMessageFeeProvider {
type Balance: BaseArithmetic + Unsigned + Copy;

/// Calculate fee in native currency for processing a message locally
/// The local component of the message processing fees in native currency
fn local_fee() -> Self::Balance;
}

Expand Down

0 comments on commit 5c03ad8

Please sign in to comment.