Skip to content

Commit

Permalink
fix: fix publishing blsToExecutionChange on post capella forks (#6070)
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Oct 27, 2023
1 parent cf13ce9 commit 2b5935a
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions packages/beacon-node/src/network/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;
Expand Down Expand Up @@ -323,11 +324,22 @@ export class Network implements INetwork {
}

async publishBlsToExecutionChange(blsToExecutionChange: capella.SignedBLSToExecutionChange): Promise<number> {
return this.publishGossip<GossipType.bls_to_execution_change>(
{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<GossipType.bls_to_execution_change>(
{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<number> {
Expand Down

0 comments on commit 2b5935a

Please sign in to comment.