Skip to content

Commit

Permalink
Improve withdrawals processing performance (hyperledger#5026)
Browse files Browse the repository at this point in the history
* Improve withdrawals processing performance
* Add a changelog entry
* refactoring + remove the changelog entry as we have not change logs for the withdrawals

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
  • Loading branch information
ahamlat authored Feb 2, 2023
1 parent ca12eae commit cdfc579
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public final class GWei extends BaseUInt64Value<GWei> 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.
*
Expand Down Expand Up @@ -111,7 +114,7 @@ public static GWei fromHexString(final String str) {
* @return Wei
*/
public Wei getAsWei() {
return Wei.of(getAsBigInteger().multiply(BigInteger.TEN.pow(9)));
return Wei.of(getAsBigInteger().multiply(GWEI_TO_WEI_MULTIPLIER));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ public void commit() {
new BonsaiValue<>(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<BonsaiValue<UInt256>> pendingStorageUpdates =
storageToUpdate.computeIfAbsent(
updatedAddress,
Expand Down

0 comments on commit cdfc579

Please sign in to comment.