diff --git a/datatypes/src/main/java/org/hyperledger/besu/datatypes/GWei.java b/datatypes/src/main/java/org/hyperledger/besu/datatypes/GWei.java index 06e3667690..0ebc6a9b8e 100644 --- a/datatypes/src/main/java/org/hyperledger/besu/datatypes/GWei.java +++ b/datatypes/src/main/java/org/hyperledger/besu/datatypes/GWei.java @@ -34,6 +34,9 @@ public final class GWei extends BaseUInt64Value implements Quantity { /** The constant MAX_GWEI. */ public static final GWei MAX_GWEI = of(UInt64.MAX_VALUE); + /** The constant GWEI_TO_WEI_MULTIPLIER. */ + private static final BigInteger GWEI_TO_WEI_MULTIPLIER = BigInteger.valueOf(1_000_000_000L); + /** * Instantiates a new GWei. * @@ -111,7 +114,7 @@ public final class GWei extends BaseUInt64Value implements Quantity { * @return Wei */ public Wei getAsWei() { - return Wei.of(getAsBigInteger().multiply(BigInteger.TEN.pow(9))); + return Wei.of(getAsBigInteger().multiply(GWEI_TO_WEI_MULTIPLIER)); } @Override diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateUpdater.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateUpdater.java index 28e1d7fcce..592861d268 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateUpdater.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateUpdater.java @@ -284,7 +284,8 @@ public class BonsaiWorldStateUpdater extends AbstractWorldUpdater(wrappedWorldView().getCode(addr).orElse(null), null)); pendingCode.setUpdated(updatedAccount.getCode()); } - + // This is especially to avoid unnecessary computation for withdrawals + if (updatedAccount.getUpdatedStorage().isEmpty()) return; final StorageConsumingMap> pendingStorageUpdates = storageToUpdate.computeIfAbsent( updatedAddress,