-
Notifications
You must be signed in to change notification settings - Fork 890
Fix get_custody_groups not sorting the result #7711
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
base: unstable
Are you sure you want to change the base?
Conversation
|
About the length check, it is not needed as it is done to prevent duplicates, but a BTreeSet is a set, so no duplicates allowed. |
Hi @nethoxa, thanks for the PR and bringing this up!
I don't fully understand what you mean by this - when broadcasting we only use the custody columns for filtering, and when we download via gossip / rpc, the order is not determined by the I'm actually working on an validator-custody related refactor, and I'm now considering to preserve the exact order of the Consider a scenario where the node's custody column is 8, it custodies the following columns Let's say mid way through the epoch, the node's CGC increased due to an extra validator being attached to the beacon node, now:
We now have to maintain two sets of custody groups, one for current epoch, and one for the next epoch. However if we maintain one full ordered list (128 ordered indices), we could easily take slices of it to determine the columns for any custody count. There are different ways to approach this of course. But I don't see the need to make our internal implementation match the spec implementation, unless it results in undesired behaviour? |
Hi @jimmygchen, as you say, no functionality rn would be affected nor any penalty. About this:
I think you should, as on futures upgrades on top may rely on compliance with the specs, so could lead to some issues in the future (has happened recently, that's why I'm saying it). About your work on an validator-custody related refactor, lemme some time to think about it. Thanks |
Issue Addressed
The function
get_custody_groups
does not follow the spec as it uses ahashset
, which, upon iterated, follows an arbitrary order. The impact, at much, is LH nodes broadcasting and downloading data unorderly, while other nodes would do it in order (kind of LH nodes being misleading). However, as all nodes have the same values, and so the same downloaded data, no punishment in the peer score is applied (at first, would need to dig more).Nevermind, this contradicts the specs which clearly enforces that the returned
custody_groups
must be ordered:link
This was not triggered by EF test suite as in the handler, it sorted the array, so even if the function returned the wrong value, the test passed:
link
Proposed Changes
HashSet
toBTreeSet
, which has the same functions and is assured to be ordered, as the test provessort
from the handlerget_custody_groups
to handle the correct typeAdditional Info
As reference, check Prysm. I think another check for the length of the set should be added as in the specs, even if redundant, just in case.