Skip to content

Commit

Permalink
fix: clone attestations for block inclusion (#6174)
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Dec 9, 2023
1 parent b94c06e commit 003a444
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,16 @@ export class AggregatedAttestationPool {
}
}

return attestationsByScore
.sort((a, b) => b.score - a.score)
.slice(0, MAX_ATTESTATIONS)
.map((attestation) => attestation.attestation);
const sortedAttestationsByScore = attestationsByScore.sort((a, b) => b.score - a.score);
const attestationsForBlock: phase0.Attestation[] = [];
for (const [i, attestationWithScore] of sortedAttestationsByScore.entries()) {
if (i >= MAX_ATTESTATIONS) {
break;
}
// attestations could be modified in this op pool, so we need to clone for block
attestationsForBlock.push(ssz.phase0.Attestation.clone(attestationWithScore.attestation));
}
return attestationsForBlock;
}

/**
Expand Down

0 comments on commit 003a444

Please sign in to comment.