Skip to content

Commit d917d9c

Browse files
update const name
1 parent bebdd56 commit d917d9c

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.20
44

55
require (
66
github.com/VictoriaMetrics/fastcache v1.10.0
7-
github.com/ava-labs/avalanchego v1.10.18-rc.15
7+
github.com/ava-labs/avalanchego v1.10.18-rc.5.0.20240105233604-41587de9c530
88
github.com/cespare/cp v0.1.0
99
github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811
1010
github.com/davecgh/go-spew v1.1.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah
5555
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
5656
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
5757
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
58-
github.com/ava-labs/avalanchego v1.10.18-rc.15 h1:8HVOLBbaZnvE9YNL89DzUk+na9zluAz+GGbAwTXZZQs=
59-
github.com/ava-labs/avalanchego v1.10.18-rc.15/go.mod h1:FsejaXWTz6rgjpk1dEbXUJvhX/Ip6ADmD4Q8WZHRNuY=
58+
github.com/ava-labs/avalanchego v1.10.18-rc.5.0.20240105233604-41587de9c530 h1:hIuoG2qeGhEuLXtspStQBidJPLl3jBrTxVe8yXIuXp4=
59+
github.com/ava-labs/avalanchego v1.10.18-rc.5.0.20240105233604-41587de9c530/go.mod h1:IbHVBINt8W+725XChBtmiUHHCGlVbakvjQYsYaHM4xs=
6060
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
6161
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
6262
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=

plugin/evm/gossip.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func (tx *GossipAtomicTx) GossipID() ids.ID {
109109
}
110110

111111
func NewGossipEthTxPool(mempool *txpool.TxPool) (*GossipEthTxPool, error) {
112-
bloom, err := gossip.NewBloomFilter(txGossipBloomMaxItems, txGossipBloomFalsePositiveRate)
112+
bloom, err := gossip.NewBloomFilter(txGossipBloomMinTargetItems, txGossipBloomTargetFalsePositiveRate, txGossipBloomResetFalsePositiveRate)
113113
if err != nil {
114114
return nil, fmt.Errorf("failed to initialize bloom filter: %w", err)
115115
}
@@ -139,10 +139,11 @@ func (g *GossipEthTxPool) Subscribe(ctx context.Context) {
139139
return
140140
case pendingTxs := <-g.pendingTxs:
141141
g.lock.Lock()
142+
optimalSize := g.mempool.PendingSize() + len(pendingTxs.Txs) // should never come close to overflowing
142143
for _, pendingTx := range pendingTxs.Txs {
143144
tx := &GossipEthTx{Tx: pendingTx}
144145
g.bloom.Add(tx)
145-
reset, err := gossip.ResetBloomFilterIfNeeded(g.bloom, txGossipMaxFalsePositiveRate)
146+
reset, err := gossip.ResetBloomFilterIfNeeded(g.bloom, optimalSize)
146147
if err != nil {
147148
log.Error("failed to reset bloom filter", "err", err)
148149
continue

plugin/evm/mempool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ type Mempool struct {
8686

8787
// NewMempool returns a Mempool with [maxSize]
8888
func NewMempool(ctx *snow.Context, maxSize int, verify func(tx *Tx) error) (*Mempool, error) {
89-
bloom, err := gossip.NewBloomFilter(txGossipBloomMaxItems, txGossipBloomFalsePositiveRate)
89+
bloom, err := gossip.NewBloomFilter(txGossipBloomMinTargetItems, txGossipBloomTargetFalsePositiveRate, txGossipBloomResetFalsePositiveRate)
9090
if err != nil {
9191
return nil, fmt.Errorf("failed to initialize bloom filter: %w", err)
9292
}
@@ -340,7 +340,7 @@ func (m *Mempool) addTx(tx *Tx, force bool) error {
340340
}
341341

342342
m.bloom.Add(&GossipAtomicTx{Tx: tx})
343-
reset, err := gossip.ResetBloomFilterIfNeeded(m.bloom, txGossipMaxFalsePositiveRate)
343+
reset, err := gossip.ResetBloomFilterIfNeeded(m.bloom, m.length())
344344
if err != nil {
345345
return err
346346
}

plugin/evm/vm.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,15 @@ const (
141141
atomicTxGossipProtocol = 0x1
142142

143143
// gossip constants
144-
txGossipBloomMaxItems = 8 * 1024
145-
txGossipBloomFalsePositiveRate = 0.01
146-
txGossipMaxFalsePositiveRate = 0.05
147-
txGossipTargetMessageSize = 20 * units.KiB
148-
maxValidatorSetStaleness = time.Minute
149-
txGossipThrottlingPeriod = 10 * time.Second
150-
txGossipThrottlingLimit = 2
151-
gossipFrequency = 10 * time.Second
152-
txGossipPollSize = 10
144+
txGossipBloomMinTargetItems = 8 * 1024
145+
txGossipBloomTargetFalsePositiveRate = 0.01
146+
txGossipBloomResetFalsePositiveRate = 0.05
147+
txGossipTargetMessageSize = 20 * units.KiB
148+
maxValidatorSetStaleness = time.Minute
149+
txGossipThrottlingPeriod = 10 * time.Second
150+
txGossipThrottlingLimit = 2
151+
gossipFrequency = 10 * time.Second
152+
txGossipPollSize = 10
153153
)
154154

155155
// Define the API endpoints for the VM

0 commit comments

Comments
 (0)