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

Improve validation when processing orphan blocks #2981

Merged
merged 1 commit into from
Aug 3, 2019

Conversation

j01tz
Copy link
Member

@j01tz j01tz commented Jul 30, 2019

The block acceptance pipeline can potentially be improved by adding a proof of work validation check before adding orphan blocks to the orphan block pool.

Currently adding an orphan block with an invalid proof of work is allowed and can consume unnecessary resources and potentially flush legitimate orphans from the pool if MAX_ORPHAN_SIZE is reached.

This PR adds a check based on the one proposed by @quentinlesceller to better validate orphan blocks before they are added to the orphan block pool.

  • Adds validate_pow_only() function to cheaply validate orphans
  • Adds validate_pow_only() check to pipe::process_block() inside the orphan conditional before ​Err​(ErrorKind::​Orphan​.into()) is returned

This is a WIP as it needs more testing, someone may find a more efficient/elegant way for this check and tests still need to be added.

Copy link
Member

@antiochp antiochp left a comment

Choose a reason for hiding this comment

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

Nice. This looks good.

Not related to this PR but we may want to refactor the existing block/header validation to do the same thing earlier in the pipeline, before we start looking for previous header in the db etc.

@j01tz j01tz changed the title [WIP] Improve validation when processing orphan blocks Improve validation when processing orphan blocks Jul 31, 2019
@antiochp
Copy link
Member

antiochp commented Aug 1, 2019

Going to do some local testing of this - will merge after that.

@antiochp antiochp merged commit ea1d14d into mimblewimble:master Aug 3, 2019
@j01tz j01tz deleted the research-13 branch August 9, 2019 19:25
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

Successfully merging this pull request may close these issues.

3 participants