Skip to content

Commit

Permalink
Add logging for newer FCU payload parameter details (hyperledger#6693)
Browse files Browse the repository at this point in the history
Move assembledBlock log to trace and only print short block string for debug level

Signed-off-by: Simon Dudley <[email protected]>
  • Loading branch information
siladu authored Mar 8, 2024
1 parent 6109275 commit c622213
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@
import java.util.List;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;

import io.vertx.core.Vertx;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.spi.LoggingEventBuilder;

public abstract class AbstractEngineForkchoiceUpdated extends ExecutionEngineJsonRpcMethod {
private static final Logger LOG = LoggerFactory.getLogger(AbstractEngineForkchoiceUpdated.class);
Expand Down Expand Up @@ -277,12 +279,31 @@ private JsonRpcResponse handleNonValidForkchoiceUpdate(
}

private void logPayload(final EnginePayloadAttributesParameter payloadAttributes) {
LOG.atDebug()
.setMessage("timestamp: {}, prevRandao: {}, suggestedFeeRecipient: {}")
.addArgument(payloadAttributes::getTimestamp)
.addArgument(() -> payloadAttributes.getPrevRandao().toHexString())
.addArgument(() -> payloadAttributes.getSuggestedFeeRecipient().toHexString())
.log();
String message = "payloadAttributes: timestamp: {}, prevRandao: {}, suggestedFeeRecipient: {}";
LoggingEventBuilder builder =
LOG.atDebug()
.setMessage(message)
.addArgument(payloadAttributes::getTimestamp)
.addArgument(() -> payloadAttributes.getPrevRandao().toHexString())
.addArgument(() -> payloadAttributes.getSuggestedFeeRecipient().toHexString());
if (payloadAttributes.getWithdrawals() != null) {
message += ", withdrawals: {}";
builder =
builder
.setMessage(message)
.addArgument(
payloadAttributes.getWithdrawals().stream()
.map(WithdrawalParameter::toString)
.collect(Collectors.joining(", ", "[", "]")));
}
if (payloadAttributes.getParentBeaconBlockRoot() != null) {
message += ", parentBeaconBlockRoot: {}";
builder =
builder
.setMessage(message)
.addArgument(() -> payloadAttributes.getParentBeaconBlockRoot().toHexString());
}
builder.log();
}

private boolean isValidForkchoiceState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext request) {
final Optional<BlockWithReceipts> blockWithReceipts =
mergeContext.get().retrieveBlockById(payloadId);
if (blockWithReceipts.isPresent()) {
final var proposal = blockWithReceipts.get();
LOG.atDebug().setMessage("assembledBlock {}").addArgument(() -> proposal).log();
final BlockWithReceipts proposal = blockWithReceipts.get();
LOG.atDebug()
.setMessage("assembledBlock for payloadId {}: {}")
.addArgument(() -> payloadId)
.addArgument(() -> proposal.getBlock().toLogString())
.log();
LOG.atTrace().setMessage("assembledBlock with receipts {}").addArgument(() -> proposal).log();
ValidationResult<RpcErrorType> forkValidationResult =
validateForkSupported(proposal.getHeader().getTimestamp());
if (!forkValidationResult.isValid()) {
Expand Down

0 comments on commit c622213

Please sign in to comment.