-
Notifications
You must be signed in to change notification settings - Fork 683
fix: reject transaction if maxFeePerGas is less than blockBaseFeePerGas of the pending block #2840
Conversation
6f2d2aa
to
940f945
Compare
96d6c7f
to
47d583d
Compare
Can you rebase this on current |
a22238f
to
0d8deaa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So with further testing I discovered that transactions with too small gas price were accepted if the gas limit is specified. I opened an issue with Geth, and they pretty much said it's expected behavior. Here is a summary of how they handle these cases and their reasoning:
Gas Limit | Gas Price | Result | Notes |
---|---|---|---|
Unspecified | Unspecified | No error | Geth chooses a good gas price, then uses that price to estimate gas limit. |
Specified | < baseFeePerGas |
No error | Geth blindly accepts the gas price because the transaction has a gas limit. |
Unspecified | < baseFeePerGas |
Error: maxFeePerGas is less than block base fee. |
Because no gas limit was specified, Geth needs to estimate it. To estimate it, it runs the transaction against the next block. Because the gas price is too low, it's rejected. |
I think the key difference between us and Geth in this case is that our eth_estimateGas
function does not enforce a baseFeePerGas
. This can be seen when we make the RuntimeBlock
in eth_estimateGas
:
const block = new RuntimeBlock(
Quantity.from((parentHeader.number.toBigInt() || 0n) + 1n),
parentHeader.parentHash,
parentHeader.miner,
tx.gas.toBuffer(),
parentHeader.gasUsed.toBuffer(),
parentHeader.timestamp,
options.miner.difficulty,
parentHeader.totalDifficulty,
0n // no baseFeePerGas for estimates
);
So I think rather than this current change, we may just want to pass in the next block's baseFeePerGas
rather than 0n
. Thoughts? @davidmurdoch @jeffsmale90
Upon further inspection, it doesn't look like we call Regardless, the current implementation now rejects the transaction in more cases than Geth. In my eyes, we could:
|
892c68f
to
0e9642f
Compare
…as of the pending block #2176
…as and (higher) next.baseFeePerGas
0d8deaa
to
f044e56
Compare
@MicaiahReid @davidmurdoch I think the best way forward is to discard this change, and consider adding a strict "Geth" mode as @MicaiahReid recommended where we pass the actual next block baseFeePerGas into vm.runTx (instead of 0). What do you guys think? |
@jeffsmale90 I'm on board for that!
@davidmurdoch thoughts? |
@MicaiahReid That sounds like a great plan to me! |
Closing this PR, after following the actions @MicaiahReid listed above. |
Fixes #2176