From 38b532963ca50fea8ae6e7aebe061c4a09f39ff2 Mon Sep 17 00:00:00 2001 From: Darioush Jalali Date: Fri, 2 Aug 2024 10:20:23 -0700 Subject: [PATCH] cleanup: use p2p.TxGossipHandlerID --- go.sum | 2 -- plugin/evm/tx_gossip_test.go | 6 +++--- plugin/evm/vm.go | 7 ++----- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/go.sum b/go.sum index 7a6f111e4f..a33e68a2f1 100644 --- a/go.sum +++ b/go.sum @@ -56,8 +56,6 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/ava-labs/avalanchego v1.11.10 h1:QujciF5OEp5FwAoe/RciFF/i47rxU5rkEr6fVuUBS1Q= -github.com/ava-labs/avalanchego v1.11.10/go.mod h1:POgZPryqe80OeHCDNrXrPOKoFre736iFuMgmUBeKaLc= github.com/ava-labs/avalanchego v1.11.11-0.20240729205337-a0f7e422bb84 h1:AmPZLlnVREbJ/viK/hDTIVn1bqX8QTB2CFtrBxHwnsw= github.com/ava-labs/avalanchego v1.11.11-0.20240729205337-a0f7e422bb84/go.mod h1:POgZPryqe80OeHCDNrXrPOKoFre736iFuMgmUBeKaLc= github.com/ava-labs/coreth v0.13.7 h1:k8T9u/ROifl8f7oXjHRc1KvSISRl9txvy7gGVmHEz6g= diff --git a/plugin/evm/tx_gossip_test.go b/plugin/evm/tx_gossip_test.go index 10c14e5587..1f04e223ce 100644 --- a/plugin/evm/tx_gossip_test.go +++ b/plugin/evm/tx_gossip_test.go @@ -69,7 +69,7 @@ func TestEthTxGossip(t *testing.T) { network, err := p2p.NewNetwork(logging.NoLog{}, peerSender, prometheus.NewRegistry(), "") require.NoError(err) - client := network.NewClient(ethTxGossipProtocol) + client := network.NewClient(p2p.TxGossipHandlerID) // we only accept gossip requests from validators requestingNodeID := ids.GenerateTestNodeID() @@ -201,7 +201,7 @@ func TestEthTxPushGossipOutbound(t *testing.T) { // we should get a message that has the protocol prefix and the gossip // message - require.Equal(byte(ethTxGossipProtocol), sent[0]) + require.Equal(byte(p2p.TxGossipHandlerID), sent[0]) require.NoError(proto.Unmarshal(sent[1:], got)) marshaller := GossipEthTxMarshaller{} @@ -259,7 +259,7 @@ func TestEthTxPushGossipInbound(t *testing.T) { inboundGossipBytes, err := proto.Marshal(inboundGossip) require.NoError(err) - inboundGossipMsg := append(binary.AppendUvarint(nil, ethTxGossipProtocol), inboundGossipBytes...) + inboundGossipMsg := append(binary.AppendUvarint(nil, p2p.TxGossipHandlerID), inboundGossipBytes...) require.NoError(vm.AppGossip(ctx, ids.EmptyNodeID, inboundGossipMsg)) require.True(vm.txPool.Has(signedTx.Hash())) diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index eaca77a71c..ad380630e4 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -106,9 +106,6 @@ const ( sdkMetricsPrefix = "sdk" chainStateMetricsPrefix = "chain_state" - // p2p app protocols - ethTxGossipProtocol = 0x0 - // gossip constants pushGossipDiscardedElements = 16_384 txGossipBloomMinTargetElements = 8 * 1024 @@ -698,7 +695,7 @@ func (vm *VM) initBlockBuilding() error { vm.cancel = cancel ethTxGossipMarshaller := GossipEthTxMarshaller{} - ethTxGossipClient := vm.Network.NewClient(ethTxGossipProtocol, p2p.WithValidatorSampling(vm.validators)) + ethTxGossipClient := vm.Network.NewClient(p2p.TxGossipHandlerID, p2p.WithValidatorSampling(vm.validators)) ethTxGossipMetrics, err := gossip.NewMetrics(vm.sdkMetrics, ethTxGossipNamespace) if err != nil { return fmt.Errorf("failed to initialize eth tx gossip metrics: %w", err) @@ -762,7 +759,7 @@ func (vm *VM) initBlockBuilding() error { ) } - if err := vm.Network.AddHandler(ethTxGossipProtocol, vm.ethTxGossipHandler); err != nil { + if err := vm.Network.AddHandler(p2p.TxGossipHandlerID, vm.ethTxGossipHandler); err != nil { return err }