-
Notifications
You must be signed in to change notification settings - Fork 148
feat(bridge): census should use affected_by_radius #1841
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
Conversation
I don't get the reason for this change. In the context of ephemeral history. We are only sending series of ephemeral keys, in my PR I am working on I just added a function called
For ephemeral keys it doesn't make sense to provide the |
4fcadda
to
ddfd40e
Compare
You are right about ephemeral headers. I didn't think about details regarding it Still, I think it's cleaner and better if Do you think we shouldn't do it in general case? Or that there is some downside if we do it? |
I think if you intend to use this functionality for the beacon network I see value in this PR. I can't think of a reason we would need this in History or State. Ideally we aren't maintaining deadcode paths is all, if we aren't using this functionality or intend to use it, why have it etc. Do we intend to use it for Beacon? |
There is no immediate use of it for beacon network as all beacon nodes should have 100% radius. We will use this (or some variation of this) for head state, as that one uses different distance metric as well (and doesn't use content_id in the same way).
It's hardly any deadcode path. Instead of passing content_id, we are now passing content_key (expect at the very end, to prevent generating content_id every time). I also think that conceptually, this is the correct code! We shouldn't filter peers based on their distance from content, if that particular content is dependent on radius and distance. |
If we will use this PR for Beacon then I am for it
We will be generating a content_id every time though no? There isn't a case when we wouldn't.
So if anything I would expect the function to ensure!() that the content_key is radius dependent and fail early
There isn't a valid reason to call this function unless the content is dependent on radius and distance |
I think we should ideally avoid passing Generics through multiple layers of structures as well. If we want the interface of Generics can be abused, and I think this is kind of it. |
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.
looks good. Milos and I had a call where we talked about how he planes to use some of this in the Beacon and State HEAD code.
Instead of doing generic functions, he updated content_key to instead take an implimentation of a trait, which I think is a lot cleaner and easier to read. It is also consistent with other parts of the code
pub fn select_peers<'a>(
&self,
content_key: &impl OverlayContentKey,
peers: impl IntoIterator<Item = &'a Peer>,
) -> Vec<PeerInfo> {
For example ^ this function already did this for peers.
So it is pretty nice!
If you rebase it will fix the tests |
aa2b058
to
b147e37
Compare
Followup to #1839
What was wrong?
The census should use distance and radius when selecting peers only if that's relevant for the provided content.
How was it fixed?
Added logic that uses
affected_by_radius
functionTo-Do