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

Check for known block when processing "header first" #2834

Merged
merged 1 commit into from
Jul 4, 2019

Conversation

antiochp
Copy link
Member

@antiochp antiochp commented May 21, 2019

When processing a header in "header first" propagation we currently perform a quick check to see if we have just processed this header.
This does not cover the case where a peer sends (intentionally or otherwise) an old header.

We should do the same check here that we already do when processing full blocks -

  • Is the block for this header on the head of the current chain?
  • Is the block for this header in our set of orphan blocks?
  • Is the block for this header in our database?

If this is a header for a "known" block then we should halt processing of the header.

@antiochp antiochp added this to the 1.1.1 milestone May 21, 2019
@antiochp antiochp requested a review from ignopeverell May 21, 2019 13:58
/// recently. Keeps duplicates from the network in check.
/// ctx here is specific to the header_head (tip of the header chain)
fn check_header_known(header: &BlockHeader, ctx: &mut BlockContext<'_>) -> Result<(), Error> {
let header_head = ctx.batch.header_head()?;
Copy link
Contributor

Choose a reason for hiding this comment

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

It said ctx here is specific to the header_head (tip of the header chain).

but in check_know(), the check_known_head(header, ctx) is using ctx.batch.head(), not header_head.

Copy link
Member Author

Choose a reason for hiding this comment

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

This code is deleted.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean your new code has very different behavior from the old check_header_known which use header_head. now you're using ctx.batch.head().

Copy link
Member Author

@antiochp antiochp May 24, 2019

Choose a reason for hiding this comment

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

We used to check that the header was known based on the header chain.
The only time we would know about headers and not yet know about the corresponding full block is during initial (header) sync.
So it's safe to check if we know about the header based on the full chain - we're processing "header first" in the context of processing full blocks.

@antiochp antiochp changed the base branch from master to milestone/2.x.x July 4, 2019 11:01
@antiochp antiochp merged commit b6daf1e into mimblewimble:milestone/2.x.x Jul 4, 2019
@antiochp antiochp deleted the check_header_known branch July 4, 2019 11:30
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.

3 participants