go-ethereum/core/rawdb
Fynn 8450e40798
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run
cmd/geth: add inspect trie tool to analysis trie storage (#28892)
This pr adds a tool names `inpsect-trie`, aimed to analyze the mpt and
its node storage more efficiently.

## Example
 ./geth db inspect-trie --datadir server/data-seed/ latest 4000

## Result

- MPT shape
- Account Trie 
- Top N Storage Trie
```
+-------+-------+--------------+-------------+--------------+
|   -   | LEVEL | SHORTNODECNT | FULLNODECNT | VALUENODECNT |
+-------+-------+--------------+-------------+--------------+
|   -   |   0   |      0       |      1      |      0       |
|   -   |   1   |      0       |     16      |      0       |
|   -   |   2   |      76      |     32      |      74      |
|   -   |   3   |      66      |      1      |      66      |
|   -   |   4   |      2       |      0      |      2       |
| Total |  144  |      50      |     142     |
+-------+-------+--------------+-------------+--------------+
AccountTrie
+-------+-------+--------------+-------------+--------------+
|   -   | LEVEL | SHORTNODECNT | FULLNODECNT | VALUENODECNT |
+-------+-------+--------------+-------------+--------------+
|   -   |   0   |      0       |      1      |      0       |
|   -   |   1   |      0       |     16      |      0       |
|   -   |   2   |     108      |     84      |     104      |
|   -   |   3   |     195      |      5      |     195      |
|   -   |   4   |      10      |      0      |      10      |
| Total |  313  |     106      |     309     |
+-------+-------+--------------+-------------+--------------+
ContractTrie-0xc874e65ccffb133d9db4ff637e62532ef6ecef3223845d02f522c55786782911
+-------+-------+--------------+-------------+--------------+
|   -   | LEVEL | SHORTNODECNT | FULLNODECNT | VALUENODECNT |
+-------+-------+--------------+-------------+--------------+
|   -   |   0   |      0       |      1      |      0       |
|   -   |   1   |      0       |     16      |      0       |
|   -   |   2   |      57      |     14      |      56      |
|   -   |   3   |      33      |      0      |      33      |
| Total |  90   |      31      |     89      |
+-------+-------+--------------+-------------+--------------+
ContractTrie-0x1d7dcb6a0ce5227c5379fc5b0e004561d7833b063355f69bfea3178f08fbaab4
+-------+-------+--------------+-------------+--------------+
|   -   | LEVEL | SHORTNODECNT | FULLNODECNT | VALUENODECNT |
+-------+-------+--------------+-------------+--------------+
|   -   |   0   |      0       |      1      |      0       |
|   -   |   1   |      5       |      8      |      5       |
|   -   |   2   |      16      |      1      |      16      |
|   -   |   3   |      2       |      0      |      2       |
| Total |  23   |      10      |     23      |
+-------+-------+--------------+-------------+--------------+
ContractTrie-0xaa8a4783ebbb3bec45d3e804b3c59bfd486edfa39cbeda1d42bf86c08a0ebc0f
+-------+-------+--------------+-------------+--------------+
|   -   | LEVEL | SHORTNODECNT | FULLNODECNT | VALUENODECNT |
+-------+-------+--------------+-------------+--------------+
|   -   |   0   |      0       |      1      |      0       |
|   -   |   1   |      9       |      3      |      9       |
|   -   |   2   |      7       |      1      |      7       |
|   -   |   3   |      2       |      0      |      2       |
| Total |  18   |      5       |     18      |
+-------+-------+--------------+-------------+--------------+
ContractTrie-0x9d2804d0562391d7cfcfaf0013f0352e176a94403a58577ebf82168a21514441
+-------+-------+--------------+-------------+--------------+
|   -   | LEVEL | SHORTNODECNT | FULLNODECNT | VALUENODECNT |
+-------+-------+--------------+-------------+--------------+
|   -   |   0   |      0       |      1      |      0       |
|   -   |   1   |      6       |      4      |      6       |
|   -   |   2   |      8       |      0      |      8       |
| Total |  14   |      5       |     14      |
+-------+-------+--------------+-------------+--------------+
ContractTrie-0x17e3eb95d0e6e92b42c0b3e95c6e75080c9fcd83e706344712e9587375de96e1
+-------+-------+--------------+-------------+--------------+
|   -   | LEVEL | SHORTNODECNT | FULLNODECNT | VALUENODECNT |
+-------+-------+--------------+-------------+--------------+
|   -   |   0   |      0       |      1      |      0       |
|   -   |   1   |      5       |      3      |      5       |
|   -   |   2   |      7       |      0      |      7       |
| Total |  12   |      4       |     12      |
+-------+-------+--------------+-------------+--------------+
ContractTrie-0xc017ca90c8aa37693c38f80436bb15bde46d7b30a503aa808cb7814127468a44
Contract Trie, total trie num: 142, ShortNodeCnt: 620, FullNodeCnt: 204, ValueNodeCnt: 615
```

---------

Co-authored-by: lightclient <lightclient@protonmail.com>
Co-authored-by: MariusVanDerWijden <m.vanderwijden@live.de>
2026-02-24 10:56:00 -07:00
..
ancienttest core/rawdb: improve the test suite for ancient store (#32555) 2025-09-09 15:19:50 +08:00
eradb internal/era: New EraE implementation (#32157) 2026-02-09 08:30:19 -07:00
testdata core/rawdb: avoid unnecessary receipt processing for log filtering (#23147) 2021-09-28 12:54:49 +02:00
accessors_chain.go core/rawdb: revert "check pruning tail in HasBody and HasReceipts" (#33865) 2026-02-19 11:43:44 +01:00
accessors_chain_test.go crypto/keccak: vendor in golang.org/x/crypto/sha3 (#33323) 2026-02-03 14:55:27 -07:00
accessors_history.go core/rawdb, triedb/pathdb: introduce trienode history (#32596) 2025-10-10 14:51:27 +08:00
accessors_indexes.go cmd/evm/internal/t8ntool, core/rawdb: fix RLP iterator error handling (#33820) 2026-02-11 14:50:39 +01:00
accessors_indexes_test.go ethapi: reduce some of the wasted effort in GetTransactionReceipt (#32021) 2025-07-01 15:18:49 +08:00
accessors_metadata.go core/rawdb: remove outdated functions (#32542) 2025-09-04 17:25:33 +08:00
accessors_overlay.go core/state: introduce the TransitionState object (verkle transition part 1) (#31634) 2025-08-05 09:34:12 +08:00
accessors_snapshot.go all: fix various typos (#29542) 2024-04-16 15:44:00 +03:00
accessors_state.go core/rawdb, triedb/pathdb: re-structure the trienode history header (#32907) 2025-10-25 16:16:16 +08:00
accessors_sync.go core, accounts, eth, trie: handle genesis state missing (#28171) 2023-09-28 10:00:53 +03:00
accessors_trie.go core/rawdb: fix misleading comment in HasTrieNode (#32599) 2025-09-15 10:45:50 +08:00
ancient_scheme.go core/rawdb, triedb/pathdb: introduce trienode history (#32596) 2025-10-10 14:51:27 +08:00
ancient_utils.go core/rawdb: close freezer table in InspectFreezerTable (#33776) 2026-02-06 22:13:37 +08:00
chain_freezer.go triedb, core/rawdb: implement the partial read in freezer (#32132) 2025-10-13 19:40:03 +08:00
chain_iterator.go core/rawdb: fix incorrect tail value in unindexTransactions log output (#33796) 2026-02-09 15:49:53 +08:00
chain_iterator_test.go core/rawdb: skip missing block bodies during tx unindexing (#33573) 2026-01-12 14:25:22 +08:00
database.go cmd/geth: add inspect trie tool to analysis trie storage (#28892) 2026-02-24 10:56:00 -07:00
freezer.go triedb, core/rawdb: implement the partial read in freezer (#32132) 2025-10-13 19:40:03 +08:00
freezer_batch.go core/rawdb: capture open file error and fix resource leak (#33147) 2025-11-11 16:01:37 +08:00
freezer_memory.go core/rawdb: fix size counting in memory freezer (#33344) 2025-12-10 16:09:24 +08:00
freezer_memory_test.go core/rawdb: allow for truncation in the freezer (#31362) 2025-03-17 16:01:37 +01:00
freezer_meta.go core/rawdb: introduce flush offset in freezer (#30392) 2025-02-04 11:45:45 +01:00
freezer_meta_test.go core/rawdb: introduce flush offset in freezer (#30392) 2025-02-04 11:45:45 +01:00
freezer_resettable.go core/rawdb: close directory fd on Readdirnames error in cleanup (#33798) 2026-02-10 10:10:56 +08:00
freezer_resettable_test.go core/rawdb: implement in-memory freezer (#29135) 2024-04-30 11:33:22 +02:00
freezer_table.go core/rawdb: capture open file error and fix resource leak (#33147) 2025-11-11 16:01:37 +08:00
freezer_table_test.go triedb, core/rawdb: implement the partial read in freezer (#32132) 2025-10-13 19:40:03 +08:00
freezer_test.go core/rawdb: report truncateErr in concurrent truncate failure (#32651) 2025-09-18 14:46:51 +08:00
freezer_utils.go core/rawdb: fsync the index file after each freezer write (#28483) 2023-11-10 12:56:39 +02:00
freezer_utils_test.go all: more linters (#24783) 2022-06-13 16:24:45 +02:00
key_length_iterator.go core/rawdb: add specified key length iterator (#24535) 2022-03-15 10:28:26 +02:00
key_length_iterator_test.go core/rawdb: add specified key length iterator (#24535) 2022-03-15 10:28:26 +02:00
schema.go core/rawdb, triedb/pathdb: introduce trienode history (#32596) 2025-10-10 14:51:27 +08:00
table.go triedb, core/rawdb: implement the partial read in freezer (#32132) 2025-10-13 19:40:03 +08:00
table_test.go ethdb: Implement DeleteRange in batch (#31947) 2025-06-20 19:40:41 +08:00