Crate pallet_gear_gas
source ·Expand description
§Gear Gas Pallet
The Gear Gas Pallet provides functionality for handling messages’ execution resources.
§Overview
The Gear Gas Pallet’s main aim is to separate message’s associated gas tree nodes storages out of Gear’s execution logic and provide soft functionality to manage them.
The Gear Gas Pallet provides functions for:
- Obtaining maximum gas amount available within one block of execution.
- Managing number of remaining gas, i.e. gas allowance.
- Managing gas tree: create, split, cut, etc new nodes determining execution resources of messages.
§Interface
The Gear Gas Pallet implements gear_common::GasProvider
trait
and shouldn’t contain any other functionality, except this trait declares.
§Usage
How to use the gas functionality from the Gear Gas Pallet:
- Implement its
Config
for your runtime with specifiedBlockGasLimit
type.
ⓘ
// `runtime/src/lib.rs`
// ... //
impl pallet_gear_gas::Config for Runtime {
type BlockGasLimit = .. ;
}
// ... //
- Provide associated type for your pallet’s
Config
, which implementsgear_common::GasProvider
trait, specifying associated types if needed.
ⓘ
// `some_pallet/src/lib.rs`
// ... //
use gear_common::GasProvider;
#[pallet::config]
pub trait Config: frame_system::Config {
// .. //
type GasProvider: GasProvider<Balance = u64, ...>;
// .. //
}
- Declare Gear Gas Pallet in your
construct_runtime!
macro.
ⓘ
// `runtime/src/lib.rs`
// ... //
construct_runtime!(
pub enum Runtime
where // ... //
{
// ... //
GearGas: pallet_gear_gas,
// ... //
}
);
// ... //
GearGas: pallet_gear_gas,
- Set
GearGas
as your palletConfig
’sGasProvider
type.
ⓘ
// `runtime/src/lib.rs`
// ... //
impl some_pallet::Config for Runtime {
// ... //
type GasProvider = GearGas;
// ... //
}
// ... //
- Work with Gear Gas Pallet in your pallet with provided associated type interface.
§Genesis config
The Gear Gas Pallet doesn’t depend on the GenesisConfig
.
Re-exports§
pub use pallet::*;
Modules§
- The
pallet
module in each FRAME pallet hosts the most important items needed to construct this pallet.
Macros§
Structs§
- Fixed-size uninterpreted hash type with 32 bytes (256 bits) size.