diff --git a/CHANGELOG.md b/CHANGELOG.md index 33055932d05d..c91183f3c7eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve - Improvements to HTTP response handling. [pr](https://github.com/prysmaticlabs/prysm/pull/14673) - Updated `Blobs` endpoint to return additional metadata fields. - Made QUIC the default method to connect with peers. +- Increase Max Payload Size in Gossip. ### Deprecated diff --git a/beacon-chain/p2p/encoder/ssz.go b/beacon-chain/p2p/encoder/ssz.go index 820af846189f..fc469969219e 100644 --- a/beacon-chain/p2p/encoder/ssz.go +++ b/beacon-chain/p2p/encoder/ssz.go @@ -18,6 +18,7 @@ var _ NetworkEncoding = (*SszNetworkEncoder)(nil) // MaxGossipSize allowed for gossip messages. var MaxGossipSize = params.BeaconConfig().GossipMaxSize // 10 Mib. var MaxChunkSize = params.BeaconConfig().MaxChunkSize // 10 Mib. +var MaxUncompressedPayloadSize = 2 * MaxGossipSize // 20 Mib. // This pool defines the sync pool for our buffered snappy writers, so that they // can be constantly reused. @@ -43,8 +44,8 @@ func (_ SszNetworkEncoder) EncodeGossip(w io.Writer, msg fastssz.Marshaler) (int if err != nil { return 0, err } - if uint64(len(b)) > MaxGossipSize { - return 0, errors.Errorf("gossip message exceeds max gossip size: %d bytes > %d bytes", len(b), MaxGossipSize) + if uint64(len(b)) > MaxUncompressedPayloadSize { + return 0, errors.Errorf("gossip message exceeds max gossip size: %d bytes > %d bytes", len(b), MaxUncompressedPayloadSize) } b = snappy.Encode(nil /*dst*/, b) return w.Write(b) @@ -81,7 +82,7 @@ func doDecode(b []byte, to fastssz.Unmarshaler) error { // DecodeGossip decodes the bytes to the protobuf gossip message provided. func (_ SszNetworkEncoder) DecodeGossip(b []byte, to fastssz.Unmarshaler) error { - b, err := DecodeSnappy(b, MaxGossipSize) + b, err := DecodeSnappy(b, MaxUncompressedPayloadSize) if err != nil { return err } diff --git a/beacon-chain/p2p/encoder/ssz_test.go b/beacon-chain/p2p/encoder/ssz_test.go index 6e12af4e7014..8a7f05c82c48 100644 --- a/beacon-chain/p2p/encoder/ssz_test.go +++ b/beacon-chain/p2p/encoder/ssz_test.go @@ -555,7 +555,7 @@ func TestSszNetworkEncoder_FailsSnappyLength(t *testing.T) { e := &encoder.SszNetworkEncoder{} att := ðpb.Fork{} data := make([]byte, 32) - binary.PutUvarint(data, encoder.MaxGossipSize+32) + binary.PutUvarint(data, encoder.MaxUncompressedPayloadSize+32) err := e.DecodeGossip(data, att) require.ErrorContains(t, "snappy message exceeds max size", err) }