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

consensus/ethash: less lookups of block data #21467

Merged
merged 1 commit into from
Apr 27, 2021

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Aug 20, 2020

This PR contains a small optimization picked from #19456

When verifying a block PoW, we need to check an ancestor's uncles. However, most blocks don't have uncles, and in those cases we can avoid loading the full block, and just make do with the header.

@holiman holiman requested a review from karalabe as a code owner August 20, 2020 18:43
@@ -204,11 +204,20 @@ func (ethash *Ethash) VerifyUncles(chain consensus.ChainReader, block *types.Blo

number, parent := block.NumberU64()-1, block.ParentHash()
for i := 0; i < 7; i++ {
ancestorHeader := chain.GetHeader(parent, number)
if ancestorHeader == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one concern, if we lose the header because the database reason, we may loosen rules for checking block.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I know. It might be worth having a panic here, but I didn't want to introduce one now -- since the current code just silently does the exact same thing

Copy link
Member

@rjl493456442 rjl493456442 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one concern, otherwise LGTM

Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@karalabe karalabe added this to the 1.10.3 milestone Apr 27, 2021
@karalabe karalabe merged commit 85a0bab into ethereum:master Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants