-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
WIP: No way to specify block number for eth_estimateGas #1046
WIP: No way to specify block number for eth_estimateGas #1046
Conversation
Changing So I would just mark any |
One more point is that geth accepts only one input (transaction) while parity/ py-evm accept two (transaction & block_identifier) This means we might have to either:
Which solution do you prefer? |
I prefer that the json-rpc get standardized in an EIP and that they all conform to it 😆 In the meantime... Parity must work if only one argument is passed, I guess. So, if no block identifier is set in web3, instead of defaulting to latest, we could leave the argument out altogether in the RPC call. This has the weird effect that the number of arguments in the RPC call can be different, which I don't think happens anywhere else. But I'd be curious to see if we could make that work. Then we don't have to do any node detection, and it would work in both geth and parity. Then if you try with an explicit block-identifier, geth will blow up (which we can't do anything about) and parity will work fine. |
This is a wayyy better solution, because then we would not have to tag several geth tests as xfail. Will work on implementing this and modifying the eth-tester now. |
Hi @ankitchiplunkar any progress to show here? Hope you're doing well 🙂 |
@vs77bb yes was busy with EthBerlin last week, getting back to the task. |
Have updated the estimateGas function as discussed above and added tests for parity and geth. Implemented a
But got the following errors, when only one input was provided to method
Have not implemented any middleware for the block_identifier as of now, mostly would need to implement a function (similar to Still need to update:
|
I think if we get creative, we can do this with existing formatters, something like: @curry
def is_length(target_length, value):
return len(value) == target_length
estimate_gas_without_block_id = apply_formatter_at_index(0, transaction_param_formatter)
estimate_gas_with_block_id = apply_formatters_to_sequence((
transaction_param_formatter,
block_number_formatter,
))
...
'eth_estimateGas': apply_one_of_formatters((
(is_length(1), estimate_gas_without_block_id),
(is_length(2), estimate_gas_with_block_id),
)) The key part is choosing which formatter to apply with |
Can you do a rebase on master instead of merging master in? Makes it cleaner to read the PR. |
I just merged #1033 which will make this rebase a bit complicated. @ankitchiplunkar Let me know if you want help. |
4b6c335
to
0461819
Compare
Can you amend the commit and write a different summary (first) line of the squashed commit? "Require compatible setuptools version " is confusing as a one-liner. Something like "Specify block number for w3.eth.estimateGas". All the "body" (remaining lines) of the commit message can stay as whatever you want. |
see ethereum#1053 added feature for inputing block_identifier in eth_estimateGas command variable inputs in estimateGas and tests formatter for block_identifier and passing tests added feature for inputing block_identifier in eth_estimateGas command variable inputs in estimateGas and tests passing lint
0461819
to
c18f639
Compare
Thanks all, for helping with squashing and rebasing. @carver I found that The Is this approach is acceptable and tests cover everything? |
Big 👍 for pushing towards cleaner commits and for a better commit message. With clean commit history it becomes really easy to dig history and we can reliably use |
web3/eth.py
Outdated
[transaction], | ||
) | ||
# TODO: move to middleware | ||
if block_identifier is None: |
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 code can be reduced to:
params = [transaction]
if block_identifier:
params.append(block_identifier)
return self.web3.manager.request_blocking(
"eth_estimateGas",
params
)
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.
Rather than mutating the params list, I would go with:
if block_identifier is None:
params = [transaction]
else:
params = [transaction, block_identifier]
return self.web3.manager.request_blocking(
"eth_estimateGas",
params,
)
Also, we don't need the second move to middleware
TODO.
Ok, not a big deal. Just a nice-to-have.
Yeah, surely not a problem with this PR. parity tests have been flaky.
Yup, approach seems good, and tests cover enough for merge, I think. Just that one last inline comment to address, and should be good to go. |
Thanks for the doc update! |
What was wrong?
No way to specify block number for eth_estimateGas
Related to Issue # #1011
How was it fixed?
Added block_identifier as an input parameter in the estimateGas method(similar to web3.eth.call), this opens a can of worms because:
estimate_gas
method in the eth_tester library takes only 2 inputs while we now have an extra input (block_identifier). To enable the passing of all tests we need to also change the https://github.com/ethereum/eth-tester libraryParity
Geth
Changing the two libraries would be a HUGE task.
How do you (@Arachnid , @carver) propose that we should proceed?
Cute Animal Picture