mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
Enable both eth/66 and eth/67 by default (#6048)
This commit is contained in:
parent
32629bdce4
commit
14c0643476
@ -521,13 +521,14 @@ Detailed explanation: [./docs/programmers_guide/db_faq.md](./docs/programmers_gu
|
||||
|
||||
| Port | Protocol | Purpose | Expose |
|
||||
|:-----:|:---------:|:----------------------:|:-------:|
|
||||
| 30303 | TCP & UDP | eth/66 or 67 peering | Public |
|
||||
| 30303 | TCP & UDP | eth/66 peering | Public |
|
||||
| 30304 | TCP & UDP | eth/67 peering | Public |
|
||||
| 9090 | TCP | gRPC Connections | Private |
|
||||
| 42069 | TCP & UDP | Snap sync (Bittorrent) | Public |
|
||||
| 6060 | TCP | Metrics or Pprof | Private |
|
||||
| 8551 | TCP | Engine API (JWT auth) | Private |
|
||||
|
||||
Typically, 30303 is exposed to the internet to allow incoming peering connections. 9090 is exposed only
|
||||
Typically, 30303 and 30304 are exposed to the internet to allow incoming peering connections. 9090 is exposed only
|
||||
internally for rpcdaemon or other connections, (e.g. rpcdaemon -> erigon).
|
||||
Port 8551 (JWT authenticated) is exposed only internally for [Engine API] JSON-RPC queries from the Consensus Layer
|
||||
node.
|
||||
|
@ -27,7 +27,7 @@ var (
|
||||
trustedPeers []string // trusted peers
|
||||
discoveryDNS []string
|
||||
nodiscover bool // disable sentry's discovery mechanism
|
||||
protocol int
|
||||
protocol uint
|
||||
netRestrict string // CIDR to restrict peering to
|
||||
maxPeers int
|
||||
maxPendPeers int
|
||||
@ -45,7 +45,7 @@ func init() {
|
||||
rootCmd.Flags().StringSliceVar(&trustedPeers, utils.TrustedPeersFlag.Name, []string{}, utils.TrustedPeersFlag.Usage)
|
||||
rootCmd.Flags().StringSliceVar(&discoveryDNS, utils.DNSDiscoveryFlag.Name, []string{}, utils.DNSDiscoveryFlag.Usage)
|
||||
rootCmd.Flags().BoolVar(&nodiscover, utils.NoDiscoverFlag.Name, false, utils.NoDiscoverFlag.Usage)
|
||||
rootCmd.Flags().IntVar(&protocol, utils.P2pProtocolVersionFlag.Name, utils.P2pProtocolVersionFlag.Value, utils.P2pProtocolVersionFlag.Usage)
|
||||
rootCmd.Flags().UintVar(&protocol, utils.P2pProtocolVersionFlag.Name, utils.P2pProtocolVersionFlag.Value.Value()[0], utils.P2pProtocolVersionFlag.Usage)
|
||||
rootCmd.Flags().StringVar(&netRestrict, utils.NetrestrictFlag.Name, utils.NetrestrictFlag.Value, utils.NetrestrictFlag.Usage)
|
||||
rootCmd.Flags().IntVar(&maxPeers, utils.MaxPeersFlag.Name, utils.MaxPeersFlag.Value, utils.MaxPeersFlag.Usage)
|
||||
rootCmd.Flags().IntVar(&maxPendPeers, utils.MaxPendingPeersFlag.Name, utils.MaxPendingPeersFlag.Value, utils.MaxPendingPeersFlag.Usage)
|
||||
@ -81,14 +81,14 @@ var rootCmd = &cobra.Command{
|
||||
staticPeers,
|
||||
trustedPeers,
|
||||
uint(port),
|
||||
uint(protocol),
|
||||
protocol,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_ = logging2.GetLoggerCmd("sentry", cmd)
|
||||
return sentry.Sentry(cmd.Context(), dirs, sentryAddr, discoveryDNS, p2pConfig, uint(protocol), healthCheck)
|
||||
return sentry.Sentry(cmd.Context(), dirs, sentryAddr, discoveryDNS, p2pConfig, protocol, healthCheck)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -502,10 +502,10 @@ var (
|
||||
Usage: "Network listening port",
|
||||
Value: 30303,
|
||||
}
|
||||
P2pProtocolVersionFlag = cli.IntFlag{
|
||||
P2pProtocolVersionFlag = cli.UintSliceFlag{
|
||||
Name: "p2p.protocol",
|
||||
Usage: "Version of eth p2p protocol",
|
||||
Value: int(nodecfg.DefaultConfig.P2P.ProtocolVersion),
|
||||
Value: cli.NewUintSlice(nodecfg.DefaultConfig.P2P.ProtocolVersion...),
|
||||
}
|
||||
SentryAddrFlag = cli.StringFlag{
|
||||
Name: "sentry.api.addr",
|
||||
@ -951,7 +951,7 @@ func setListenAddress(ctx *cli.Context, cfg *p2p.Config) {
|
||||
cfg.ListenAddr = fmt.Sprintf(":%d", ctx.Int(ListenPortFlag.Name))
|
||||
}
|
||||
if ctx.IsSet(P2pProtocolVersionFlag.Name) {
|
||||
cfg.ProtocolVersion = uint(ctx.Int(P2pProtocolVersionFlag.Name))
|
||||
cfg.ProtocolVersion = ctx.UintSlice(P2pProtocolVersionFlag.Name)
|
||||
}
|
||||
if ctx.IsSet(SentryAddrFlag.Name) {
|
||||
cfg.SentryAddr = SplitAndTrim(ctx.String(SentryAddrFlag.Name))
|
||||
|
@ -26,6 +26,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -155,6 +156,16 @@ type Ethereum struct {
|
||||
agg *libstate.Aggregator22
|
||||
}
|
||||
|
||||
func splitAddrIntoHostAndPort(addr string) (host string, port int, err error) {
|
||||
idx := strings.LastIndexByte(addr, ':')
|
||||
if idx < 0 {
|
||||
return "", 0, errors.New("invalid address format")
|
||||
}
|
||||
host = addr[:idx]
|
||||
port, err = strconv.Atoi(addr[idx+1:])
|
||||
return
|
||||
}
|
||||
|
||||
// New creates a new Ethereum object (including the
|
||||
// initialisation of the common Ethereum object)
|
||||
func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethereum, error) {
|
||||
@ -297,12 +308,22 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cfg := stack.Config().P2P
|
||||
cfg.NodeDatabase = filepath.Join(stack.Config().Dirs.Nodes, eth.ProtocolToString[cfg.ProtocolVersion])
|
||||
server := sentry.NewGrpcServer(backend.sentryCtx, discovery, readNodeInfo, &cfg, cfg.ProtocolVersion)
|
||||
|
||||
backend.sentryServers = append(backend.sentryServers, server)
|
||||
sentries = []direct.SentryClient{direct.NewSentryClientDirect(cfg.ProtocolVersion, server)}
|
||||
refCfg := stack.Config().P2P
|
||||
listenHost, listenPort, err := splitAddrIntoHostAndPort(refCfg.ListenAddr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, protocol := range refCfg.ProtocolVersion {
|
||||
cfg := refCfg
|
||||
cfg.NodeDatabase = filepath.Join(stack.Config().Dirs.Nodes, eth.ProtocolToString[protocol])
|
||||
cfg.ListenAddr = fmt.Sprintf("%s:%d", listenHost, listenPort)
|
||||
listenPort++
|
||||
|
||||
server := sentry.NewGrpcServer(backend.sentryCtx, discovery, readNodeInfo, &cfg, protocol)
|
||||
backend.sentryServers = append(backend.sentryServers, server)
|
||||
sentries = append(sentries, direct.NewSentryClientDirect(protocol, server))
|
||||
}
|
||||
|
||||
go func() {
|
||||
logEvery := time.NewTicker(120 * time.Second)
|
||||
|
@ -45,7 +45,7 @@ var DefaultConfig = Config{
|
||||
WSModules: []string{"net", "web3"},
|
||||
P2P: p2p.Config{
|
||||
ListenAddr: ":30303",
|
||||
ProtocolVersion: 66, // eth/66 by default
|
||||
ProtocolVersion: []uint{66, 67},
|
||||
MaxPeers: 100,
|
||||
MaxPendingPeers: 1000,
|
||||
NAT: nat.Any(),
|
||||
|
@ -140,7 +140,7 @@ type Config struct {
|
||||
ListenAddr string
|
||||
|
||||
// eth/66, eth/67, etc
|
||||
ProtocolVersion uint
|
||||
ProtocolVersion []uint
|
||||
|
||||
SentryAddr []string
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user