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

op-node: Remove ConnGater and ConnMngr constructors from p2p config #5733

Merged
merged 2 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 0 additions & 3 deletions op-node/p2p/cli/load_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ func NewConfig(ctx *cli.Context, blockTime uint64) (*p2p.Config, error) {
return nil, fmt.Errorf("failed to load p2p topic scoring options: %w", err)
}

conf.ConnGater = p2p.DefaultConnGater
conf.ConnMngr = p2p.DefaultConnManager

conf.EnableReqRespSync = ctx.GlobalBool(flags.SyncReqRespFlag.Name)

return conf, nil
Expand Down
9 changes: 0 additions & 9 deletions op-node/p2p/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ type Config struct {
// Underlying store that hosts connection-gater and peerstore data.
Store ds.Batching

ConnGater func(conf *Config) (connmgr.ConnectionGater, error)
ConnMngr func(conf *Config) (connmgr.ConnManager, error)

EnableReqRespSync bool
}

Expand Down Expand Up @@ -193,12 +190,6 @@ func (conf *Config) Check() error {
if conf.PeersLo == 0 || conf.PeersHi == 0 || conf.PeersLo > conf.PeersHi {
return fmt.Errorf("peers lo/hi tides are invalid: %d, %d", conf.PeersLo, conf.PeersHi)
}
if conf.ConnMngr == nil {
return errors.New("need a connection manager")
}
if conf.ConnGater == nil {
return errors.New("need a connection gater")
}
if conf.MeshD <= 0 || conf.MeshD > maxMeshParam {
return fmt.Errorf("mesh D param must not be 0 or exceed %d, but got %d", maxMeshParam, conf.MeshD)
}
Expand Down
4 changes: 2 additions & 2 deletions op-node/p2p/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ func (conf *Config) Host(log log.Logger, reporter metrics.Reporter) (host.Host,
return nil, fmt.Errorf("failed to set up peerstore with pub key: %w", err)
}

connGtr, err := conf.ConnGater(conf)
connGtr, err := DefaultConnGater(conf)
if err != nil {
return nil, fmt.Errorf("failed to open connection gater: %w", err)
}

connMngr, err := conf.ConnMngr(conf)
connMngr, err := DefaultConnManager(conf)
if err != nil {
return nil, fmt.Errorf("failed to open connection manager: %w", err)
}
Expand Down
10 changes: 0 additions & 10 deletions op-node/p2p/host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ import (
ds "github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/sync"
"github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p/core/connmgr"
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
tswarm "github.com/libp2p/go-libp2p/p2p/net/swarm/testing"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"

Expand Down Expand Up @@ -54,10 +52,6 @@ func TestingConfig(t *testing.T) *Config {
TimeoutAccept: time.Second * 2,
TimeoutDial: time.Second * 2,
Store: sync.MutexWrap(ds.NewMapDatastore()),
ConnGater: func(conf *Config) (connmgr.ConnectionGater, error) {
return tswarm.DefaultMockConnectionGater(), nil
},
ConnMngr: DefaultConnManager,
}
}

Expand Down Expand Up @@ -113,8 +107,6 @@ func TestP2PFull(t *testing.T) {
TimeoutAccept: time.Second * 2,
TimeoutDial: time.Second * 2,
Store: sync.MutexWrap(ds.NewMapDatastore()),
ConnGater: DefaultConnGater,
ConnMngr: DefaultConnManager,
}
// copy config A, and change the settings for B
confB := confA
Expand Down Expand Up @@ -262,8 +254,6 @@ func TestDiscovery(t *testing.T) {
TimeoutDial: time.Second * 2,
Store: sync.MutexWrap(ds.NewMapDatastore()),
DiscoveryDB: discDBA,
ConnGater: DefaultConnGater,
ConnMngr: DefaultConnManager,
}
// copy config A, and change the settings for B
confB := confA
Expand Down