Skip to content

Commit

Permalink
[network] Remove Legacy Gossiper + Only Push Gossip from RPC (ava-lab…
Browse files Browse the repository at this point in the history
…s#497)

Co-authored-by: Joshua Kim <[email protected]>
Co-authored-by: Stephen Buttolph <[email protected]>
Co-authored-by: Darioush Jalali <[email protected]>
  • Loading branch information
4 people authored and oxbee committed Nov 6, 2024
1 parent 2af7a1d commit d4fcd44
Show file tree
Hide file tree
Showing 20 changed files with 369 additions and 1,222 deletions.
9 changes: 8 additions & 1 deletion eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,14 @@ func (b *EthAPIBackend) SendTx(ctx context.Context, signedTx *types.Transaction)
if err := ctx.Err(); err != nil {
return err
}
return b.eth.txPool.AddLocal(signedTx)
if err := b.eth.txPool.AddLocal(signedTx); err != nil {
return err
}

// We only enqueue transactions for push gossip if they were submitted over the RPC and
// added to the mempool.
b.eth.gossiper.Add(signedTx)
return nil
}

func (b *EthAPIBackend) GetPoolTransactions() (types.Transactions, error) {
Expand Down
9 changes: 9 additions & 0 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,20 @@ type Settings struct {
MaxBlocksPerRequest int64 // Maximum number of blocks to serve per getLogs request
}

// PushGossiper sends pushes pending transactions to peers until they are
// removed from the mempool.
type PushGossiper interface {
Add(*types.Transaction)
}

// Ethereum implements the Ethereum full node service.
type Ethereum struct {
config *Config

// Handlers
txPool *txpool.TxPool
blockchain *core.BlockChain
gossiper PushGossiper

// DB interfaces
chainDb ethdb.Database // Block chain database
Expand Down Expand Up @@ -118,6 +125,7 @@ func New(
stack *node.Node,
config *Config,
cb dummy.ConsensusCallbacks,
gossiper PushGossiper,
chainDb ethdb.Database,
settings Settings,
lastAcceptedHash common.Hash,
Expand Down Expand Up @@ -151,6 +159,7 @@ func New(

eth := &Ethereum{
config: config,
gossiper: gossiper,
chainDb: chainDb,
eventMux: new(event.TypeMux),
accountManager: stack.AccountManager(),
Expand Down
47 changes: 23 additions & 24 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21

require (
github.com/VictoriaMetrics/fastcache v1.10.0
github.com/ava-labs/avalanchego v1.11.1
github.com/ava-labs/avalanchego v1.11.2-rc.3
github.com/cespare/cp v0.1.0
github.com/davecgh/go-spew v1.1.1
github.com/deckarep/golang-set/v2 v2.1.0
Expand All @@ -13,7 +13,7 @@ require (
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5
github.com/fsnotify/fsnotify v1.6.0
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08
github.com/google/uuid v1.3.0
github.com/google/uuid v1.6.0
github.com/gorilla/rpc v1.2.0
github.com/gorilla/websocket v1.4.2
github.com/hashicorp/go-bexpr v0.1.10
Expand All @@ -34,15 +34,15 @@ require (
github.com/stretchr/testify v1.8.4
github.com/tyler-smith/go-bip39 v1.1.0
github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa
go.uber.org/goleak v1.2.1
go.uber.org/goleak v1.3.0
go.uber.org/mock v0.4.0
golang.org/x/crypto v0.17.0
golang.org/x/crypto v0.18.0
golang.org/x/exp v0.0.0-20231127185646-65229373498e
golang.org/x/sync v0.5.0
golang.org/x/sys v0.15.0
golang.org/x/sync v0.6.0
golang.org/x/sys v0.16.0
golang.org/x/text v0.14.0
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af
google.golang.org/protobuf v1.31.0
google.golang.org/protobuf v1.32.0
gopkg.in/natefinch/lumberjack.v2 v2.0.0
)

Expand All @@ -52,7 +52,7 @@ require (
github.com/bits-and-blooms/bitset v1.7.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/btcsuite/btcd/btcutil v1.1.3 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/errors v1.9.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
Expand All @@ -67,7 +67,7 @@ require (
github.com/dlclark/regexp2 v1.7.0 // indirect
github.com/ethereum/c-kzg-4844 v0.2.0 // indirect
github.com/getsentry/sentry-go v0.18.0 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
Expand All @@ -81,7 +81,7 @@ require (
github.com/google/renameio/v2 v2.0.0 // indirect
github.com/graph-gophers/graphql-go v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.12.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huin/goupnp v1.0.3 // indirect
github.com/influxdata/influxdb-client-go/v2 v2.4.0 // indirect
Expand Down Expand Up @@ -119,23 +119,22 @@ require (
github.com/tklauser/numcpus v0.2.2 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.opentelemetry.io/otel v1.11.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.11.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.11.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.11.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.11.0 // indirect
go.opentelemetry.io/otel/sdk v1.11.0 // indirect
go.opentelemetry.io/otel/trace v1.11.0 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
go.opentelemetry.io/otel v1.22.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.22.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.22.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.22.0 // indirect
go.opentelemetry.io/otel/metric v1.22.0 // indirect
go.opentelemetry.io/otel/sdk v1.22.0 // indirect
go.opentelemetry.io/otel/trace v1.22.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
go.uber.org/multierr v1.10.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/term v0.16.0 // indirect
gonum.org/v1/gonum v0.11.0 // indirect
google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/grpc v1.58.3 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/grpc v1.62.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
Loading

0 comments on commit d4fcd44

Please sign in to comment.