Skip to content

Commit b3baac7

Browse files
committed
rebaseing to the refactored prepare beacon proposer
1 parent d55e95d commit b3baac7

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

packages/lodestar/src/chain/beaconProposerCache.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ export class BeaconProposerCache {
3131
}
3232
}
3333

34-
get(proposerIndex: number | string): string {
34+
getOrDefault(proposerIndex: number | string): string {
3535
return this.feeRecipientByValidatorIndex.getOrDefault(`${proposerIndex}`).feeRecipient;
3636
}
37+
38+
get(proposerIndex: number | string): string | undefined {
39+
return this.feeRecipientByValidatorIndex.get(`${proposerIndex}`)?.feeRecipient;
40+
}
3741
}

packages/lodestar/src/chain/blocks/importBlock.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
getEffectiveBalanceIncrementsZeroInactive,
99
altair,
1010
computeEpochAtSlot,
11+
bellatrix,
1112
allForks,
1213
} from "@chainsafe/lodestar-beacon-state-transition";
1314
import {IForkChoice, OnBlockPrecachedData, ForkChoiceError, ForkChoiceErrorCode} from "@chainsafe/lodestar-fork-choice";
@@ -26,7 +27,8 @@ import {PendingEvents} from "./utils/pendingEvents";
2627
import {FullyVerifiedBlock} from "./types";
2728
import {SeenAggregatedAttestations} from "../seenCache/seenAggregateAndProof";
2829
import {prepareExecutionPayload} from "../factory/block/body";
29-
30+
import {IEth1ForBlockProduction} from "../../eth1";
31+
import {BeaconProposerCache} from "../beaconProposerCache";
3032
/**
3133
* Fork-choice allows to import attestations from current (0) or past (1) epoch.
3234
*/
@@ -38,7 +40,9 @@ export type ImportBlockModules = {
3840
stateCache: StateContextCache;
3941
checkpointStateCache: CheckpointStateCache;
4042
seenAggregatedAttestations: SeenAggregatedAttestations;
43+
beaconProposerCache: BeaconProposerCache;
4144
lightClientServer: LightClientServer;
45+
eth1: IEth1ForBlockProduction;
4246
executionEngine: IExecutionEngine;
4347
emitter: ChainEventEmitter;
4448
config: IChainForkConfig;
@@ -270,7 +274,7 @@ export async function issueNextProposerEngineFcU(
270274
if (bellatrix.isBellatrixStateType(prepareState)) {
271275
try {
272276
const proposerIndex = prepareState.epochCtx.getBeaconProposer(prepareSlot);
273-
const feeRecipient = chain.executionEngine.proposers.get(proposerIndex)?.feeRecipient;
277+
const feeRecipient = chain.beaconProposerCache.get(proposerIndex);
274278
if (feeRecipient) {
275279
const finalizedBlockHash = chain.forkChoice.getFinalizedBlock().executionPayloadBlockHash ?? ZERO_HASH_HEX;
276280
return prepareExecutionPayload(chain, finalizedBlockHash, prepareState, feeRecipient);

packages/lodestar/src/chain/chain.ts

+1
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ export class BeaconChain implements IBeaconChain {
199199
stateCache,
200200
checkpointStateCache,
201201
seenAggregatedAttestations: this.seenAggregatedAttestations,
202+
beaconProposerCache: this.beaconProposerCache,
202203
emitter,
203204
config,
204205
logger,

packages/lodestar/src/chain/factory/block/body.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export async function assembleBody(
9393
// - Call prepareExecutionPayload again if parameters change
9494

9595
const finalizedBlockHash = chain.forkChoice.getFinalizedBlock().executionPayloadBlockHash;
96-
const feeRecipient = chain.beaconProposerCache.get(proposerIndex);
96+
const feeRecipient = chain.beaconProposerCache.getOrDefault(proposerIndex);
9797

9898
// prepareExecutionPayload will throw error via notifyForkchoiceUpdate if
9999
// the EL returns Syncing on this request to prepare a payload

0 commit comments

Comments
 (0)