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

Make SingleLookupRequestState fields private #5563

Merged
merged 2 commits into from
Apr 15, 2024

Conversation

dapplion
Copy link
Collaborator

@dapplion dapplion commented Apr 11, 2024

Issue Addressed

SingleLookupRequestState fields are public and mutated all over the place. This makes the code unnecessarily difficult to follow. Instead, its fields should be private and mutated through setters such that looking the the implementation of SingleLookupRequestState is sufficient to view and understand all possible state transitions.

Part of:

Proposed Changes

  • Make SingleLookupRequestState fields private
  • Move state transition to download result from verify_response_inner (specific per request) to verify_response (generic for the trait)
  • In verify_response use the actual response sending peer instead of the one being tracked in the state. See code comment about potential inconsistencies.

A future PR should add more checks in setters like on_download_success such that a state transition from Processed -> Downloading is not possible

@realbigsean
Copy link
Member

definitely support consolidating where these state changes are made. Not tracking this led to one of our recent bugs in duplicate parent lookups

A future PR should add more checks in setters like on_download_success such that a state transition from Processed -> Downloading is not possible

Agreed

@realbigsean
Copy link
Member

@dapplion mentioned offline the TODOs here will be fixed in #5583

@realbigsean realbigsean added the ready-for-merge This PR is ready to merge. label Apr 15, 2024
@realbigsean
Copy link
Member

@Mergifyio queue

Copy link

mergify bot commented Apr 15, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at fee2ee9

@mergify mergify bot merged commit fee2ee9 into sigp:unstable Apr 15, 2024
29 checks passed
@dapplion
Copy link
Collaborator Author

dapplion commented Apr 15, 2024

@realbigsean about this todo

// TODO: We requested a download from Downloading { peer_id }, but the network
// injects a response from a different peer_id. What should we do? The peer_id to
// track for scoring is the one that actually sent the response, not the state's

not sure if this was just overlooked in the original design. The peer returned from the network is decided by internal logic. If there are not bugs in routing the correct request_id the peer_id should always match. Then, should we even track the downloading peer?

@dapplion dapplion deleted the single-lookup-state branch April 16, 2024 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge This PR is ready to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants