Skip to content

Commit

Permalink
fix: for await in validateGossipAttestationsSameAttData
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Aug 20, 2023
1 parent e0fe66a commit 3c4a2c7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/beacon-node/src/chain/validation/attestation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,14 @@ export async function validateGossipAttestationsSameAttData(
}

// phase0: do all verifications except for signature verification
const phase0ResultOrErrors = await Promise.all(
attestationOrBytesArr.map((attestationOrBytes) =>
wrapError(phase0ValidationFn(fork, chain, attestationOrBytes, subnet))
)
);
// this for await pattern below seems to be bad but it's not
// for seen AttestationData, it's the same to await Promise.all() pattern
// for unseen AttestationData, the 1st call will be cached and the rest will be fast
const phase0ResultOrErrors: Result<Phase0Result>[] = [];
for (const attestationOrBytes of attestationOrBytesArr) {
const resultOrError = await wrapError(phase0ValidationFn(fork, chain, attestationOrBytes, subnet));
phase0ResultOrErrors.push(resultOrError);
}

// phase1: verify signatures of all valid attestations
// map new index to index in resultOrErrors
Expand Down

0 comments on commit 3c4a2c7

Please sign in to comment.