From b4ee745a6e830416c8f4f7044a7eee476459157c Mon Sep 17 00:00:00 2001 From: gajinder Date: Fri, 27 Oct 2023 14:46:56 +0530 Subject: [PATCH] fix: fix publishing blsToExecutionChange on post capella forks --- packages/beacon-node/src/network/network.ts | 24 +++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/beacon-node/src/network/network.ts b/packages/beacon-node/src/network/network.ts index fba3c7a23e22..834ebacaa7a8 100644 --- a/packages/beacon-node/src/network/network.ts +++ b/packages/beacon-node/src/network/network.ts @@ -8,7 +8,7 @@ import {computeStartSlotAtEpoch, computeTimeAtSlot} from "@lodestar/state-transi import {phase0, allForks, deneb, altair, Root, capella, SlotRootHex} from "@lodestar/types"; import {routes} from "@lodestar/api"; import {ResponseIncoming} from "@lodestar/reqresp"; -import {ForkName, ForkSeq, MAX_BLOBS_PER_BLOCK} from "@lodestar/params"; +import {ForkSeq, MAX_BLOBS_PER_BLOCK} from "@lodestar/params"; import {Metrics, RegistryMetricCreator} from "../metrics/index.js"; import {IBeaconChain} from "../chain/index.js"; import {IBeaconDb} from "../db/interface.js"; @@ -33,6 +33,7 @@ import {GetReqRespHandlerFn, Version, requestSszTypeByMethod, responseSszTypeByM import {collectSequentialBlocksInRange} from "./reqresp/utils/collectSequentialBlocksInRange.js"; import {getGossipSSZType, gossipTopicIgnoreDuplicatePublishError, stringifyGossipTopic} from "./gossip/topic.js"; import {AggregatorTracker} from "./processor/aggregatorTracker.js"; +import {getActiveForks} from "./forks.js"; type NetworkModules = { opts: NetworkOptions; @@ -323,11 +324,22 @@ export class Network implements INetwork { } async publishBlsToExecutionChange(blsToExecutionChange: capella.SignedBLSToExecutionChange): Promise { - return this.publishGossip( - {type: GossipType.bls_to_execution_change, fork: ForkName.capella}, - blsToExecutionChange, - {ignoreDuplicatePublishError: true} - ); + const publishChanges = []; + for (const fork of getActiveForks(this.config, this.clock.currentEpoch)) { + if (ForkSeq[fork] >= ForkSeq.capella) { + const publishPromise = this.publishGossip( + {type: GossipType.bls_to_execution_change, fork}, + blsToExecutionChange, + {ignoreDuplicatePublishError: true} + ); + publishChanges.push(publishPromise); + } + } + + if (publishChanges.length === 0) { + throw Error("No capella+ fork active yet to publish blsToExecutionChange"); + } + return Promise.any(publishChanges); } async publishProposerSlashing(proposerSlashing: phase0.ProposerSlashing): Promise {