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

ethclient.Client#HeaderByNumber fails for pending block #22507

Closed
meowsbits opened this issue Mar 16, 2021 · 2 comments
Closed

ethclient.Client#HeaderByNumber fails for pending block #22507

meowsbits opened this issue Mar 16, 2021 · 2 comments
Labels

Comments

@meowsbits
Copy link
Contributor

meowsbits commented Mar 16, 2021

System information

Geth version:

Geth
Version: 1.10.2-unstable
Git Commit: 91726e8aadeebc4bda8f136aebf4b5c7da8b9d74
Git Commit Date: 20210316
Architecture: amd64
Go Version: go1.16
Operating System: linux
GOPATH=/home/ia/go
GOROOT=/home/ia/go1.16.linux-amd64

Expected behaviour

ethclient.Client#HeaderByNumber(-1) returns a pending block header equivalent to the value returned by an external RPC call, eg. eth_getBlockByNumber("pending", false).

Actual behaviour

This method returns an error and an almost-empty header.
Error returned is: missing required field 'miner' for Header", want %!q(<nil>), though this will not be the only issue since the types.Header JSON unmarshaling methods are not able to handle consensus-invalid headers.
Below, a JSON-encoded example of the response.

{
    "parentHash": "0x228d7580ae75567749daa5ed31ff1fcc09803ebe001b44f64b0f364c19bff4cb",
    "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
    "miner": "0x0000000000000000000000000000000000000000",
    "stateRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "transactionsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "difficulty": null,
    "number": null,
    "gasLimit": "0x0",
    "gasUsed": "0x0",
    "timestamp": "0x0",
    "extraData": "0x",
    "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "nonce": "0x0000000000000000",
    "hash": "0xc5343d7f4960fbc487e877585726949b6a36150e3ed7cd0954741f467b98d0b8"
}

Steps to reproduce the behaviour

I've created a branch (and an adhoc PR) with additional ethclient tests demonstrating the issue here: #22515.

meowsbits added a commit to etclabscore/ethereum.go-ethereum that referenced this issue Mar 17, 2021
Rel ethereum#22507

Date: 2021-03-17 08:07:51-05:00
Signed-off-by: meows <b5c6@protonmail.com>
@meowsbits meowsbits changed the title ethclient.Client#HeaderByNumber returns invalid header for pending block ethclient.Client#HeaderByNumber fails for pending block Mar 17, 2021
@ligi
Copy link
Member

ligi commented Mar 18, 2021

Can you tell us more about your use-case?

@meowsbits
Copy link
Contributor Author

Closing since the PR resolving this issue is already closed as a "wont-fix" (#22517)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants