From 4d36a9f501d4f1042806a7d9544b2b379d3ffa20 Mon Sep 17 00:00:00 2001 From: jaypan Date: Tue, 8 Oct 2024 16:11:08 +0200 Subject: [PATCH] Use default GasWeightMapping --- runtime/krest/src/lib.rs | 15 ++------------- runtime/peaq-dev/src/lib.rs | 15 ++------------- runtime/peaq/src/lib.rs | 17 +++-------------- 3 files changed, 7 insertions(+), 40 deletions(-) diff --git a/runtime/krest/src/lib.rs b/runtime/krest/src/lib.rs index 25bfae7f..be104ec5 100644 --- a/runtime/krest/src/lib.rs +++ b/runtime/krest/src/lib.rs @@ -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( @@ -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; type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping; type CallOrigin = EnsureAddressTruncated; type WithdrawOrigin = EnsureAddressTruncated; @@ -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, Event} = 14, diff --git a/runtime/peaq-dev/src/lib.rs b/runtime/peaq-dev/src/lib.rs index 0b015f37..0756edd1 100644 --- a/runtime/peaq-dev/src/lib.rs +++ b/runtime/peaq-dev/src/lib.rs @@ -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( @@ -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; type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping; type CallOrigin = EnsureAddressTruncated; type WithdrawOrigin = EnsureAddressTruncated; @@ -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, Event} = 14, diff --git a/runtime/peaq/src/lib.rs b/runtime/peaq/src/lib.rs index 67ceb90e..84f057cb 100644 --- a/runtime/peaq/src/lib.rs +++ b/runtime/peaq/src/lib.rs @@ -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( @@ -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; type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping; type CallOrigin = EnsureAddressTruncated; type WithdrawOrigin = EnsureAddressTruncated; @@ -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, Event} = 14, @@ -1762,7 +1751,7 @@ impl_runtime_apis! { } fn elasticity() -> Option { - Some(pallet_base_fee::Elasticity::::get()) + None } fn gas_limit_multiplier_support() {}