Commit 8bdbfc9
authored
feat(cli): add the --discovery.* option group (#580)
## What
Adds the three operator-facing flags the discv5 work needs, on their
own, so
the implementation PR (#579) is confined to the p2p crate.
| Flag | Default | Meaning |
| --- | --- | --- |
| `--discovery.enable` | `false` | turn discv5 peer discovery on |
| `--discovery.port` | `9000` | UDP port for the discv5 socket |
| `--discovery.advertise-ip` | unset | IP to advertise in the ENR |
The flags parse and validate here. **Nothing reads them yet**, which is
the
point of splitting them out: this is reviewable on its own and cannot
change
runtime behaviour of a node that does not pass them.
## Why the port validation
`--discovery.port` and `--gossipsub-port` are both UDP and both default
to
9000, so enabling discovery without moving one of them collides. Left
unchecked, that surfaces at bind time as an opaque `EADDRINUSE` on
whichever
socket loses the race, pointing at neither flag.
`CliOptions::validate_discovery`
rejects it at startup with a message naming both flags and their values.
The check only fires when discovery is enabled, so the shared default is
harmless for every existing deployment.
## Why `--discovery.advertise-ip`
The node binds the wildcard `0.0.0.0`, which is not dialable as
published. A
node whose reachable address differs from what it listens on (a devnet
on
`127.0.0.1`, or a host behind NAT) needs to say so explicitly. discv5's
PONG-based IP voting may still learn and substitute the real external
address
at runtime; this only sets what the ENR carries at startup.
## Testing
- `make lint` clean.
- Colliding ports are rejected by name:
```
$ ethlambda ... --discovery.enable
Error: --discovery.port (9000) must differ from --gossipsub-port (9000):
both bind UDP and cannot share a port
```
- Distinct ports pass validation and startup proceeds:
```
$ ethlambda ... --discovery.enable --discovery.port 9010
Error: failed to load node key from /nonexistent/node.key
```
- The group renders under `--help` with its dotted prefixes intact.
## Relationship to #579
#579 carries the discv5 implementation and currently includes these same
flags. If this lands first, #579 rebases onto it and drops the `cli.rs`
hunk.1 parent 7ecd85f commit 8bdbfc9
2 files changed
Lines changed: 47 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
116 | 118 | | |
117 | 119 | | |
118 | 120 | | |
119 | 121 | | |
120 | 122 | | |
121 | 123 | | |
122 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
123 | 169 | | |
124 | 170 | | |
125 | 171 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
| |||
0 commit comments