Skip to content

Commit

Permalink
Revert the checks
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong committed Jan 17, 2024
1 parent 85cb976 commit af15053
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 18 deletions.
2 changes: 2 additions & 0 deletions parachain/pallets/outbound-queue/src/process_message_impl.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2023 Snowfork <[email protected]>
//! Implementation for [`frame_support::traits::ProcessMessage`]
use super::*;
use crate::weights::WeightInfo;
Expand Down
10 changes: 2 additions & 8 deletions parachain/pallets/outbound-queue/src/send_message_impl.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2023 Snowfork <[email protected]>
//! Implementation for [`snowbridge_core::outbound::SendMessage`]
use super::*;
use bridge_hub_common::AggregateMessageOrigin;
Expand All @@ -15,7 +17,6 @@ use snowbridge_core::{
},
ChannelId, PRIMARY_GOVERNANCE_CHANNEL,
};
use sp_arithmetic::traits::Zero;
use sp_core::H256;
use sp_runtime::BoundedVec;

Expand Down Expand Up @@ -58,14 +59,7 @@ where
.unwrap_or_else(|| unique((message.channel_id, &message.command)).into());

let gas_used_at_most = T::GasMeter::maximum_gas_used_at_most(&message.command);
ensure!(
gas_used_at_most > T::GasMeter::MAXIMUM_BASE_GAS &&
gas_used_at_most < T::GasMeter::MAXIMUM_GAS_CAP,
SendError::MessageInvalidGasFees
);
let fee = Self::calculate_fee(gas_used_at_most, T::PricingParameters::get());
let zero_fee = <Self as SendMessageFeeProvider>::Balance::zero();
ensure!(fee.local > zero_fee && fee.remote > zero_fee, SendError::MessageInvalidGasFees);

let queued_message: VersionedQueuedMessage = QueuedMessage {
id: message_id,
Expand Down
2 changes: 2 additions & 0 deletions parachain/pallets/outbound-queue/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2023 Snowfork <[email protected]>
use codec::{Decode, Encode};
use ethabi::Token;
use frame_support::traits::ProcessMessage;
Expand Down
2 changes: 1 addition & 1 deletion parachain/pallets/system/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ fn set_pricing_parameters_invalid() {
params = Parameters::get();
params.rewards.remote = sp_core::U256::zero();
assert_noop!(
EthereumSystem::set_pricing_parameters(origin.clone(), params),
EthereumSystem::set_pricing_parameters(origin, params),
Error::<Test>::InvalidPricingParameters
);
});
Expand Down
9 changes: 0 additions & 9 deletions parachain/primitives/core/src/outbound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,18 +339,13 @@ pub enum SendError {
Halted,
/// Invalid Channel
InvalidChannel,
/// Message with gas or fees calculated invalid
MessageInvalidGasFees,
}

pub trait GasMeter {
/// All the gas used for submitting a message to Ethereum, minus the cost of dispatching
/// the command within the message
const MAXIMUM_BASE_GAS: u64;

/// Hard limit for the maximum gas allowed among all commands
const MAXIMUM_GAS_CAP: u64;

fn maximum_gas_used_at_most(command: &Command) -> u64 {
Self::MAXIMUM_BASE_GAS + Self::maximum_dispatch_gas_used_at_most(command)
}
Expand All @@ -376,8 +371,6 @@ impl GasMeter for ConstantGasMeter {
// for message verification
const MAXIMUM_BASE_GAS: u64 = 185_000;

const MAXIMUM_GAS_CAP: u64 = 5_000_000;

fn maximum_dispatch_gas_used_at_most(command: &Command) -> u64 {
match command {
Command::CreateAgent { .. } => 275_000,
Expand Down Expand Up @@ -412,8 +405,6 @@ impl GasMeter for ConstantGasMeter {
impl GasMeter for () {
const MAXIMUM_BASE_GAS: u64 = 1;

const MAXIMUM_GAS_CAP: u64 = 100;

fn maximum_dispatch_gas_used_at_most(_: &Command) -> u64 {
1
}
Expand Down

0 comments on commit af15053

Please sign in to comment.