diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayload.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayload.java index 206602c7c88..06851239211 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayload.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayload.java @@ -21,7 +21,6 @@ import static org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.ExecutionEngineJsonRpcMethod.EngineStatus.VALID; import static org.hyperledger.besu.util.Slf4jLambdaHelper.debugLambda; import static org.hyperledger.besu.util.Slf4jLambdaHelper.traceLambda; -import static org.hyperledger.besu.util.Slf4jLambdaHelper.warnLambda; import org.hyperledger.besu.consensus.merge.blockcreation.MergeMiningCoordinator; import org.hyperledger.besu.datatypes.Hash; @@ -251,24 +250,28 @@ JsonRpcResponse respondWith( } // engine api calls are synchronous, no need for volatile - private long lastInvalidWarn = System.currentTimeMillis(); + private long lastInvalidWarn = 0; JsonRpcResponse respondWithInvalid( final Object requestId, final EnginePayloadParameter param, final Hash latestValidHash, final String validationError) { + final String invalidBlockLogMessage = + String.format( + "Invalid new payload: number: %s, hash: %s, parentHash: %s, latestValidHash: %s, status: %s, validationError: %s", + param.getBlockNumber(), + param.getBlockHash(), + param.getParentHash(), + latestValidHash == null ? null : latestValidHash.toHexString(), + INVALID.name(), + validationError); + // always log invalid at DEBUG + LOG.debug(invalidBlockLogMessage); + // periodically log at WARN if (lastInvalidWarn + ENGINE_API_LOGGING_THRESHOLD < System.currentTimeMillis()) { lastInvalidWarn = System.currentTimeMillis(); - warnLambda( - LOG, - "Invalid new payload: number: {}, hash: {}, parentHash: {}, latestValidHash: {}, status: {}, validationError: {}", - () -> param.getBlockNumber(), - () -> param.getBlockHash(), - () -> param.getParentHash(), - () -> latestValidHash == null ? null : latestValidHash.toHexString(), - INVALID::name, - () -> validationError); + LOG.warn(invalidBlockLogMessage); } return new JsonRpcSuccessResponse( requestId,