Skip to content

Commit

Permalink
persist accounts that have storage updates, but no nonce, balance nor…
Browse files Browse the repository at this point in the history
… code

Signed-off-by: Daniel Lehrner <[email protected]>
  • Loading branch information
daniellehrner committed Jul 15, 2024
1 parent 37606f2 commit 9c9121a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,6 @@ public TransactionProcessingResult processTransaction(
coinbaseCalculator.price(usedGas, transactionGasPrice, blockHeader.getBaseFee());

coinbase.incrementBalance(coinbaseWeiDelta);
authorizedCodeService.resetAuthorities();

operationTracer.traceEndTransaction(
worldUpdater,
Expand All @@ -516,8 +515,13 @@ public TransactionProcessingResult processTransaction(
initialFrame.getSelfDestructs().forEach(worldState::deleteAccount);

if (clearEmptyAccounts) {
worldState.clearAccountsThatAreEmpty();
// TODO remove for devnet-2 and later as in the new version of 7702 the nonce of the
// authorities is increased
// and will not be cleared anymore in case of storage change only
worldState.clearAccountsThatAreEmpty(authorizedCodeService.getAuthorities());
// worldState.clearAccountsThatAreEmpty();
}
authorizedCodeService.resetAuthorities();

if (initialFrame.getState() == MessageFrame.State.COMPLETED_SUCCESS) {
return TransactionProcessingResult.successful(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;
import java.util.Set;

import org.apache.tuweni.bytes.Bytes;

Expand Down Expand Up @@ -175,6 +176,19 @@ default void clearAccountsThatAreEmpty() {
.stream().filter(Account::isEmpty).forEach(a -> deleteAccount(a.getAddress()));
}

/**
* Clears any accounts that are empty, excluding those in the provided set
*
* @param excludedAddresses the addresses to exclude from deletion
*/
default void clearAccountsThatAreEmpty(final Set<Address> excludedAddresses) {
new ArrayList<>(getTouchedAccounts())
.stream()
.filter(a -> !excludedAddresses.contains(a.getAddress()))
.filter(Account::isEmpty)
.forEach(a -> deleteAccount(a.getAddress()));
}

/** Mark transaction boundary. */
default void markTransactionBoundary() {
// default is to ignore
Expand Down

0 comments on commit 9c9121a

Please sign in to comment.