Conversation
🤖 Kimi Code ReviewSecurity & Correctness IssuesLine 465-467: The
Line 468: Hardcoded IPv4 assumption - this will crash on IPv6-only networks. Suggested FixReplace the parsing logic with proper error handling: let ip = record.pairs
.iter()
.find(|(key, _)| key.as_ref() == b"ip")
.and_then(|(_, bytes)| {
// Try IPv4 first, then IPv6
Ipv4Addr::decode(bytes.as_ref())
.map(IpAddr::from)
.or_else(|_| Ipv6Addr::decode(bytes.as_ref()).map(IpAddr::from))
})
.unwrap_or_else(|| {
// Log warning and skip this ENR instead of panicking
warn!("Skipping ENR without valid IP: {}", enr);
return None;
})?;Also, the function should return Minor Issues
Automated review by Kimi (Moonshot AI) · custom prompt |
🤖 Codex Code ReviewFocused review of the diff in Findings (ordered by severity)
Security implications
Performance
Rust best practices
Suggested direction
If you want, I can draft a small refactor to handle Suggested next steps:
Automated review by OpenAI Codex · custom prompt |
🤖 Claude Code ReviewBased on my review of the PR, here's my analysis: PR Review: Fix bootnode IP address parsingSummaryThe PR correctly fixes the hardcoded Findings
|
Greptile OverviewGreptile Summary
Confidence Score: 3/5
|
| Filename | Overview |
|---|---|
| crates/net/p2p/src/lib.rs | Parses bootnode IP from ENR record instead of hardcoding 127.0.0.1, but the new code only supports the ENR ip (IPv4) key and will panic for valid ENRs that use ip6/non-IPv4 encodings. |
Sequence Diagram
sequenceDiagram
participant Cfg as Config (bootnodes ENRs)
participant P2P as p2p::start_p2p
participant Parser as parse_enrs
participant ENR as NodeRecord
participant Swarm as libp2p::Swarm
Cfg->>P2P: bootnodes: Vec<String>
P2P->>Parser: parse_enrs(enrs)
loop each enr_str
Parser->>ENR: base64 decode + RLP decode
Parser->>ENR: find "quic" + "secp256k1"
Parser->>ENR: find "ip" (new)
Parser-->>Parser: decode IPv4 bytes => IpAddr
Parser-->>P2P: Bootnode { ip, quic_port, public_key }
end
P2P->>Swarm: dial /ip{ip}/udp/{quic_port}/quic-v1/p2p/{peer_id}
Swarm-->>P2P: ConnectionEstablished / ConnectionClosed events
We had a hardcoded value of 127.0.0.1 for bootnode IPs. This worked for local devnets but not for remote deployments.
This PR adds parsing from the ENRs to populate this value, including both "ip" (IPv4) and "ip6" (IPv6) fields, but using the IPv4 address only if both are specified.