`gasPrice` stuck on `8 WEI`.
Closed this issue · 3 comments
When starting a new chain using the frontier-node-template
I see that the gasPrice
starts to decrease (as expected).
If I start sending txns to the node right at the beginning of block production, the gasPrice
starts to increase (as expected).
Block: 001 | txns: 0000 | gasUsed: 00000000 | gasPrice: 875205000
Block: 002 | txns: 0000 | gasUsed: 00000000 | gasPrice: 765983793
Block: 003 | txns: 0001 | gasUsed: 00874371 | gasPrice: 672067287
Block: 004 | txns: 0001 | gasUsed: 00058324 | gasPrice: 588241007
Block: 005 | txns: 0100 | gasUsed: 06209005 | gasPrice: 522696253
Block: 006 | txns: 0100 | gasUsed: 02100000 | gasPrice: 460210530
Block: 007 | txns: 0000 | gasUsed: 00000000 | gasPrice: 402778557 <--- Started sending the txns with fixed gasPrice (1B)
Block: 008 | txns: 1198 | gasUsed: 74819892 | gasPrice: 427857563
Block: 009 | txns: 1198 | gasUsed: 74819892 | gasPrice: 452630088
Block: 010 | txns: 1198 | gasUsed: 74819892 | gasPrice: 477628847
Block: 011 | txns: 1198 | gasUsed: 74819892 | gasPrice: 504798286
Block: 012 | txns: 1198 | gasUsed: 74819892 | gasPrice: 533699502
Block: 013 | txns: 1198 | gasUsed: 74819892 | gasPrice: 562143550
Block: 014 | txns: 1198 | gasUsed: 74819892 | gasPrice: 592673566
Block: 015 | txns: 1198 | gasUsed: 74819892 | gasPrice: 625134889
Block: 016 | txns: 1198 | gasUsed: 74819892 | gasPrice: 659661714
Block: 017 | txns: 1198 | gasUsed: 74819892 | gasPrice: 696761088
Block: 018 | txns: 1198 | gasUsed: 74819892 | gasPrice: 738062298
Block: 019 | txns: 1198 | gasUsed: 74819892 | gasPrice: 781135613
Block: 020 | txns: 1198 | gasUsed: 74819892 | gasPrice: 824134003
Block: 021 | txns: 1198 | gasUsed: 74819892 | gasPrice: 873064487
Block: 022 | txns: 1198 | gasUsed: 74819892 | gasPrice: 927230280
Block: 023 | txns: 1198 | gasUsed: 74819892 | gasPrice: 984074132
Block: 024 | txns: 1198 | gasUsed: 74819892 | gasPrice: 1042500581
Block: 025 | txns: 1198 | gasUsed: 74819892 | gasPrice: 1107369137
But if I wait until the gasPrice
reaches its lowest value (8 WEI
) and then start sending the same txns, I see that it stays forever at that value:
Block: 001 | txns: 0000 | gasUsed: 00000000 | gasPrice: 875205000
Block: 002 | txns: 0000 | gasUsed: 00000000 | gasPrice: 765983793
Block: 003 | txns: 0001 | gasUsed: 00874371 | gasPrice: 672067287
Block: 004 | txns: 0001 | gasUsed: 00058324 | gasPrice: 588294772
Block: 005 | txns: 0100 | gasUsed: 06209005 | gasPrice: 524010626
Block: 006 | txns: 0100 | gasUsed: 02100000 | gasPrice: 461367776
Block: 007 | txns: 0000 | gasUsed: 00000000 | gasPrice: 403791385
Block: 008 | txns: 0000 | gasUsed: 00000000 | gasPrice: 353400240
Block: 009 | txns: 0000 | gasUsed: 00000000 | gasPrice: 309297658
Block: 010 | txns: 0000 | gasUsed: 00000000 | gasPrice: 270698857
...
Block: 135 | txns: 0000 | gasUsed: 00000000 | gasPrice: 20
Block: 136 | txns: 0000 | gasUsed: 00000000 | gasPrice: 18
Block: 137 | txns: 0000 | gasUsed: 00000000 | gasPrice: 16
Block: 138 | txns: 0000 | gasUsed: 00000000 | gasPrice: 15
Block: 139 | txns: 0000 | gasUsed: 00000000 | gasPrice: 14
Block: 140 | txns: 0000 | gasUsed: 00000000 | gasPrice: 13
Block: 141 | txns: 0000 | gasUsed: 00000000 | gasPrice: 12
Block: 142 | txns: 0000 | gasUsed: 00000000 | gasPrice: 11
Block: 143 | txns: 0000 | gasUsed: 00000000 | gasPrice: 10
Block: 144 | txns: 0000 | gasUsed: 00000000 | gasPrice: 9
Block: 145 | txns: 0000 | gasUsed: 00000000 | gasPrice: 8 <--- Started sending the txns with fixed gasPrice (1B)
Block: 146 | txns: 1198 | gasUsed: 74819892 | gasPrice: 8
Block: 147 | txns: 1198 | gasUsed: 74819892 | gasPrice: 8
Block: 148 | txns: 1198 | gasUsed: 74819892 | gasPrice: 8
Block: 149 | txns: 1198 | gasUsed: 74819892 | gasPrice: 8
Block: 150 | txns: 1198 | gasUsed: 74819892 | gasPrice: 8
Block: 151 | txns: 1198 | gasUsed: 74819892 | gasPrice: 8
Block: 152 | txns: 1198 | gasUsed: 74819892 | gasPrice: 8
Block: 153 | txns: 1198 | gasUsed: 74819892 | gasPrice: 8
Block: 154 | txns: 1198 | gasUsed: 74819892 | gasPrice: 8
Block: 155 | txns: 1198 | gasUsed: 74819892 | gasPrice: 8
Block: 156 | txns: 1198 | gasUsed: 74819892 | gasPrice: 8
Block: 157 | txns: 1198 | gasUsed: 74819892 | gasPrice: 8
Block: 158 | txns: 1198 | gasUsed: 74819892 | gasPrice: 8
Block: 159 | txns: 1198 | gasUsed: 74819892 | gasPrice: 8
Block: 160 | txns: 1198 | gasUsed: 74819892 | gasPrice: 8
...
I think I had this issue half a year ago. I remember the reason for this is the current base-fee
's flaw, it doesn't involves a lowest gas_price design, the gas_price goes to near zero when producing a consistent empty block. I don't know if there are other projects that use this FeeCalculator
in the production, it's not perfect now.
Hey @boundless-forest, thanks for the reply.
What I've done so far was to be sure that we increase/decrease at leas 1
from the current base_fee at base-fee/src/lib.rs#L152-L184, eg:
let mut increase = scaled_basefee
.checked_div(U256::from(1_000_000))
.unwrap_or_else(U256::zero);
if increase.is_zero() {
increase = U256::one();
}
*bf = bf.saturating_add(increase);
With that the gas_price
will increase, ofc, but it will takes a lot of blocks to get back to a sustainable value.
I think that it would be better to set a lowest gas_price
there, like you said.
Setting it to T::DefaultBaseFeePerGas::get()
. Does that make sense?
Another odd thing is that we have the following code comment at base-fee/src/lib.rs#L160:
// Normalize to GWEI.
But then we get a .checked_div(U256::from(1_000_000))
, shouldn't it be .checked_div(U256::from(1_000_000_000))
there?
Fixed by #1115