Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
darioush committed Jan 29, 2025
1 parent b2b0b98 commit 7855976
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion plugin/evm/statesync/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package statesync

import (
"context"
"fmt"

"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow/engine/common"
Expand Down Expand Up @@ -53,7 +54,7 @@ func NewOutboundPeer(nodeID ids.NodeID, sender common.AppSender) *snap.Peer {
func (o *outbound) WriteMsg(msg ethp2p.Msg) error {
bytes, err := toBytes(msg)
if err != nil {
return err
return fmt.Errorf("failed to convert message to bytes: %w, expected: %d", err, msg.Size)
}

nodeIDs := set.NewSet[ids.NodeID](1)
Expand Down
4 changes: 3 additions & 1 deletion plugin/evm/statesync/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/ava-labs/avalanchego/utils/wrappers"
"github.com/ava-labs/coreth/core"
"github.com/ava-labs/coreth/eth/protocols/snap"
"github.com/ava-labs/libevm/log"
ethp2p "github.com/ava-labs/libevm/p2p"
"github.com/ava-labs/libevm/p2p/enode"
)
Expand Down Expand Up @@ -113,6 +114,7 @@ func (rw *rw) WriteMsg(msg ethp2p.Msg) error {
func toBytes(msg ethp2p.Msg) ([]byte, error) {
bytes := make([]byte, msg.Size+wrappers.LongLen)
binary.BigEndian.PutUint64(bytes, msg.Code)
_, err := msg.Payload.Read(bytes[wrappers.LongLen:])
n, err := msg.Payload.Read(bytes[wrappers.LongLen:])
log.Debug("toBytes", "n", n, "err", err)
return bytes, err
}

0 comments on commit 7855976

Please sign in to comment.