Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve withdrawals processing performance #5026

Merged
merged 5 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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