-
Notifications
You must be signed in to change notification settings - Fork 16
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
Engine switching with committee rotation #531
Engine switching with committee rotation #531
Conversation
…asier understandable at which slot certain conditions apply
…d thus prevented weight/ratifier propagation
…didates that were decided before the target slot instead of after
…aringThreshold=2*maxCommittableAge
…re committing in attestation manager. This is because at the time the attestation was created, the committee might have been different from the current one (due to rotation at epoch boundary).
… instead of always relying on accountsData of committee before forking point (important when fork persists over epoch boundary with rotating committee)
…s and weight propagation
…ed throughout the slot where blocks are issued. If that is not the case, some blocks might already commit to a more recent commitment (which became committable because of issuing). This, however, makes the issuance non-deterministic and assertions of e.g. attestations impossible
aab424b
to
b31645c
Compare
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 have to really remark the very high quality of this PR: clean code, well commented and well designed. VERY GOOD JOB!!!! 👍 👍 👍 👍
if exists { | ||
validatorAccounts, err := committee.Accounts() | ||
if err == nil { | ||
validatorAccountsData, err := c.engine.Ledger.PastAccounts(validatorAccounts.IDs(), c.lastCommonSlotBeforeFork) |
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.
So if you have a committee for the new epoch you take those accounts with the data at the last common slot before the fork. If instead you don't have a committee for the new epoch you are going to keep using the previous (or initial) validatorAccountsData
; you are therefore assuming that the committee should be re-used and it was not rotated.
If I reed the following code correctly, in either case you would need accurate account data at lastCommonSlotBeforeFork
ONLY in terms of signing keys: to verify attestations' signatures.
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.
Yes exactly
pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go
Outdated
Show resolved
Hide resolved
// Determine the rewards root. | ||
{ | ||
targetRewardsEpoch := currentEpoch | ||
if slot == currentEpochEndSlot { |
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.
Why would we calculate the rewards for the next epoch? I don't get this.
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.
Was asking myself the same question. I just refactored that code to be easier understandable what is happening at which time because before it was basically impossible to read
} | ||
|
||
if err := p.rollbackCommitteesCandidates(targetEpoch, pruningRange[0]-1); err != nil { | ||
if err := p.rollbackCommitteesCandidates(targetEpoch, startPruneRange); err != nil { |
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.
You removed the original -1
from the startPruneRange. Was it intended?
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 fixed a bug in the condition as it was candidacySlot < targetSlot
which lead to the wrong slots being deleted.
And yes, it was intended because I changed it to be inclusive candidacySlot >= deletionStartSlot
. So we delete everything starting and including deletionStartSlot
…ing-committee-rotation-test
This PR addresses several problems around engine switching with committee rotation across epoch boundaries:
AttestationManager
: Use the committee of the slot of the attestation in contrast to the slot that we're committing. This is because at the time the attestation was created, the committee might have been different from the current one (due to rotation at epoch boundary).CommitmentVerifier
: UpdatevalidatorAccountsData
if fork happened across epoch boundaries. We try to use the latest accounts data (atlastCommonSlotBeforeFork
) for the current epoch. This is necessary because the committee might have rotated at the epoch boundary and different validators might be part of it. In case anything goes wrong we keep using previously known accounts data (initially set to the accounts data of the validators for the epoch of the last common commitment before the fork). It could be, that we don't know about a validator when we verify the attestations: we then simply ignore this attestation (just like with public key changes) and weight of the chain will build up slower.Fixes #210, #266, #255