Skip to content

Commit

Permalink
fix: return correct type from attestation validation when using cache
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig committed Nov 28, 2024
1 parent cfe6c89 commit 603aae8
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions packages/beacon-node/src/chain/validation/attestation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,27 +510,31 @@ async function validateAttestationNoSignatureCheck(
}

// no signature check, leave that for step1
const indexedAttestationContent = {
const indexedAttestation: IndexedAttestation = {
attestingIndices,
data: attData,
signature,
};
const indexedAttestation =
ForkSeq[fork] >= ForkSeq.electra
? (indexedAttestationContent as electra.IndexedAttestation)
: (indexedAttestationContent as phase0.IndexedAttestation);

const attestationContent = attestationOrCache.attestation ?? {
aggregationBits,
data: attData,
committeeIndex,
signature,
};

const attestation =
ForkSeq[fork] >= ForkSeq.electra
? (attestationContent as SingleAttestation<ForkPostElectra>)
: (attestationContent as SingleAttestation<ForkPreElectra>);
let attestation: SingleAttestation;
if (attestationOrCache.attestation) {
attestation = attestationOrCache.attestation;
} else {
if (!isForkPostElectra(fork)) {
attestation = {
aggregationBits,
data: attData,
signature,
} as SingleAttestation<ForkPreElectra>;
} else {
attestation = {
committeeIndex,
attesterIndex: validatorIndex,
data: attData,
signature,
} as SingleAttestation<ForkPostElectra>;
}
}

return {
attestation,
Expand Down

0 comments on commit 603aae8

Please sign in to comment.