-
Notifications
You must be signed in to change notification settings - Fork 20.2k
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
base: master
Are you sure you want to change the base?
ethapi: add block override to estimateGas #30695
Conversation
b135064
to
b7a664e
Compare
b7a664e
to
7702e9e
Compare
7702e9e
to
b304b13
Compare
internal/ethapi/api.go
Outdated
Chain: NewChainContext(ctx, b), | ||
Header: header, | ||
Chain: chainContext, | ||
Header: blockOverrides.MakeHeader(header), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Add block overrides to
eth_estimateGas
to align consistency witheth_call
#27800 (comment)
Fixes #28175