diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/worldview/BonsaiWorldState.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/worldview/BonsaiWorldState.java index 7c7f7fd551..73717425de 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/worldview/BonsaiWorldState.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/worldview/BonsaiWorldState.java @@ -282,7 +282,10 @@ public class BonsaiWorldState worldStateUpdater.getAccountsToUpdate().get(updatedAddress); final BonsaiAccount accountOriginal = accountValue.getPrior(); final Hash storageRoot = - (accountOriginal == null) ? Hash.EMPTY_TRIE_HASH : accountOriginal.getStorageRoot(); + (accountOriginal == null + || worldStateUpdater.getStorageToClear().contains(updatedAddress)) + ? Hash.EMPTY_TRIE_HASH + : accountOriginal.getStorageRoot(); final StoredMerklePatriciaTrie storageTrie = createTrie( (location, key) -> diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/worldview/BonsaiWorldStateUpdateAccumulator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/worldview/BonsaiWorldStateUpdateAccumulator.java index f66fcd0f56..f4a0da55c9 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/worldview/BonsaiWorldStateUpdateAccumulator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/worldview/BonsaiWorldStateUpdateAccumulator.java @@ -328,17 +328,6 @@ public class BonsaiWorldStateUpdateAccumulator } if (tracked.getStorageWasCleared()) { updatedAccount.clearStorage(); - wrappedWorldView() - .getAllAccountStorage(updatedAddress, updatedAccount.getStorageRoot()) - .forEach( - (keyHash, entryValue) -> { - final StorageSlotKey storageSlotKey = - new StorageSlotKey(Hash.wrap(keyHash), Optional.empty()); - final UInt256 value = UInt256.fromBytes(RLP.decodeOne(entryValue)); - pendingStorageUpdates.put( - storageSlotKey, new BonsaiValue<>(value, null, true)); - }); - updatedAccount.setStorageRoot(Hash.EMPTY_TRIE_HASH); } tracked.getUpdatedStorage().forEach(updatedAccount::setStorageValue); }