Skip to content

Commit

Permalink
fix: address attDataBase64 for both linear & indexed queues
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Aug 18, 2023
1 parent d6cf1cd commit 37cfb6e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
5 changes: 1 addition & 4 deletions packages/beacon-node/src/chain/errors/attestationError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ export enum AttestationErrorCode {
INVALID_SERIALIZED_BYTES = "ATTESTATION_ERROR_INVALID_SERIALIZED_BYTES",
/** Too many skipped slots. */
TOO_MANY_SKIPPED_SLOTS = "ATTESTATION_ERROR_TOO_MANY_SKIPPED_SLOTS",
/** attDataBase64 is not available */
NO_INDEXED_DATA = "ATTESTATION_ERROR_NO_INDEXED_DATA",
}

export type AttestationErrorType =
Expand Down Expand Up @@ -168,8 +166,7 @@ export type AttestationErrorType =
| {code: AttestationErrorCode.INVALID_AGGREGATOR}
| {code: AttestationErrorCode.INVALID_INDEXED_ATTESTATION}
| {code: AttestationErrorCode.INVALID_SERIALIZED_BYTES}
| {code: AttestationErrorCode.TOO_MANY_SKIPPED_SLOTS; headBlockSlot: Slot; attestationSlot: Slot}
| {code: AttestationErrorCode.NO_INDEXED_DATA};
| {code: AttestationErrorCode.TOO_MANY_SKIPPED_SLOTS; headBlockSlot: Slot; attestationSlot: Slot};

export class AttestationError extends GossipActionError<AttestationErrorType> {
getMetadata(): Record<string, string | number | null> {
Expand Down
13 changes: 6 additions & 7 deletions packages/beacon-node/src/chain/validation/attestation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {RegenCaller} from "../regen/index.js";
import {
AttDataBase64,
getAggregationBitsFromAttestationSerialized,
getAttDataBase64FromAttestationSerialized,
getSignatureFromAttestationSerialized,
} from "../../util/sszBytes.js";
import {AttestationDataCacheEntry} from "../seenCache/seenAttestationData.js";
Expand Down Expand Up @@ -233,16 +234,14 @@ async function validateGossipAttestationNoSignatureCheck(
let attestationOrCache:
| {attestation: phase0.Attestation; cache: null}
| {attestation: null; cache: AttestationDataCacheEntry; serializedData: Uint8Array};
let attDataBase64: AttDataBase64 | null;
let attDataBase64: AttDataBase64 | null = null;
if (attestationOrBytes.serializedData) {
// gossip
const attSlot = attestationOrBytes.attSlot;
if (!attestationOrBytes.attDataBase64) {
throw new AttestationError(GossipAction.IGNORE, {
code: AttestationErrorCode.NO_INDEXED_DATA,
});
}
attDataBase64 = attestationOrBytes.attDataBase64;
// for old LIFO linear gossip queue we don't have attDataBase64
// for indexed gossip queue we have attDataBase64
attDataBase64 =
attestationOrBytes.attDataBase64 ?? getAttDataBase64FromAttestationSerialized(attestationOrBytes.serializedData);
const cachedAttData = attDataBase64 !== null ? chain.seenAttestationDatas.get(attSlot, attDataBase64) : null;
if (cachedAttData === null) {
const attestation = sszDeserializeAttestation(attestationOrBytes.serializedData);
Expand Down

0 comments on commit 37cfb6e

Please sign in to comment.