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

[Fix] Clear cached validator requests on disconnect #3254

Merged
merged 3 commits into from
May 23, 2024

Conversation

niklaslong
Copy link
Collaborator

@niklaslong niklaslong commented May 13, 2024

This PR clears the validator requests cache map for a particular peer on disconnect. This ensures the collection is periodically cleaned up despite not having a time-based expiry and is sufficient to avoid infinite growth as the committee size is bounded (but the IP may change).

A small aside for future discussion: when time permits, we may want to revisit our approach to cache invalidation both in the gateway and the router. One option would be to use an LRU with a fixed size that we clear on specific state transitions (e.g. on round increment).

@niklaslong niklaslong changed the title [Fix] clear cached validator requests on disconnect [Fix] Clear cached validator requests on disconnect May 13, 2024
@niklaslong niklaslong marked this pull request as ready for review May 14, 2024 11:45
Comment on lines 43 to 45
/// Note: we don't clear this map based on time but only on peer disconnect.
/// This is sufficient to avoid infinite growth as the committee has a fixed number
/// of members.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Note: we don't clear this map based on time but only on peer disconnect.
/// This is sufficient to avoid infinite growth as the committee has a fixed number
/// of members.
/// The map of IPs to the number of validators requests

This shouldn't be explained within the struct member comment, but instead on the invocation of clear_outbound_validators_requests

node/bft/src/gateway.rs Show resolved Hide resolved
Copy link
Contributor

@raychu86 raychu86 left a comment

Choose a reason for hiding this comment

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

LGTM,

The only use of seen_outbound_validators_requests is when we check that an incoming ValidatorsResponse corresponds to an existing ValidatorsRequest.

@howardwu howardwu merged commit 7ff06a8 into AleoNet:mainnet-staging May 23, 2024
zosorock added a commit that referenced this pull request May 24, 2024
This reverts commit 7ff06a8, reversing
changes made to 9cc67c9.
@niklaslong niklaslong deleted the fix/cache branch May 24, 2024 09:00
vicsn added a commit to AleoHQ/snarkOS that referenced this pull request May 28, 2024
joske pushed a commit to eqlabs/snarkOS that referenced this pull request May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants