{"record":{"id":"4c5772f5ef79596a","repo":"ethereum/go-ethereum","slug":"sub-trie-ancestor-not-found-x","errorCode":null,"errorMessage":"sub-trie ancestor not found: %x","messagePattern":"sub-trie ancestor not found: %x","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"trie/sync.go","lineNumber":312,"sourceCode":"\texist, inconsistent := s.hasNode(owner, inner, root)\n\tif exist {\n\t\t// The entire subtrie is already present in the database.\n\t\treturn\n\t} else if inconsistent {\n\t\t// There is a pre-existing node with the wrong hash in DB, remove it.\n\t\ts.membatch.delNode(owner, inner)\n\t}\n\t// Assemble the new sub-trie sync request\n\treq := &nodeRequest{\n\t\thash:     root,\n\t\tpath:     path,\n\t\tcallback: callback,\n\t}\n\t// If this sub-trie has a designated parent, link them together\n\tif parent != (common.Hash{}) {\n\t\tancestor := s.nodeReqs[string(parentPath)]\n\t\tif ancestor == nil {\n\t\t\tpanic(fmt.Sprintf(\"sub-trie ancestor not found: %x\", parent))\n\t\t}\n\t\tancestor.deps++\n\t\treq.parent = ancestor\n\t}\n\ts.scheduleNodeRequest(req)\n}\n\n// AddCodeEntry schedules the direct retrieval of a contract code that should not\n// be interpreted as a trie node, but rather accepted and stored into the database\n// as is.\nfunc (s *Sync) AddCodeEntry(hash common.Hash, path []byte, parent common.Hash, parentPath []byte) {\n\t// Short circuit if the entry is empty or already known\n\tif hash == types.EmptyCodeHash {\n\t\treturn\n\t}\n\tif s.membatch.hasCode(hash) {\n\t\treturn\n\t}","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/ethereum/go-ethereum/blob/6bb0588ad8e7f922e4ad5580f51265a4097af08f/trie/sync.go#L294-L330","documentation":"Error \"sub-trie ancestor not found: %x\" thrown in ethereum/go-ethereum.","triggerScenarios":"trie.Sync scheduling a sub-trie request whose designated parent hash was not previously scheduled as a node request.","commonSituations":"Snap sync healing or state sync code scheduling child sub-tries before their ancestors.","solutions":["The scheduled sub-trie request references a parent that was never registered. Ensure parent sub-trie paths are scheduled before (or together with) their children in trie.Sync, and that path prefixes are consistent.","Treat this as an internal sync-scheduling bug: check that the caller derives sub-trie parent paths correctly."],"exampleFix":"// Parent sub-trie must be scheduled first:\nsync := trie.NewSync(root, db, callback, scheme)\nsync.AddSubTrie(parentPath, parentPathHash, parentRoot, nil)\nsync.AddSubTrie(childPath, childHash, childRoot, parentRoot) // parent known","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6bb0588ad8e7f922e4ad5580f51265a4097af08f","analyzedAt":"2026-08-15T10:06:53.996Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}