difftreelog
feat make ethereum pricing based on reads, not writes
in: master
2 files changed
primitives/common/src/constants.rsdiffbeforeafterboth52pub const SESSION_LENGTH: BlockNumber = HOURS;52pub const SESSION_LENGTH: BlockNumber = HOURS;535354// Targeting 0.1 UNQ per transfer54// Targeting 0.1 UNQ per transfer55pub const WEIGHT_TO_FEE_COEFF: u64 = /*<weight2fee>*/78_254_739_568_813_617/*</weight2fee>*/;55pub const WEIGHT_TO_FEE_COEFF: u64 = /*<weight2fee>*/76_840_511_488_584_762/*</weight2fee>*/;565657// Targeting 0.15 UNQ per transfer via ETH57// Targeting 0.15 UNQ per transfer via ETH58pub const MIN_GAS_PRICE: u64 = /*<mingasprice>*/952_266_075_838/*</mingasprice>*/;58pub const MIN_GAS_PRICE: u64 = /*<mingasprice>*/1_906_626_161_453/*</mingasprice>*/;595960/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.60/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.61/// This is used to limit the maximal weight of a single extrinsic.61/// This is used to limit the maximal weight of a single extrinsic.runtime/common/config/ethereum.rsdiffbeforeafterboth--- a/runtime/common/config/ethereum.rs
+++ b/runtime/common/config/ethereum.rs
@@ -20,12 +20,15 @@
pub type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;
-// 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 / <Runtime as frame_system::Config>::DbWeight::get().write;
- pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;
+ pub const ReadsPerSecond: u64 = WEIGHT_REF_TIME_PER_SECOND / <Runtime as frame_system::Config>::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);