Skip to content

Commit f47590a

Browse files
committed
add a fix to load correctly the storage trie in the Bonsai WorldState (#6205)
revert some modification that was made to pass tests #5686 and fix this tests by loading the storage with EMPTY_TRIE_HASH if we detect that it has been cleared before pushing the new slots after recreation. --------- Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Signed-off-by: matkt <karim.t2am@gmail.com>
1 parent e90a7fa commit f47590a

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/worldview/BonsaiWorldState.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,10 @@ private void updateAccountStorageState(
282282
worldStateUpdater.getAccountsToUpdate().get(updatedAddress);
283283
final BonsaiAccount accountOriginal = accountValue.getPrior();
284284
final Hash storageRoot =
285-
(accountOriginal == null) ? Hash.EMPTY_TRIE_HASH : accountOriginal.getStorageRoot();
285+
(accountOriginal == null
286+
|| worldStateUpdater.getStorageToClear().contains(updatedAddress))
287+
? Hash.EMPTY_TRIE_HASH
288+
: accountOriginal.getStorageRoot();
286289
final StoredMerklePatriciaTrie<Bytes, Bytes> storageTrie =
287290
createTrie(
288291
(location, key) ->

ethereum/core/src/main/java/org/hyperledger/besu/ethereum/bonsai/worldview/BonsaiWorldStateUpdateAccumulator.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -328,17 +328,6 @@ public void commit() {
328328
}
329329
if (tracked.getStorageWasCleared()) {
330330
updatedAccount.clearStorage();
331-
wrappedWorldView()
332-
.getAllAccountStorage(updatedAddress, updatedAccount.getStorageRoot())
333-
.forEach(
334-
(keyHash, entryValue) -> {
335-
final StorageSlotKey storageSlotKey =
336-
new StorageSlotKey(Hash.wrap(keyHash), Optional.empty());
337-
final UInt256 value = UInt256.fromBytes(RLP.decodeOne(entryValue));
338-
pendingStorageUpdates.put(
339-
storageSlotKey, new BonsaiValue<>(value, null, true));
340-
});
341-
updatedAccount.setStorageRoot(Hash.EMPTY_TRIE_HASH);
342331
}
343332
tracked.getUpdatedStorage().forEach(updatedAccount::setStorageValue);
344333
}

0 commit comments

Comments
 (0)