Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Sharding/propose attestations #1219

Merged
merged 22 commits into from
Nov 15, 2018
Merged

Conversation

zilm13
Copy link
Collaborator

@zilm13 zilm13 commented Oct 22, 2018

Should resolve #1192, #1193
not finished
need help

@zilm13 zilm13 requested a review from mkalinin October 22, 2018 21:40
Copy link
Contributor

@mkalinin mkalinin left a comment

Choose a reason for hiding this comment

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

Let's also add tests on validators and attestations aggregation

@@ -129,6 +134,12 @@ private void initDepositContract() {
contractInit.complete(null);
}

public void initSubscriptions() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think subscribing to specific events should be a part of the component initialization logic that is triggered by WorldManager. Just like ValidatorSearvice.init() works

block.getAttestations().forEach(at -> beaconAttester.purgeAttestations(at));

activeState = activeState
.withPendingAttestations(mergedAttestations);
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better to have something like addAttestations(List<AttestationRecord> newAttestations) to avoid the above merging.

List<AttestationRecord> mergedAttestations = new ArrayList<>();
mergedAttestations.addAll(activeState.getPendingAttestations());
mergedAttestations.addAll(block.getAttestations());
block.getAttestations().forEach(at -> beaconAttester.purgeAttestations(at));
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think if we drive this part by a pub/sub mechanism? It would let us avoid tight components coupling.

@@ -67,8 +84,19 @@ public BeaconState applyBlock(Beacon block, BeaconState to) {
.withDynasty(dynasty)
.withLastStateRecalc(cycleStartSlot(block))
.withFinality(finality);

// remove attestations older than last_state_recalc
List<AttestationRecord> uptodateAttestations = new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

I am starting to think of decoupling crystallized and active state transitions when looking at these lines.

uptodateAttestations.add(record);
}
}
beaconAttester.removeOldSlots(crystallized.getLastStateRecalc());
Copy link
Contributor

Choose a reason for hiding this comment

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

The same "pub/sub" note as previous one. I guess it could be even processed by same handler.

@@ -27,6 +27,7 @@
Exist,
NoParent,
StateMismatch,
Invalid,
Copy link
Contributor

Choose a reason for hiding this comment

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

It should also be added to ProcessingResult.fromValidation. Looks like we need a note about that or better design to be sure that in future this problem won't arise again


Committee[][] committees = crystallized.getDynasty().getCommittees();

int index = (int) data.parent.getSlotNumber() % committees.length;
Copy link
Contributor

Choose a reason for hiding this comment

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

Look in ValidatorServiceImpl to see how this logic should look like. Maybe wrap it with some utility method to re-use?

int index = (int) data.parent.getSlotNumber() % committees.length;

if (block.getAttestations().isEmpty()) {
return Invalid;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd increase the level of verbosity and call it InvalidAttestations


AttestationRecord proposerAttestation = block.getAttestations().get(0);

if (proposerAttestation.getSlot() != data.parent.getSlotNumber()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It, also, should be checked that hash matched, shouldn't it?

@coveralls
Copy link

coveralls commented Nov 13, 2018

Coverage Status

Coverage decreased (-0.6%) to 55.317% when pulling 9324ce2 on sharding/propose-attestations into 476fbfd on research/sharding.

Copy link
Contributor

@mkalinin mkalinin left a comment

Choose a reason for hiding this comment

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

I'd merge it if @zilm13 is OK too.

@mkalinin mkalinin deleted the sharding/propose-attestations branch December 26, 2018 06:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants