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

Issue168: fix es-node crash when --p2p.disable set #170

Merged
merged 8 commits into from
Jan 19, 2024
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ The full list of options that you can use to configure an es-node are as follows
|`--p2p.advertise.udp`|The UDP port to advertise in Discv5 as fallback if not determined by Discv5, put into the ENR of the node. Set to p2p.listen.udp value if 0.|`0`||
|`--p2p.ban.peers`|Enables peer banning. This should ONLY be enabled once certain peer scoring is working correctly.|||
|`--p2p.bootnodes`|Comma-separated base64-format ENR list. Bootnodes to start discovering other node records from.|||
|`--p2p.disable`|Completely disable the P2P stack|||
|`--p2p.disable`|Completely disable the P2P stack, if P2P is disabled, mining will not start automatically.|||
|`--p2p.discovery.path`|Discovered ENRs are persisted in a database to recover from a restart without having to bootstrap the discovery process again. Set to 'memory' to never persist the peerstore.|`esnode_discovery_db`||
|`--p2p.listen.ip`|IP to bind LibP2P and Discv5 to|`0.0.0.0`||
|`--p2p.listen.tcp`|TCP port to bind LibP2P to. Any available system port if set to 0.|`9222`||
Expand Down
2 changes: 1 addition & 1 deletion ethstorage/flags/p2p_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func p2pEnv(v string) string {
var (
DisableP2P = cli.BoolFlag{
Name: "p2p.disable",
Usage: "Completely disable the P2P stack",
Usage: "Completely disable the P2P stack, if P2P is disabled, mining will not start automatically.",
Required: false,
EnvVar: p2pEnv("DISABLE"),
}
Expand Down
8 changes: 5 additions & 3 deletions ethstorage/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,11 @@ func (n *EsNode) Start(ctx context.Context, cfg *Config) error {
return err
}

if err := n.p2pNode.Start(); err != nil {
n.log.Error("Could not start a p2pNode", "err", err)
return err
if n.p2pNode != nil {
if err := n.p2pNode.Start(); err != nil {
n.log.Error("Could not start a p2pNode", "err", err)
return err
}
}

return nil
Expand Down
5 changes: 4 additions & 1 deletion ethstorage/p2p/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,10 @@ func (n *NodeP2P) ConnectionManager() connmgr.ConnManager {
}

func (n *NodeP2P) Start() error {
return n.syncCl.Start()
if n.syncCl != nil {
return n.syncCl.Start()
}
return nil
}

func (n *NodeP2P) Close() error {
Expand Down