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

Fix BSC gas price issues by treating chains with a base fee of 0 as non-1559 #3462

Merged
merged 4 commits into from
Mar 21, 2024

Conversation

tkporter
Copy link
Collaborator

@tkporter tkporter commented Mar 21, 2024

Description

So turns out this is because:

  • BSC nodes tend to enforce a minimum gas price of 3 gwei when you submit a tx
  • it's possible for validators to include privileged txs at a lower gas price, so in practice (probably some mev stuff ?) there are a bunch of txs in blocks with transactions lower than 3 gwei
  • BSC's 1559 situation is they have a base fee of zero, so it's basically like they just use legacy txs
  • when we try to figure out what to pay in prio fees, we are suggested a 1 gwei priority fee:
$ cast rpc eth_feeHistory 10 latest "[5.0]" --rpc-url https://rpc.ankr.com/bsc
{"oldestBlock":"0x23706f7","reward":[["0x3b9aca00"]],"baseFeePerGas":["0x0","0x0"],"gasUsedRatio":[0.1149265]}

$ cast td 0x3b9aca00
1000000000

So options are:

  1. tx overrides for bsc, set it to 3 gwei

  2. use a different eip 1559 estimator and set the percentile used in eth_feeHistory to something higher. Atm the percentile is 5%, if you change this to 50% we seem to get 3 gwei. This would have consequences for other chains tho

  3. another heuristic, to fall back to legacy txs (where we can trust the eth_gasPrice to give us an accurate price) whenever the base fee is 0

I'm a tx override hater and we don't have this in the agents so far so I'm gonna go with 3. It's the least intrusive change

Copy link

changeset-bot bot commented Mar 21, 2024

⚠️ No Changeset found

Latest commit: ebcd4c7

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.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

Copy link

codecov bot commented Mar 21, 2024

Codecov Report

Merging #3462 (ebcd4c7) into main (59e89af) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #3462   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files          1       1           
  Lines         16      16           
=====================================
  Misses        16      16           
Components Coverage Δ
core ∅ <ø> (∅)
hooks ∅ <ø> (∅)
isms ∅ <ø> (∅)
token ∅ <ø> (∅)
middlewares ∅ <ø> (∅)

@tkporter tkporter changed the title BSC gas price issues Fix BSC gas price issues by treating chains with a base fee of 0 as non-1559 Mar 21, 2024
@tkporter tkporter marked this pull request as ready for review March 21, 2024 11:58
@tkporter tkporter merged commit 176e710 into main Mar 21, 2024
36 of 38 checks passed
@tkporter tkporter deleted the trevor/fix-bsc-gas-price branch March 21, 2024 13:50
tkporter added a commit that referenced this pull request Mar 21, 2024
### Description

- Fixes #3396 
- Backport of #3462
yorhodes pushed a commit that referenced this pull request Mar 22, 2024
…on-1559 (#3462)

### Description

- Fixes #3396 
- See v2 backport here #3463 

So turns out this is because:
- BSC nodes tend to enforce a minimum gas price of 3 gwei when you
submit a tx
- it's possible for validators to include privileged txs at a lower gas
price, so in practice (probably some mev stuff ?) there are a bunch of
txs in blocks with transactions lower than 3 gwei
- BSC's 1559 situation is they have a base fee of zero, so it's
basically like they just use legacy txs
- when we try to figure out what to pay in prio fees, we are suggested a
1 gwei priority fee:
```
$ cast rpc eth_feeHistory 10 latest "[5.0]" --rpc-url https://rpc.ankr.com/bsc
{"oldestBlock":"0x23706f7","reward":[["0x3b9aca00"]],"baseFeePerGas":["0x0","0x0"],"gasUsedRatio":[0.1149265]}

$ cast td 0x3b9aca00
1000000000
```

So options are:
1. tx overrides for bsc, set it to 3 gwei

2. use a different eip 1559 estimator and set the percentile used in
eth_feeHistory to something higher. Atm the percentile is 5%, if you
change this to 50% we seem to get 3 gwei. This would have consequences
for other chains tho

3. another heuristic, to fall back to legacy txs (where we can trust the
eth_gasPrice to give us an accurate price) whenever the base fee is 0


I'm a tx override hater and we don't have this in the agents so far so
I'm gonna go with 3. It's the least intrusive change
daniel-savu pushed a commit that referenced this pull request Jun 5, 2024
### Description

- Fixes #3396 
- Backport of #3462
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
2 participants