Skip to content

Commit

Permalink
Fix "No state available" for latest block
Browse files Browse the repository at this point in the history
  • Loading branch information
alexb5dh committed Nov 5, 2024
1 parent 8e69a02 commit fb027fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/Nethermind/Nethermind.Trie/Pruning/OverlayTrieStore.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited
// SPDX-License-Identifier: LGPL-3.0-only

using System;
using Nethermind.Core;
using Nethermind.Core.Crypto;
using Nethermind.Logging;
Expand All @@ -12,10 +13,14 @@ public class OverlayTrieStore(IKeyValueStoreWithBatching? keyValueStore, IReadOn
public override bool IsPersisted(Hash256? address, in TreePath path, in ValueHash256 keccak) =>
base.IsPersisted(address, in path, in keccak) || store.IsPersisted(address, in path, in keccak);

public override TrieNode FindCachedOrUnknown(Hash256? address, in TreePath path, Hash256? hash)
internal override TrieNode FindCachedOrUnknown(Hash256? address, in TreePath path, Hash256? hash, bool isReadOnly)
{
TrieNode node = base.FindCachedOrUnknown(address, in path, hash);
return node.NodeType == NodeType.Unknown ? store.FindCachedOrUnknown(address, in path, hash) : node;
ArgumentNullException.ThrowIfNull(hash);

TrieNode node = base.FindCachedOrUnknown(address, in path, hash, isReadOnly);
return node.NodeType == NodeType.Unknown
? store.FindCachedOrUnknown(address, in path, hash) // no need to pass isReadOnly - IReadOnlyTrieStore overrides it as true
: node;
}

public override byte[]? LoadRlp(Hash256? address, in TreePath path, Hash256 hash, ReadFlags flags = ReadFlags.None) =>
Expand Down
4 changes: 2 additions & 2 deletions src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,10 @@ public IReadOnlyTrieStore AsReadOnly(INodeStorage? store) =>

public bool IsNodeCached(Hash256? address, in TreePath path, Hash256? hash) => DirtyNodesIsNodeCached(new TrieStoreDirtyNodesCache.Key(address, path, hash));

public virtual TrieNode FindCachedOrUnknown(Hash256? address, in TreePath path, Hash256? hash) =>
public TrieNode FindCachedOrUnknown(Hash256? address, in TreePath path, Hash256? hash) =>
FindCachedOrUnknown(address, path, hash, false);

internal TrieNode FindCachedOrUnknown(Hash256? address, in TreePath path, Hash256? hash, bool isReadOnly)
internal virtual TrieNode FindCachedOrUnknown(Hash256? address, in TreePath path, Hash256? hash, bool isReadOnly)
{
ArgumentNullException.ThrowIfNull(hash);

Expand Down

0 comments on commit fb027fb

Please sign in to comment.