-
-
Notifications
You must be signed in to change notification settings - Fork 416
feat: update vc to submit beacon committee selections once per epoch #8669
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
Open
nflaig
wants to merge
3
commits into
unstable
Choose a base branch
from
nflaig/update-dvt-aggregation
base: unstable
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -204,6 +204,17 @@ export class AttestationDutiesService { | |
| for (const epoch of [currentEpoch, nextEpoch]) { | ||
| const epochDuties = this.dutiesByIndexByEpoch.get(epoch)?.dutiesByIndex; | ||
| if (epochDuties) { | ||
| if (this.opts?.distributedAggregationSelection) { | ||
| // Validator in distributed cluster only has a key share, not the full private key. | ||
| // The partial selection proofs must be exchanged for combined selection proofs by | ||
| // calling submitBeaconCommitteeSelections on the distributed validator middleware client. | ||
| // This is required to correctly determine if validator is aggregator and to produce | ||
| // a AggregateAndProof that can be threshold aggregated by the middleware client. | ||
| await this.runDistributedAggregationSelectionTasks(Array.from(epochDuties.values()), epoch).catch((e) => | ||
| this.logger.error("Error on attestation aggregation selection", {epoch}, e) | ||
| ); | ||
| } | ||
|
|
||
| for (const {duty, selectionProof} of epochDuties.values()) { | ||
| if (indexSet.has(duty.validatorIndex)) { | ||
| beaconCommitteeSubscriptions.push({ | ||
|
|
@@ -367,6 +378,12 @@ export class AttestationDutiesService { | |
| const epochDuties = this.dutiesByIndexByEpoch.get(dutyEpoch)?.dutiesByIndex; | ||
|
|
||
| if (epochDuties) { | ||
| if (this.opts?.distributedAggregationSelection) { | ||
| await this.runDistributedAggregationSelectionTasks(Array.from(epochDuties.values()), dutyEpoch).catch((e) => | ||
| this.logger.error("Error on attestation aggregation selection after duties reorg", logContext, e) | ||
| ); | ||
| } | ||
|
|
||
| for (const {duty, selectionProof} of epochDuties.values()) { | ||
| beaconCommitteeSubscriptions.push({ | ||
| validatorIndex: duty.validatorIndex, | ||
|
|
@@ -403,8 +420,8 @@ export class AttestationDutiesService { | |
| if (this.opts?.distributedAggregationSelection) { | ||
| // Validator in distributed cluster only has a key share, not the full private key. | ||
| // Passing a partial selection proof to `is_aggregator` would produce incorrect result. | ||
| // AttestationService will exchange partial for combined selection proofs retrieved from | ||
| // distributed validator middleware client and determine aggregators at beginning of every slot. | ||
| // Before subscribing to beacon committee subnets, aggregators are determined by exchanging | ||
| // partial for combined selection proofs retrieved from distributed validator middleware client. | ||
| return {duty, selectionProof: null, partialSelectionProof: selectionProof}; | ||
| } | ||
|
|
||
|
|
@@ -427,4 +444,47 @@ export class AttestationDutiesService { | |
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Performs additional attestation aggregation tasks required if validator is part of distributed cluster | ||
| * | ||
| * 1. Exchange partial for combined selection proofs | ||
| * 2. Determine validators that should aggregate attestations | ||
| * 3. Mutate duty objects to set selection proofs for aggregators | ||
| */ | ||
| private async runDistributedAggregationSelectionTasks(duties: AttDutyAndProof[], epoch: Epoch): Promise<void> { | ||
| const partialSelections: routes.validator.BeaconCommitteeSelection[] = duties.map( | ||
| ({duty, partialSelectionProof}) => ({ | ||
| validatorIndex: duty.validatorIndex, | ||
| slot: duty.slot, | ||
| selectionProof: partialSelectionProof as BLSSignature, | ||
| }) | ||
| ); | ||
|
|
||
| this.logger.debug("Submitting partial beacon committee selection proofs", {epoch, count: partialSelections.length}); | ||
|
|
||
| const res = await this.api.validator.submitBeaconCommitteeSelections({selections: partialSelections}); | ||
nflaig marked this conversation as resolved.
Show resolved
Hide resolved
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we call this with duties for a whole epoch, could consider batching the request but generally assume vc and charon run on the same host without any proxy in-between that could cause issues due to large request body size |
||
|
|
||
| const combinedSelections = res.value(); | ||
| this.logger.debug("Received combined beacon committee selection proofs", {epoch, count: combinedSelections.length}); | ||
|
|
||
| for (const dutyAndProof of duties) { | ||
| const {slot, validatorIndex, committeeIndex, committeeLength} = dutyAndProof.duty; | ||
| const logCtxValidator = {slot, index: committeeIndex, validatorIndex}; | ||
|
|
||
| const combinedSelection = combinedSelections.find((s) => s.validatorIndex === validatorIndex && s.slot === slot); | ||
|
|
||
| if (!combinedSelection) { | ||
| this.logger.warn("Did not receive combined beacon committee selection proof", logCtxValidator); | ||
| continue; | ||
| } | ||
|
|
||
| const isAggregator = isAggregatorFromCommitteeLength(committeeLength, combinedSelection.selectionProof); | ||
|
|
||
| if (isAggregator) { | ||
| // Update selection proof by mutating duty object | ||
| dutyAndProof.selectionProof = combinedSelection.selectionProof; | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
the google doc is no longer accessible