-
Notifications
You must be signed in to change notification settings - Fork 1
client connection issues #192
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
Open
vladimir-ea
wants to merge
11
commits into
main
Choose a base branch
from
ve/lh_issues
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e386139
markups
3cd7602
clean up logs
dea9e46
score fix
f9a9ffa
fix bad score timeout
d9026f1
attestation unknown root counter
db5a425
default idel timeout
fe40d45
gossip getting sped past
546976d
gossip getting sped past
9882f8a
manage over population
1a25fdd
manage over population
10acb1e
reject inbound if over capacity
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,7 @@ | ||||||||||
| use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6}; | ||||||||||
| use std::{ | ||||||||||
| net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6}, | ||||||||||
| time::{SystemTime, UNIX_EPOCH}, | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| pub use chain_config::ChainConfig; | ||||||||||
| pub use discovery_config::DiscoveryConfig; | ||||||||||
|
|
@@ -230,6 +233,15 @@ impl Config { | |||||||||
|
|
||||||||||
| pub fn enr(&self) -> Result<Enr, Error> { | ||||||||||
| let mut builder = Enr::builder(); | ||||||||||
| // Remotes only replace a cached record on a strictly higher seq, and | ||||||||||
| // the node key (= node_id) is stable across restarts — a constant | ||||||||||
| // seed pins the network to whatever record it saw first, so record | ||||||||||
| // changes (tcp, attnets) never propagate. Boot time is monotonic | ||||||||||
| // across restarts; in-boot `set_*` bumps of +1 stay far below the | ||||||||||
| // next boot's seed. | ||||||||||
| let boot_seq = | ||||||||||
| SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default().as_millis() as u64; | ||||||||||
| builder.seq(boot_seq); | ||||||||||
| let mut eth2 = [0u8; 16]; | ||||||||||
| eth2[..4].copy_from_slice(&self.fork_digest); | ||||||||||
| eth2[4..8].copy_from_slice(&self.next_fork_version); | ||||||||||
|
|
@@ -250,6 +262,11 @@ impl Config { | |||||||||
| } | ||||||||||
| if let Some(qp) = self.quic_port { | ||||||||||
| builder.quic4(qp).quic6(qp); | ||||||||||
| // Not served: lighthouse's discovery predicate (v8.x | ||||||||||
| // `start_query`) drops ENRs without a tcp port, so QUIC-only | ||||||||||
| // nodes are never dialed by it. Its dialer tries the quic | ||||||||||
| // address first, so advertising tcp gets us QUIC-dialed. | ||||||||||
| builder.tcp4(qp).tcp6(qp); | ||||||||||
|
vladimir-ea marked this conversation as resolved.
|
||||||||||
| } | ||||||||||
| Ok(builder.build(self.keypair()?.secret_key())?) | ||||||||||
| } | ||||||||||
|
|
@@ -296,6 +313,14 @@ impl Config { | |||||||||
| self.discovery_config.clone() | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /// Hard cap on transport connections — inbound accepts are refused at | ||||||||||
| /// the QUIC layer beyond it. Sits above the peer manager's trim band | ||||||||||
| /// (`max_priority_peers` + 10%) so score-based trimming has room to | ||||||||||
| /// work inside it. | ||||||||||
| pub fn max_connections(&self) -> usize { | ||||||||||
| self.peer_score_params.max_priority_peers * 12 / 10 | ||||||||||
| } | ||||||||||
|
|
||||||||||
| pub fn peer_score_params(&self) -> ScoreParams { | ||||||||||
| self.peer_score_params.clone() | ||||||||||
| } | ||||||||||
|
|
@@ -376,6 +401,22 @@ mod tests { | |||||||||
| assert_eq!(cfg.gossip_topics().unwrap().len(), 8); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /// discv5 peers silently drop records over 300 bytes — an oversized ENR | ||||||||||
| /// makes the node invisible to discovery, not degraded. | ||||||||||
| #[test] | ||||||||||
| fn production_enr_fits_discv5_record_cap() { | ||||||||||
| let cfg = Config::new([1u8; 32], [1, 2, 3, 4], [5, 6, 7, 8], 123_456) | ||||||||||
| .with_external_ip_v4(Ipv4Addr::new(203, 0, 113, 7)) | ||||||||||
| .with_discovery_port(9000) | ||||||||||
| .with_quic_port(9001); | ||||||||||
| let mut enr = cfg.enr().unwrap(); | ||||||||||
| let key = cfg.keypair().unwrap(); | ||||||||||
| enr.set_attnets([0xff; 8], key.secret_key()).unwrap(); | ||||||||||
| // Unpadded base64: 4 chars per 3 bytes. | ||||||||||
|
Comment on lines
+413
to
+415
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit —
Suggested change
|
||||||||||
| let bytes = enr.to_base64().trim_start_matches("enr:").len() * 3 / 4; | ||||||||||
| assert!(bytes <= 300, "ENR is {bytes} bytes, discv5 caps records at 300"); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| #[test] | ||||||||||
| fn builders_set_external_ip_and_genesis() { | ||||||||||
| let cfg = Config::new([1u8; 32], [0u8; 4], [0u8; 4], 0) | ||||||||||
|
|
||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion — Seeding the ENR seq from the wall clock assumes boot time is monotonic across restarts, which fails on an NTP step backwards, a VM/container snapshot restore, or a host without RTC sync at boot: the new record then has a lower seq than the one peers cached and no subsequent
set_*bump can catch up, leaving the node advertising a stale address indefinitely. Persisting the last-used seq (or clamping tomax(persisted + 1, now_millis)) removes the clock dependency. Also noteunwrap_or_default()silently yields seq 0.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm really?