Repository navigation
refactor(l1): drop the unused discovery lookup interval config - #7163
Conversation
`DiscoveryConfig::initial_lookup_interval` stopped being read in #6511, which gave iterative lookups their own 500ms -> 10s bounds because each one emits ~16 FindNode messages instead of 1. The field kept being threaded from the CLI into the discovery server, where nothing looked at it. `--p2p.lookup-interval` still governs the RLPx initiator's dial pacing, which is what its help text now says.
`Options::default()` left `lookup_interval` at f64's default of 0.0. Every path built from it (`default_l1`, `default_l2`, the L2 node options) therefore handed the RLPx initiator a 0ms lower bound, so with no peers connected the easing curve returns a zero delay and the initiator re-arms its timer in a tight loop. Use the same constant clap uses for the flag.
|
🤖 Claude Code ReviewConfirmed, no leftover Review: PR 7163 — drop unused discovery lookup interval configThis is a clean, well-scoped dead-code removal plus a real bug fix. I verified the changes against the full call graph ( Correctness
Style / clarity
Minor observations (not blocking)
No correctness, security, or consensus-rule concerns — this only touches peer-discovery/connection pacing, not block/state validation. Automated review by Claude (Anthropic) · sonnet · custom prompt |
🤖 Kimi Code ReviewReview Summary Detailed Feedback 1. Potential dead code in context (cmd/ethrex/network.rs)
2. DiscoveryConfig Default implementation removal (crates/networking/p2p/discovery/mod.rs) 3. Comment accuracy (crates/networking/p2p/discovery/mod.rs) 4. CLI help text improvement (cmd/ethrex/cli.rs) 5. Explicit struct initialization (cmd/ethrex/initializers.rs) 6. No regression in configurability Minor Suggestion Security Assessment
Verdict Automated review by Kimi (Moonshot AI) · kimi-k2.5 · custom prompt |
🤖 Codex Code ReviewFindings
No material correctness, security, performance, or Ethereum-protocol issues stood out in the actual behavior change. The patch looks sound: cmd/ethrex/cli.rs now aligns I could not run Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
Lines of code reportTotal lines added: Detailed view |
The `Verify CLI Help Consistency` job diffs `ethrex --help` against the BEGIN_CLI_HELP block in docs/CLI.md, so rewording the flag's help left the two out of step.
Resolutions, all in main's favor where main superseded the branch: - DiscoveryConfig: main dropped initial_lookup_interval (#7163); the branch's nat_extip_set field is added to main's struct and every construction site sets all three fields explicitly, so the branch's Default impl is gone too. - update_local_ip: main's edit-based version (#7143) wins. It preserves every ENR entry, which strictly subsumes the branch's rebuild that carried over only the fork id. - Discv5State keeps main's shape minus the IP-voting predictor this branch extracts into discovery/ip_predictor.rs. The five in-file voting tests go with the mechanism; their coverage lives on in test/tests/p2p/discovery/ip_predictor_tests.rs, and main's three update_local_ip ENR-preservation tests are kept. - DiscoveryServer drops the branch's store field: main moved ENR building out of discovery (#7147), so discovery no longer needs storage; apply_predicted_ip goes through main's update_local_ip. - start_network/DiscoveryServer::spawn keep main's signatures plus the branch's shared_local_node parameter. - The native-rollup RPC path (#6418, newer than this branch) is ported to the SharedLocalNode-taking init_rpc_api; no discovery runs there, so the shared identity is constant after construction.
…ambdaclass#6811) Follow-up to lambdaclass#6713, which deferred geth-style devp2p endpoint prediction. Closes lambdaclass#6714. On discv4-only devnets the majority-vote IP predictor never reached quorum because it only ran on discv5, so the node kept advertising its private/bridge IP and got 0 inbound peers. Extract `IpPredictor` out of `Discv5State` into `discovery/ip_predictor.rs`, owned by `DiscoveryServer` and fed by both discv4 (`PONG.to`, the peer's observed source of our PING) and discv5 PONGs. Applied via the existing `update_local_ip`, which bumps ENR seq and re-signs. `--nat.extip` sets `ip_override_locked`, preventing any predictor update; address-family mismatches are skipped. Votes discard only never-routable addresses (loopback/link-local/unspecified); RFC1918/unique-local private IPs are kept as candidates. On finalize the predictor prefers a public winner and falls back to a private one only if no public IP reaches quorum. A NAT/SNAT node converges on its public IP (peers observe the routable source); a node on a flat private network (e.g. a kurtosis enclave, where no public IP is ever observed) converges on its reachable private IP instead of advertising nothing. Tests from `discv5/server.rs` are relocated to `ip_predictor.rs`, plus discv4 PONG feeding, flat-network private convergence, and prefer-public-over-private. ## Post-restructure merge (2026-08-27) Main restructured discovery underneath this PR; the merge resolves in main's favor wherever main superseded it: - **`update_local_ip`**: main's edit-based version (lambdaclass#7143) wins — it preserves every ENR entry, strictly subsuming this branch's rebuild that carried over only the fork id. - **`DiscoveryServer` keeps no `store`**: main moved ENR building out of discovery (lambdaclass#7147), so the field this branch added for fork-id re-derivation is no longer needed; `apply_predicted_ip` goes through main's `update_local_ip`. - **`DiscoveryConfig`**: main dropped `initial_lookup_interval` (lambdaclass#7163); only `nat_extip_set` is added, and all construction sites set every field explicitly. - **The five in-file `Discv5State` voting tests** go with the mechanism they tested; their coverage lives on in `test/tests/p2p/discovery/ip_predictor_tests.rs` (8 tests), and main's three `update_local_ip` ENR-preservation tests are kept. - **The native-rollup RPC path** (lambdaclass#6418, newer than this branch) is ported to the `SharedLocalNode`-taking `init_rpc_api`. Post-merge verification: workspace clippy and `--features l2` clippy clean, fmt clean, 105 `ethrex-p2p` unit + 151 p2p integration + 57 rpc integration tests pass, and the vote wiring is confirmed intact (discv4 PONG → `record_ip_vote` → `apply_predicted_ip("discv4")`, discv5 likewise, prune tick → `check_timeout` → `apply_predicted_ip("timeout")`). ## Test plan - `cargo test -p ethrex-test ip_predictor` passes - discv4-only devnet (discv5 disabled): node converges to the correct external IP after 3 PONGs from distinct peers - `--nat.extip` still hard-locks the advertised address --------- Co-authored-by: ilitteri <ivanlitteri@hotmail.com> Co-authored-by: Ivan Litteri <67517699+ilitteri@users.noreply.github.com>
Motivation
DiscoveryConfig::initial_lookup_intervalis dead data. #6511 (kademliak-bucket routing table v2) replaced the configurable bound in
DiscoveryServer::get_lookup_intervalwith its own constants, becauseeach iterative lookup emits ~16 FindNode messages instead of 1 and
needed a rescaled schedule:
lookup_interval_function( peer_completion, - self.config.initial_lookup_interval, - super::LOOKUP_INTERVAL_MS, + ITERATIVE_LOOKUP_INITIAL_MS, // 500.0 + ITERATIVE_LOOKUP_INTERVAL_MS, // 10_000.0 )The field itself survived, still threaded from
--p2p.lookup-intervalthrough
P2PContextandstart_networkinto aDiscoveryServerthatnever reads it. The only live consumer of the flag is the RLPx
initiator, so the help text was also misleading.
While tracing it, a second problem turned up:
impl Default for Optionssets
lookup_interval: Default::default(), which is0.0forf64rather than the
INITIAL_LOOKUP_INTERVAL_MSthat clap uses for theflag.
default_l1(),default_l2()and the L2 node options all buildon that impl, so they hand the RLPx initiator a 0ms lower bound. With no
peers connected the easing curve returns
Duration::ZERO, andhandle_look_for_peerre-arms its timer with no delay at all. Presentsince #5518 added the flag.
Description
initial_lookup_intervalfromDiscoveryConfigand stopoverriding it in
start_network.DiscoveryConfig'sDefaultimplgoes with it: both remaining fields are set explicitly at the single
construction site, and clap already defaults them to
true.--p2p.lookup-interval's help to describe what it actuallycontrols, and refresh the now-stale doc comments on
INITIAL_LOOKUP_INTERVAL_MS/LOOKUP_INTERVAL_MS/lookup_interval_function.Options::lookup_intervaltoINITIAL_LOOKUP_INTERVAL_MS.No behavior change for the discovery server, which was already running
on its own constants. The second commit does change behavior for the
dev/L2 paths that go through
Options::default(), restoring the 100msfloor they were meant to have.
Checklist
STORE_SCHEMA_VERSION(crates/storage/lib.rs) if the PR includes breaking changes to theStorerequiring a re-sync.