Skip to content

Commit

Permalink
plug v3 into vlidator and get it working
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Aug 21, 2023
1 parent 021d947 commit c7a8f5a
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 268 deletions.
17 changes: 13 additions & 4 deletions packages/api/src/beacon/routes/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -714,10 +714,19 @@ export function getReturnTypes(): ReturnTypes<Api> {
produceBlock: ContainerData(ssz.phase0.BeaconBlock),
produceBlockV2: produceBlockOrContents,
produceBlockV3: {
toJson: (data) =>
data.executionPayloadBlinded === true
? produceBlindedBlockOrContents.toJson(data)
: produceBlockOrContents.toJson(data),
toJson: (data) => {
if (data.executionPayloadBlinded) {
return {
execution_payload_blinded: true,
...(produceBlindedBlockOrContents.toJson(data) as Record<string, unknown>),
};
} else {
return {
execution_payload_blinded: false,
...(produceBlockOrContents.toJson(data) as Record<string, unknown>),
};
}
},
fromJson: (data) => {
if ((data as {execution_payload_blinded: true}).execution_payload_blinded) {
return {executionPayloadBlinded: true, ...produceBlindedBlockOrContents.fromJson(data)};
Expand Down
8 changes: 4 additions & 4 deletions packages/beacon-node/src/api/impl/validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ export function getValidatorApi({
// Callback to log the race events for better debugging capability
(event: RaceEvent, delayMs: number, index?: number) => {
const eventRef = index !== undefined ? {source: promisesOrder[index]} : {};
logger.debug("Block production race (builder vs execution)", {
logger.verbose("Block production race (builder vs execution)", {
event,
...eventRef,
delayMs,
Expand Down Expand Up @@ -481,21 +481,21 @@ export function getValidatorApi({
selectedSource = ProducedBlockSource.builder;
}
}
logger.debug(`Selected ${selectedSource} block`, {
logger.verbose(`Selected ${selectedSource} block`, {
builderSelection,
// winston logger doesn't like bigint
enginePayloadValue: `${enginePayloadValue}`,
builderPayloadValue: `${builderPayloadValue}`,
});
} else if (fullBlock && !blindedBlock) {
selectedSource = ProducedBlockSource.engine;
logger.debug("Selected engine block: no builder block produced", {
logger.verbose("Selected engine block: no builder block produced", {
// winston logger doesn't like bigint
enginePayloadValue: `${enginePayloadValue}`,
});
} else if (blindedBlock && !fullBlock) {
selectedSource = ProducedBlockSource.builder;
logger.debug("Selected builder block: no engine block produced", {
logger.verbose("Selected builder block: no engine block produced", {
// winston logger doesn't like bigint
builderPayloadValue: `${builderPayloadValue}`,
});
Expand Down
8 changes: 4 additions & 4 deletions packages/params/src/forkName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ export function isForkLightClient(fork: ForkName): fork is ForkLightClient {
}

export type ForkPreExecution = ForkPreLightClient | ForkName.altair;
export type ForkExecution = Exclude<ForkLightClient, ForkPreExecution>;
export type ForkExecution = Exclude<ForkName, ForkPreExecution>;
export function isForkExecution(fork: ForkName): fork is ForkExecution {
return isForkLightClient(fork) && fork !== ForkName.altair;
}

export type ForkPreWithdrawals = ForkPreExecution | ForkName.bellatrix;
export type ForkWithdrawals = Exclude<ForkExecution, ForkPreWithdrawals>;
export type ForkWithdrawals = Exclude<ForkName, ForkPreWithdrawals>;
export function isForkWithdrawals(fork: ForkName): fork is ForkWithdrawals {
return isForkExecution(fork) && fork !== ForkName.bellatrix;
}

export type ForkPreBlobs = ForkPreWithdrawals | ForkName.capella;
export type ForkBlobs = Exclude<ForkExecution, ForkPreBlobs>;
export function isForkBlobs(fork: ForkName): fork is ForkBlobs {
export type ForkBlobs = Exclude<ForkName, ForkPreBlobs>;
export function isForkBlobs(fork: ForkName): fork is ForkName.deneb {
return isForkWithdrawals(fork) && fork !== ForkName.capella;
}
Loading

0 comments on commit c7a8f5a

Please sign in to comment.