Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Sep 16, 2024
1 parent 7752694 commit 15de165
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -191,8 +192,8 @@ private SafeFuture<BlockContainer> 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);
}
Expand Down

0 comments on commit 15de165

Please sign in to comment.