Skip to content

Commit

Permalink
Add optional withdrawals to the NewPayload log (hyperledger#5021)
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
  • Loading branch information
siladu authored and elenduuche committed Aug 16, 2023
1 parent ae5243e commit dc24913
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
import org.hyperledger.besu.plugin.services.exception.StorageException;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -320,16 +321,24 @@ protected EngineStatus getInvalidBlockHashStatus() {
}

private void logImportedBlockInfo(final Block block, final double timeInS) {
LOG.info(
String.format(
"Imported #%,d / %d tx / base fee %s / %,d (%01.1f%%) gas / (%s) in %01.3fs. Peers: %d",
block.getHeader().getNumber(),
block.getBody().getTransactions().size(),
final StringBuilder message = new StringBuilder();
message.append("Imported #%,d / %d tx");
final List<Object> messageArgs =
new ArrayList<>(
List.of(block.getHeader().getNumber(), block.getBody().getTransactions().size()));
if (block.getBody().getWithdrawals().isPresent()) {
message.append(" / %d ws");
messageArgs.add(block.getBody().getWithdrawals().get().size());
}
message.append(" / base fee %s / %,d (%01.1f%%) gas / (%s) in %01.3fs. Peers: %d");
messageArgs.addAll(
List.of(
block.getHeader().getBaseFee().map(Wei::toHumanReadableString).orElse("N/A"),
block.getHeader().getGasUsed(),
(block.getHeader().getGasUsed() * 100.0) / block.getHeader().getGasLimit(),
block.getHash().toHexString(),
timeInS,
ethPeers.peerCount()));
LOG.info(String.format(message.toString(), messageArgs.toArray()));
}
}

0 comments on commit dc24913

Please sign in to comment.