-
Notifications
You must be signed in to change notification settings - Fork 298
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
Passing GOSSIP_MAX_SIZE to snappy uncompressor #8899
Passing GOSSIP_MAX_SIZE to snappy uncompressor #8899
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good...
0ae1ed9
to
373b638
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
...2p/src/test/java/tech/pegasys/teku/networking/p2p/libp2p/config/LibP2PParamsFactoryTest.java
Outdated
Show resolved
Hide resolved
...2/src/main/java/tech/pegasys/teku/networking/eth2/gossip/encoding/SnappyBlockCompressor.java
Outdated
Show resolved
Hide resolved
.isInstanceOf(DecodingException.class); | ||
} | ||
|
||
@Test | ||
void uncompress_uncompressedLengthLongerThanMaxLength() { | ||
void uncompress_uncompressedLengthLongerThanSszLenghtBounds() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- uncompress_uncompressedLengthLongerThanSszLenghtBounds()
+ uncompress_uncompressedLengthLongerThanSszLenghthBounds()
} | ||
|
||
@Test | ||
void uncompress_uncompressedLengthEqualThanMaxBytesLength() throws DecodingException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- uncompress_uncompressedLengthEqualThanMaxBytesLength()
+ uncompress_uncompressedLengthEqualToMaxBytesLength()
final Bytes original = Bytes.fromHexString("0x010203040506"); | ||
final long smallMaxBytesLength = 3; | ||
assertThat(smallMaxBytesLength).isLessThan(original.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be a little more precise, I would probably do something like:
assertThat(original.size()).isNotEqualTo(0);
final long smallMaxBytesLength = original.size() - 1;
@@ -24,16 +24,24 @@ | |||
*/ | |||
public class SnappyBlockCompressor { | |||
|
|||
public Bytes uncompress(final Bytes compressedData, final SszLengthBounds lengthBounds) | |||
public Bytes uncompress( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also add a check to compress
to ensure that the uncompressed size is <= maxBytesLength
.
Likewise, clients MUST NOT emit or propagate messages larger than this limit.
PR Description
In this PR we are passing the network config GOSSIP_MAX_SIZE to
SnappyBlockCompressor#uncompress
to check the size of an uncompressed message (as per spec). This way we can check the size of the uncompressed message without actually decompressing it.TODO
MAX_COMPRESSED_GOSSIP_SIZE
(LibP2PParamsFactory
)GossipHandler
has a check for the compressed message size. Decide if we want to keep it.Fixed Issue(s)
related to #8895
Documentation
doc-change-required
label to this PR if updates are required.Changelog