mirror of
https://github.com/ChainSafe/lodestar.git
synced 2026-01-08 23:28:10 -05:00
refactor: use map to lookup combined beacon committee selection for duty (#8710)
https://github.com/ChainSafe/lodestar/pull/8669#discussion_r2636951039
This commit is contained in:
@@ -469,20 +469,33 @@ export class AttestationDutiesService {
|
||||
|
||||
const res = await this.api.validator.submitBeaconCommitteeSelections({selections: partialSelections});
|
||||
|
||||
const combinedSelections = res.value();
|
||||
this.logger.debug("Received combined beacon committee selection proofs", {epoch, count: combinedSelections.length});
|
||||
const combinedSelections = new Map<ValidatorIndex, routes.validator.BeaconCommitteeSelection>();
|
||||
for (const selection of res.value()) {
|
||||
combinedSelections.set(selection.validatorIndex, selection);
|
||||
}
|
||||
this.logger.debug("Received combined beacon committee selection proofs", {epoch, count: combinedSelections.size});
|
||||
|
||||
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);
|
||||
const combinedSelection = combinedSelections.get(validatorIndex);
|
||||
|
||||
if (!combinedSelection) {
|
||||
this.logger.debug("Did not receive combined beacon committee selection proof", logCtxValidator);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (combinedSelection.slot !== slot) {
|
||||
this.logger.debug("Received combined beacon committee selection proof for different slot", {
|
||||
expected: slot,
|
||||
actual: combinedSelection.slot,
|
||||
index: committeeIndex,
|
||||
validatorIndex,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
const isAggregator = isAggregatorFromCommitteeLength(committeeLength, combinedSelection.selectionProof);
|
||||
|
||||
if (isAggregator) {
|
||||
|
||||
Reference in New Issue
Block a user