git.delta.rocks / unique-network / refs/commits / cbbf2e97dd31

difftreelog

feat make ethereum pricing based on reads, not writes

Yaroslav Bolyukin2023-05-22parent: #b12d771.patch.diff
in: master

2 files changed

modifiedprimitives/common/src/constants.rsdiffbeforeafterboth
52pub const SESSION_LENGTH: BlockNumber = HOURS;52pub const SESSION_LENGTH: BlockNumber = HOURS;
5353
54// Targeting 0.1 UNQ per transfer54// Targeting 0.1 UNQ per transfer
55pub 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>*/;
5656
57// Targeting 0.15 UNQ per transfer via ETH57// Targeting 0.15 UNQ per transfer via ETH
58pub const MIN_GAS_PRICE: u64 = /*<mingasprice>*/952_266_075_838/*</mingasprice>*/;58pub const MIN_GAS_PRICE: u64 = /*<mingasprice>*/1_906_626_161_453/*</mingasprice>*/;
5959
60/// 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.
modifiedruntime/common/config/ethereum.rsdiffbeforeafterboth
2020
21pub type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;21pub type CrossAccountId = pallet_evm::account::BasicCrossAccountId<Runtime>;
2222
23// Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case23// ~~Assuming slowest ethereum opcode is SSTORE, with gas price of 20000 as our worst case~~
24// (contract, which only writes a lot of data),24// ~~(contract, which only writes a lot of data),~~
25// approximating on top of our real store write weight25// ~~approximating on top of our real store write weight~~
26//
27// The above approach is very wrong, and the reason is described there:
28// https://forum.polkadot.network/t/frontier-support-for-evm-weight-v2/2470/5#problem-2
26parameter_types! {29parameter_types! {
27 pub const WritesPerSecond: u64 = WEIGHT_REF_TIME_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().write;30 pub const ReadsPerSecond: u64 = WEIGHT_REF_TIME_PER_SECOND / <Runtime as frame_system::Config>::DbWeight::get().read;
28 pub const GasPerSecond: u64 = WritesPerSecond::get() * 20000;31 pub const GasPerSecond: u64 = ReadsPerSecond::get() * 2100;
29 pub const WeightTimePerGas: u64 = WEIGHT_REF_TIME_PER_SECOND / GasPerSecond::get();32 pub const WeightTimePerGas: u64 = WEIGHT_REF_TIME_PER_SECOND / GasPerSecond::get();
3033
31 pub const WeightPerGas: Weight = Weight::from_parts(WeightTimePerGas::get(), 0);34 pub const WeightPerGas: Weight = Weight::from_parts(WeightTimePerGas::get(), 0);