Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correctly get signature from single attestation bytes #7266

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/beacon-node/src/chain/validation/attestation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {
getCommitteeBitsFromSignedAggregateAndProofElectra,
getCommitteeIndexFromSingleAttestationSerialized,
getSignatureFromAttestationSerialized,
getSignatureFromSingleAttestationSerialized,
} from "../../util/sszBytes.js";
import {Result, wrapError} from "../../util/wrapError.js";
import {AttestationError, AttestationErrorCode, GossipAction} from "../errors/index.js";
Expand Down Expand Up @@ -470,7 +471,9 @@ async function validateAttestationNoSignatureCheck(
let attDataRootHex: RootHex;
const signature = attestationOrCache.attestation
? attestationOrCache.attestation.signature
: getSignatureFromAttestationSerialized(attestationOrCache.serializedData);
: !isForkPostElectra(fork)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally would like to see the fork switching logic to be hidden in sszBytes.ts

Maybe a function named getSignatureFromBeaconAttestationSerialized in a similar fashion as getBlockRootFromBeaconAttestationSerialized.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was debating that as well but figured we only use those in network processor and this pattern was used before already so I went with explicit fork logic in validation itself

const committeeIndexForLookup = isForkPostElectra(fork)
? (getCommitteeIndexFromAttestationOrBytes(fork, attestationOrBytes) ?? 0)
: PRE_ELECTRA_SINGLE_ATTESTATION_COMMITTEE_INDEX;

Either one seems fine to me

? getSignatureFromAttestationSerialized(attestationOrCache.serializedData)
: getSignatureFromSingleAttestationSerialized(attestationOrCache.serializedData);
if (signature === null) {
throw new AttestationError(GossipAction.REJECT, {
code: AttestationErrorCode.INVALID_SERIALIZED_BYTES,
Expand Down
Loading