diff --git a/packages/beacon-node/src/chain/seenCache/seenAttestationData.ts b/packages/beacon-node/src/chain/seenCache/seenAttestationData.ts index 498c8f36ef8e..eeba3f3a381f 100644 --- a/packages/beacon-node/src/chain/seenCache/seenAttestationData.ts +++ b/packages/beacon-node/src/chain/seenCache/seenAttestationData.ts @@ -1,5 +1,5 @@ import {BitArray} from "@chainsafe/ssz"; -import {CommitteeIndex, RootHex, Slot, phase0} from "@lodestar/types"; +import {CommitteeIndex, RootHex, Slot, ValidatorIndex, phase0} from "@lodestar/types"; import {MapDef} from "@lodestar/utils"; import {Metrics} from "../../metrics/metrics.js"; import {InsertOutcome} from "../opPools/types.js"; @@ -11,8 +11,8 @@ type AttDataBase64 = string; export type AttestationDataCacheEntry = { // part of shuffling data, so this does not take memory committeeValidatorIndices: Uint32Array; - // TODO: remove this? this is available in SingleAttestation committeeIndex: CommitteeIndex; + attesterIndex: ValidatorIndex; // IndexedAttestationData signing root, 32 bytes signingRoot: Uint8Array; // to be consumed by forkchoice and oppool diff --git a/packages/beacon-node/src/chain/validation/attestation.ts b/packages/beacon-node/src/chain/validation/attestation.ts index 305cbba3fbde..e5b78589f537 100644 --- a/packages/beacon-node/src/chain/validation/attestation.ts +++ b/packages/beacon-node/src/chain/validation/attestation.ts @@ -407,10 +407,16 @@ async function validateAttestationNoSignatureCheck( if (!isForkPostElectra(fork)) { // The validity of aggregation bits are already checked above assert.notNull(aggregationBits); - const bitIndex = aggregationBits.getSingleTrueBit(); - assert.notNull(bitIndex); - validatorIndex = committeeValidatorIndices[bitIndex]; + if (attestationOrCache.attestation) { + const bitIndex = aggregationBits.getSingleTrueBit(); + assert.notNull(bitIndex); + + validatorIndex = committeeValidatorIndices[bitIndex]; + } else { + validatorIndex = attestationOrCache.cache.attesterIndex; + } + // [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. @@ -420,7 +426,10 @@ async function validateAttestationNoSignatureCheck( }); } } else { - validatorIndex = (attestationOrCache.attestation as SingleAttestation).attesterIndex; + validatorIndex = attestationOrCache.attestation + ? (attestationOrCache.attestation as SingleAttestation).attesterIndex + : attestationOrCache.cache.attesterIndex; + // [REJECT] The attester is a member of the committee -- i.e. // `attestation.attester_index in get_beacon_committee(state, attestation.data.slot, index)`. // If `aggregationBitsElectra` exists, that means we have already cached it. No need to check again @@ -498,6 +507,7 @@ async function validateAttestationNoSignatureCheck( chain.seenAttestationDatas.add(attSlot, committeeIndex, attDataKey, { committeeValidatorIndices, committeeIndex, + attesterIndex: validatorIndex, signingRoot: signatureSet.signingRoot, subnet: expectedSubnet, // precompute this to be used in forkchoice