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

Devp2p: fix a peer data processing bug #1064

Merged
merged 1 commit into from
Jan 20, 2021

Conversation

holgerd77
Copy link
Member

@holgerd77 holgerd77 commented Jan 20, 2021

This PR fixes a critical devp2p bug where peer data processing stays in an endless while loop on retrieval of malformed data, code change should be relatively self-explanatory, so if an error is thrown "early enough" before the data is consumed the loop will be executed ever and ever again (while the peer is disconnected anyhow).

Stumbled upon this in the client where the following error has been hammered out in an endless fashion on some malformed peer data:

ERROR [01-19|18:55:59] AssertionError [ERR_ASSERTION]: should have valid tag: c9994806780c34bf140355955ad1d2f5aeb38a61cea495379a435931d8bf7e6e / 176a38c21a95454505a8d05627c9975ce84673da8903b33fe48b80b082595cc0
    at new AssertionError (internal/assert/assertion_error.js:447:11)
    at Object.assertEq (/ethereumjs-vm/packages/devp2p/dist/util.js:73:15)
    at ECIES._decryptMessage (/EthereumJS/ethereumjs-vm/packages/devp2p/dist/rlpx/ecies.js:126:16)
    at ECIES.parseAuthPlain (/EthereumJS/ethereumjs-vm/packages/devp2p/dist/rlpx/ecies.js:197:32)
    at ECIES.parseAuthEIP8 (/EthereumJS/ethereumjs-vm/packages/devp2p/dist/rlpx/ecies.js:236:14)
    at Peer._handleAuth (/EthereumJS/ethereumjs-vm/packages/devp2p/dist/rlpx/peer.js:238:32)
    at Peer._onSocketData (/EthereumJS/ethereumjs-vm/packages/devp2p/dist/rlpx/peer.js:443:30)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)

I think I already had this in other occasions before as well.

This might also solve some client "hanging" situations - so this behavior might have also been occurred together with the error not propagated through as an output for the client log, so the situation just looked as if the client just hangs. That's just an assumption though, we'll eventually see.

@codecov
Copy link

codecov bot commented Jan 20, 2021

Codecov Report

Merging #1064 (c379f14) into master (df57cc0) will increase coverage by 0.10%.
The diff coverage is 40.00%.

Impacted file tree graph

Flag Coverage Δ
block 77.65% <ø> (ø)
blockchain 77.92% <ø> (ø)
client 88.41% <ø> (ø)
common 92.37% <ø> (+0.43%) ⬆️
devp2p 82.98% <40.00%> (+0.25%) ⬆️
ethash 82.08% <ø> (ø)
tx 90.00% <ø> (ø)
vm 83.09% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@holgerd77 holgerd77 force-pushed the fix-devp2p-data-processing-bug branch from 9183abd to c379f14 Compare January 20, 2021 10:14
Copy link
Contributor

@cgewecke cgewecke left a comment

Choose a reason for hiding this comment

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

Makes sense and looks good 💯

(Have checked the cov report because it dropped and believe codecov is mistaken about this. Their diff shows no newly untested logic.)

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.

2 participants