Skip to content

Commit

Permalink
Remove legacy p2p message handling (#2833)
Browse files Browse the repository at this point in the history
Co-authored-by: Stephen Buttolph <[email protected]>
  • Loading branch information
dhrubabasu and StephenButtolph authored Mar 9, 2024
1 parent b15c743 commit d003d29
Show file tree
Hide file tree
Showing 13 changed files with 8 additions and 944 deletions.
16 changes: 0 additions & 16 deletions proto/message/tx.proto

This file was deleted.

232 changes: 0 additions & 232 deletions proto/pb/message/tx.pb.go

This file was deleted.

44 changes: 0 additions & 44 deletions vms/avm/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"time"

"github.com/prometheus/client_golang/prometheus"
"go.uber.org/zap"

"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/network/p2p"
Expand All @@ -18,7 +17,6 @@ import (
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/vms/avm/txs"
"github.com/ava-labs/avalanchego/vms/avm/txs/mempool"
"github.com/ava-labs/avalanchego/vms/components/message"
)

const txGossipHandlerID = 0
Expand Down Expand Up @@ -182,48 +180,6 @@ func (n *Network) PullGossip(ctx context.Context) {
gossip.Every(ctx, n.log, n.txPullGossiper, n.txPullGossipFrequency)
}

func (n *Network) AppGossip(ctx context.Context, nodeID ids.NodeID, msgBytes []byte) error {
n.log.Debug("called AppGossip message handler",
zap.Stringer("nodeID", nodeID),
zap.Int("messageLen", len(msgBytes)),
)

msgIntf, err := message.Parse(msgBytes)
if err != nil {
n.log.Debug("forwarding AppGossip message to SDK network",
zap.String("reason", "failed to parse message"),
)

return n.Network.AppGossip(ctx, nodeID, msgBytes)
}

msg, ok := msgIntf.(*message.Tx)
if !ok {
n.log.Debug("dropping unexpected message",
zap.Stringer("nodeID", nodeID),
)
return nil
}

tx, err := n.parser.ParseTx(msg.Tx)
if err != nil {
n.log.Verbo("received invalid tx",
zap.Stringer("nodeID", nodeID),
zap.Binary("tx", msg.Tx),
zap.Error(err),
)
return nil
}

if err := n.mempool.Add(tx); err != nil {
n.log.Debug("tx failed to be added to the mempool",
zap.Stringer("txID", tx.ID()),
zap.Error(err),
)
}
return nil
}

// IssueTxFromRPC attempts to add a tx to the mempool, after verifying it. If
// the tx is added to the mempool, it will attempt to push gossip the tx to
// random peers in the network.
Expand Down
Loading

0 comments on commit d003d29

Please sign in to comment.