Skip to content

Commit

Permalink
Remove-rate-limit (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
blasrodri authored Aug 17, 2023
1 parent 7b8335d commit d5e693d
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 38 deletions.
29 changes: 0 additions & 29 deletions contracts/pallet-ibc/src/ics20/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,6 @@ pub type Ics20TransferMsg = ibc::applications::transfer::msgs::transfer::MsgTran
ibc::applications::transfer::Coin<ibc::applications::transfer::PrefixedDenom>,
>;

#[derive(Debug, Clone, Copy)]
pub enum FlowType {
Transfer,
Deliver,
}

pub trait Ics20RateLimiter {
#[allow(clippy::result_unit_err)]
fn allow(msg: &Ics20TransferMsg, flow_type: FlowType) -> Result<(), ()>;
}

impl Ics20RateLimiter for frame_support::traits::Everything {
fn allow(_msg: &Ics20TransferMsg, _flow_type: FlowType) -> Result<(), ()> {
Ok(())
}
}

#[derive(Clone, Eq, Debug, PartialEq)]
pub struct IbcModule<T: Config>(PhantomData<T>);

Expand Down Expand Up @@ -244,18 +227,6 @@ where
Ics04Error::implementation_specific("Failed to parse token denom".to_string())
})?;

let msg = Ics20TransferMsg {
source_port: packet.source_port.clone(),
memo: packet_data.memo.clone(),
sender: packet_data.sender.clone(),
receiver: packet_data.receiver.clone(),
source_channel: packet.source_channel,
token,
timeout_height: packet.timeout_height,
timeout_timestamp: packet.timeout_timestamp,
};
T::Ics20RateLimiter::allow(&msg, FlowType::Deliver)
.map_err(|_| Ics04Error::implementation_specific("rate limiter".to_string()))?;
let amount = packet_data.token.amount.as_u256();
u128::try_from(amount)
.map_err(|e| Ics04Error::implementation_specific(format!("{e:?}")))?;
Expand Down
8 changes: 1 addition & 7 deletions contracts/pallet-ibc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,7 @@ pub mod weight;

pub use weight::WeightInfo;

use crate::{
ics20::{FlowType, Ics20RateLimiter},
ics20_fee::FlatFeeConverter,
};
use crate::ics20_fee::FlatFeeConverter;

#[frame_support::pallet]
pub mod pallet {
Expand Down Expand Up @@ -265,7 +262,6 @@ pub mod pallet {
type IbcAccountId: Into<AccountId32>;
type TransferOrigin: EnsureOrigin<Self::RuntimeOrigin, Success = Self::IbcAccountId>;
type RelayerOrigin: EnsureOrigin<Self::RuntimeOrigin, Success = Self::AccountId>;
type Ics20RateLimiter: Ics20RateLimiter;
/// Handle Ics20 Memo
type HandleMemo: HandleMemo<Self> + Default;
/// Memo Message types supported by the runtime
Expand Down Expand Up @@ -976,8 +972,6 @@ pub mod pallet {
memo: memo.map(|memo| memo.to_string()).unwrap_or_default(),
};

T::Ics20RateLimiter::allow(&msg, FlowType::Transfer)
.map_err(|_| Error::<T>::RateLimiter)?;
let is_sender_source = is_sender_chain_source(
msg.source_port.clone(),
msg.source_channel,
Expand Down
1 change: 0 additions & 1 deletion contracts/pallet-ibc/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ impl Config for Test {
type MemoMessage = alloc::string::String;
type IsReceiveEnabled = sp_core::ConstBool<true>;
type IsSendEnabled = sp_core::ConstBool<true>;
type Ics20RateLimiter = Everything;
type FeeAccount = FeeAccount;
type CleanUpPacketsPeriod = CleanUpPacketsPeriod;
type ServiceChargeOut = ServiceCharge;
Expand Down
1 change: 0 additions & 1 deletion utils/parachain-node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,6 @@ impl pallet_ibc::Config for Runtime {
type PalletPrefix = IbcTriePrefix;
type LightClientProtocol = GRANDPA;
type IbcAccountId = Self::AccountId;
type Ics20RateLimiter = Everything;
type FeeAccount = FeeAccount;
type CleanUpPacketsPeriod = CleanUpPacketsPeriod;
type ServiceChargeOut = IbcIcs20ServiceCharge;
Expand Down

0 comments on commit d5e693d

Please sign in to comment.