From cbbf2e97dd313662ac278c9cbc3e3bddd39b9a1a Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Mon, 22 May 2023 08:03:06 +0000 Subject: [PATCH] feat: make ethereum pricing based on reads, not writes --- --- a/primitives/common/src/constants.rs +++ b/primitives/common/src/constants.rs @@ -52,10 +52,10 @@ pub const SESSION_LENGTH: BlockNumber = HOURS; // Targeting 0.1 UNQ per transfer -pub const WEIGHT_TO_FEE_COEFF: u64 = /**/78_254_739_568_813_617/**/; +pub const WEIGHT_TO_FEE_COEFF: u64 = /**/76_840_511_488_584_762/**/; // Targeting 0.15 UNQ per transfer via ETH -pub const MIN_GAS_PRICE: u64 = /**/952_266_075_838/**/; +pub const MIN_GAS_PRICE: u64 = /**/1_906_626_161_453/**/; /// We assume that ~10% of the block weight is consumed by `on_initalize` handlers. /// This is used to limit the maximal weight of a single extrinsic. --- a/runtime/common/config/ethereum.rs +++ b/runtime/common/config/ethereum.rs @@ -20,12 +20,15 @@ pub type CrossAccountId = pallet_evm::account::BasicCrossAccountId; -// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case -// (contract, which only writes a lot of data), -// approximating on top of our real store write weight +// ~~Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case~~ +// ~~(contract, which only writes a lot of data),~~ +// ~~approximating on top of our real store write weight~~ +// +// The above approach is very wrong, and the reason is described there: +// https://forum.polkadot.network/t/frontier-support-for-evm-weight-v2/2470/5#problem-2 parameter_types! { - pub const WritesPerSecond: u64 = WEIGHT_REF_TIME_PER_SECOND / ::DbWeight::get().write; - pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000; + pub const ReadsPerSecond: u64 = WEIGHT_REF_TIME_PER_SECOND / ::DbWeight::get().read; + pub const GasPerSecond: u64 = ReadsPerSecond::get() * 2100; pub const WeightTimePerGas: u64 = WEIGHT_REF_TIME_PER_SECOND / GasPerSecond::get(); pub const WeightPerGas: Weight = Weight::from_parts(WeightTimePerGas::get(), 0); -- gitstuff