Skip to content

Commit ef4092c

Browse files
ensi321g11tech
authored andcommitted
fix: publish attestations with non-zero committee index (ChainSafe#6790)
Fix publishing att with non-zero comm index
1 parent f0dc964 commit ef4092c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/validator/src/services/attestation.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,13 @@ export class AttestationService {
148148
this.metrics?.attesterStepCallProduceAggregate.observe(this.clock.secFromSlot(slot + 2 / 3));
149149

150150
const dutiesByCommitteeIndex = groupAttDutiesByCommitteeIndex(dutiesAll);
151+
const isAfterElectra = computeEpochAtSlot(slot) >= this.config.ELECTRA_FORK_EPOCH;
151152

152153
// Then download, sign and publish a `SignedAggregateAndProof` for each
153154
// validator that is elected to aggregate for this `slot` and `committeeIndex`.
154155
await Promise.all(
155156
Array.from(dutiesByCommitteeIndex.entries()).map(([index, dutiesSameCommittee]) => {
156-
const attestationData: phase0.AttestationData = {...attestationNoCommittee, index};
157+
const attestationData: phase0.AttestationData = {...attestationNoCommittee, index: isAfterElectra ? 0 : index};
157158
return this.produceAndPublishAggregates(attestationData, index, dutiesSameCommittee);
158159
})
159160
);
@@ -184,10 +185,11 @@ export class AttestationService {
184185
const signedAttestations: phase0.Attestation[] = [];
185186
const headRootHex = toHexString(attestationNoCommittee.beaconBlockRoot);
186187
const currentEpoch = computeEpochAtSlot(slot);
188+
const isAfterElectra = currentEpoch >= this.config.ELECTRA_FORK_EPOCH;
187189

188190
await Promise.all(
189191
duties.map(async ({duty}) => {
190-
const index = duty.committeeIndex;
192+
const index = isAfterElectra ? 0 : duty.committeeIndex;
191193
const attestationData: phase0.AttestationData = {...attestationNoCommittee, index};
192194
const logCtxValidator = {slot, index, head: headRootHex, validatorIndex: duty.validatorIndex};
193195

0 commit comments

Comments
 (0)