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

ethapi: add block override to estimateGas #30695

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

antonydenyer
Copy link

Add block overrides to eth_estimateGas to align consistency with eth_call

#27800 (comment)

Fixes #28175

accounts/abi/abi.go Outdated Show resolved Hide resolved
Chain: NewChainContext(ctx, b),
Header: header,
Chain: chainContext,
Header: blockOverrides.MakeHeader(header),
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert this line. The EVM doesn't have access to the header directly anyway. It only accesses block fields via the block context object.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah it took me a while to find this, I was taking most of the code fromDoCall path which doesn't do this. But the problem with the estimate path is that it uses the header in https://github.com/ethereum/go-ethereum/blob/master/eth/gasestimator/gasestimator.go#L221

Without this line the block overrides are not available in solidity code when running the unit test; this could be because is the test isn't setup correctly or it could genuinely be needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Riighhtt this made me realize we should do this differently. Right now you're effectively only applying the block overrides to mutate the header and pass that to the gasestimator.

IMO we should pass in the overrides to gasestimator and apply them there just before execution. But that will create an import cycle. Hmm...

Copy link
Author

Choose a reason for hiding this comment

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

I was surprised by the number of differences between the two endpoints. They are basically the same thing, except when they are not!

Copy link
Author

Choose a reason for hiding this comment

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

Another option is to move the gasestimator package up into the ethapi package to prevent this.

let me know what you think ...
c5af175

Copy link
Contributor

Choose a reason for hiding this comment

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

This was a deliberate change to move gas estimator out of rpc: #28600. let me think about it

Copy link
Author

Choose a reason for hiding this comment

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

Alternatively, I could pass it in on the options, but that didn't feel right.

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.

Use next block's context for eth_estimateGas
3 participants