diff --git a/infrastructure/logging/src/main/java/tech/pegasys/teku/infrastructure/logging/Converter.java b/infrastructure/logging/src/main/java/tech/pegasys/teku/infrastructure/logging/Converter.java index 28eff67ee7f..cdc46acdeb7 100644 --- a/infrastructure/logging/src/main/java/tech/pegasys/teku/infrastructure/logging/Converter.java +++ b/infrastructure/logging/src/main/java/tech/pegasys/teku/infrastructure/logging/Converter.java @@ -30,20 +30,14 @@ public static String weiToEth(final UInt256 wei) { return result.setScale(6, RoundingMode.HALF_UP).toString(); } - public static String gweiToEth(final UInt256 gwei) { - return gweiToEth(new BigDecimal(gwei.toBigInteger())); - } - public static String gweiToEth(final UInt64 gwei) { - return gweiToEth(new BigDecimal(gwei.bigIntegerValue())); + return new BigDecimal(gwei.bigIntegerValue()) + .divide(gweiToEthFactor, 6, RoundingMode.HALF_UP) + .toString(); } public static UInt64 weiToGwei(final UInt256 wei) { final BigInteger gwei = Convert.fromWei(wei.toDecimalString(), Unit.GWEI).toBigInteger(); return UInt64.valueOf(gwei); } - - private static String gweiToEth(final BigDecimal gwei) { - return gwei.divide(gweiToEthFactor, 6, RoundingMode.HALF_UP).toString(); - } } diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/BlockProductionDuty.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/BlockProductionDuty.java index 5158eac7532..686e3f724c4 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/BlockProductionDuty.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/duties/BlockProductionDuty.java @@ -15,6 +15,7 @@ import static com.google.common.base.Preconditions.checkArgument; import static tech.pegasys.teku.infrastructure.logging.Converter.gweiToEth; +import static tech.pegasys.teku.infrastructure.logging.Converter.weiToEth; import static tech.pegasys.teku.infrastructure.logging.ValidatorLogger.VALIDATOR_LOGGER; import static tech.pegasys.teku.infrastructure.unsigned.UInt64.ZERO; @@ -191,8 +192,8 @@ private SafeFuture validateBlock( LOG.info( "Received block for slot {}, block rewards {} ETH, execution payload value {} ETH", slot, - gweiToEth(blockContainerAndMetaData.consensusBlockValue()), - gweiToEth(blockContainerAndMetaData.executionPayloadValue())); + weiToEth(blockContainerAndMetaData.consensusBlockValue()), + weiToEth(blockContainerAndMetaData.executionPayloadValue())); } return SafeFuture.completedFuture(unsignedBlockContainer); }