From ad53c2d83caa360a32705a000161fdf1e386d897 Mon Sep 17 00:00:00 2001 From: Julien Eluard Date: Fri, 8 Dec 2023 13:59:27 +0100 Subject: [PATCH] Fix operationId of bls_to_execution_changes routes --- packages/api/src/beacon/routes/beacon/pool.ts | 18 +++++----- .../api/test/unit/beacon/testData/beacon.ts | 4 +-- .../src/api/impl/beacon/pool/index.ts | 18 +++++----- .../chain/errors/blsToExecutionChangeError.ts | 12 +++---- .../beacon-node/src/chain/opPools/opPool.ts | 18 +++++----- .../beacon-node/src/chain/opPools/utils.ts | 2 +- .../chain/validation/blsToExecutionChange.ts | 34 +++++++++---------- packages/beacon-node/src/network/interface.ts | 2 +- packages/beacon-node/src/network/network.ts | 2 +- .../src/network/processor/gossipHandlers.ts | 6 ++-- .../test/e2e/network/gossipsub.test.ts | 10 +++--- .../test/spec/presets/operations.test.ts | 2 +- .../validation/blsToExecutionChange.test.ts | 32 ++++++++--------- .../chain/validation/voluntaryExit.test.ts | 2 +- .../cmds/validator/blsToExecutionChange.ts | 6 ++-- .../cli/test/e2e/blsToExecutionchange.test.ts | 2 +- .../src/block/processBlsToExecutionChange.ts | 14 ++++---- .../src/block/processOperations.ts | 6 ++-- packages/state-transition/src/index.ts | 2 +- .../src/signatureSets/blsToExecutionChange.ts | 10 +++--- .../src/signatureSets/index.ts | 4 +-- .../unit/signatureSets/signatureSets.test.ts | 4 +-- 22 files changed, 105 insertions(+), 105 deletions(-) diff --git a/packages/api/src/beacon/routes/beacon/pool.ts b/packages/api/src/beacon/routes/beacon/pool.ts index 65467e98b721..e272dcd6f322 100644 --- a/packages/api/src/beacon/routes/beacon/pool.ts +++ b/packages/api/src/beacon/routes/beacon/pool.ts @@ -63,7 +63,7 @@ export type Api = { * @returns any Successful response * @throws ApiError */ - getPoolBlsToExecutionChanges(): Promise< + getPoolBLSToExecutionChanges(): Promise< ApiClientResponse<{[HttpStatusCode.OK]: {data: capella.SignedBLSToExecutionChange[]}}> >; @@ -123,7 +123,7 @@ export type Api = { * @returns any BLSToExecutionChange is stored in node and broadcasted to network * @throws ApiError */ - submitPoolBlsToExecutionChange( + submitPoolBLSToExecutionChange( blsToExecutionChange: capella.SignedBLSToExecutionChange[] ): Promise>; @@ -143,12 +143,12 @@ export const routesData: RoutesData = { getPoolAttesterSlashings: {url: "/eth/v1/beacon/pool/attester_slashings", method: "GET"}, getPoolProposerSlashings: {url: "/eth/v1/beacon/pool/proposer_slashings", method: "GET"}, getPoolVoluntaryExits: {url: "/eth/v1/beacon/pool/voluntary_exits", method: "GET"}, - getPoolBlsToExecutionChanges: {url: "/eth/v1/beacon/pool/bls_to_execution_changes", method: "GET"}, + getPoolBLSToExecutionChanges: {url: "/eth/v1/beacon/pool/bls_to_execution_changes", method: "GET"}, submitPoolAttestations: {url: "/eth/v1/beacon/pool/attestations", method: "POST"}, submitPoolAttesterSlashings: {url: "/eth/v1/beacon/pool/attester_slashings", method: "POST"}, submitPoolProposerSlashings: {url: "/eth/v1/beacon/pool/proposer_slashings", method: "POST"}, submitPoolVoluntaryExit: {url: "/eth/v1/beacon/pool/voluntary_exits", method: "POST"}, - submitPoolBlsToExecutionChange: {url: "/eth/v1/beacon/pool/bls_to_execution_changes", method: "POST"}, + submitPoolBLSToExecutionChange: {url: "/eth/v1/beacon/pool/bls_to_execution_changes", method: "POST"}, submitPoolSyncCommitteeSignatures: {url: "/eth/v1/beacon/pool/sync_committees", method: "POST"}, }; @@ -158,12 +158,12 @@ export type ReqTypes = { getPoolAttesterSlashings: ReqEmpty; getPoolProposerSlashings: ReqEmpty; getPoolVoluntaryExits: ReqEmpty; - getPoolBlsToExecutionChanges: ReqEmpty; + getPoolBLSToExecutionChanges: ReqEmpty; submitPoolAttestations: {body: unknown}; submitPoolAttesterSlashings: {body: unknown}; submitPoolProposerSlashings: {body: unknown}; submitPoolVoluntaryExit: {body: unknown}; - submitPoolBlsToExecutionChange: {body: unknown}; + submitPoolBLSToExecutionChange: {body: unknown}; submitPoolSyncCommitteeSignatures: {body: unknown}; }; @@ -177,12 +177,12 @@ export function getReqSerializers(): ReqSerializers { getPoolAttesterSlashings: reqEmpty, getPoolProposerSlashings: reqEmpty, getPoolVoluntaryExits: reqEmpty, - getPoolBlsToExecutionChanges: reqEmpty, + getPoolBLSToExecutionChanges: reqEmpty, submitPoolAttestations: reqOnlyBody(ArrayOf(ssz.phase0.Attestation), Schema.ObjectArray), submitPoolAttesterSlashings: reqOnlyBody(ssz.phase0.AttesterSlashing, Schema.Object), submitPoolProposerSlashings: reqOnlyBody(ssz.phase0.ProposerSlashing, Schema.Object), submitPoolVoluntaryExit: reqOnlyBody(ssz.phase0.SignedVoluntaryExit, Schema.Object), - submitPoolBlsToExecutionChange: reqOnlyBody(ArrayOf(ssz.capella.SignedBLSToExecutionChange), Schema.ObjectArray), + submitPoolBLSToExecutionChange: reqOnlyBody(ArrayOf(ssz.capella.SignedBLSToExecutionChange), Schema.ObjectArray), submitPoolSyncCommitteeSignatures: reqOnlyBody(ArrayOf(ssz.altair.SyncCommitteeMessage), Schema.ObjectArray), }; } @@ -193,6 +193,6 @@ export function getReturnTypes(): ReturnTypes { getPoolAttesterSlashings: ContainerData(ArrayOf(ssz.phase0.AttesterSlashing)), getPoolProposerSlashings: ContainerData(ArrayOf(ssz.phase0.ProposerSlashing)), getPoolVoluntaryExits: ContainerData(ArrayOf(ssz.phase0.SignedVoluntaryExit)), - getPoolBlsToExecutionChanges: ContainerData(ArrayOf(ssz.capella.SignedBLSToExecutionChange)), + getPoolBLSToExecutionChanges: ContainerData(ArrayOf(ssz.capella.SignedBLSToExecutionChange)), }; } diff --git a/packages/api/test/unit/beacon/testData/beacon.ts b/packages/api/test/unit/beacon/testData/beacon.ts index 54b2537648cb..5169492e1396 100644 --- a/packages/api/test/unit/beacon/testData/beacon.ts +++ b/packages/api/test/unit/beacon/testData/beacon.ts @@ -93,7 +93,7 @@ export const testData: GenericServerTestCases = { args: [], res: {data: [ssz.phase0.SignedVoluntaryExit.defaultValue()]}, }, - getPoolBlsToExecutionChanges: { + getPoolBLSToExecutionChanges: { args: [], res: {data: [ssz.capella.SignedBLSToExecutionChange.defaultValue()]}, }, @@ -113,7 +113,7 @@ export const testData: GenericServerTestCases = { args: [ssz.phase0.SignedVoluntaryExit.defaultValue()], res: undefined, }, - submitPoolBlsToExecutionChange: { + submitPoolBLSToExecutionChange: { args: [[ssz.capella.SignedBLSToExecutionChange.defaultValue()]], res: undefined, }, diff --git a/packages/beacon-node/src/api/impl/beacon/pool/index.ts b/packages/beacon-node/src/api/impl/beacon/pool/index.ts index 170c358fe417..47b162ff4176 100644 --- a/packages/beacon-node/src/api/impl/beacon/pool/index.ts +++ b/packages/beacon-node/src/api/impl/beacon/pool/index.ts @@ -5,7 +5,7 @@ import {validateApiAttestation} from "../../../../chain/validation/index.js"; import {validateApiAttesterSlashing} from "../../../../chain/validation/attesterSlashing.js"; import {validateApiProposerSlashing} from "../../../../chain/validation/proposerSlashing.js"; import {validateApiVoluntaryExit} from "../../../../chain/validation/voluntaryExit.js"; -import {validateApiBlsToExecutionChange} from "../../../../chain/validation/blsToExecutionChange.js"; +import {validateApiBLSToExecutionChange} from "../../../../chain/validation/blsToExecutionChange.js"; import {validateApiSyncCommittee} from "../../../../chain/validation/syncCommittee.js"; import {ApiModules} from "../../types.js"; import {AttestationError, GossipAction, SyncCommitteeError} from "../../../../chain/errors/index.js"; @@ -41,8 +41,8 @@ export function getBeaconPoolApi({ return {data: chain.opPool.getAllVoluntaryExits()}; }, - async getPoolBlsToExecutionChanges() { - return {data: chain.opPool.getAllBlsToExecutionChanges().map(({data}) => data)}; + async getPoolBLSToExecutionChanges() { + return {data: chain.opPool.getAllBLSToExecutionChanges().map(({data}) => data)}; }, async submitPoolAttestations(attestations) { @@ -116,26 +116,26 @@ export function getBeaconPoolApi({ await network.publishVoluntaryExit(voluntaryExit); }, - async submitPoolBlsToExecutionChange(blsToExecutionChanges) { + async submitPoolBLSToExecutionChange(blsToExecutionChanges) { const errors: Error[] = []; await Promise.all( blsToExecutionChanges.map(async (blsToExecutionChange, i) => { try { // Ignore even if the change exists and reprocess - await validateApiBlsToExecutionChange(chain, blsToExecutionChange); + await validateApiBLSToExecutionChange(chain, blsToExecutionChange); const preCapella = chain.clock.currentEpoch < chain.config.CAPELLA_FORK_EPOCH; - chain.opPool.insertBlsToExecutionChange(blsToExecutionChange, preCapella); + chain.opPool.insertBLSToExecutionChange(blsToExecutionChange, preCapella); chain.emitter.emit(routes.events.EventType.blsToExecutionChange, blsToExecutionChange); if (!preCapella) { - await network.publishBlsToExecutionChange(blsToExecutionChange); + await network.publishBLSToExecutionChange(blsToExecutionChange); } } catch (e) { errors.push(e as Error); logger.error( - `Error on submitPoolBlsToExecutionChange [${i}]`, + `Error on submitPoolBLSToExecutionChange [${i}]`, {validatorIndex: blsToExecutionChange.message.validatorIndex}, e as Error ); @@ -144,7 +144,7 @@ export function getBeaconPoolApi({ ); if (errors.length > 1) { - throw Error("Multiple errors on submitPoolBlsToExecutionChange\n" + errors.map((e) => e.message).join("\n")); + throw Error("Multiple errors on submitPoolBLSToExecutionChange\n" + errors.map((e) => e.message).join("\n")); } else if (errors.length === 1) { throw errors[0]; } diff --git a/packages/beacon-node/src/chain/errors/blsToExecutionChangeError.ts b/packages/beacon-node/src/chain/errors/blsToExecutionChangeError.ts index 2d18d3531f45..a9960559b6ea 100644 --- a/packages/beacon-node/src/chain/errors/blsToExecutionChangeError.ts +++ b/packages/beacon-node/src/chain/errors/blsToExecutionChangeError.ts @@ -1,13 +1,13 @@ import {GossipActionError} from "./gossipValidation.js"; -export enum BlsToExecutionChangeErrorCode { +export enum BLSToExecutionChangeErrorCode { ALREADY_EXISTS = "BLS_TO_EXECUTION_CHANGE_ERROR_ALREADY_EXISTS", INVALID = "BLS_TO_EXECUTION_CHANGE_ERROR_INVALID", INVALID_SIGNATURE = "BLS_TO_EXECUTION_CHANGE_ERROR_INVALID_SIGNATURE", } -export type BlsToExecutionChangeErrorType = - | {code: BlsToExecutionChangeErrorCode.ALREADY_EXISTS} - | {code: BlsToExecutionChangeErrorCode.INVALID} - | {code: BlsToExecutionChangeErrorCode.INVALID_SIGNATURE}; +export type BLSToExecutionChangeErrorType = + | {code: BLSToExecutionChangeErrorCode.ALREADY_EXISTS} + | {code: BLSToExecutionChangeErrorCode.INVALID} + | {code: BLSToExecutionChangeErrorCode.INVALID_SIGNATURE}; -export class BlsToExecutionChangeError extends GossipActionError {} +export class BLSToExecutionChangeError extends GossipActionError {} diff --git a/packages/beacon-node/src/chain/opPools/opPool.ts b/packages/beacon-node/src/chain/opPools/opPool.ts index cee8d0614c30..091b2cd8723b 100644 --- a/packages/beacon-node/src/chain/opPools/opPool.ts +++ b/packages/beacon-node/src/chain/opPools/opPool.ts @@ -19,7 +19,7 @@ import {IBeaconDb} from "../../db/index.js"; import {SignedBLSToExecutionChangeVersioned} from "../../util/types.js"; import {BlockType} from "../interface.js"; import {Metrics} from "../../metrics/metrics.js"; -import {isValidBlsToExecutionChangeForBlockInclusion} from "./utils.js"; +import {isValidBLSToExecutionChangeForBlockInclusion} from "./utils.js"; type HexRoot = string; type AttesterSlashingCached = { @@ -72,7 +72,7 @@ export class OpPool { this.insertVoluntaryExit(voluntaryExit); } for (const item of blsToExecutionChanges) { - this.insertBlsToExecutionChange(item.data, item.preCapella); + this.insertBLSToExecutionChange(item.data, item.preCapella); } } @@ -120,7 +120,7 @@ export class OpPool { return this.voluntaryExits.has(validatorIndex); } - hasSeenBlsToExecutionChange(validatorIndex: ValidatorIndex): boolean { + hasSeenBLSToExecutionChange(validatorIndex: ValidatorIndex): boolean { return this.blsToExecutionChanges.has(validatorIndex); } @@ -153,7 +153,7 @@ export class OpPool { } /** Must be validated beforehand */ - insertBlsToExecutionChange(blsToExecutionChange: capella.SignedBLSToExecutionChange, preCapella = false): void { + insertBLSToExecutionChange(blsToExecutionChange: capella.SignedBLSToExecutionChange, preCapella = false): void { this.blsToExecutionChanges.set(blsToExecutionChange.message.validatorIndex, { data: blsToExecutionChange, preCapella, @@ -262,7 +262,7 @@ export class OpPool { const endBlsToExecutionChanges = stepsMetrics?.startTimer(); const blsToExecutionChanges: capella.SignedBLSToExecutionChange[] = []; for (const blsToExecutionChange of this.blsToExecutionChanges.values()) { - if (isValidBlsToExecutionChangeForBlockInclusion(state, blsToExecutionChange.data)) { + if (isValidBLSToExecutionChangeForBlockInclusion(state, blsToExecutionChange.data)) { blsToExecutionChanges.push(blsToExecutionChange.data); if (blsToExecutionChanges.length >= MAX_BLS_TO_EXECUTION_CHANGES) { break; @@ -292,7 +292,7 @@ export class OpPool { } /** For beacon pool API */ - getAllBlsToExecutionChanges(): SignedBLSToExecutionChangeVersioned[] { + getAllBLSToExecutionChanges(): SignedBLSToExecutionChangeVersioned[] { return Array.from(this.blsToExecutionChanges.values()); } @@ -303,7 +303,7 @@ export class OpPool { this.pruneAttesterSlashings(headState); this.pruneProposerSlashings(headState); this.pruneVoluntaryExits(headState); - this.pruneBlsToExecutionChanges(headState, finalizedState); + this.pruneBLSToExecutionChanges(headState, finalizedState); } /** @@ -372,12 +372,12 @@ export class OpPool { * Prune blsToExecutionChanges for validators which have been set with withdrawal * credentials */ - private pruneBlsToExecutionChanges( + private pruneBLSToExecutionChanges( headState: CachedBeaconStateAllForks, finalizedState: CachedBeaconStateAllForks | null ): void { for (const [key, blsToExecutionChange] of this.blsToExecutionChanges.entries()) { - // TODO CAPELLA: We need the finalizedState to safely prune BlsToExecutionChanges. Finalized state may not be + // TODO CAPELLA: We need the finalizedState to safely prune BLSToExecutionChanges. Finalized state may not be // available in the cache, so it can be null. Once there's a head only prunning strategy, change if (finalizedState !== null) { const validator = finalizedState.validators.getReadonly(blsToExecutionChange.data.message.validatorIndex); diff --git a/packages/beacon-node/src/chain/opPools/utils.ts b/packages/beacon-node/src/chain/opPools/utils.ts index 906f51593bde..39b91153e8f7 100644 --- a/packages/beacon-node/src/chain/opPools/utils.ts +++ b/packages/beacon-node/src/chain/opPools/utils.ts @@ -37,7 +37,7 @@ export function signatureFromBytesNoCheck(signature: Uint8Array): Signature { * Ensures that a SignedBLSToExecutionChange object is _still_ valid for block inclusion. An object valid for the pool, * can become invalid for certain forks. */ -export function isValidBlsToExecutionChangeForBlockInclusion( +export function isValidBLSToExecutionChangeForBlockInclusion( state: CachedBeaconStateAllForks, signedBLSToExecutionChange: capella.SignedBLSToExecutionChange ): boolean { diff --git a/packages/beacon-node/src/chain/validation/blsToExecutionChange.ts b/packages/beacon-node/src/chain/validation/blsToExecutionChange.ts index e5ad56daeb5c..5383bcd92880 100644 --- a/packages/beacon-node/src/chain/validation/blsToExecutionChange.ts +++ b/packages/beacon-node/src/chain/validation/blsToExecutionChange.ts @@ -1,29 +1,29 @@ import {capella} from "@lodestar/types"; import { - isValidBlsToExecutionChange, - getBlsToExecutionChangeSignatureSet, + isValidBLSToExecutionChange, + getBLSToExecutionChangeSignatureSet, CachedBeaconStateCapella, } from "@lodestar/state-transition"; import {IBeaconChain} from ".."; -import {BlsToExecutionChangeError, BlsToExecutionChangeErrorCode, GossipAction} from "../errors/index.js"; +import {BLSToExecutionChangeError, BLSToExecutionChangeErrorCode, GossipAction} from "../errors/index.js"; -export async function validateApiBlsToExecutionChange( +export async function validateApiBLSToExecutionChange( chain: IBeaconChain, blsToExecutionChange: capella.SignedBLSToExecutionChange ): Promise { const ignoreExists = true; const prioritizeBls = true; - return validateBlsToExecutionChange(chain, blsToExecutionChange, {ignoreExists, prioritizeBls}); + return validateBLSToExecutionChange(chain, blsToExecutionChange, {ignoreExists, prioritizeBls}); } -export async function validateGossipBlsToExecutionChange( +export async function validateGossipBLSToExecutionChange( chain: IBeaconChain, blsToExecutionChange: capella.SignedBLSToExecutionChange ): Promise { - return validateBlsToExecutionChange(chain, blsToExecutionChange); + return validateBLSToExecutionChange(chain, blsToExecutionChange); } -async function validateBlsToExecutionChange( +async function validateBLSToExecutionChange( chain: IBeaconChain, blsToExecutionChange: capella.SignedBLSToExecutionChange, opts: {ignoreExists?: boolean; prioritizeBls?: boolean} = {ignoreExists: false, prioritizeBls: false} @@ -31,9 +31,9 @@ async function validateBlsToExecutionChange( const {ignoreExists, prioritizeBls} = opts; // [IGNORE] The blsToExecutionChange is the first valid blsToExecutionChange received for the validator with index // signedBLSToExecutionChange.message.validatorIndex. - if (!ignoreExists && chain.opPool.hasSeenBlsToExecutionChange(blsToExecutionChange.message.validatorIndex)) { - throw new BlsToExecutionChangeError(GossipAction.IGNORE, { - code: BlsToExecutionChangeErrorCode.ALREADY_EXISTS, + if (!ignoreExists && chain.opPool.hasSeenBLSToExecutionChange(blsToExecutionChange.message.validatorIndex)) { + throw new BLSToExecutionChangeError(GossipAction.IGNORE, { + code: BLSToExecutionChangeErrorCode.ALREADY_EXISTS, }); } @@ -45,17 +45,17 @@ async function validateBlsToExecutionChange( // [REJECT] All of the conditions within process_bls_to_execution_change pass validation. // verifySignature = false, verified in batch below - const {valid} = isValidBlsToExecutionChange(state as CachedBeaconStateCapella, blsToExecutionChange, false); + const {valid} = isValidBLSToExecutionChange(state as CachedBeaconStateCapella, blsToExecutionChange, false); if (!valid) { - throw new BlsToExecutionChangeError(GossipAction.REJECT, { - code: BlsToExecutionChangeErrorCode.INVALID, + throw new BLSToExecutionChangeError(GossipAction.REJECT, { + code: BLSToExecutionChangeErrorCode.INVALID, }); } - const signatureSet = getBlsToExecutionChangeSignatureSet(config, blsToExecutionChange); + const signatureSet = getBLSToExecutionChangeSignatureSet(config, blsToExecutionChange); if (!(await chain.bls.verifySignatureSets([signatureSet], {batchable: true, priority: prioritizeBls}))) { - throw new BlsToExecutionChangeError(GossipAction.REJECT, { - code: BlsToExecutionChangeErrorCode.INVALID_SIGNATURE, + throw new BLSToExecutionChangeError(GossipAction.REJECT, { + code: BLSToExecutionChangeErrorCode.INVALID_SIGNATURE, }); } } diff --git a/packages/beacon-node/src/network/interface.ts b/packages/beacon-node/src/network/interface.ts index 047263d15022..20508eee00e7 100644 --- a/packages/beacon-node/src/network/interface.ts +++ b/packages/beacon-node/src/network/interface.ts @@ -48,7 +48,7 @@ export interface INetwork extends INetworkCorePublic { publishBeaconAggregateAndProof(aggregateAndProof: phase0.SignedAggregateAndProof): Promise; publishBeaconAttestation(attestation: phase0.Attestation, subnet: number): Promise; publishVoluntaryExit(voluntaryExit: phase0.SignedVoluntaryExit): Promise; - publishBlsToExecutionChange(blsToExecutionChange: capella.SignedBLSToExecutionChange): Promise; + publishBLSToExecutionChange(blsToExecutionChange: capella.SignedBLSToExecutionChange): Promise; publishProposerSlashing(proposerSlashing: phase0.ProposerSlashing): Promise; publishAttesterSlashing(attesterSlashing: phase0.AttesterSlashing): Promise; publishSyncCommitteeSignature(signature: altair.SyncCommitteeMessage, subnet: number): Promise; diff --git a/packages/beacon-node/src/network/network.ts b/packages/beacon-node/src/network/network.ts index d2571a2a92e0..b8f9d471f3d1 100644 --- a/packages/beacon-node/src/network/network.ts +++ b/packages/beacon-node/src/network/network.ts @@ -323,7 +323,7 @@ export class Network implements INetwork { }); } - async publishBlsToExecutionChange(blsToExecutionChange: capella.SignedBLSToExecutionChange): Promise { + async publishBLSToExecutionChange(blsToExecutionChange: capella.SignedBLSToExecutionChange): Promise { const publishChanges = []; for (const fork of getActiveForks(this.config, this.clock.currentEpoch)) { if (ForkSeq[fork] >= ForkSeq.capella) { diff --git a/packages/beacon-node/src/network/processor/gossipHandlers.ts b/packages/beacon-node/src/network/processor/gossipHandlers.ts index 2e9ab3bb5a11..5b4be513c498 100644 --- a/packages/beacon-node/src/network/processor/gossipHandlers.ts +++ b/packages/beacon-node/src/network/processor/gossipHandlers.ts @@ -33,7 +33,7 @@ import { validateGossipSyncCommittee, validateSyncCommitteeGossipContributionAndProof, validateGossipVoluntaryExit, - validateGossipBlsToExecutionChange, + validateGossipBLSToExecutionChange, AggregateAndProofValidationResult, validateGossipAttestationsSameAttData, validateGossipAttestation, @@ -548,11 +548,11 @@ function getDefaultHandlers(modules: ValidatorFnsModules, options: GossipHandler }: GossipHandlerParamGeneric) => { const {serializedData} = gossipData; const blsToExecutionChange = sszDeserialize(topic, serializedData); - await validateGossipBlsToExecutionChange(chain, blsToExecutionChange); + await validateGossipBLSToExecutionChange(chain, blsToExecutionChange); // Handler try { - chain.opPool.insertBlsToExecutionChange(blsToExecutionChange); + chain.opPool.insertBLSToExecutionChange(blsToExecutionChange); } catch (e) { logger.error("Error adding blsToExecutionChange to pool", {}, e as Error); } diff --git a/packages/beacon-node/test/e2e/network/gossipsub.test.ts b/packages/beacon-node/test/e2e/network/gossipsub.test.ts index 1c7a57650eca..14b6aef97388 100644 --- a/packages/beacon-node/test/e2e/network/gossipsub.test.ts +++ b/packages/beacon-node/test/e2e/network/gossipsub.test.ts @@ -99,14 +99,14 @@ function runTests({useWorker}: {useWorker: boolean}): void { }); it("Publish and receive a blsToExecutionChange", async function () { - let onBlsToExecutionChange: (blsToExec: Uint8Array) => void; - const onBlsToExecutionChangePromise = new Promise((resolve) => (onBlsToExecutionChange = resolve)); + let onBLSToExecutionChange: (blsToExec: Uint8Array) => void; + const onBLSToExecutionChangePromise = new Promise((resolve) => (onBLSToExecutionChange = resolve)); const {netA, netB} = await mockModules({ [GossipType.bls_to_execution_change]: async ({ gossipData, }: GossipHandlerParamGeneric) => { - onBlsToExecutionChange(gossipData.serializedData); + onBLSToExecutionChange(gossipData.serializedData); }, }); @@ -126,9 +126,9 @@ function runTests({useWorker}: {useWorker: boolean}): void { } const blsToExec = ssz.capella.SignedBLSToExecutionChange.defaultValue(); - await netA.publishBlsToExecutionChange(blsToExec); + await netA.publishBLSToExecutionChange(blsToExec); - const receivedblsToExec = await onBlsToExecutionChangePromise; + const receivedblsToExec = await onBLSToExecutionChangePromise; expect(Buffer.from(receivedblsToExec)).toEqual( Buffer.from(ssz.capella.SignedBLSToExecutionChange.serialize(blsToExec)) ); diff --git a/packages/beacon-node/test/spec/presets/operations.test.ts b/packages/beacon-node/test/spec/presets/operations.test.ts index e7cb8a90dbb4..60b7fc3f1ed0 100644 --- a/packages/beacon-node/test/spec/presets/operations.test.ts +++ b/packages/beacon-node/test/spec/presets/operations.test.ts @@ -78,7 +78,7 @@ const operationFns: Record> = }, bls_to_execution_change: (state, testCase: {address_change: capella.SignedBLSToExecutionChange}) => { - blockFns.processBlsToExecutionChange(state as CachedBeaconStateCapella, testCase.address_change); + blockFns.processBLSToExecutionChange(state as CachedBeaconStateCapella, testCase.address_change); }, withdrawals: (state, testCase: {execution_payload: capella.ExecutionPayload}) => { diff --git a/packages/beacon-node/test/unit/chain/validation/blsToExecutionChange.test.ts b/packages/beacon-node/test/unit/chain/validation/blsToExecutionChange.test.ts index dd4402255949..db679131283d 100644 --- a/packages/beacon-node/test/unit/chain/validation/blsToExecutionChange.test.ts +++ b/packages/beacon-node/test/unit/chain/validation/blsToExecutionChange.test.ts @@ -16,8 +16,8 @@ import { import {createBeaconConfig} from "@lodestar/config"; import {generateState} from "../../../utils/state.js"; -import {validateGossipBlsToExecutionChange} from "../../../../src/chain/validation/blsToExecutionChange.js"; -import {BlsToExecutionChangeErrorCode} from "../../../../src/chain/errors/blsToExecutionChangeError.js"; +import {validateGossipBLSToExecutionChange} from "../../../../src/chain/validation/blsToExecutionChange.js"; +import {BLSToExecutionChangeErrorCode} from "../../../../src/chain/errors/blsToExecutionChangeError.js"; import {expectRejectedWithLodestarError} from "../../../utils/errors.js"; import {createCachedBeaconStateTest} from "../../../utils/cachedBeaconState.js"; import {MockedBeaconChain, getMockedBeaconChain} from "../../../__mocks__/mockedBeaconChain.js"; @@ -89,7 +89,7 @@ describe("validate bls to execution change", () => { opPool = chainStub.opPool; vi.spyOn(chainStub, "getHeadState").mockReturnValue(state); vi.spyOn(chainStub, "getHeadStateAtCurrentEpoch"); - vi.spyOn(opPool, "hasSeenBlsToExecutionChange"); + vi.spyOn(opPool, "hasSeenBLSToExecutionChange"); }); afterEach(() => { @@ -102,17 +102,17 @@ describe("validate bls to execution change", () => { signature: Buffer.alloc(96, 0), }; - // Return BlsToExecutionChange known - opPool.hasSeenBlsToExecutionChange.mockReturnValue(true); + // Return BLSToExecutionChange known + opPool.hasSeenBLSToExecutionChange.mockReturnValue(true); await expectRejectedWithLodestarError( - validateGossipBlsToExecutionChange(chainStub, signedBlsToExecChangeInvalid), - BlsToExecutionChangeErrorCode.ALREADY_EXISTS + validateGossipBLSToExecutionChange(chainStub, signedBlsToExecChangeInvalid), + BLSToExecutionChangeErrorCode.ALREADY_EXISTS ); }); it("should return valid blsToExecutionChange ", async () => { - await validateGossipBlsToExecutionChange(chainStub, signedBlsToExecChange); + await validateGossipBLSToExecutionChange(chainStub, signedBlsToExecChange); }); it("should return invalid bls to execution Change - invalid validatorIndex", async () => { @@ -126,8 +126,8 @@ describe("validate bls to execution change", () => { }; await expectRejectedWithLodestarError( - validateGossipBlsToExecutionChange(chainStub, signedBlsToExecChangeInvalid), - BlsToExecutionChangeErrorCode.INVALID + validateGossipBLSToExecutionChange(chainStub, signedBlsToExecChangeInvalid), + BLSToExecutionChangeErrorCode.INVALID ); }); @@ -141,8 +141,8 @@ describe("validate bls to execution change", () => { }; await expectRejectedWithLodestarError( - validateGossipBlsToExecutionChange(chainStub, signedBlsToExecChangeInvalid), - BlsToExecutionChangeErrorCode.INVALID + validateGossipBLSToExecutionChange(chainStub, signedBlsToExecChangeInvalid), + BLSToExecutionChangeErrorCode.INVALID ); }); @@ -157,8 +157,8 @@ describe("validate bls to execution change", () => { }; await expectRejectedWithLodestarError( - validateGossipBlsToExecutionChange(chainStub, signedBlsToExecChangeInvalid), - BlsToExecutionChangeErrorCode.INVALID + validateGossipBLSToExecutionChange(chainStub, signedBlsToExecChangeInvalid), + BLSToExecutionChangeErrorCode.INVALID ); }); @@ -173,8 +173,8 @@ describe("validate bls to execution change", () => { }; await expectRejectedWithLodestarError( - validateGossipBlsToExecutionChange(chainStub, signedBlsToExecChangeInvalid), - BlsToExecutionChangeErrorCode.INVALID + validateGossipBLSToExecutionChange(chainStub, signedBlsToExecChangeInvalid), + BLSToExecutionChangeErrorCode.INVALID ); }); }); diff --git a/packages/beacon-node/test/unit/chain/validation/voluntaryExit.test.ts b/packages/beacon-node/test/unit/chain/validation/voluntaryExit.test.ts index 2933fdc1ef77..b3ef2d15b379 100644 --- a/packages/beacon-node/test/unit/chain/validation/voluntaryExit.test.ts +++ b/packages/beacon-node/test/unit/chain/validation/voluntaryExit.test.ts @@ -65,7 +65,7 @@ describe("validate voluntary exit", () => { chainStub = getMockedBeaconChain(); opPool = chainStub.opPool; vi.spyOn(chainStub, "getHeadStateAtCurrentEpoch").mockResolvedValue(state); - vi.spyOn(opPool, "hasSeenBlsToExecutionChange"); + vi.spyOn(opPool, "hasSeenBLSToExecutionChange"); vi.spyOn(opPool, "hasSeenVoluntaryExit"); }); diff --git a/packages/cli/src/cmds/validator/blsToExecutionChange.ts b/packages/cli/src/cmds/validator/blsToExecutionChange.ts index ec81a9370bd3..9ed4eba8395c 100644 --- a/packages/cli/src/cmds/validator/blsToExecutionChange.ts +++ b/packages/cli/src/cmds/validator/blsToExecutionChange.ts @@ -14,13 +14,13 @@ import {IValidatorCliArgs} from "./options.js"; /* eslint-disable no-console */ -type BlsToExecutionChangeArgs = { +type BLSToExecutionChangeArgs = { publicKey?: string; fromBlsPrivkey?: string; toExecutionAddress?: string; }; -export const blsToExecutionChange: CliCommand = { +export const blsToExecutionChange: CliCommand = { command: "bls-to-execution-change", describe: @@ -94,7 +94,7 @@ like to choose for BLS To Execution Change.", }; ApiError.assert( - await client.beacon.submitPoolBlsToExecutionChange([signedBLSToExecutionChange]), + await client.beacon.submitPoolBLSToExecutionChange([signedBLSToExecutionChange]), "Can not submit bls to execution change" ); console.log(`Submitted bls to execution change for ${publicKey}`); diff --git a/packages/cli/test/e2e/blsToExecutionchange.test.ts b/packages/cli/test/e2e/blsToExecutionchange.test.ts index 9ea73e3b4afd..764d3bc366d6 100644 --- a/packages/cli/test/e2e/blsToExecutionchange.test.ts +++ b/packages/cli/test/e2e/blsToExecutionchange.test.ts @@ -72,7 +72,7 @@ describe("bLSToExecutionChange cmd", function () { "--toExecutionAddress 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", ]); - const pooledBlsChanges = await client.beacon.getPoolBlsToExecutionChanges(); + const pooledBlsChanges = await client.beacon.getPoolBLSToExecutionChanges(); ApiError.assert(pooledBlsChanges); const message = pooledBlsChanges.response.data[0].message; const {validatorIndex, toExecutionAddress, fromBlsPubkey} = message; diff --git a/packages/state-transition/src/block/processBlsToExecutionChange.ts b/packages/state-transition/src/block/processBlsToExecutionChange.ts index 1cc3706a756f..93daa541ab24 100644 --- a/packages/state-transition/src/block/processBlsToExecutionChange.ts +++ b/packages/state-transition/src/block/processBlsToExecutionChange.ts @@ -2,17 +2,17 @@ import {toHexString, byteArrayEquals} from "@chainsafe/ssz"; import {digest} from "@chainsafe/as-sha256"; import {capella} from "@lodestar/types"; import {BLS_WITHDRAWAL_PREFIX, ETH1_ADDRESS_WITHDRAWAL_PREFIX} from "@lodestar/params"; -import {verifyBlsToExecutionChangeSignature} from "../signatureSets/index.js"; +import {verifyBLSToExecutionChangeSignature} from "../signatureSets/index.js"; import {CachedBeaconStateCapella} from "../types.js"; -export function processBlsToExecutionChange( +export function processBLSToExecutionChange( state: CachedBeaconStateCapella, - signedBlsToExecutionChange: capella.SignedBLSToExecutionChange + signedBLSToExecutionChange: capella.SignedBLSToExecutionChange ): void { - const addressChange = signedBlsToExecutionChange.message; + const addressChange = signedBLSToExecutionChange.message; - const validation = isValidBlsToExecutionChange(state, signedBlsToExecutionChange, true); + const validation = isValidBLSToExecutionChange(state, signedBLSToExecutionChange, true); if (!validation.valid) { throw validation.error; } @@ -26,7 +26,7 @@ export function processBlsToExecutionChange( validator.withdrawalCredentials = newWithdrawalCredentials; } -export function isValidBlsToExecutionChange( +export function isValidBLSToExecutionChange( state: CachedBeaconStateCapella, signedBLSToExecutionChange: capella.SignedBLSToExecutionChange, verifySignature = true @@ -67,7 +67,7 @@ export function isValidBlsToExecutionChange( }; } - if (verifySignature && !verifyBlsToExecutionChangeSignature(state, signedBLSToExecutionChange)) { + if (verifySignature && !verifyBLSToExecutionChangeSignature(state, signedBLSToExecutionChange)) { return { valid: false, error: Error( diff --git a/packages/state-transition/src/block/processOperations.ts b/packages/state-transition/src/block/processOperations.ts index c523f1dad246..a34d15c2b225 100644 --- a/packages/state-transition/src/block/processOperations.ts +++ b/packages/state-transition/src/block/processOperations.ts @@ -7,7 +7,7 @@ import {processProposerSlashing} from "./processProposerSlashing.js"; import {processAttesterSlashing} from "./processAttesterSlashing.js"; import {processDeposit} from "./processDeposit.js"; import {processVoluntaryExit} from "./processVoluntaryExit.js"; -import {processBlsToExecutionChange} from "./processBlsToExecutionChange.js"; +import {processBLSToExecutionChange} from "./processBLSToExecutionChange.js"; import {ProcessBlockOpts} from "./types.js"; export { @@ -16,7 +16,7 @@ export { processAttestations, processDeposit, processVoluntaryExit, - processBlsToExecutionChange, + processBLSToExecutionChange, }; export function processOperations( @@ -51,7 +51,7 @@ export function processOperations( if (fork >= ForkSeq.capella) { for (const blsToExecutionChange of (body as capella.BeaconBlockBody).blsToExecutionChanges) { - processBlsToExecutionChange(state as CachedBeaconStateCapella, blsToExecutionChange); + processBLSToExecutionChange(state as CachedBeaconStateCapella, blsToExecutionChange); } } } diff --git a/packages/state-transition/src/index.ts b/packages/state-transition/src/index.ts index e72b6fa0581c..bbd01f3beb83 100644 --- a/packages/state-transition/src/index.ts +++ b/packages/state-transition/src/index.ts @@ -51,7 +51,7 @@ export { // BeaconChain validation export {isValidVoluntaryExit} from "./block/processVoluntaryExit.js"; -export {isValidBlsToExecutionChange} from "./block/processBlsToExecutionChange.js"; +export {isValidBLSToExecutionChange} from "./block/processBLSToExecutionChange.js"; export {assertValidProposerSlashing} from "./block/processProposerSlashing.js"; export {assertValidAttesterSlashing} from "./block/processAttesterSlashing.js"; export {ExecutionPayloadStatus, DataAvailableStatus, type BlockExternalData} from "./block/externalData.js"; diff --git a/packages/state-transition/src/signatureSets/blsToExecutionChange.ts b/packages/state-transition/src/signatureSets/blsToExecutionChange.ts index f0a50643e4ac..4a8da11b3308 100644 --- a/packages/state-transition/src/signatureSets/blsToExecutionChange.ts +++ b/packages/state-transition/src/signatureSets/blsToExecutionChange.ts @@ -7,17 +7,17 @@ import {BeaconConfig} from "@lodestar/config"; import {computeSigningRoot, ISignatureSet, SignatureSetType, verifySignatureSet} from "../util/index.js"; import {CachedBeaconStateAllForks} from "../types.js"; -export function verifyBlsToExecutionChangeSignature( +export function verifyBLSToExecutionChangeSignature( state: CachedBeaconStateAllForks, signedBLSToExecutionChange: capella.SignedBLSToExecutionChange ): boolean { - return verifySignatureSet(getBlsToExecutionChangeSignatureSet(state.config, signedBLSToExecutionChange)); + return verifySignatureSet(getBLSToExecutionChangeSignatureSet(state.config, signedBLSToExecutionChange)); } /** * Extract signatures to allow validating all block signatures at once */ -export function getBlsToExecutionChangeSignatureSet( +export function getBLSToExecutionChangeSignatureSet( config: BeaconConfig, signedBLSToExecutionChange: capella.SignedBLSToExecutionChange ): ISignatureSet { @@ -35,11 +35,11 @@ export function getBlsToExecutionChangeSignatureSet( }; } -export function getBlsToExecutionChangeSignatureSets( +export function getBLSToExecutionChangeSignatureSets( config: BeaconConfig, signedBlock: capella.SignedBeaconBlock ): ISignatureSet[] { return signedBlock.message.body.blsToExecutionChanges.map((blsToExecutionChange) => - getBlsToExecutionChangeSignatureSet(config, blsToExecutionChange) + getBLSToExecutionChangeSignatureSet(config, blsToExecutionChange) ); } diff --git a/packages/state-transition/src/signatureSets/index.ts b/packages/state-transition/src/signatureSets/index.ts index 05e4ad4b197a..4200904b11c1 100644 --- a/packages/state-transition/src/signatureSets/index.ts +++ b/packages/state-transition/src/signatureSets/index.ts @@ -9,7 +9,7 @@ import {getAttestationsSignatureSets} from "./indexedAttestation.js"; import {getBlockProposerSignatureSet} from "./proposer.js"; import {getRandaoRevealSignatureSet} from "./randao.js"; import {getVoluntaryExitsSignatureSets} from "./voluntaryExits.js"; -import {getBlsToExecutionChangeSignatureSets} from "./blsToExecutionChange.js"; +import {getBLSToExecutionChangeSignatureSets} from "./blsToExecutionChange.js"; export * from "./attesterSlashings.js"; export * from "./indexedAttestation.js"; @@ -60,7 +60,7 @@ export function getBlockSignatureSets( // only after capella fork if (fork >= ForkSeq.capella) { - const blsToExecutionChangeSignatureSets = getBlsToExecutionChangeSignatureSets( + const blsToExecutionChangeSignatureSets = getBLSToExecutionChangeSignatureSets( state.config, signedBlock as capella.SignedBeaconBlock ); diff --git a/packages/state-transition/test/unit/signatureSets/signatureSets.test.ts b/packages/state-transition/test/unit/signatureSets/signatureSets.test.ts index 9e084dc783a3..71785aa63615 100644 --- a/packages/state-transition/test/unit/signatureSets/signatureSets.test.ts +++ b/packages/state-transition/test/unit/signatureSets/signatureSets.test.ts @@ -45,7 +45,7 @@ describe("signatureSets", () => { attestations: [getMockAttestations(1)], deposits: [] as phase0.Deposit[], voluntaryExits: [getMockSignedVoluntaryExit({validatorIndex: 0, signature: EMPTY_SIGNATURE})], - blsToExecutionChanges: [getMockSignedBlsToExecutionChange({validatorIndex: 0, signature: EMPTY_SIGNATURE})], + blsToExecutionChanges: [getMockSignedBLSToExecutionChange({validatorIndex: 0, signature: EMPTY_SIGNATURE})], }, }; @@ -177,7 +177,7 @@ type SignedBLStoExecutionChange = { validatorIndex: ValidatorIndex; }; -function getMockSignedBlsToExecutionChange(data: SignedBLStoExecutionChange): capella.SignedBLSToExecutionChange { +function getMockSignedBLSToExecutionChange(data: SignedBLStoExecutionChange): capella.SignedBLSToExecutionChange { return { message: { validatorIndex: data.validatorIndex,