Description
Similarly to TraceRpcModule and EthRpcModule, DebugRpcModule should return a clear error message when the state is pruned.
Here is an example from TraceRpcModule: TraceRpcModule.cs#L88.
We need to review all DebugRpcModule endpoints and add proper error handling where necessary.
This is what will happen in debug_traceTransaction:
{'jsonrpc': '2.0', 'error': {'code': -32603, 'message': 'Internal error', 'data': 'System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.\n ---> Nethermind.Trie.MissingTrieNodeException: Node 0x671687b7c114dab66c76046659f0daf9a85cc314295dd809883296dd9be2cf48 is missing from the DB\n ---> Nethermind.Trie.TrieNodeException: Failed to load root hash 0x671687b7c114dab66c76046659f0daf9a85cc314295dd809883296dd9be2cf48 while loading key 2b9cfb0759b99df35efc8ee729cb85b86bf83a0c0a7df72c6cb4d92494c36042.\nNode 0x671687b7c114dab66c76046659f0daf9a85cc314295dd809883296dd9be2cf48 is missing from the DB\n at Nethermind.Trie.Pruning.TrieStore.LoadRlp(Hash256 address, TreePath& path, Hash256 keccak, INodeStorage nodeStorage, ReadFlags readFlags) in /src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs:line 387\n at Nethermind.Trie.Pruning.ReadOnlyTrieStore.LoadRlp(Hash256 address, TreePath& treePath, Hash256 hash, ReadFlags flags) in /src/Nethermind/Nethermind.Trie/Pruning/ReadOnlyTrieStore.cs:line 22\n at Nethermind.Trie.Pruning.ReadOnlyTrieStore.Nethermind.Trie.Pruning.ITrieStoreInternal.LoadRlp(Hash256 address, TreePath& path, Hash256 hash, ReadFlags flags)\n at Nethermind.Trie.Pruning.OverlayTrieStore.LoadRlp(Hash256 address, TreePath& path, Hash256 hash, ReadFlags flags) in /src/Nethermind/Nethermind.Trie/Pruning/OverlayTrieStore.cs:line 27\n at Nethermind.Trie.Pruning.ScopedTrieStore.LoadRlp(TreePath& path, Hash256 hash, ReadFlags flags) in /src/Nethermind/Nethermind.Trie/Pruning/ScopedTrieStore.cs:line 15\n at Nethermind.Trie.Pruning.ScopedTrieStore.Nethermind.Trie.Pruning.ITrieNodeResolver.LoadRlp(TreePath& path, Hash256 hash, ReadFlags flags)\n at Nethermind.Trie.TrieNode.ResolveUnknownNode(ITrieNodeResolver tree, TreePath& path, ReadFlags readFlags, ICappedArrayPool bufferPool) in /src/Nethermind/Nethermind.Trie/TrieNode.cs:line 398\n at Nethermind.Trie.PatriciaTree.ResolveNode(TrieNode node, TraverseContext& traverseContext, TreePath& path) in /src/Nethermind/Nethermind.Trie/PatriciaTree.cs:line 573\n --- End of inner exception stack trace ---\n at Nethermind.Trie.PatriciaTree.ResolveNode(TrieNode node, TraverseContext& traverseContext, TreePath& path) in /src/Nethermind/Nethermind.Trie/PatriciaTree.cs:line 581\n at Nethermind.Trie.PatriciaTree.Run(TreePath& updatePathTreePath, CappedArray
1& updateValue, Span1 updatePath, Boolean isUpdate, Boolean ignoreMissingDelete, Hash256 startRootHash, Boolean isNodeRead) in /src/Nethermind/Nethermind.Trie/PatriciaTree.cs:line 538\n at Nethermind.Trie.PatriciaTree.Get(ReadOnlySpan
1 rawKey, Hash256 rootHash) in /src/Nethermind/Nethermind.Trie/PatriciaTree.cs:line 334\n at Nethermind.State.StateTree.Get(Address address, Hash256 rootHash) in /src/Nethermind/Nethermind.State/StateTree.cs:line 45\n at Nethermind.State.StateProvider.<.ctor>b__49_0(AddressAsKey address) in /src/Nethermind/Nethermind.State/StateProvider.cs:line 646\n at Nethermind.State.StateProvider.GetStatePopulatePrewarmCache(AddressAsKey addressAsKey) in /src/Nethermind/Nethermind.State/StateProvider.cs:line 675\n at Nethermind.State.StateProvider.GetState(Address address) in /src/Nethermind/Nethermind.State/StateProvider.cs:line 661\n at Nethermind.State.StateProvider.GetAndAddToCache(Address address) in /src/Nethermind/Nethermind.State/StateProvider.cs:line 711\n at Nethermind.State.StateProvider.AccountExists(Address address) in /src/Nethermind/Nethermind.State/StateProvider.cs:line 91\n at Nethermind.State.WorldState.AccountExists(Address address) in /src/Nethermind/Nethermind.State/WorldState.cs:line 216\n at Nethermind.Blockchain.Blocks.BlockhashStore.ApplyBlockhashStateChanges(BlockHeader blockHeader) in /src/Nethermind/Nethermind.Blockchain/Blocks/BlockhashStore.cs:line 28\n at Nethermind.Consensus.Processing.BlockProcessor.ProcessBlock(Block block, IBlockTracer blockTracer, ProcessingOptions options) in /src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs:line 328\n at`