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

FastChainSyncer now handles data requests from peers #993

Merged
merged 2 commits into from
Jul 10, 2018

Conversation

gsalgado
Copy link
Contributor

@gsalgado gsalgado commented Jul 5, 2018

It used to handle only GetBlockHeader requests, and now handles the rest as well

Includes commits from other PRs, so please review just f80d8ba

@gsalgado gsalgado requested a review from pipermerriam July 5, 2018 13:52
p2p/chain.py Outdated
elif isinstance(cmd, eth.NodeData):
# When doing a chain sync we never send GetNodeData requests, so peers should not send
# us NodeData msgs.
self.logger.warn("Unexpected NodeData msg from %s", peer)
Copy link
Member

Choose a reason for hiding this comment

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

Should we also disconnect from the peer? Otherwise a malicious peer could flood the terminal with these messages.

p2p/chain.py Outdated
async def _handle_block_receipts(
self, peer: ETHPeer, receipts_by_block: List[List[eth.Receipt]]) -> None:
# When doing a regular sync we never request receipts.
self.logger.warn("Unexpected BlockReceipts msg from %s", peer)
Copy link
Member

Choose a reason for hiding this comment

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

Any reason this was not inlined in the if/elif block on lines 485-500 the same way that the NodeData warning is inlined. Similarly, should we disconnect in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lines 485-500 are in FastChainSyncer, and during a fast sync we send GetReceipts requests and expect Receipts responses. This is RegularChainSyncer, and during a regular (i.e. block-processing) sync we don't send GetReceipts. I guess it'd make sense to disconnect as well, yeah

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NodeData, on the other hand, is unexpected in both syncers -- it is only the StateDownloader that requests those

Copy link
Member

Choose a reason for hiding this comment

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

I mis-read the diff and didn't see that those were two different classes.

@gsalgado gsalgado force-pushed the fast-sync-handle-data-requests branch 3 times, most recently from b2e5f79 to 6a94a8a Compare July 10, 2018 13:08
@@ -485,6 +488,8 @@ def disconnect(self, reason: DisconnectReason) -> None:
self.logger.debug("Disconnecting from remote peer; reason: %s", reason.name)
self.base_protocol.send_disconnect(reason.value)
self.close()
if self.is_running:
await self.cancel()
Copy link
Member

Choose a reason for hiding this comment

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

cc @carver as you added a wait_disconnect method in your other PR and I think this is a better pattern.

@gsalgado gsalgado force-pushed the fast-sync-handle-data-requests branch 4 times, most recently from 64b24e9 to a01347e Compare July 10, 2018 19:52
gsalgado added 2 commits July 10, 2018 21:05
It used to handle only GetBlockHeader requests, and now
handles the rest as well
Also disconnect from remotes if we get unexpected NodeData or Receipts
msgs during a sync
@gsalgado gsalgado force-pushed the fast-sync-handle-data-requests branch from a01347e to 9183298 Compare July 10, 2018 20:05
@gsalgado gsalgado merged commit db9d25c into ethereum:master Jul 10, 2018
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.

2 participants