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

Fix codec size for large blocks #423

Merged
merged 8 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions plugin/evm/message/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ var (
)

func init() {
Codec = codec.NewManager(maxMessageSize)
c := linearcodec.NewDefault()
StephenButtolph marked this conversation as resolved.
Show resolved Hide resolved
Codec = codec.NewManager(maxMessageSize + wrappers.ShortLen) // Add room for the codec version
StephenButtolph marked this conversation as resolved.
Show resolved Hide resolved
c := linearcodec.NewCustomMaxLength(maxMessageSize)

errs := wrappers.Errs{}
errs.Add(
Expand Down Expand Up @@ -53,8 +53,8 @@ func init() {
panic(errs.Err)
}

CrossChainCodec = codec.NewManager(maxMessageSize)
ccc := linearcodec.NewDefault()
CrossChainCodec = codec.NewManager(maxMessageSize + wrappers.ShortLen) // Add room for the codec version
ccc := linearcodec.NewCustomMaxLength(maxMessageSize)

errs = wrappers.Errs{}
errs.Add(
Expand Down
2 changes: 1 addition & 1 deletion plugin/evm/message/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestEthTxsTooLarge(t *testing.T) {
assert := assert.New(t)

builtMsg := EthTxsGossip{
Txs: utils.RandomBytes(1024 * units.KiB),
Txs: utils.RandomBytes(maxMessageSize),
}
_, err := BuildGossipMessage(Codec, builtMsg)
assert.Error(err)
Expand Down
2 changes: 1 addition & 1 deletion sync/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func (c *client) get(ctx context.Context, request message.Request, parseFn parse
responseIntf, numElements, err = parseFn(c.codec, request, response)
if err != nil {
lastErr = err
log.Info("could not validate response, retrying", "nodeID", nodeID, "attempt", attempt, "request", request, "err", err)
log.Debug("could not validate response, retrying", "nodeID", nodeID, "attempt", attempt, "request", request, "err", err)
StephenButtolph marked this conversation as resolved.
Show resolved Hide resolved
c.networkClient.TrackBandwidth(nodeID, 0)
metric.IncFailed()
metric.IncInvalidResponse()
Expand Down
2 changes: 1 addition & 1 deletion sync/handlers/block_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func TestBlockRequestHandlerLargeBlocks(t *testing.T) {
blocks, _, err := core.GenerateChain(gspec.Config, genesis, engine, memdb, 96, 0, func(i int, b *core.BlockGen) {
var data []byte
switch {
case i < 32:
case i <= 32:
StephenButtolph marked this conversation as resolved.
Show resolved Hide resolved
data = make([]byte, units.MiB)
default:
data = make([]byte, units.MiB/16)
Expand Down
Loading