Skip to content

Commit

Permalink
fix: get aggregate and proofs signature sets (#6757)
Browse files Browse the repository at this point in the history
fix: get signature for SignedAggregateAndProof based on fork
  • Loading branch information
twoeths authored and g11tech committed Aug 27, 2024
1 parent 9f599f3 commit c34eac7
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {PublicKey} from "@chainsafe/blst";
import {DOMAIN_AGGREGATE_AND_PROOF} from "@lodestar/params";
import {ssz} from "@lodestar/types";
import {Epoch, phase0} from "@lodestar/types";
import type {PublicKey} from "@chainsafe/bls/types";
import {DOMAIN_AGGREGATE_AND_PROOF, ForkSeq} from "@lodestar/params";
import {allForks, ssz} from "@lodestar/types";
import {Epoch} from "@lodestar/types";
import {
computeSigningRoot,
computeStartSlotAtEpoch,
Expand All @@ -13,22 +13,23 @@ import {BeaconConfig} from "@lodestar/config";
export function getAggregateAndProofSigningRoot(
config: BeaconConfig,
epoch: Epoch,
aggregateAndProof: phase0.SignedAggregateAndProof
aggregateAndProof: allForks.SignedAggregateAndProof
): Uint8Array {
// previously, we call `const aggregatorDomain = state.config.getDomain(state.slot, DOMAIN_AGGREGATE_AND_PROOF, slot);`
// at fork boundary, it's required to dial to target epoch https://github.com/ChainSafe/lodestar/blob/v1.11.3/packages/beacon-node/src/chain/validation/attestation.ts#L573
// instead of that, just use the fork of slot in the attestation data
const slot = computeStartSlotAtEpoch(epoch);
const fork = config.getForkName(slot);
const aggregatorDomain = config.getDomainAtFork(fork, DOMAIN_AGGREGATE_AND_PROOF);
return computeSigningRoot(ssz.phase0.AggregateAndProof, aggregateAndProof.message, aggregatorDomain);
const sszType = ForkSeq[fork] >= ForkSeq.electra ? ssz.electra.AggregateAndProof : ssz.phase0.AggregateAndProof;
return computeSigningRoot(sszType, aggregateAndProof.message, aggregatorDomain);
}

export function getAggregateAndProofSignatureSet(
config: BeaconConfig,
epoch: Epoch,
aggregator: PublicKey,
aggregateAndProof: phase0.SignedAggregateAndProof
aggregateAndProof: allForks.SignedAggregateAndProof
): ISignatureSet {
return createSingleSignatureSetFromComponents(
aggregator,
Expand Down

0 comments on commit c34eac7

Please sign in to comment.