-
Notifications
You must be signed in to change notification settings - Fork 810
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
Delete expensive chain compatibility checks in check_peer_relevance #7056
Conversation
33870c1
to
d5e5d18
Compare
This pull request has merge conflicts. Could you please resolve them @dapplion? 🙏 |
d5e5d18
to
bcedb76
Compare
match remote.finalized_epoch.cmp(&local.finalized_epoch) { | ||
// This peer has a finalized epoch less than ours. This peer is likely to not be | ||
// useful to us, as they want to sync from us. As a nice gesture, we could do work | ||
// from them and check if their finalized_root matches our imported chain. |
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.
// from them and check if their finalized_root matches our imported chain. | |
// for them and check if their finalized_root matches our imported chain. |
// However, this check is unncessary, as if we are incompatible the peer will be | ||
// eventually disconnected anyway. Consider the two cases: | ||
// | ||
// - Peer is our chain: we should forward peer to sync to allow them to sync from us |
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.
// - Peer is our chain: we should forward peer to sync to allow them to sync from us | |
// - Peer is on our chain: we should forward peer to sync to allow them to sync from us |
)) | ||
} | ||
} | ||
// Peer claims to know about a finalized checkpoint ahead of hours. Send peer to |
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.
// Peer claims to know about a finalized checkpoint ahead of hours. Send peer to | |
// Peer claims to know about a finalized checkpoint ahead of ours. Send peer to |
} | ||
} | ||
// Out of bounds root check, allow the peer to connected to us and expect | ||
// they to disconnect or be disconnected if we are in incompatible chains |
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.
// they to disconnect or be disconnected if we are in incompatible chains | |
// them to disconnect or be disconnected if we are in incompatible chains |
)) | ||
} | ||
} | ||
// Out of bounds root check, allow the peer to connected to us and expect |
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.
// Out of bounds root check, allow the peer to connected to us and expect | |
// Out of bounds root check, allow the peer to connect to us and expect |
// chain. | ||
if self | ||
.chain | ||
.block_root_at_slot(remote_finalized_slot, WhenSlotSkipped::Prev) |
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.
If this check is indeed cheap, I would prefer to keep it as it would cause make it harder for peers to sync in a chaotic network if we remove this.
I do not have a sense of how cheap this is though.
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.
It's very cheap, reading a single block root from the freezer is fast (<3ms)
Closing as not required, but feel free to reopon |
Issue Addressed
Extends #5481 not to do any DB reads when processing status messages. These have proven to be very expensive during the Holesky incident
Proposed Changes
I added extensive comments to justify the changes, please check those :)
A working solution that doesn't read anything from the chain is 92a3936. Then 33870c1 covers a bit more ground by using the existing cached head which should be free