-
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
getBlockByHash and getBlockByNumber will return a block number if block is pending #1572
Comments
Hi. I would like to write tests for this fix (#20616). However, I have a few questions on how to go about this.
Any help would be appreciated. Thank you! |
If I'm reading the geth releases correctly, it looks like the change from #20616 went in to geth version 1.9.11. Currently, the geth 1.9 version that we're testing against is 1.9.7, so this test is passing because 1.9.7 returns a block number instead of null. Since that's the case, actually testing this PR just got a little more complicated. I'm not sure that it's a great use of our time since I'm pretty sure that this line is what allows us to handle either null or a block number: https://github.com/ethereum/web3.py/blob/master/web3/_utils/method_formatters.py#L380-L381. What I'll do is spend a little bit of time next week making a new fixture to test against 1.9.11+ and if there are a bunch of breakages I'll probably just keep the test at 1.9.7, otherwise fixing a few failing tests might be a good task for you if you're up for it. I'll keep you posted!
#20616 doesn't fix this issue, it just fixes an issue in the go-ethereum code base, where they wanted to return null for a
Thank you! |
@tmckenzie51 I forgot we'll have to add the most recent geth versions to py-geth before we can make a fixture. If you're interested, you can follow this PR to add the most recent geth versions to py-geth, and then I can generate a new fixture for you. Aside from this issue, we have another issue that was raised this week related to versions of geth 1.9.12+, so I think that would be a good use of your time! |
Thank you! That's very helpful! I'll use that to test against the different versions.
I think I’m having a bit confusion about the return values of the different geth versions. My understanding from the issue description here is:
However, based on this it seems that geth 1.9.7 returns a number rather than null, but that seems to contradict with my initial understanding of the return values of the different versions that I outlined above. Is it then as outlined below instead? :
Also, based on this it seems that merge #20616 which returns null for pending blocks was applied to geth version 1.9.11. Does this then mean that 1.9.11 actually returns null rather than a number? Is it then as outlined below, instead? I've based this PR on this last interpretation.
Thank you for sharing that line of code with me. I’m interpreting that line of code of taking a non-null value then doing block-formatting on it. How would this handle null values? |
@kclowes I also found a package online called 'semver' that could help with semantic versioning. Is this necessary here? Is it possible for me to add new libraries? If so, how may I go about adding a library such that it is incorporated in the CI tests? |
Looks like this was fixed in #1790 |
What was wrong?
As of geth 1.9.11,
eth_getBlockByHash
andeth_getBlockByNumber
will be returning a block number if the block is pending, instead ofnull
. Older versions of geth were returning a number, but as of 1.9.7, geth returnsnull
if the block is pending.https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblockbyhash
Context:
ethereum/go-ethereum#20587
How can it be fixed?
Check to make sure that web3 can handle either a null response or a block number. This probably means adding some testing. Will also need to check parity's responses.
The text was updated successfully, but these errors were encountered: