Skip to content

l2geth: gas related API changes#661

Closed
tynes wants to merge 5 commits intomasterfrom
geth/eth-gas
Closed

l2geth: gas related API changes#661
tynes wants to merge 5 commits intomasterfrom
geth/eth-gas

Conversation

@tynes
Copy link
Copy Markdown
Contributor

@tynes tynes commented Apr 27, 2021

Description

  • update eth_estimateGas to have a min gas value that is returned. This is due to Metamask failing for transactions when the gas limit is less than 21000.
  • remove check for transaction gasLimit being greater than the block gas limit

@K-Ho

Closes #608
Closes #607

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 27, 2021

🦋 Changeset detected

Latest commit: 35f5526

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@eth-optimism/integration-tests Patch
@eth-optimism/l2geth Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@tynes tynes requested review from K-Ho and gakonst April 28, 2021 20:50
@tynes tynes added A-geth C-feature Category: features labels Apr 28, 2021
@tynes
Copy link
Copy Markdown
Contributor Author

tynes commented Apr 28, 2021

Note: we charge the entire tx fee up front and do not give refunds like how L1 normally does so this means that there is a floor for how expensive transactions are. I think that breaking up the sequencer entrypoint into multiple steps would fix some problems here

Copy link
Copy Markdown
Contributor

@karlfloersch karlfloersch left a comment

Choose a reason for hiding this comment

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

Left a quick comment on removing the gas limit check. Other than that looks good!

// Prevent transactions from being submitted if the gas limit too high
if signedTx.Gas() >= b.gasLimit {
return fmt.Errorf("Transaction gasLimit (%d) is greater than max gasLimit (%d)", signedTx.Gas(), b.gasLimit)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could be a good idea that we don't remove this check entirely, but instead just replace it with a call to DoEstimateGas + a ~50% safety margin. That way we don't end up with a tx that is way incorrectly priced

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm open if you don't think this is worth the complexity

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1 on this idea

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If we add this before the execution price goes into the state and the sequencer changes the values then this will brick a lot things and will require manual gasLimits to be set

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There is currently a bug in the gas estimation logic that is unknown. The only way that this would be safe is ignore the case when there is an error, otherwise a set of transactions will not be able to be sent

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think we should follow up with this addition after we figure out the bug in gas estimation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've opened up an issue here: #694

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok I'm down to do this! Let's make sure to prioritize the follow up though

fee := core.CalculateRollupFee(*args.Data, uint64(gasUsed), dataPrice, executionPrice).Uint64() / defaultGasPrice
if fee < 21000 {
fee = 21000
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note that we probably should set the default gasPrice to 0.1 gwei considering our minimum gas limit has to be 21k. At 21k the minimum fee would end up being 0.000021 ETH which is just a little too high

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agree with this, just a matter of changing the value of defaultGasPrice

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've updated the defaultGasPrice to be 0.1 gwei

// Prevent transactions from being submitted if the gas limit too high
if signedTx.Gas() >= b.gasLimit {
return fmt.Errorf("Transaction gasLimit (%d) is greater than max gasLimit (%d)", signedTx.Gas(), b.gasLimit)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1 on this idea

Comment on lines -38 to -40
if err.Error() != fmt.Sprintf("Transaction gasLimit (%d) is greater than max gasLimit (%d)", gasLimit, backend.GasLimit()) {
t.Fatalf("Unexpected error type: %s", err)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Given the suggestion above, I think this test could/should be revived and test the condition that the transaction being submitted is within the gas estimation limit.

fee := core.CalculateRollupFee(*args.Data, uint64(gasUsed), dataPrice, executionPrice).Uint64() / defaultGasPrice
if fee < 21000 {
fee = 21000
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agree with this, just a matter of changing the value of defaultGasPrice

@tynes
Copy link
Copy Markdown
Contributor Author

tynes commented Apr 29, 2021

The integration tests are breaking due to the defaultGasPrice changing

Copy link
Copy Markdown
Contributor

@karlfloersch karlfloersch left a comment

Choose a reason for hiding this comment

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

LGTM!

// Prevent transactions from being submitted if the gas limit too high
if signedTx.Gas() >= b.gasLimit {
return fmt.Errorf("Transaction gasLimit (%d) is greater than max gasLimit (%d)", signedTx.Gas(), b.gasLimit)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok I'm down to do this! Let's make sure to prioritize the follow up though

@tynes tynes mentioned this pull request Apr 29, 2021
@tynes
Copy link
Copy Markdown
Contributor Author

tynes commented Apr 29, 2021

Closing in favor of #695

@tynes tynes closed this Apr 29, 2021
@tynes tynes deleted the geth/eth-gas branch April 29, 2021 21:57
OptimismBot pushed a commit that referenced this pull request Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-feature Category: features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

estimateGas can return under 21000 Cannot send a tx with a gasLimit over 9m

3 participants