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: missing mixHash in JSON block header #3230

Closed
stevenroose opened this issue Nov 3, 2016 · 10 comments
Closed

ethclient: missing mixHash in JSON block header #3230

stevenroose opened this issue Nov 3, 2016 · 10 comments

Comments

@stevenroose
Copy link
Contributor

System information

Geth version: develop branch
OS & Version: Arch Linux
Commit hash : ed2bc7f

Expected behaviour

ethclient.HeaderByNumber should return a *types.Header instance

Actual behaviour

JSON unmarshal error: missing mixHash in JSON block header

@fjl
Copy link
Contributor

fjl commented Nov 3, 2016

You get this error because the server did not return all required fields. The field is needed because we cannot recompute the header hash correctly if mixHash is missing.

@stevenroose
Copy link
Contributor Author

Can this be because of an inconsistency between Parity's and Geth's JSON
API?

On 11/03/2016 06:10 PM, Felix Lange wrote:

You get this error because the server did not return all required fields.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#3230 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA0F3ITYVjhzvj0uttEkx8cWYBFKRbMRks5q6hV4gaJpZM4Koqd-.

@fjl
Copy link
Contributor

fjl commented Nov 3, 2016

The only server implementation that returns this field is geth 1.5.0, which is not released yet. If you are using parity please ask them to include this field in API responses.

@fjl fjl changed the title ethclient.HeaderByNumber fails to parse response JSON ethclient: missing mixHash in JSON block header Nov 3, 2016
@fjl
Copy link
Contributor

fjl commented Nov 9, 2016

This is now fixed in the parity master branch, closing.

@fjl fjl closed this as completed Nov 9, 2016
@stevenroose
Copy link
Contributor Author

I seem to have bumped into this again. Just started using stable Parity.

@dtco-kimi
Copy link

I have the same issue also. @stevenroose would you mind reopen this issue again? Thanks.
Parity version: v2.0.3-beta-a0a2bed-20180831

@stevenroose
Copy link
Contributor Author

@dtco-kimi I don't have reopen permissions, sorry. You should ask @fjl

@pstehlik
Copy link

It seems like this problem only occurs when using Parity against Kovan (POA chain). There, the field is not returned. When running Parity against ropsten it actually returns the field.
Contrary to that, geth returns 0x0 in the mixHash field when running against Rinkeby (also POA) thus allowing clients to rely on the field always being there.

It would be great if the go-ethereum ethclient would gracefully ignore the field not being present. I don't know if there's an easy way to distinguish between POA/POW chains and only error out when interacting with a POW chain and the field is missing. That could be a good solution.

@TwinbrotherPro
Copy link

Having the same Issue with my own POA (Parity) Network. Would be glad if the suggestion of pstehlik could be somehow implemented :)

@TwinbrotherPro
Copy link

As I am writing this I really think I should not post this, but as a quick fix you can just modify those lines in the json unmarshaller in https://github.com/ethereum/go-ethereum/blob/master/core/types/gen_header_json.go .

	// if dec.MixDigest == nil {
	// 	return errors.New("missing required field 'mixHash' for Header")
	// }
	if dec.MixDigest != nil {
		h.MixDigest = *dec.MixDigest
	}
	// if dec.Nonce == nil {
	// 	return errors.New("missing required field 'nonce' for Header")
	// }
	if dec.Nonce != nil {
		h.Nonce = *dec.Nonce
	}

A better way would be of having the possibility of creating a header type just for a POA chain which does not require Nonce and MixDigest. But I am still not in the code, yet so there might be a better way to solve this.

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

No branches or pull requests

5 participants