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

Deeper tracing of self-destructed accounts #7284

Merged
merged 2 commits into from
Jul 1, 2024
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 @@ -128,7 +128,6 @@ public A getWrappedAccount() {
public void setWrappedAccount(final A account) {
if (this.account == null) {
this.account = account;
storageWasCleared = false;
} else {
throw new IllegalStateException("Already tracking a wrapped account");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
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}.
*
Expand Down Expand Up @@ -73,8 +75,29 @@ default MutableAccount createAccount(final Address address) {
* #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);
}
}

/**
Expand Down
Loading