Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Aug 24, 2023
1 parent 5cdbbe0 commit dd320bc
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions packages/beacon-node/src/api/impl/validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
SLOTS_PER_HISTORICAL_ROOT,
SYNC_COMMITTEE_SUBNET_SIZE,
isForkBlobs,
isForkExecution,
} from "@lodestar/params";
import {
Root,
Expand Down Expand Up @@ -265,14 +266,11 @@ export function getValidatorApi({
slot: Slot,
randaoReveal: BLSSignature,
graffiti: string,
feeRecipient?: string,
{strictFeeRecipientCheck}: {strictFeeRecipientCheck?: boolean} = {}
// this field can only be used to validate the builder bid (as it is a registration based system) which
// as of now doesn't return to what fee recipient the bid pay outs to.
_feeRecipient?: string
): Promise<routes.validator.ProduceBlindedBlockOrContentsRes> {
const source = ProducedBlockSource.builder;
// TODO PR
if (strictFeeRecipientCheck) {
throw Error(`strictFeeRecipientCheck not implemented yet for source=${source}`);
}

let timer;
metrics?.blockProductionRequests.inc({source});
Expand Down Expand Up @@ -300,6 +298,7 @@ export function getValidatorApi({
randaoReveal,
graffiti: toGraffitiBuffer(graffiti || ""),
});

metrics?.blockProductionSuccess.inc({source});
metrics?.blockProductionNumAggregated.observe({source}, block.body.attestations.length);
logger.verbose("Produced blinded block", {
Expand Down Expand Up @@ -357,14 +356,22 @@ export function getValidatorApi({
graffiti: toGraffitiBuffer(graffiti || ""),
feeRecipient,
});

const version = config.getForkName(block.slot);
if (strictFeeRecipientCheck && feeRecipient && isForkExecution(version)) {
const blockFeeRecipient = toHexString((block as bellatrix.BeaconBlock).body.executionPayload.feeRecipient);
if (blockFeeRecipient !== feeRecipient) {
throw Error(`Invalid feeRecipient set in engine block expected=${feeRecipient} actual=${blockFeeRecipient}`);
}
}

metrics?.blockProductionSuccess.inc({source});
metrics?.blockProductionNumAggregated.observe({source}, block.body.attestations.length);
logger.verbose("Produced execution block", {
slot,
executionPayloadValue,
root: toHexString(config.getForkTypes(slot).BeaconBlock.hashTreeRoot(block)),
});
const version = config.getForkName(block.slot);
if (isForkBlobs(version)) {
const blockHash = toHex((block as bellatrix.BeaconBlock).body.executionPayload.blockHash);
const {blobSidecars} = chain.producedBlobSidecarsCache.get(blockHash) ?? {};
Expand Down Expand Up @@ -399,12 +406,11 @@ export function getValidatorApi({

// Start calls for building execution and builder blocks
const blindedBlockPromise = chain.executionBuilder
? produceBlindedBlockOrContents(slot, randaoReveal, graffiti, feeRecipient, {strictFeeRecipientCheck}).catch(
(e) => {
logger.error("produceBlindedBlockOrContents failed to produce block", {slot}, e);
return null;
}
)
? // can't do fee recipient checks as builder bid doesn't return feeRecipient as of now
produceBlindedBlockOrContents(slot, randaoReveal, graffiti).catch((e) => {
logger.error("produceBlindedBlockOrContents failed to produce block", {slot}, e);
return null;
})
: null;

const fullBlockPromise =
Expand Down

0 comments on commit dd320bc

Please sign in to comment.