Skip to content

Commit

Permalink
Merge pull request #297 from peaqnetwork/feat/1208500128481486_evm_fe…
Browse files Browse the repository at this point in the history
…e_unreachable

WIP: Feat/1208500128481486 evm fee unreachable
  • Loading branch information
sfffaaa authored Oct 14, 2024
2 parents cdabce8 + 7a9cfae commit e8b1509
Show file tree
Hide file tree
Showing 12 changed files with 8 additions and 132 deletions.
21 changes: 0 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ fp-evm = { git = "https://github.com/peaqnetwork/frontier", branch = "peaq-polka
fp-rpc = { git = "https://github.com/peaqnetwork/frontier", branch = "peaq-polkadot-v1.7.2", default-features = false }
fp-self-contained = { git = "https://github.com/peaqnetwork/frontier", branch = "peaq-polkadot-v1.7.2", default-features = false, features = ["serde"] }
pallet-base-fee = { git = "https://github.com/peaqnetwork/frontier", branch = "peaq-polkadot-v1.7.2", default-features = false }
pallet-dynamic-fee = { git = "https://github.com/peaqnetwork/frontier", branch = "peaq-polkadot-v1.7.2", default-features = false }
pallet-ethereum = { git = "https://github.com/peaqnetwork/frontier", branch = "peaq-polkadot-v1.7.2", default-features = false }
pallet-evm = { git = "https://github.com/peaqnetwork/frontier", branch = "peaq-polkadot-v1.7.2", default-features = false }
pallet-evm-precompile-blake2 = { git = "https://github.com/peaqnetwork/frontier", branch = "peaq-polkadot-v1.7.2", default-features = false }
Expand Down
1 change: 0 additions & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ fp-consensus = { workspace = true, default-features = true }
fp-storage = { workspace = true, default-features = true }
fp-rpc = { workspace = true, default-features = true }
pallet-base-fee = { workspace = true, default-features = true }
pallet-dynamic-fee = { workspace = true, default-features = true }
pallet-ethereum = { workspace = true, default-features = true }
pallet-evm = { workspace = true, default-features = true }
tokio = { workspace = true, default-features = true, features = [ "macros", "sync" ] }
Expand Down
1 change: 0 additions & 1 deletion node/src/parachain/dev_chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ fn configure_genesis(
..Default::default()
},
ethereum: EthereumConfig { ..Default::default() },
dynamic_fee: Default::default(),
base_fee: Default::default(),
polkadot_xcm: peaq_dev_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
Expand Down
1 change: 0 additions & 1 deletion node/src/parachain/krest_chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ fn configure_genesis(
..Default::default()
},
ethereum: EthereumConfig { ..Default::default() },
dynamic_fee: Default::default(),
base_fee: Default::default(),
polkadot_xcm: peaq_krest_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
Expand Down
2 changes: 0 additions & 2 deletions node/src/parachain/peaq_chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ fn configure_genesis(
..Default::default()
},
ethereum: EthereumConfig { ..Default::default() },
dynamic_fee: Default::default(),
base_fee: Default::default(),
polkadot_xcm: peaq_runtime::PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
..Default::default()
Expand Down
3 changes: 0 additions & 3 deletions runtime/krest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ fp-evm = { workspace = true, default-features = false }
fp-rpc = { workspace = true, default-features = false }
fp-self-contained = { workspace = true, default-features = false }
pallet-base-fee = { workspace = true, default-features = false }
pallet-dynamic-fee = { workspace = true, default-features = false }
pallet-ethereum = { workspace = true, default-features = false, features = ["forbid-evm-reentrancy"] }
pallet-evm = { workspace = true, default-features = false, features = ["forbid-evm-reentrancy"] }
pallet-evm-precompile-blake2 = { workspace = true, default-features = false }
Expand Down Expand Up @@ -227,7 +226,6 @@ std = [
"fp-evm/std",
"fp-self-contained/std",
"pallet-base-fee/std",
"pallet-dynamic-fee/std",
"pallet-ethereum/std",
"pallet-evm/std",
"pallet-evm-precompile-simple/std",
Expand Down Expand Up @@ -328,7 +326,6 @@ try-runtime = [
"pallet-sudo/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-evm/try-runtime",
"pallet-dynamic-fee/try-runtime",
"pallet-base-fee/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-contracts/try-runtime",
Expand Down
24 changes: 2 additions & 22 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 @@ -713,14 +701,6 @@ impl pallet_ethereum::Config for Runtime {
type ExtraDataLength = ConstU32<30>;
}

frame_support::parameter_types! {
pub BoundDivision: U256 = U256::from(1024);
}

impl pallet_dynamic_fee::Config for Runtime {
type MinGasPriceBoundDivisor = BoundDivision;
}

frame_support::parameter_types! {
pub DefaultBaseFeePerGas: U256 = U256::from(1024);
pub DefaultElasticity: Permill = Permill::zero();
Expand Down Expand Up @@ -1072,7 +1052,7 @@ construct_runtime!(
// EVM
Ethereum: pallet_ethereum = 11,
EVM: pallet_evm = 12,
DynamicFee: pallet_dynamic_fee = 13,
// DynamicFee: pallet_dynamic_fee = 13,
BaseFee: pallet_base_fee::{Pallet, Call, Storage, Config<T>, Event} = 14,

// Parachain
Expand Down
3 changes: 0 additions & 3 deletions runtime/peaq-dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ fp-evm = { workspace = true, default-features = false }
fp-rpc = { workspace = true, default-features = false }
fp-self-contained = { workspace = true, default-features = false }
pallet-base-fee = { workspace = true, default-features = false }
pallet-dynamic-fee = { workspace = true, default-features = false }
pallet-ethereum = { workspace = true, default-features = false, features = ["forbid-evm-reentrancy"] }
pallet-evm = { workspace = true, default-features = false, features = ["forbid-evm-reentrancy"] }
pallet-evm-precompile-blake2 = { workspace = true, default-features = false }
Expand Down Expand Up @@ -229,7 +228,6 @@ std = [
"fp-evm/std",
"fp-self-contained/std",
"pallet-base-fee/std",
"pallet-dynamic-fee/std",
"pallet-ethereum/std",
"pallet-evm/std",
"pallet-evm-precompile-simple/std",
Expand Down Expand Up @@ -330,7 +328,6 @@ try-runtime = [
"pallet-sudo/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-evm/try-runtime",
"pallet-dynamic-fee/try-runtime",
"pallet-base-fee/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-contracts/try-runtime",
Expand Down
24 changes: 2 additions & 22 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 @@ -719,14 +707,6 @@ impl pallet_ethereum::Config for Runtime {
type ExtraDataLength = ConstU32<30>;
}

frame_support::parameter_types! {
pub BoundDivision: U256 = U256::from(1024);
}

impl pallet_dynamic_fee::Config for Runtime {
type MinGasPriceBoundDivisor = BoundDivision;
}

frame_support::parameter_types! {
pub DefaultBaseFeePerGas: U256 = U256::from(1024);
pub DefaultElasticity: Permill = Permill::zero();
Expand Down Expand Up @@ -1086,7 +1066,7 @@ construct_runtime!(
// EVM
Ethereum: pallet_ethereum = 11,
EVM: pallet_evm = 12,
DynamicFee: pallet_dynamic_fee = 13,
// DynamicFee: pallet_dynamic_fee = 13,
BaseFee: pallet_base_fee::{Pallet, Call, Storage, Config<T>, Event} = 14,

// Parachain
Expand Down
6 changes: 0 additions & 6 deletions runtime/peaq/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ sp-io = { workspace = true, default-features = false }
fp-evm = { workspace = true, default-features = false }
fp-rpc = { workspace = true, default-features = false }
fp-self-contained = { workspace = true, default-features = false }
pallet-base-fee = { workspace = true, default-features = false }
pallet-dynamic-fee = { workspace = true, default-features = false }
pallet-ethereum = { workspace = true, default-features = false, features = ["forbid-evm-reentrancy"] }
pallet-evm = { workspace = true, default-features = false, features = ["forbid-evm-reentrancy"] }
pallet-evm-precompile-blake2 = { workspace = true, default-features = false }
Expand Down Expand Up @@ -226,8 +224,6 @@ std = [
"sp-io/std",
"fp-evm/std",
"fp-self-contained/std",
"pallet-base-fee/std",
"pallet-dynamic-fee/std",
"pallet-ethereum/std",
"pallet-evm/std",
"pallet-evm-precompile-simple/std",
Expand Down Expand Up @@ -328,8 +324,6 @@ try-runtime = [
"pallet-sudo/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-evm/try-runtime",
"pallet-dynamic-fee/try-runtime",
"pallet-base-fee/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-contracts/try-runtime",
"pallet-utility/try-runtime",
Expand Down
53 changes: 4 additions & 49 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 @@ -761,39 +749,6 @@ impl pallet_ethereum::Config for Runtime {
type ExtraDataLength = ConstU32<30>;
}

frame_support::parameter_types! {
pub BoundDivision: U256 = U256::from(1024);
}

impl pallet_dynamic_fee::Config for Runtime {
type MinGasPriceBoundDivisor = BoundDivision;
}

frame_support::parameter_types! {
pub DefaultBaseFeePerGas: U256 = U256::from(1024);
pub DefaultElasticity: Permill = Permill::zero();
}

pub struct BaseFeeThreshold;
impl pallet_base_fee::BaseFeeThreshold for BaseFeeThreshold {
fn lower() -> Permill {
Permill::zero()
}
fn ideal() -> Permill {
Permill::from_parts(500_000)
}
fn upper() -> Permill {
Permill::from_parts(1_000_000)
}
}

impl pallet_base_fee::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Threshold = BaseFeeThreshold;
type DefaultBaseFeePerGas = DefaultBaseFeePerGas;
type DefaultElasticity = DefaultElasticity;
}

impl pallet_insecure_randomness_collective_flip::Config for Runtime {}

// Parachain
Expand Down Expand Up @@ -1119,8 +1074,8 @@ construct_runtime!(
// EVM
Ethereum: pallet_ethereum = 11,
EVM: pallet_evm = 12,
DynamicFee: pallet_dynamic_fee = 13,
BaseFee: pallet_base_fee::{Pallet, Call, Storage, Config<T>, Event} = 14,
// DynamicFee: pallet_dynamic_fee = 13,
// BaseFee: pallet_base_fee::{Pallet, Call, Storage, Config<T>, Event} = 14,

// Parachain
InflationManager: inflation_manager::{Pallet, Call, Storage, Config<T>, Event<T>} = 15,
Expand Down Expand Up @@ -1762,7 +1717,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 e8b1509

Please sign in to comment.