Skip to content

Commit

Permalink
chore: add beacon node info log when publishing block (#6661)
Browse files Browse the repository at this point in the history
* chore: add beacon node info log when publishing block

* Reorder log context to print slot first
  • Loading branch information
nflaig committed Apr 15, 2024
1 parent 3d30f2f commit 2dae605
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions packages/beacon-node/src/api/impl/beacon/blocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function getBeaconBlockApi({
const bodyRoot = toHex(chain.config.getForkTypes(slot).BeaconBlockBody.hashTreeRoot(signedBlock.message.body));
const blockLocallyProduced =
chain.producedBlockRoot.has(blockRoot) || chain.producedBlindedBlockRoot.has(blockRoot);
const valLogMeta = {broadcastValidation, blockRoot, bodyRoot, blockLocallyProduced, slot};
const valLogMeta = {slot, blockRoot, bodyRoot, broadcastValidation, blockLocallyProduced};

switch (broadcastValidation) {
case routes.beacon.BroadcastValidation.gossip: {
Expand Down Expand Up @@ -183,6 +183,7 @@ export function getBeaconBlockApi({

// TODO: Validate block
metrics?.registerBeaconBlock(OpSource.api, seenTimestampSec, blockForImport.block.message);
chain.logger.info("Publishing block", valLogMeta);
const publishPromises = [
// Send the block, regardless of whether or not it is valid. The API
// specification is very clear that this is the desired behaviour.
Expand Down Expand Up @@ -226,26 +227,26 @@ export function getBeaconBlockApi({
const executionPayload = chain.producedBlockRoot.get(blockRoot);
if (executionPayload !== undefined) {
const source = ProducedBlockSource.engine;
chain.logger.debug("Reconstructing signedBlockOrContents", {blockRoot, slot, source});
chain.logger.debug("Reconstructing signedBlockOrContents", {slot, blockRoot, source});

const contents = executionPayload
? chain.producedContentsCache.get(toHex(executionPayload.blockHash)) ?? null
: null;
const signedBlockOrContents = reconstructFullBlockOrContents(signedBlindedBlock, {executionPayload, contents});

chain.logger.info("Publishing assembled block", {blockRoot, slot, source});
chain.logger.info("Publishing assembled block", {slot, blockRoot, source});
return publishBlock(signedBlockOrContents, opts);
} else {
const source = ProducedBlockSource.builder;
chain.logger.debug("Reconstructing signedBlockOrContents", {blockRoot, slot, source});
chain.logger.debug("Reconstructing signedBlockOrContents", {slot, blockRoot, source});

const signedBlockOrContents = await reconstructBuilderBlockOrContents(chain, signedBlindedBlock);

// the full block is published by relay and it's possible that the block is already known to us
// by gossip
//
// see: https://github.com/ChainSafe/lodestar/issues/5404
chain.logger.info("Publishing assembled block", {blockRoot, slot, source});
chain.logger.info("Publishing assembled block", {slot, blockRoot, source});
return publishBlock(signedBlockOrContents, {...opts, ignoreIfKnown: true});
}
};
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/api/impl/validator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,9 +542,9 @@ export function getValidatorApi({
}

const loggerContext = {
slot,
fork,
builderSelection,
slot,
isBuilderEnabled,
isEngineEnabled,
strictFeeRecipientCheck,
Expand Down

0 comments on commit 2dae605

Please sign in to comment.