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

cleanup: use p2p.TxGossipHandlerID #1266

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
6 changes: 3 additions & 3 deletions plugin/evm/tx_gossip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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{}
Expand Down Expand Up @@ -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()))
Expand Down
7 changes: 2 additions & 5 deletions plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ const (
sdkMetricsPrefix = "sdk"
chainStateMetricsPrefix = "chain_state"

// p2p app protocols
ethTxGossipProtocol = 0x0

// gossip constants
pushGossipDiscardedElements = 16_384
txGossipBloomMinTargetElements = 8 * 1024
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

Expand Down
Loading