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

Delete expensive chain compatibility checks in check_peer_relevance #7056

Closed
wants to merge 2 commits into from

Conversation

dapplion
Copy link
Collaborator

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

@dapplion dapplion requested a review from jxs as a code owner February 27, 2025 17:57
@dapplion dapplion added the ready-for-review The code is ready for review label Feb 27, 2025
@pawanjay176 pawanjay176 changed the base branch from unstable to holesky-rescue February 27, 2025 18:19
Copy link

mergify bot commented Feb 27, 2025

This pull request has merge conflicts. Could you please resolve them @dapplion? 🙏

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.
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
// 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
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
// - 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
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
// 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
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
// 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
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
// 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)
Copy link
Member

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.

Copy link
Member

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)

@michaelsproul
Copy link
Member

Closing as not required, but feel free to reopon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-review The code is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants