UNPKG

@lodestar/state-transition

Version:

Beacon Chain state transition function and utils

23 lines 1.2 kB
import { ssz } from "@lodestar/types"; import { SignatureSetType, computeSigningRoot, computeStartSlotAtEpoch, verifySignatureSet, } from "../util/index.js"; export function verifyVoluntaryExitSignature(state, signedVoluntaryExit) { return verifySignatureSet(getVoluntaryExitSignatureSet(state, signedVoluntaryExit)); } /** * Extract signatures to allow validating all block signatures at once */ export function getVoluntaryExitSignatureSet(state, signedVoluntaryExit) { const { epochCtx } = state; const slot = computeStartSlotAtEpoch(signedVoluntaryExit.message.epoch); const domain = state.config.getDomainForVoluntaryExit(state.slot, slot); return { type: SignatureSetType.single, pubkey: epochCtx.index2pubkey[signedVoluntaryExit.message.validatorIndex], signingRoot: computeSigningRoot(ssz.phase0.VoluntaryExit, signedVoluntaryExit.message, domain), signature: signedVoluntaryExit.signature, }; } export function getVoluntaryExitsSignatureSets(state, signedBlock) { return signedBlock.message.body.voluntaryExits.map((voluntaryExit) => getVoluntaryExitSignatureSet(state, voluntaryExit)); } //# sourceMappingURL=voluntaryExits.js.map