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

GetBlockHeaders [reverse = true, skip = 0, origin type = hash] duplicates genesis in response #2076

Closed
Nashatyrev opened this issue Dec 15, 2015 · 4 comments
Assignees
Labels

Comments

@Nashatyrev
Copy link
Member

E.g. when sending GetBlockHeaders(Origin = blockHash, Amount = 1000, Skip = 1, Reverse = true) (where blockHash is the block #4) I'm getting block headers #4, #2, #0
When sending with Skip = 0 getting headers #4, #3, #2, #1, #0, #0 (two zero blocks at the end)
The problem seems to be in that line:
https://github.com/ethereum/go-ethereum/blob/master/eth/handler.go#L421

@karalabe
Copy link
Member

Hmmm, indeed I've managed to reproduce it. The bug is not in that line of code, it's a side effect of using the query itself as an iterator. When we reach the root of the chain, the parent of the genesis block is the nil hash, which is interpreted in a special way in the code. I guess we haven't caught this issue because we don't use this type of queries currently in the code. Let me see how to cleanly solve this.

@karalabe karalabe self-assigned this Dec 15, 2015
@karalabe karalabe changed the title GetBlockHeaders msg with Reverse = true and Skip > 0 incorrectly processed GetBlockHeaders [reverse = true, skip = 0, origin type = hash] duplicates genesis in response Dec 15, 2015
@karalabe
Copy link
Member

This should be fixed by the commit linked above. If you try it out yourself, please report back whether it worked or not. Otherwise is should be reviewed fairly quickly as it's a trivial fix and land the develop I guess by tonight.

@Nashatyrev
Copy link
Member Author

We are currently not using such messages as well, just accidentally found this problem.
Thanks for prompt response!

karalabe added a commit to karalabe/go-ethereum that referenced this issue Dec 16, 2015
obscuren added a commit that referenced this issue Dec 17, 2015
eth: fix #2076, where end of hash query was interpreted number query
@karalabe
Copy link
Member

Fixed and merged. Thanks for the report!

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

3 participants