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

feat: eip-1559 fixed gas prices #2398

Merged
merged 1 commit into from
Aug 24, 2023
Merged

feat: eip-1559 fixed gas prices #2398

merged 1 commit into from
Aug 24, 2023

Conversation

schmanu
Copy link
Member

@schmanu schmanu commented Aug 15, 2023

What it solves

This PR fixes the usage of chain gas configs in general and adds a new fixed gas config.
Resolves #2222

How this PR fixes it

Enabled fixed gas prices for EIP-1559

How to test it

Fixed 1559 gas prices
We added Optimism with the desired gas price config to staging and enabled 1559 there.

  1. Create any tx on optimism staging
  2. Go to execute modal
  3. Expand the gas price details
  4. Observe 0.1 for maxFeePerGas and 0.0001 for maxPriorityFeePerGas
  5. Execute
  6. Observe same values in i.e. connected metamask

Bug fix: Use gas price configs
This PR also fixed our gas estimations in general which never considered the gas price configs from our config service before.
To test this try to create transactions on networks with specific gas price configs:

  • Gas price oracles
    • Mainnet
    • Polygon
  • Fixed
    • Görli

Screenshots

The screenshot shows the desired fixed gas price of 0.1 maxFee and 0.0001 maxPrio on Optimism.
Screenshot 2023-08-15 at 10 35 36

Checklist

  • I've tested the branch on mobile 📱
  • I've documented how it affects the analytics (if at all) 📊
  • I've written a unit/e2e test for it (if applicable) 🧑‍💻

Fixes the evaluation of the chain's gas configs
@github-actions
Copy link

github-actions bot commented Aug 15, 2023

Branch preview

✅ Deploy successful!

https://feat_fixed_1559_gasprice--walletweb.review-wallet-web.5afe.dev

@github-actions
Copy link

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

Comment on lines +188 to +198
await act(async () => {
await Promise.resolve()
})
// assert the hook is not loading
expect(result.current[2]).toBe(false)

// assert fixed gas price as minimum of 0.1 gwei
expect(result.current[0]?.maxFeePerGas?.toString()).toBe('100000000')

// assert fixed priority fee
expect(result.current[0]?.maxPriorityFeePerGas?.toString()).toBe('100000')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: You can also wrap all the expects with an await waitFor() call instead of having an empty Promise.resolve() to achieve the same

Comment on lines +99 to +126
const getGasParameters = (
estimation: EstimatedGasPrice | undefined,
feeData: FeeData | undefined,
isEIP1559: boolean,
): GasFeeParams => {
if (!estimation) {
return {
maxFeePerGas: isEIP1559 ? feeData?.maxFeePerGas : feeData?.gasPrice,
maxPriorityFeePerGas: isEIP1559 ? feeData?.maxPriorityFeePerGas : undefined,
}
}

if (isEIP1559 && 'maxFeePerGas' in estimation && 'maxPriorityFeePerGas' in estimation) {
return estimation
}

if ('gasPrice' in estimation) {
return {
maxFeePerGas: estimation.gasPrice,
maxPriorityFeePerGas: isEIP1559 ? feeData?.maxPriorityFeePerGas : undefined,
}
}

return {
maxFeePerGas: undefined,
maxPriorityFeePerGas: undefined,
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks more readable now but I would suggest to write a few tests to cover some of the edge-cases like if there is no estimation and it is EIP1559 but there is also no feeData etc.

@francovenica
Copy link
Contributor

For goerli I think 200 is waaay to high. Not a big deal since goerli is a test network, but I think we can reduce it to 50 or so:
here in MM estimates that "Aggressive" should be " 2 ".
gas fee

@francovenica
Copy link
Contributor

Tried send funds for ETH and Poly and Add owner for Optimism

In optimism the values are set to 0.1 for maxFeePerGas and 0.0001 for maxPriorityFeePerGas and the tx works fine. These values were suggested by the people on optimism just fine
image

For ETH the tx worked fine, the values passed to MM are correct
image

For Poly we is also working fine, takes about 2 or so mins for the tx to go through tho. We are estimating a value that is slower than the "Slow" MM estimation, so we should monitor the user experience after releasing this.
image

NOTE: we seen with Manu and Usame that in Poly MM is using the same number of Prio Fee and uses it into Max base fee as well. It seems is the way it works for poly and it is how it works in Prod currently, so not an issue, but still leaving it here for the
record

Since executing the tx works, and the only "issue" that I had was goerli way overestimating the gasprice I'm fine passing this ticket.

@schmanu
Copy link
Member Author

schmanu commented Aug 24, 2023

Hey @francovenica
To me this is fine.
If we get user complaints about too slow transactions on polygon, we can just remove the gas oracle config which will fallback to the behavior as it was before.
Same for Görli. We should just remove the too high fixed value which will lead to the previous behavior.

@francovenica
Copy link
Contributor

Passing it then. thanks for the comment

@schmanu schmanu merged commit 370635d into dev Aug 24, 2023
7 checks passed
@schmanu schmanu deleted the feat/fixed-1559-gasprice branch August 24, 2023 14:59
@github-actions github-actions bot locked and limited conversation to collaborators Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EIP-1559 is not enabled on Optimism and gas price estimation is leading to stuck txs
3 participants