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

feat(census): keep track of liveness checks #1575

Merged
merged 2 commits into from
Nov 1, 2024

Conversation

morph-dev
Copy link
Collaborator

What was wrong?

Census doesn't keep track of previous liveness checks or other request sent to peers.

Needed for: #1501

How was it fixed?

This PR does ground work focused on liveness checks, and followup PR will introduce other requests (that will later be used for peer scoring).

@morph-dev
Copy link
Collaborator Author

Followup PR: #1576

Copy link
Member

@KolbyML KolbyML left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit: looks good

Comment on lines 84 to 86
} else {
self.enr = enr.clone();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else {
self.enr = enr.clone();
}
} else if self.enr.seq() < enr.seq() {
self.enr = enr.clone();
}

it probably doesn't matter, but wouldn't we only need to do the clone if a updated enr was given, which should be fairly infrequent so we might as well avoid the clone

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed function signature so it accepts Enr, in which case we never clone it.


let total_peers = self.network.peers.len();
let ending_peers = self.network.peers.len();
let new_peers = ending_peers - starting_peers;
Copy link
Member

@KolbyML KolbyML Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am assuming the possibility that new_peers can be negative is a feature to display we lost peers? Because isn't there a case where ending_peers can be less then starting_peers i.e. if more peers were removed then added?

This doesn't really look like an issue, just wanted to point it out.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about it and concluded that it shouldn't happen. Unless there is some weird race-condition and/or Census is performing very badly.

But, you are right, it's technically possible. It's also possible that we change logic in the future and forget to update and this would panic (or difference no longer means that these are added).

So I updated the code to not panic and changed the message.

@morph-dev morph-dev merged commit 40f5b7b into ethereum:master Nov 1, 2024
9 checks passed
@morph-dev morph-dev deleted the liveness_checks branch November 1, 2024 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
portal-bridge Portal bridge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants