Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

fix(Receiver): Ignore unwanted blocks #24

Merged
merged 1 commit into from
Nov 15, 2018

Conversation

hannahhoward
Copy link
Contributor

Goals

If Bitswap receives a block that isn't in it's wantlist, is should ignore it, and not add it to the block store

Implementation

Blocks get received in bitswap one of two ways. They're either added by the user (HasBlock) -- and in this case it seems like they should always get added to the blockstore. Or, they come in through the network -- through the ReceiveMessage function. It seems to me, and it's possible I'm missing something, this is the place to ignore an unwanted block. This perhaps naive implementation simply checks blocks received from the network against the global wantlist and ignores them if they aren't in the wantlist.

For Discussion

There are interesting questions about what exactly we want to do and not do with an unwanted block. This approach counts the block in statistics but doesn't provide it, add it to the block store, send it to sessions, or anything else.

The reason for counting in statistics is information was transferred and received, and duplicate blocks likely have been removed from the wantlist but were requested at some point, making them worth recording as duplicate blocks.

But it might merit further examination to figure out if this is the exact right set of things to "not do" if we get a block that's not in the want list.

fix #21 fix #22

If Bitswap receives a block that isn't in it's wantlist, is should ignore it

fix #21 fix #22
@ghost ghost assigned hannahhoward Nov 13, 2018
@ghost ghost added the status/in-progress In progress label Nov 13, 2018
@schomatis
Copy link
Contributor

Is the broadcast wantlist (bcwl) always contained by the regular one? Should the session's tofetch queue be considered here? (although it seems outside of the scope of the Bitswap struct)

@hannahhoward
Copy link
Contributor Author

@schomatis
Question 1: I believe so -- based on my read of wantmanager.go, every block that gets requested through WantBlocks ends up on the wl wantlist. bcwl is a subset, and blocks get added if no targets are passed to WantBlocks. See my comment here: #22 (comment)

Actually I'm curious if my read looks right to you.

Question 2: Ooh... good question. So toFetch is a list of keys that have been requested in code through the sessions GetBlocks/GetBlock methods but the request for those blocks has not yet gone out to the network. So should they be stored in the block store if they are received from the network? The situation I could see this being relevant is if at some point we decide to start optimistically sending blocks to peers based on the structure of the Merkledag. We don't do that at the moment, but maybe it's worth exploring? Either way, I wonder if this is a concern we need to solve for now, or we can wait till that becomes an optimization need.

@hannahhoward
Copy link
Contributor Author

@schomatis are you ok with addressing toFetch later?

Seeking your LGTM + 1 more

Copy link
Contributor

@schomatis schomatis left a comment

Choose a reason for hiding this comment

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

LGTM

@schomatis are you ok with addressing toFetch later?

Yes, this is definitely a step in the right direction, we can address the other issues later.

Copy link
Contributor

@michaelavila michaelavila left a comment

Choose a reason for hiding this comment

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

LGTM

@hannahhoward hannahhoward merged commit c5b071d into master Nov 15, 2018
@ghost ghost removed the status/in-progress In progress label Nov 15, 2018
Jorropo pushed a commit to Jorropo/go-libipfs that referenced this pull request Jan 26, 2023
…anted-blocks-21

fix(Receiver): Ignore unwanted blocks

This commit was moved from ipfs/go-bitswap@c5b071d
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Store a complete wantlist Reject unwanted blocks
3 participants