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 rpc gas strategy #3065

Merged
merged 3 commits into from Jul 26, 2023
Merged

Fix rpc gas strategy #3065

merged 3 commits into from Jul 26, 2023

Conversation

fselmo
Copy link
Collaborator

@fselmo fselmo commented Jul 26, 2023

What was wrong?

  • rpc_gas_price_strategy incorrectly returns the hex value without convesion to int even though the defined return type is Wei.
  • We don't have tests to catch this
  • bonus: Let's also not assume the value will always be an int and only convert to hex if it is an int in the gas_price_strategy_middleware.

How was it fixed?

  • In the rpc_gas_price_strategy, use the eth module gas_price call which always returns an int, rather than request_blocking which can be variable depending on the provider.
  • Convert gasPrice value from strategy to hex only if it's an int
  • Add tests that would've failed before this change. The reason here is we only test on EthereumTesterProvider (core test suite)... but eth-tester already returns an int, even though most providers return the hex value.

Todo:

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

- All gas_price_strategy implementations expect to return Wei, but some return the hex value without result formatting to int
- Catch a known case / bug where this happens and make sure to convert appropriately when building the transaction params
@fselmo fselmo marked this pull request as ready for review July 26, 2023 17:12
@fselmo fselmo requested review from kclowes, reedsa and pacrob July 26, 2023 17:13
Copy link
Collaborator

@kclowes kclowes left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

@fselmo fselmo merged commit ecb19cb into ethereum:main Jul 26, 2023
84 checks passed
@fselmo fselmo deleted the fix-rpc-gas-strategy branch July 26, 2023 17:51
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.

None yet

2 participants