Improve withdrawals processing performance (#5026)

* 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>
pull/5042/head
ahamlat 2 years ago committed by GitHub
parent ca12eaebab
commit cdfc5796e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      datatypes/src/main/java/org/hyperledger/besu/datatypes/GWei.java
  2. 3
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/BonsaiWorldStateUpdater.java

@ -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.
*
@ -111,7 +114,7 @@ public final class GWei extends BaseUInt64Value<GWei> 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

@ -284,7 +284,8 @@ public class BonsaiWorldStateUpdater extends AbstractWorldUpdater<BonsaiWorldVie
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,

Loading…
Cancel
Save