Skip to content
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 op-node/flags/p2p_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ var (
}
UserAgent = cli.StringFlag{
Name: "p2p.useragent",
Usage: "User-agent string to share via LibP2P identify. If empty it defaults to 'optimism-VERSIONHERE'.",
Usage: "User-agent string to share via LibP2P identify. If empty it defaults to 'optimism'.",
Hidden: true,
Required: false,
Value: "optimism",
Expand Down
5 changes: 4 additions & 1 deletion op-node/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type OpNode struct {
l2Engines []*driver.Driver // engines to keep synced
l2Nodes []*rpc.Client // L2 Execution Engines to close at shutdown
server *rpcServer // RPC server hosting the rollup-node API
p2pNode p2p.Node // P2P node functionality
p2pNode *p2p.NodeP2P // P2P node functionality
p2pSigner p2p.Signer // p2p gogssip application messages will be signed with this signer
tracer Tracer // tracer to get events for testing/debugging

Expand Down Expand Up @@ -221,6 +221,9 @@ func (n *OpNode) initP2P(ctx context.Context, cfg *Config) error {
return err
}
n.p2pNode = p2pNode
if n.p2pNode.Dv5Udp() != nil {
go n.p2pNode.DiscoveryProcess(n.resourcesCtx, n.log, &cfg.Rollup, cfg.P2P.TargetPeers())
}
}
return nil
}
Expand Down
9 changes: 8 additions & 1 deletion op-node/p2p/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"strings"
"time"

"github.com/ethereum-optimism/optimism/op-node/rollup"

"github.com/libp2p/go-libp2p-core/peer"

"github.com/ethereum/go-ethereum/log"
Expand Down Expand Up @@ -44,7 +46,8 @@ type SetupP2P interface {
// Host creates a libp2p host service. Returns nil, nil if p2p is disabled.
Host(log log.Logger) (host.Host, error)
// Discovery creates a disc-v5 service. Returns nil, nil, nil if discovery is disabled.
Discovery(log log.Logger) (*enode.LocalNode, *discover.UDPv5, error)
Discovery(log log.Logger, rollupCfg *rollup.Config, tcpPort uint16) (*enode.LocalNode, *discover.UDPv5, error)
TargetPeers() uint
}

// Config sets up a p2p host and discv5 service from configuration.
Expand Down Expand Up @@ -175,6 +178,10 @@ func NewConfig(ctx *cli.Context) (*Config, error) {
return conf, nil
}

func (conf *Config) TargetPeers() uint {
return conf.PeersLo
}

func (conf *Config) loadListenOpts(ctx *cli.Context) error {
listenIP := ctx.GlobalString(flags.ListenIP.Name)
if listenIP != "" { // optional
Expand Down
Loading