-
Notifications
You must be signed in to change notification settings - Fork 148
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
support gas estimates with block identifier #189
Conversation
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.
Nice that the block number was already supported by _get_normalized_and_unsigned_evm_transaction
. Makes this a short and sweet PR.
Only other thing to add is a test. See this for inspiration:
The best kind of test would be one that checks that the gas cost is actually different depending on the block supplied. One way to do it would be to estimate the gas cost of running the transaction before the contract was deployed.
8549d2a
to
4f55ceb
Compare
4f55ceb
to
1e6e2f1
Compare
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, looking at the test, I'm realizing that the assertion is pretty weak, because the estimates are allowed to vary somewhat randomly.
I guess I should have said the best kind of test would be to write a contract that burns gas in a way that's easily detectable by block number, like burning (100k * block_number) gas. But given how much other low-hanging fruit there is for improvement in other places & projects, I'm okay calling this good enough and moving on. 👍 if you want to add an issue to do that ^. (it's right on the border of a Good First Issue: great that nothing else will block on its progress, not good that it will surely require a lot of back and forth as a new test contract is added)
Bike-shedding over the the way to test: Contract with a toggle-able flag which just returns immediately or burns a bunch of gas in a loop. Then you can set it and test on either side of the block number where the flag was toggled. Agreed on this being lower priority for testing. Like @carver said, probably better to document the testing approach in a "good first issue". |
👍 new issue coming following the merge. |
What was wrong?
Re: ethereum/web3.py#1639, py-evm supports gas estimation with block identifiers, but eth-tester didn't yet pass those values through.
How was it fixed?
estimate_gas
now accepts and processes ablock_number
.Feedback appreciated @carver (and anyone else interested); I processed the minimum surface area of this package required to get this far and get passing tests on the Web3 side.
To-Do:
Cute Animal Picture