diff --git a/pallets/gear-eth-bridge/src/builtin.rs b/pallets/gear-eth-bridge/src/builtin.rs
index 32c887fe407..73ea7650b48 100644
--- a/pallets/gear-eth-bridge/src/builtin.rs
+++ b/pallets/gear-eth-bridge/src/builtin.rs
@@ -17,7 +17,7 @@
// along with this program. If not, see .
use crate::{Config, Error, Pallet, WeightInfo};
-use common::Origin;
+use common::{storage::Limiter, BlockLimiter, Origin};
use core::marker::PhantomData;
use gbuiltin_eth_bridge::{Request, Response};
use gear_core::{
@@ -30,6 +30,8 @@ use parity_scale_codec::{Decode, Encode};
use sp_runtime::traits::Zero;
use sp_std::vec::Vec;
+pub type GasAllowanceOf = <::BlockLimiter as BlockLimiter>::GasAllowance;
+
/// Gear builtin actor providing functionality of `pallet-gear-eth-bridge`.
///
/// Check out `gbuiltin-eth-bridge` to observe builtin interface.
@@ -79,6 +81,9 @@ where
if gas_limit < gas_cost {
return (Err(BuiltinActorError::InsufficientGas), 0);
}
+ if GasAllowanceOf::::get() < gas_cost {
+ return (Err(BuiltinActorError::GasAllowanceExceeded), 0);
+ }
let res = Pallet::::queue_message(source, destination, payload)
.map(|(nonce, hash)| {
diff --git a/pallets/gear-eth-bridge/src/lib.rs b/pallets/gear-eth-bridge/src/lib.rs
index 364e8592341..3e55a6c7378 100644
--- a/pallets/gear-eth-bridge/src/lib.rs
+++ b/pallets/gear-eth-bridge/src/lib.rs
@@ -48,7 +48,7 @@ mod tests;
#[frame_support::pallet]
pub mod pallet {
use super::*;
- use common::Origin;
+ use common::{BlockLimiter, Origin};
use frame_support::{
pallet_prelude::*,
traits::{ConstBool, OneSessionHandler, StorageInstance, StorageVersion},
@@ -93,6 +93,9 @@ pub mod pallet {
#[pallet::constant]
type SessionsPerEra: Get;
+ /// Block limits.
+ type BlockLimiter: BlockLimiter;
+
/// Weight cost incurred by pallet calls.
type WeightInfo: WeightInfo;
}
diff --git a/pallets/gear-eth-bridge/src/mock.rs b/pallets/gear-eth-bridge/src/mock.rs
index fe34115954e..5514a87d73e 100644
--- a/pallets/gear-eth-bridge/src/mock.rs
+++ b/pallets/gear-eth-bridge/src/mock.rs
@@ -293,6 +293,7 @@ impl pallet_gear_eth_bridge::Config for Test {
type MaxPayloadSize = ConstU32<1024>;
type QueueCapacity = ConstU32<32>;
type SessionsPerEra = SessionsPerEra;
+ type BlockLimiter = GearGas;
type WeightInfo = ();
}
diff --git a/runtime/vara/src/lib.rs b/runtime/vara/src/lib.rs
index f51e564f04a..538bda88589 100644
--- a/runtime/vara/src/lib.rs
+++ b/runtime/vara/src/lib.rs
@@ -1239,6 +1239,7 @@ impl pallet_gear_eth_bridge::Config for Runtime {
type MaxPayloadSize = ConstU32<16_384>; // 16 KiB
type QueueCapacity = ConstU32<2048>;
type SessionsPerEra = SessionsPerEra;
+ type BlockLimiter = GearGas;
type WeightInfo = weights::pallet_gear_eth_bridge::SubstrateWeight;
}