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

set fees to zero for zero base fee chains (e.g. anvil) #963

Closed
wants to merge 2 commits into from

Conversation

holic
Copy link
Contributor

@holic holic commented Aug 1, 2023

We use anvil locally with --block-base-fee-per-gas 0, because we often create arbitrary burner accounts and don't want to do all the plumbing to fund new accounts per local instance.

However, viem isn't accounting for this in its fee calculation, always sending 1.5 gwei unless you 1) fund the account or 2) manually set each transaction call to { maxFeePerGas: 0n, maxPriorityFeePerGas: 0n }.

We'd like to avoid the former, and the latter would leave us with wrapping viem or our own contract abstraction or something, but would be nice to keep to plain ol' viem.

See related issues that were fixed in foundry/anvil:


PR-Codex overview

This PR focuses on implementing EIP-1559 fees and handling zero base fee.

Detailed summary:

  • Added logic to set fees to zero when running with zero base fee.
  • Implemented a buffer of 1.2x on top of the base fee to account for fluctuations.
  • Added tests for zero base fee and legacy fees.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@changeset-bot
Copy link

changeset-bot bot commented Aug 1, 2023

⚠️ No Changeset found

Latest commit: 0787ace

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Aug 1, 2023

@holic is attempting to deploy a commit to the wagmi Team on Vercel.

A member of the Team first needs to authorize it.

@holic
Copy link
Contributor Author

holic commented Aug 1, 2023

I tried to add a test for this but calling setNextBlockBaseFeePerGas to 0n doesn't seem to be doing what I expect?

image

@jxom
Copy link
Member

jxom commented Aug 9, 2023

Closing in favor of #1006

@jxom jxom closed this Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants