Skip to content

Conversation

@karalabe
Copy link
Member

@karalabe karalabe commented Jan 25, 2021

In the current code, a peer is allowed to join both on the eth and snap protocols. Although both protocol handlers enforces that snap-requires-eth, this is done with a timeout mechanism after the peer was added to all internal structs. Since we allowed a peer to (maliciously) connect with only snap, we needed the snap handler to clean out the peer on disconnect, similar to how eth does when peer is dropped. This resulted in double-cleanups during normal disconnects since both protocols tries to racily clean.

This PR solves the issue by adding doing eth/snap registration in two phases. Snap is registered as a protocol extension in the peerset and eth consumes (or blocks until it can) this registration. Only then will eth proceed. All submodule (downloader, syncer, fetcher) registrations and removals are done on the main eth pathways.

@karalabe karalabe requested review from fjl and holiman January 25, 2021 18:47
@holiman holiman linked an issue Jan 26, 2021 that may be closed by this pull request
@karalabe karalabe requested a review from zsfelfoldi as a code owner February 1, 2021 13:56
@karalabe karalabe added this to the 1.10.0 milestone Feb 2, 2021
Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

Looks good enough to me it seems OK to merge it and get more testing on master

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.

Failing to unregister sync peer (which not registered)

2 participants