Skip to content

Commit

Permalink
Warm up empty trees for accesslists (#7111)
Browse files Browse the repository at this point in the history
  • Loading branch information
benaadams authored May 30, 2024
1 parent e3b68b1 commit f1ff7a7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
11 changes: 9 additions & 2 deletions src/Nethermind/Nethermind.State/PersistentStorageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,16 @@ private StorageTree GetOrCreateStorage(Address address)
return value;
}

public void WarmUp(in StorageCell storageCell)
public void WarmUp(in StorageCell storageCell, bool isEmpty)
{
LoadFromTree(in storageCell);
if (isEmpty)
{
_preBlockCache[storageCell] = Array.Empty<byte>();
}
else
{
LoadFromTree(in storageCell);
}
}

private ReadOnlySpan<byte> LoadFromTree(in StorageCell storageCell)
Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.State/StateProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -654,9 +654,9 @@ public StateProvider(IScopedTrieStore? trieStore,
};
}

public void WarmUp(Address address)
public bool WarmUp(Address address)
{
GetState(address);
return GetState(address) is not null;
}

private Account? GetState(Address address)
Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.State/WorldState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ public void WarmUp(AccessList? accessList)
{
foreach ((Address address, AccessList.StorageKeysEnumerable storages) in accessList)
{
_stateProvider.WarmUp(address);
bool exists = _stateProvider.WarmUp(address);
foreach (UInt256 storage in storages)
{
_persistentStorageProvider.WarmUp(new StorageCell(address, storage));
_persistentStorageProvider.WarmUp(new StorageCell(address, storage), isEmpty: !exists);
}
}
}
Expand Down

0 comments on commit f1ff7a7

Please sign in to comment.