diff --git a/packages/beacon-node/src/chain/validation/attestation.ts b/packages/beacon-node/src/chain/validation/attestation.ts index 8594ed31327..5220fc9d028 100644 --- a/packages/beacon-node/src/chain/validation/attestation.ts +++ b/packages/beacon-node/src/chain/validation/attestation.ts @@ -326,6 +326,7 @@ async function validateAttestationNoSignatureCheck( } let aggregationBits: BitArray | null = null; + let committeeValidatorIndex: number | null = null; if (!isForkPostElectra(fork)) { // [REJECT] The attestation is unaggregated -- that is, it has exactly one participating validator // (len([bit for bit in attestation.aggregation_bits if bit]) == 1, i.e. exactly 1 bit is set). @@ -345,6 +346,7 @@ async function validateAttestationNoSignatureCheck( code: AttestationErrorCode.NOT_EXACTLY_ONE_AGGREGATION_BIT_SET, }); } + committeeValidatorIndex = bitIndex; } let committeeValidatorIndices: Uint32Array; @@ -399,16 +401,13 @@ async function validateAttestationNoSignatureCheck( } let validatorIndex: number; - let committeeValidatorIndex: number; if (!isForkPostElectra(fork)) { // The validity of aggregation bits are already checked above assert.notNull(aggregationBits); - const bitIndex = aggregationBits.getSingleTrueBit(); - assert.notNull(bitIndex); + assert.notNull(committeeValidatorIndex); - validatorIndex = committeeValidatorIndices[bitIndex]; - committeeValidatorIndex = bitIndex; + validatorIndex = committeeValidatorIndices[committeeValidatorIndex]; // [REJECT] The number of aggregation bits matches the committee size // -- i.e. len(attestation.aggregation_bits) == len(get_beacon_committee(state, data.slot, data.index)). // > TODO: Is this necessary? Lighthouse does not do this check.