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

Fixed the gas estimation tutorial not working on arbitrum goerli #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BarneyChambers
Copy link

@BarneyChambers BarneyChambers commented Dec 11, 2023

This pull request addresses a gas estimation issue on the Arbitrum Goerli testnet. The core problem stemmed from the fact that Arbitrum Goerli does not settle its transactions on Layer 1 (L1), leading to a division by zero error in gas estimation.

Changes

  • Added a check to see if the amount of L1 gas cost to send the tx is zero, if so it avoid a division by zero error. The code now accurately estimates gas on the mainnet and arbitrum testnets

// If the L1 price is 0, we set the size to 0
l1Size = 0;
}else{
l1Size = l1Cost.div(l1EstimatedPrice).add(140);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the 140 bytes are already factored in at this point and you don't need to add them. L1 cost has the full cost of the L1 component, including the 140 extra bytes.

let l1Size;
if(l1EstimatedPrice.eq(0)) {
// If the L1 price is 0, we set the size to 0
l1Size = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you cast this as a BigNumber to keep consistency between both sides of the condition?

Copy link
Contributor

@TucksonDev TucksonDev left a comment

Choose a reason for hiding this comment

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

Thanks very much @BarneyChambers , this is a great catch!
I added two minor comments.

What I think is happening here is that even though Arbitrum Goerli settles to Ethereum Goerli (L1), sometimes the L1 estimated price is so small that it is rounded to 0. During Dec 8th and Dec 9th, for example, there was a gas dip where the base fee was just a few wei (not gwei).

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