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

Shorter chain is chosen in re-org when totalDifficulty is the same #24230

Closed
guoyiteng opened this issue Jan 12, 2022 · 1 comment
Closed

Shorter chain is chosen in re-org when totalDifficulty is the same #24230

guoyiteng opened this issue Jan 12, 2022 · 1 comment

Comments

@guoyiteng
Copy link

Hi, I noticed that geth picked up the the shorter chain when totalDifficulty is the same in ForkChoice. May I ask why this is the case?
https://github.com/ethereum/go-ethereum/blob/master/core/forkchoice.go#L96

number, headNumber := header.Number.Uint64(), current.Number.Uint64()

Also the variable name headerNumber here is a bit confusing. I know this came from a recent refactor #23761 but it would be clearer if we can rename these two variables to something like headerNumber, number.

@rjl493456442
Copy link
Member

rjl493456442 commented Jan 13, 2022

Regarding the reason for choosing the block with lower number, maybe you can try to read the paper we linked here.

And about the variable names, I think number, headNumber is better. current here refers to the local head header, and the header refers to a header given by a remote peer(so no guarantee it can be the canonical chain head).

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

No branches or pull requests

4 participants
@ligi @rjl493456442 @guoyiteng and others