ethereum/go-ethereum · critical

%T: invalid node: %v

Error message

%T: invalid node: %v

What it means

The trie inspector (trie/inspect.go) panics when it encounters a node type it does not know how to traverse (the default branch of its per-node-type switch). The inspector walks accounts and storage tries by concrete node type (shortNode, fullNode, valueNode, hashNode); any other type means the structure is invalid for inspection.

Source

Thrown at trie/inspect.go:495

			owner := common.BytesToHash(hexToCompact(path))
			storage, err := New(StorageTrieID(in.root, owner, account.Root), in.triedb)
			if err != nil {
				log.Error("Failed to open account storage trie", "node", n, "error", err, "height", height, "path", common.Bytes2Hex(path))
				break
			}
			storageStat := NewLevelStats()
			run := func() {
				in.recordRootSize(storage, account.Root, storageStat)
				in.inspect(storage, storage.root, 0, []byte{}, storageStat)
				in.writeDumpRecord(owner, storageStat)
			}
			if in.trySpawn(&wg, run) {
				break
			}
			run()
		}
	default:
		panic(fmt.Sprintf("%T: invalid node: %v", n, n))
	}

	// Wait for all goroutines spawned at this level before recording
	// the current node. This ensures the entire subtree is counted
	// before this call returns.
	wg.Wait()

	// Record stats for current height.
	stat.add(n, height)
}

// Summarize performs pass 2 over a trie dump and reports account stats,
// aggregate storage statistics, and top-N rankings.
func Summarize(dumpPath string, config *InspectConfig) error {
	config = normalizeInspectConfig(config)
	if dumpPath == "" {
		dumpPath = config.DumpPath
	}

View on GitHub (pinned to 6bb0588ad8)

Solutions

  1. Verify the database is intact (e.g. run the node's integrity/verification tools) before inspecting.
  2. Re-sync the chain data if corruption is confirmed.
  3. If running custom trie code, make sure every node type you introduce is handled by the inspector's switch.
  4. Capture the panic stack and the offending node type (%T) to identify which subtree is malformed.
Defensive patterns

Strategy: try-catch

Try / catch

defer func() {
    if r := recover(); r != nil {
        return fmt.Errorf("trie inspection aborted on invalid node: %v", r)
    }
}()
err := inspector.Run()

Prevention

When it happens

Trigger: Running trie dump/inspect APIs over a trie containing unexpected node implementations; corrupted trie data loaded from a damaged database; custom node types injected by forked trie code.

Common situations: Running chain data inspection tools (trie dump, state size accounting) against a corrupted or partially-written datadir; mixing trie package versions after an incomplete upgrade; inspecting tries built by modified node software.

Related errors


AI-assisted analysis of ethereum/go-ethereum@6bb0588ad8 (2026-08-15). Data as JSON: /api/errors/c592a99139698cb3. Report an issue: GitHub.