diff --git a/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts b/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts index 281399235301..0fe847c2187c 100644 --- a/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts +++ b/packages/beacon-node/src/chain/produceBlock/produceBlockBody.ts @@ -53,8 +53,8 @@ export type BlockAttributes = { }; export enum BlockType { - Full, - Blinded, + Full = "Full", + Blinded = "Blinded", } export type AssembledBodyType = T extends BlockType.Full ? allForks.BeaconBlockBody @@ -98,6 +98,14 @@ export async function produceBlockBody( // TODO: Does not guarantee that preDeneb enum goes with a preDeneb block let blobsResult: BlobsResult; let blockValue: Wei; + const fork = currentState.config.getForkName(blockSlot); + + const logMeta: Record = { + fork, + blockType, + slot: blockSlot, + }; + this.logger.verbose("Producing beacon block body", logMeta); // TODO: // Iterate through the naive aggregation pool and ensure all the attestations from there @@ -127,8 +135,6 @@ export async function produceBlockBody( voluntaryExits, }; - this.logger.verbose("Produced phase0 beacon block body", {slot: blockSlot, numAttestations: attestations.length}); - const blockEpoch = computeEpochAtSlot(blockSlot); if (blockEpoch >= this.config.ALTAIR_FORK_EPOCH) { @@ -139,12 +145,25 @@ export async function produceBlockBody( (blockBody as altair.BeaconBlockBody).syncAggregate = syncAggregate; } - const fork = currentState.config.getForkName(blockSlot); + Object.assign(logMeta, { + attestations: attestations.length, + deposits: deposits.length, + voluntaryExits: voluntaryExits.length, + attesterSlashings: attesterSlashings.length, + proposerSlashings: proposerSlashings.length, + }); if (isForkExecution(fork)) { const safeBlockHash = this.forkChoice.getJustifiedBlock().executionPayloadBlockHash ?? ZERO_HASH_HEX; const finalizedBlockHash = this.forkChoice.getFinalizedBlock().executionPayloadBlockHash ?? ZERO_HASH_HEX; const feeRecipient = requestedFeeRecipient ?? this.beaconProposerCache.getOrDefault(proposerIndex); + const feeRecipientType = requestedFeeRecipient + ? "requested" + : this.beaconProposerCache.get(proposerIndex) + ? "cached" + : "default"; + + Object.assign(logMeta, {feeRecipientType, feeRecipient}); if (blockType === BlockType.Blinded) { if (!this.executionBuilder) throw Error("Execution Builder not available"); @@ -184,6 +203,8 @@ export async function produceBlockBody( } (blockBody as deneb.BlindedBeaconBlockBody).blobKzgCommitments = blobKzgCommitments; blobsResult = {type: BlobsResultType.blinded}; + + Object.assign(logMeta, {blobs: blobKzgCommitments.length}); } else { blobsResult = {type: BlobsResultType.preDeneb}; } @@ -267,6 +288,8 @@ export async function produceBlockBody( return blobSidecar; }) as deneb.BlobSidecars; blobsResult = {type: BlobsResultType.produced, blobSidecars, blockHash}; + + Object.assign(logMeta, {blobs: blobSidecars.length}); } else { blobsResult = {type: BlobsResultType.preDeneb}; } @@ -301,8 +324,13 @@ export async function produceBlockBody( if (ForkSeq[fork] >= ForkSeq.capella) { // TODO: blsToExecutionChanges should be passed in the produceBlock call (blockBody as capella.BeaconBlockBody).blsToExecutionChanges = blsToExecutionChanges; + Object.assign({ + blsToExecutionChanges: blsToExecutionChanges.length, + withdrawals: (blockBody as capella.BeaconBlockBody).executionPayload.withdrawals.length, + }); } + this.logger.verbose("Produced beacon block body", logMeta); return {body: blockBody as AssembledBodyType, blobs: blobsResult, blockValue}; }