Deeper tracing of self-destructed accounts (#7284)

Consider previously self-destructed accounts when creating accounts.

Signed-off-by: Danno Ferrin <danno@numisight.com>
release-24.7.0
Danno Ferrin 5 months ago committed by GitHub
parent c0efeef89a
commit 264e7d9fac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      evm/src/main/java/org/hyperledger/besu/evm/worldstate/UpdateTrackingAccount.java
  2. 27
      evm/src/main/java/org/hyperledger/besu/evm/worldstate/WorldUpdater.java

@ -128,7 +128,6 @@ public class UpdateTrackingAccount<A extends Account> implements MutableAccount
public void setWrappedAccount(final A account) {
if (this.account == null) {
this.account = account;
storageWasCleared = false;
} else {
throw new IllegalStateException("Already tracking a wrapped account");
}

@ -24,6 +24,8 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;
import org.apache.tuweni.bytes.Bytes;
/**
* An object that buffers updates made over a particular {@link WorldView}.
*
@ -73,8 +75,29 @@ public interface WorldUpdater extends MutableWorldView {
* #createAccount(Address)} (and thus all his fields will be zero/empty).
*/
default MutableAccount getOrCreate(final Address address) {
final MutableAccount account = getAccount(address);
return account == null ? createAccount(address) : account;
MutableAccount account = getAccount(address);
if (account == null) {
account = createAccount(address);
if (parentUpdater().isPresent() && parentUpdater().get().isDeleted(address)) {
account.clearStorage();
account.setCode(Bytes.EMPTY);
}
}
return account;
}
/**
* Check this and parent updaters to see if an address has been deleted since the last persist
*
* @param address address to check
* @return true if any updaters have marked the address as deleted.
*/
default boolean isDeleted(final Address address) {
if (getDeletedAccountAddresses().contains(address)) {
return true;
} else {
return parentUpdater().map(wu -> wu.isDeleted(address)).orElse(false);
}
}
/**

Loading…
Cancel
Save