Skip to content

cmd/geth, core/rawdb: add inspect-contract and inspect-trie#33721

Closed
weiihann wants to merge 5 commits intoethereum:masterfrom
weiihann:feat/dbcmd-inspect-trie
Closed

cmd/geth, core/rawdb: add inspect-contract and inspect-trie#33721
weiihann wants to merge 5 commits intoethereum:masterfrom
weiihann:feat/dbcmd-inspect-trie

Conversation

@weiihann
Copy link
Copy Markdown
Contributor

inspect-contract

Command: geth inspect-contract 0x06450dEe7FD2Fb8E39061434BAbCFC05599a6Fb8
Output:

=== Contract Inspection: 0x06450dEe7FD2Fb8E39061434BAbCFC05599a6Fb8 ===
Account hash: 0x159e4890cde46d5cadbfcd08a052f495ae791244728e06d910cc743ed05eae12

Account snapshot: 103.00 B
Snapshot storage: 127623837 slots (8.60 GiB)
Storage trie:     169564729 nodes (16.81 GiB)

Storage Trie Depth Distribution:
Depth | Nodes         | Size
------|---------------|---------------
    0 |             1 |      565.00 B
    1 |            16 |      8.84 KiB
    2 |           256 |    141.75 KiB
    3 |          4096 |      2.22 MiB
    4 |         65536 |     35.56 MiB
    5 |       1048576 |    569.75 MiB
    6 |      16768951 |      3.94 GiB
    7 |     101501501 |      8.45 GiB
    8 |      46428263 |      3.55 GiB
    9 |       3659548 |    282.64 MiB
   10 |         87591 |      6.81 MiB
   11 |           394 |     31.22 KiB

inspect-trie

Command: geth inspect-trie db inspect-trie
Output:

=== Trie Depth Distribution ===

Account Trie: 467961098 nodes
Storage Tries: 1968481249 nodes across 24908373 tries

Depth | Account Nodes | Account Size  | Storage Nodes | Storage Size
------|---------------|---------------|---------------|---------------
    0 |             1 |      533.00 B |      24908373 |      3.42 GiB
    1 |            16 |      8.34 KiB |      57584907 |      6.81 GiB
    2 |           256 |    133.75 KiB |      93966044 |     13.02 GiB
    3 |          4096 |      2.09 MiB |     226558031 |     27.83 GiB
    4 |         65536 |     33.56 MiB |     426906948 |     43.03 GiB
    5 |       1048576 |    538.00 MiB |     444882726 |     43.28 GiB
    6 |      16777216 |      6.17 GiB |     396152769 |     36.43 GiB
    7 |     192728465 |     19.54 GiB |     235874524 |     19.31 GiB
    8 |     230852311 |     24.68 GiB |      57631515 |      4.46 GiB
    9 |      25260640 |      2.72 GiB |       3925909 |    305.94 MiB
   10 |       1214276 |    135.58 MiB |         89104 |      6.95 MiB
   11 |          9587 |      1.07 MiB |           399 |     31.66 KiB
   12 |           122 |     13.80 KiB |             0 |        0.00 B

@rjl493456442
Copy link
Copy Markdown
Member

Probably we can unify them to inspect-tree with an optional contract address?

@MariusVanDerWijden
Copy link
Copy Markdown
Member

this duplicates a bit the work from here: #28892

@fjl
Copy link
Copy Markdown
Contributor

fjl commented Feb 3, 2026

The older tool is a bit different, it logs the node types and their count, but does not track the total size of each level. We do think it's useful to know the node types, so this PR could be extended to cover this.

@fjl fjl removed the status:triage label Feb 3, 2026
@lightclient
Copy link
Copy Markdown
Member

To track the short, full, and hash nodes, we need to actually walk the trie as in #28892, so right now I'm integrating the size tracking there to print the same "Trie Depth Distribution" chart that this PR introduces.

The "Contract Inspection" chart needs some info from the snapshot to compute the storage sizes and the slot counts, so it would make sense to keep in this PR in rawdb.

@weiihann would you mind removing inspect-trie from this PR and checking #28892 to provides the needed information for your analysis?

@lightclient lightclient self-assigned this Feb 19, 2026
@weiihann
Copy link
Copy Markdown
Contributor Author

To track the short, full, and hash nodes, we need to actually walk the trie as in #28892, so right now I'm integrating the size tracking there to print the same "Trie Depth Distribution" chart that this PR introduces.

The "Contract Inspection" chart needs some info from the snapshot to compute the storage sizes and the slot counts, so it would make sense to keep in this PR in rawdb.

@weiihann would you mind removing inspect-trie from this PR and checking #28892 to provides the needed information for your analysis?

Yup I just checked the latest changes in #28892. I think this PR is no longer useful, as we can add an optional address argument to inspect-trie like what Gary said.

@weiihann weiihann closed this Feb 19, 2026
@Xdiamond4
Copy link
Copy Markdown

Gary was concurrent

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.

6 participants