Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.
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: 1 addition & 1 deletion plugin/evm/gossip.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func newTxGossipHandler[T gossip.Gossipable](
maxMessageSize int,
throttlingPeriod time.Duration,
throttlingLimit int,
validators *p2p.Validators,
validators p2p.ValidatorSet,
) txGossipHandler {
// push gossip messages can be handled from any peer
handler := gossip.NewHandler(
Expand Down
19 changes: 19 additions & 0 deletions plugin/evm/validators.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package evm

import (
"context"

"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/set"
)

type validatorSet struct {
set set.Set[ids.NodeID]
}

func (v *validatorSet) Has(ctx context.Context, nodeID ids.NodeID) bool {
return v.set.Contains(nodeID)
}
55 changes: 35 additions & 20 deletions plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,11 @@ func (vm *VM) initBlockBuilding() error {
vm.builder = vm.NewBlockBuilder(vm.toEngine)
vm.builder.awaitSubmittedTxs()

var p2pValidators p2p.ValidatorSet = &validatorSet{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will work but might leave confusing logs in DEBUG as we log when we drop messages because it's not a validator. An alternative would be to use p2p.NoOpHandler

if vm.config.PullGossipFrequency.Duration > 0 {
p2pValidators = vm.p2pValidators
}

if vm.ethTxGossipHandler == nil {
vm.ethTxGossipHandler = newTxGossipHandler[*GossipEthTx](
vm.ctx.Log,
Expand All @@ -1129,7 +1134,7 @@ func (vm *VM) initBlockBuilding() error {
txGossipTargetMessageSize,
txGossipThrottlingPeriod,
txGossipThrottlingLimit,
vm.p2pValidators,
p2pValidators,
)
}

Expand All @@ -1146,7 +1151,7 @@ func (vm *VM) initBlockBuilding() error {
txGossipTargetMessageSize,
txGossipThrottlingPeriod,
txGossipThrottlingLimit,
vm.p2pValidators,
p2pValidators,
)
}

Expand All @@ -1171,15 +1176,20 @@ func (vm *VM) initBlockBuilding() error {
}
}

vm.shutdownWg.Add(2)
go func() {
gossip.Every(ctx, vm.ctx.Log, ethTxPushGossiper, vm.config.PushGossipFrequency.Duration)
vm.shutdownWg.Done()
}()
go func() {
gossip.Every(ctx, vm.ctx.Log, vm.ethTxPullGossiper, vm.config.PullGossipFrequency.Duration)
vm.shutdownWg.Done()
}()
if vm.config.PushGossipFrequency.Duration > 0 {
vm.shutdownWg.Add(1)
go func() {
gossip.Every(ctx, vm.ctx.Log, ethTxPushGossiper, vm.config.PushGossipFrequency.Duration)
vm.shutdownWg.Done()
}()
}
if vm.config.PullGossipFrequency.Duration > 0 {
vm.shutdownWg.Add(1)
go func() {
gossip.Every(ctx, vm.ctx.Log, vm.ethTxPullGossiper, vm.config.PullGossipFrequency.Duration)
vm.shutdownWg.Done()
}()
}

if vm.atomicTxPullGossiper == nil {
atomicTxPullGossiper := gossip.NewPullGossiper[*atomic.GossipAtomicTx](
Expand All @@ -1198,15 +1208,20 @@ func (vm *VM) initBlockBuilding() error {
}
}

vm.shutdownWg.Add(2)
go func() {
gossip.Every(ctx, vm.ctx.Log, vm.atomicTxPushGossiper, vm.config.PushGossipFrequency.Duration)
vm.shutdownWg.Done()
}()
go func() {
gossip.Every(ctx, vm.ctx.Log, vm.atomicTxPullGossiper, vm.config.PullGossipFrequency.Duration)
vm.shutdownWg.Done()
}()
if vm.config.PushGossipFrequency.Duration > 0 {
vm.shutdownWg.Add(1)
go func() {
gossip.Every(ctx, vm.ctx.Log, vm.atomicTxPushGossiper, vm.config.PushGossipFrequency.Duration)
vm.shutdownWg.Done()
}()
}
if vm.config.PullGossipFrequency.Duration > 0 {
vm.shutdownWg.Add(1)
go func() {
gossip.Every(ctx, vm.ctx.Log, vm.atomicTxPullGossiper, vm.config.PullGossipFrequency.Duration)
vm.shutdownWg.Done()
}()
}

return nil
}
Expand Down
Loading