-
Notifications
You must be signed in to change notification settings - Fork 275
fix: support maximum block size in P2P sync #3419
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package sync | ||
|
|
||
| import ( | ||
| "github.com/celestiaorg/go-libp2p-messenger/serde" | ||
|
|
||
| "github.com/evstack/ev-node/pkg/blobsize" | ||
| ) | ||
|
|
||
| func init() { | ||
| // go-header wraps block data in another protobuf message, so leave room for | ||
| // framing overhead beyond the maximum block payload. | ||
| serde.MaxMessageSize = 2 * blobsize.DefaultMaxBlobSize | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package sync | ||
|
|
||
| import ( | ||
| "encoding/binary" | ||
| "testing" | ||
|
|
||
| p2ppb "github.com/celestiaorg/go-header/p2p/pb" | ||
| "github.com/celestiaorg/go-libp2p-messenger/serde" | ||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/evstack/ev-node/pkg/blobsize" | ||
| "github.com/evstack/ev-node/types" | ||
| ) | ||
|
|
||
| func TestP2PMessageSizeSupportsMaxBlob(t *testing.T) { | ||
| data := &types.P2PData{ | ||
| Data: &types.Data{ | ||
| Metadata: &types.Metadata{ | ||
| ChainID: "test-chain", | ||
| Height: 1, | ||
| Time: 1, | ||
| }, | ||
| Txs: types.Txs{make([]byte, int(blobsize.DefaultMaxBlobSize))}, | ||
| }, | ||
| } | ||
|
|
||
| body, err := data.MarshalBinary() | ||
| require.NoError(t, err) | ||
|
|
||
| response := &p2ppb.HeaderResponse{Body: body} | ||
| buf := make([]byte, response.Size()+binary.MaxVarintLen64) | ||
| _, err = serde.Marshal(response, buf) | ||
| require.NoError(t, err) | ||
|
Comment on lines
+30
to
+33
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Set The successful go-header server path serializes 🤖 Prompt for AI Agents |
||
| } | ||
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.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
Repository: evstack/ev-node
Length of output: 1867
🏁 Script executed:
Repository: evstack/ev-node
Length of output: 2029
🏁 Script executed:
Repository: evstack/ev-node
Length of output: 1542
🏁 Script executed:
Repository: evstack/ev-node
Length of output: 4349
🏁 Script executed:
Repository: evstack/ev-node
Length of output: 36389
🏁 Script executed:
Repository: evstack/ev-node
Length of output: 334
Avoid widening the process-wide
serdelimit before reading requests.go-headerreads inboundHeaderRequestwithserde.Read, so this global setting also applies to requests. A peer can makego-libp2p-messengerallocate a buffer up to2 * DefaultMaxBlobSizefor the request length beforeHeaderRequest.Unmarshalrejects it. Keepserde.MaxMessageSizesmall enough forHeaderRequest, and widen the limit only whereHeaderResponseserialization is constrained.🤖 Prompt for AI Agents
Source: MCP tools