diff --git a/src/Nethermind/Nethermind.Trie/Pruning/OverlayTrieStore.cs b/src/Nethermind/Nethermind.Trie/Pruning/OverlayTrieStore.cs index 6108165f1a2..9038dd5b1b3 100644 --- a/src/Nethermind/Nethermind.Trie/Pruning/OverlayTrieStore.cs +++ b/src/Nethermind/Nethermind.Trie/Pruning/OverlayTrieStore.cs @@ -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; @@ -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) => diff --git a/src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs b/src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs index f3781550d06..ad14529d092 100644 --- a/src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs +++ b/src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs @@ -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);