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

Better estimating of proposer gas price and gas limit #671

Merged
merged 2 commits into from
May 25, 2022

Conversation

Westlad
Copy link
Contributor

@Westlad Westlad commented May 19, 2022

fixes #666

The proposer uses the nf3 class to submit transactions. The way that this set the gasPrice and gasLimit was quite crude and results in the proposer paying over the odds for gas and using such a high gas limit that there is not enough in the proposer's account to submit the transaction. This PR fixes that and gives much better values for both. The strategy used is essentially the same as for the wallet.

For gasPrice:

  • it uses Etherescan to get an average value for the last several block. If that fails...
  • it uses web3js to find the gasPrice for the previous block, If that fails...
  • it uses a fixed value (set at 100 GWei, currently).
    In each case, the resulting figure is multiplied by a fixed multiplier (GAS_PRICE_MULTIPLIER) to give high confidence of a successful transaction.

For gasLimit:

  • it uses web3.estimate gas. If that fails (it often does)...
  • it uses a fixed value (set at 4MGas).
    In each case, the resulting figure is multiplied by a fixed multiplier (GAS_MULTIPLIER) to give high confidence of a successful transaction.

To test. Use the standard npm t test but temporarily edit the test script in package.json so that LOG_LEVEL=debug. You can then see the gas price and gas limit chosen, as the test proceeds.

@druiz0992 druiz0992 self-requested a review May 25, 2022 09:22
@druiz0992 druiz0992 merged commit 5f8b165 into master May 25, 2022
@druiz0992 druiz0992 deleted the westlad/proposer-gas branch May 25, 2022 09:23
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.

Improve proposer gas estimation
3 participants