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
[WIP] Attestation committees #1185
Conversation
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.
Look good!
return; | ||
|
||
// get number of the next slot that validator is eligible to propose | ||
long slotNumber = calcNextProposingSlot(proposer.getSlotNumber(System.currentTimeMillis()), |
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.
Let's move System.currentTimeMillis()
somewhere to one source, as sharding logic is dependant of time and we may need some accuracy tweaks for it in future or whatever.
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.
I think adding getCurrentSlot()
method to BeaconProposer
should manage that
// each committee dedicated for own shard | ||
int shard = startShard; | ||
for (Committee[] slot : committees) { | ||
for (Committee committee : slot) { |
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.
slot.length == SHARD_COUNT ?
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.
nope, slot.length == CYCLE_LENGTH
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.
Sorry, slot.length
depends on the size of active validator set. It varies from 1
to (1 << 24) / CYCLE_LENGTH / (MIN_COMMITTEE_SIZE * 2) + 1
, it's calculated with ShufflingCommitteeFactory#calcShardsPerSlot()
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.
Got it
public void testShuffle() { | ||
int[] in = IntStream.range(1, BeaconConstants.MIN_COMMITTEE_SIZE * 1024).toArray(); | ||
int[] out = new ShufflingCommitteeFactory().shuffle(HashUtil.randomHash(), in); | ||
assertFalse(Arrays.equals(in, out)); |
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.
It will fail one day 😿
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.
yep, in theory it may be, but hardly the case in practice :)
There one thing worth to add before the merge. Proposer service schedules each slot in current implementation, it should be linked to committees transition to only produce blocks for slots it assigned to.
Resolves #1142