Skip to content

Commit

Permalink
Use default GasWeightMapping
Browse files Browse the repository at this point in the history
  • Loading branch information
jaypan authored and Jay Pan committed Oct 8, 2024
1 parent 5306bf5 commit 4d36a9f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 40 deletions.
15 changes: 2 additions & 13 deletions runtime/krest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,18 +640,6 @@ pub const GAS_PER_SECOND: u64 = 40_000_000;
/// u64 works for approximations because Weight is a very small unit compared to gas.
pub const WEIGHT_PER_GAS: u64 = WEIGHT_REF_TIME_PER_SECOND.saturating_div(GAS_PER_SECOND);

pub struct PeaqGasWeightMapping;
impl pallet_evm::GasWeightMapping for PeaqGasWeightMapping {
fn gas_to_weight(gas: u64, _without_base_weight: bool) -> Weight {
let weight = gas.saturating_mul(WEIGHT_PER_GAS);
Weight::from_parts(weight, 0)
}

fn weight_to_gas(weight: Weight) -> u64 {
weight.ref_time().wrapping_div(WEIGHT_PER_GAS)
}
}

parameter_types! {
pub const EvmChainId: u64 = 2241;
pub BlockGasLimit: U256 = U256::from(
Expand Down Expand Up @@ -680,7 +668,7 @@ parameter_types! {
impl pallet_evm::Config for Runtime {
type FeeCalculator = BaseFee;
type WeightPerGas = WeightPerGas;
type GasWeightMapping = PeaqGasWeightMapping;
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;
type CallOrigin = EnsureAddressTruncated;
type WithdrawOrigin = EnsureAddressTruncated;
Expand Down Expand Up @@ -1072,6 +1060,7 @@ construct_runtime!(
// EVM
Ethereum: pallet_ethereum = 11,
EVM: pallet_evm = 12,
// [TODO] Disable the fee evm calculator pallet because we didn't use that
DynamicFee: pallet_dynamic_fee = 13,
BaseFee: pallet_base_fee::{Pallet, Call, Storage, Config<T>, Event} = 14,

Expand Down
15 changes: 2 additions & 13 deletions runtime/peaq-dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,18 +646,6 @@ pub const GAS_PER_SECOND: u64 = 40_000_000;
/// u64 works for approximations because Weight is a very small unit compared to gas.
pub const WEIGHT_PER_GAS: u64 = WEIGHT_REF_TIME_PER_SECOND.saturating_div(GAS_PER_SECOND);

pub struct PeaqGasWeightMapping;
impl pallet_evm::GasWeightMapping for PeaqGasWeightMapping {
fn gas_to_weight(gas: u64, _without_base_weight: bool) -> Weight {
let weight = gas.saturating_mul(WEIGHT_PER_GAS);
Weight::from_parts(weight, 0)
}

fn weight_to_gas(weight: Weight) -> u64 {
weight.ref_time().wrapping_div(WEIGHT_PER_GAS)
}
}

parameter_types! {
pub const EvmChainId: u64 = 9990;
pub BlockGasLimit: U256 = U256::from(
Expand Down Expand Up @@ -686,7 +674,7 @@ parameter_types! {
impl pallet_evm::Config for Runtime {
type FeeCalculator = BaseFee;
type WeightPerGas = WeightPerGas;
type GasWeightMapping = PeaqGasWeightMapping;
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;
type CallOrigin = EnsureAddressTruncated;
type WithdrawOrigin = EnsureAddressTruncated;
Expand Down Expand Up @@ -1086,6 +1074,7 @@ construct_runtime!(
// EVM
Ethereum: pallet_ethereum = 11,
EVM: pallet_evm = 12,
// [TODO] Disable the fee evm calculator pallet because we didn't use that
DynamicFee: pallet_dynamic_fee = 13,
BaseFee: pallet_base_fee::{Pallet, Call, Storage, Config<T>, Event} = 14,

Expand Down
17 changes: 3 additions & 14 deletions runtime/peaq/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,18 +666,6 @@ pub const GAS_PER_SECOND: u64 = 40_000_000;
/// u64 works for approximations because Weight is a very small unit compared to gas.
pub const WEIGHT_PER_GAS: u64 = WEIGHT_REF_TIME_PER_SECOND.saturating_div(GAS_PER_SECOND);

pub struct PeaqGasWeightMapping;
impl pallet_evm::GasWeightMapping for PeaqGasWeightMapping {
fn gas_to_weight(gas: u64, _without_base_weight: bool) -> Weight {
let weight = gas.saturating_mul(WEIGHT_PER_GAS);
Weight::from_parts(weight, 0)
}

fn weight_to_gas(weight: Weight) -> u64 {
weight.ref_time().wrapping_div(WEIGHT_PER_GAS)
}
}

parameter_types! {
pub const EvmChainId: u64 = 3338;
pub BlockGasLimit: U256 = U256::from(
Expand Down Expand Up @@ -728,7 +716,7 @@ impl FeeCalculator for TransactionPaymentAsGasPrice {
impl pallet_evm::Config for Runtime {
type FeeCalculator = TransactionPaymentAsGasPrice;
type WeightPerGas = WeightPerGas;
type GasWeightMapping = PeaqGasWeightMapping;
type GasWeightMapping = pallet_evm::FixedGasWeightMapping<Self>;
type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;
type CallOrigin = EnsureAddressTruncated;
type WithdrawOrigin = EnsureAddressTruncated;
Expand Down Expand Up @@ -1119,6 +1107,7 @@ construct_runtime!(
// EVM
Ethereum: pallet_ethereum = 11,
EVM: pallet_evm = 12,
// [TODO] We should disable the fee evm calculator pallet because we didn't use that anymore
DynamicFee: pallet_dynamic_fee = 13,
BaseFee: pallet_base_fee::{Pallet, Call, Storage, Config<T>, Event} = 14,

Expand Down Expand Up @@ -1762,7 +1751,7 @@ impl_runtime_apis! {
}

fn elasticity() -> Option<Permill> {
Some(pallet_base_fee::Elasticity::<Runtime>::get())
None
}

fn gas_limit_multiplier_support() {}
Expand Down

0 comments on commit 4d36a9f

Please sign in to comment.