Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make missing root hash exception clearer #5879

Merged
merged 5 commits into from
Jul 3, 2023

Conversation

asdacap
Copy link
Contributor

@asdacap asdacap commented Jul 3, 2023

  • When a root node is missing, a TrieException shows up, which has the same message as when an inner node is missing.
  • But a missing root node does not necessariliy mean a corrupted DB, it can also happen when trying to execute blocks without the state of its parent.
  • The message now looks like:
{"jsonrpc":"2.0","error":{"code":-32603,"message":"Internal error","data":"Nethermind.Trie.TrieException: Failed to load root hash 0x56d728b50eeb9a280dd350ab614d5adcf52db7c27c11d4b4701fb9a048629555 while loading key c6a8e965934f1446869aa2be83c3ac28067ff29dd92f045dbd49563371bece03.\n ---> Nethermind.Trie.MissingNodeException: Node 0x56d728b50eeb9a280dd350ab614d5adcf52db7c27c11d4b4701fb9a048629555 is missing from the DB\n   at Nethermind.Trie.Pruning.TrieStore.LoadRlp(Keccak keccak, IKeyValueStore keyValueStore, ReadFlags readFlags) in /home/amirul/repo/nethermind/src/Nethermind/Nethermind.Trie/Pruning/TrieStore.cs:line 336\n   at Nethermind.Trie.TrieNode.ResolveNode(ITrieNodeResolver tree, ReadFlags readFlags) in /home/amirul/repo/nethermind/src/Nethermind/Nethermind.Trie/TrieNode.cs:line 308\n   at Nethermind.Trie.PatriciaTree.Get(Span`1 rawKey, Keccak rootHash) in /home/amirul/repo/nethermind/src/Nethermind/Nethermind.Trie/PatriciaTree.cs:line 322\n   --- End of inner exception stack trace ---\n   at Nethermind.Trie.PatriciaTree.Get(Span`1 rawKey, Keccak rootHash) in /home/amirul/repo/nethermind/src/Nethermind/Nethermind.Trie/PatriciaTree.cs:line 322\n   at Nethermind.State.StateProvider.GetAndAddToCache(Address address) in /home/amirul/repo/nethermind/src/Nethermind/Nethermind.State/StateProvider.cs:line 691\n   at Nethermind.State.StateProvider.GetNonce(Address address) in /home/amirul/repo/nethermind/src/Nethermind/Nethermind.State/StateProvider.cs:line 126\n   at Nethermind.Consensus.Processing.BlockProcessor.ProcessBlock(Block block, IBlockTracer blockTracer, ProcessingOptions options) in /home/amirul/repo/nethermind/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs:line 251\n   at Nethermind.Consensus.Processing.BlockProcessor.Process(Keccak newBranchStateRoot, List`1 suggestedBlocks, ProcessingOptions options, IBlockTracer blockTracer) in /home/amirul/repo/nethermind/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs:line 173\n   at Nethermind.Consensus.Processing.BlockchainProcessor.ProcessBranch(ProcessingBranch& processingBranch, ProcessingOptions options, IBlockTracer tracer) in /home/amirul/repo/nethermind/src/Nethermind/Nethermind.Consensus/Processing/BlockchainProcessor.cs:line 531\n   at Nethermind.Consensus.Processing.BlockchainProcessor.Process(Block suggestedBlock, ProcessingOptions options, IBlockTracer tracer) in /home/amirul/repo/nethermind/src/Nethermind/Nethermind.Consensus/Processing/BlockchainProcessor.cs:line 359\n   at Nethermind.Consensus.Processing.OneTimeChainProcessor.Process(Block block, ProcessingOptions options, IBlockTracer tracer) in /home/amirul/repo/nethermind/src/Nethermind/Nethermind.Consensus/Processing/OneTimeProcessor.cs:line 54\n   at Nethermind.Consensus.Tracing.GethStyleTracer.Trace(Block block, Keccak txHash, CancellationToken cancellationToken, GethTraceOptions options) in /home/amirul/repo/nethermind/src/Nethermind/Nethermind.Consensus/Tracing/GethStyleTracer.cs:line 126\n   at Nethermind.Consensus.Tracing.GethStyleTracer.Trace(BlockParameter blockParameter, Transaction tx, GethTraceOptions options, CancellationToken cancellationToken) in /home/amirul/repo/nethermind/src/Nethermind/Nethermind.Consensus/Tracing/GethStyleTracer.cs:line 72\n   at Nethermind.JsonRpc.Modules.DebugModule.DebugRpcModule.debug_traceCall(TransactionForRpc call, BlockParameter blockParameter, GethTraceOptions options) in /home/amirul/repo/nethermind/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugRpcModule.cs:line 80\n   at InvokeStub_IDebugRpcModule.debug_traceCall(Object, Object, IntPtr*)\n   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)"},"id":12}

Changes

  • Wrap load failure into MissingNodeException.
  • If inner node is MissingNodeException and the node hash is the same as the root, change the message to make it clear.

Types of changes

What types of changes does your code introduce?

  • Refactoring

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

Notes on testing

  • RPC message works as expected.

@asdacap asdacap merged commit 7e43273 into master Jul 3, 2023
61 checks passed
@asdacap asdacap deleted the refactor/separate-missing-roothash-exception branch July 3, 2023 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants