Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Handle RLPException when processing incoming DevP2P messages #1491

Merged
merged 3 commits into from
May 28, 2019

Conversation

ajsutton
Copy link
Contributor

PR description

An RLPException may be thrown if the message we receive from a peer is invalid. DeFramer should treat this the same as a FramingException - the message is invalid and the peer should be disconnected with breach of protocol.

Avoids printing errors like:

2019-05-23 21:46:33.825+00:00 | nioEventLoopGroup-3-1 | ERROR | DeFramer | Exception while processing incoming message
io.netty.handler.codec.DecoderException: tech.pegasys.pantheon.ethereum.rlp.RLPException: Not at the end of the current list (at bytes 3-43: f87905[a76f6461...2e382e33]ccc58365...)
        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:472) ~[netty-codec-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:278) ~[netty-codec-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:644) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:579) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:496) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:458) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897) [netty-common-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.30.Final.jar:4.1.30.Final]
        at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: tech.pegasys.pantheon.ethereum.rlp.RLPException: Not at the end of the current list (at bytes 3-43: f87905[a76f6461...2e382e33]ccc58365...)
        at tech.pegasys.pantheon.ethereum.rlp.AbstractRLPInput.error(AbstractRLPInput.java:202) ~[pantheon-ethereum-rlp-1.1.1-SNAPSHOT.jar:1.1.1-dev-02f8531d]
        at tech.pegasys.pantheon.ethereum.rlp.AbstractRLPInput.leaveList(AbstractRLPInput.java:502) ~[pantheon-ethereum-rlp-1.1.1-SNAPSHOT.jar:1.1.1-dev-02f8531d]
        at tech.pegasys.pantheon.ethereum.rlp.BytesValueRLPInput.leaveList(BytesValueRLPInput.java:22) ~[pantheon-ethereum-rlp-1.1.1-SNAPSHOT.jar:1.1.1-dev-02f8531d]
        at tech.pegasys.pantheon.ethereum.rlp.AbstractRLPInput.leaveList(AbstractRLPInput.java:493) ~[pantheon-ethereum-rlp-1.1.1-SNAPSHOT.jar:1.1.1-dev-02f8531d]
        at tech.pegasys.pantheon.ethereum.rlp.BytesValueRLPInput.leaveList(BytesValueRLPInput.java:22) ~[pantheon-ethereum-rlp-1.1.1-SNAPSHOT.jar:1.1.1-dev-02f8531d]
        at tech.pegasys.pantheon.ethereum.p2p.wire.messages.DisconnectMessage$Data.readFrom(DisconnectMessage.java:82) ~[pantheon-p2p-1.1.1-SNAPSHOT.jar:1.1.1-dev-02f8531d]
        at tech.pegasys.pantheon.ethereum.p2p.wire.messages.DisconnectMessage.getReason(DisconnectMessage.java:58) ~[pantheon-p2p-1.1.1-SNAPSHOT.jar:1.1.1-dev-02f8531d]
        at tech.pegasys.pantheon.ethereum.p2p.network.netty.DeFramer.decode(DeFramer.java:150) ~[pantheon-p2p-1.1.1-SNAPSHOT.jar:1.1.1-dev-02f8531d]
        at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:502) ~[netty-codec-4.1.30.Final.jar:4.1.30.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:441) ~[netty-codec-4.1.30.Final.jar:4.1.30.Final]
        ... 16 more

Copy link
Contributor

@AbdelStark AbdelStark left a comment

Choose a reason for hiding this comment

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

lgtm

@ajsutton ajsutton merged commit e8586b9 into PegaSysEng:master May 28, 2019
@ajsutton ajsutton deleted the handle-invalid-rlp branch May 28, 2019 21:05
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.

2 participants