Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anvil: problems with estimate gas - max fee per gas less than block base fee #7769

Closed
2 tasks done
clarkohw opened this issue Apr 23, 2024 · 5 comments · Fixed by #7792
Closed
2 tasks done

anvil: problems with estimate gas - max fee per gas less than block base fee #7769

clarkohw opened this issue Apr 23, 2024 · 5 comments · Fixed by #7792
Labels
T-bug Type: bug

Comments

@clarkohw
Copy link

clarkohw commented Apr 23, 2024

Component

Anvil

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

nightly-008922d5165c764859bc540d7298045eebf5bc60

What command(s) is the bug in?

anvil

Operating System

macOS (Apple Silicon) / Linux (x86)

Describe the bug

I'm aware of #7638 and the corresponding issues. I have a very similar problem, but when interacting with anvil. We use hardhat to manage contract deployment + sending txs. We use anvil as a drop in replacement for the hardhat node. this worked up until nightly-460319558e455611be1de64be8364c65c6896d15 (as mentioned in #7620). the hardhat code also works with deployed evm chains (ie Arbitrum), therefore I think that recent anvil change has made eth_estimateGas lose parity w/ deployed chains.

Perhaps: #7515

This is the error message i get from hardhat:

ProviderError: max fee per gas less than block base fee

my current fix is using an older anvil version: nightly-2cb875799419c907cc3709e586ece2559e6b340e

@clarkohw clarkohw added the T-bug Type: bug label Apr 23, 2024
@klkvr
Copy link
Member

klkvr commented Apr 23, 2024

just confirming that you are hitting max fee per gas less than block base fee while calling eth_estimateGas on anvil? or it is happening when sending transactions?

@clarkohw
Copy link
Author

clarkohw commented Apr 24, 2024

@klkvr It happens when i try to send a transaction. I looked around in the code and found that it is due to some automatic gas config that hardhat is taking care of. the source of the difference is in the eth_feeHistory method. Hardhat uses this to calculate the maxFeePerGas value to set. For the following request, i get different results for different versions
cast rpc eth_feeHistory 0x1 latest

On nightly-2cb875799419c907cc3709e586ece2559e6b340e (working for me):
{"gasUsedRatio":[],"oldestBlock":"0x0","reward":[]}

On the most recent version:
{"baseFeePerGas":["0x3b9aca00","0x1dcd6500"],"gasUsedRatio":[0.0],"oldestBlock":"0x0","reward":[]}

In the most recent version, i think its a little odd that there are two entries returned, when no blocks have been mined on the node, but this seems to be the source of the issue. Not sure if this is intended behavior or not.

it seems to be fixed in the most recent version of hardhat, which I can't upgrade to at the moment, but given that other issues in other places arose around the same time (previously mentioned issues), i'm wondering if its intended.

@klkvr
Copy link
Member

klkvr commented Apr 24, 2024

Fee history contains items for genesis block and for the next block (pending) which is correct I believe, not sure why exactly such response makes hardhat to produce an invalid transaction

@clarkohw
Copy link
Author

I see thanks for the explanation. That makes sense, but is it a little odd that the next block value: 0x1dcd6500 is 500,000,000 when the node base fee is 1,000,000,000?

@Liberalite
Copy link

Thanks you clarkohw for providing a working anvil version:
nightly-2cb875799419c907cc3709e586ece2559e6b340e

Installed Foundry today to simulate forking combined with a hardhat environment and was getting the same error for the second contract that was deployed, the first contract deployment always works:
ProviderError: max fee per gas less than block base fee

Using this command worked:
foundryup -v nightly-2cb875799419c907cc3709e586ece2559e6b340e

I don't really think that it matter, but just for reference i'm using:
Macbook M2 Pro with latest Sonoma MacOS updates!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants