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

cmd/geth: add db dumptrie command #22563

Merged
merged 2 commits into from
Mar 30, 2021
Merged

cmd/geth: add db dumptrie command #22563

merged 2 commits into from
Mar 30, 2021

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Mar 23, 2021

The db getslots <storage_root> can help investigate issues regarding data corruption

Copy link
Member

@rjl493456442 rjl493456442 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@holiman
Copy link
Contributor Author

holiman commented Mar 24, 2021

Actually, maybe this should just be geth db dumptrie <root> <prefix> <seek>, and not be specific to 'slots'?

@holiman
Copy link
Contributor Author

holiman commented Mar 25, 2021

I changed this to be more generic. Example:

Dumping out the main account trie: from a certain position, max 10 accounts:

[user@work go-ethereum]$ ./build/bin/geth --yolov3 db dumptrie  "0xbd763e50ee03749d8f30071512394914a1fa72e87e674015eaf419e545650a03" 0xff965edd4984f1a102dc1b6f0d70ece5e9290f2fcae8c35e3a135df622ce98a6 10
INFO [03-25|11:42:46.371] Maximum peer count                       ETH=50 LES=0 total=50
INFO [03-25|11:42:46.371] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [03-25|11:42:46.372] Set global gas cap                       cap=25000000
INFO [03-25|11:42:46.372] Allocated cache and file handles         database=/home/user/.ethereum/yolo-v3/geth/chaindata cache=512.00MiB handles=262144 readonly=true
INFO [03-25|11:42:46.390] Opened ancient database                  database=/home/user/.ethereum/yolo-v3/geth/chaindata/ancient readonly=true
  0. key 0xff965edd4984f1a102dc1b6f0d70ece5e9290f2fcae8c35e3a135df622ce98a6: 0xf8440280a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
  1. key 0xffa10b8ac43e1f348b7e98a74036cc431b6d661b48676f246b9c1d979244ab3e: 0xf8440280a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
  2. key 0xffa27262e411d72833134d2df290f0ba24605826352f22a164e993542f28f8fb: 0xf8440280a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
  3. key 0xffa67ad012883eb485e682a2e3f3d777101c0626e644356b7cc4c4922a0a2996: 0xf8440280a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
  4. key 0xffb0f51dbb93d62ee577177d2b73f50611241361e98dd016111edc0ee8581fd3: 0xf8440280a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
  5. key 0xffb34916b2e221888d31a2ecdbbd8577a1128bce4ae7f08ace185c3d0e4e677d: 0xf8440180a0f38f9f63c760d088d7dd04f743619b6291f63beebd8bdf530628f90e9cfa52d7a09e43cf7a6f14cf2afe778be08ecc23ee06f6cf70df2c8f01e995c4bf1ea77464
  6. key 0xffb92f00509ecb11a9bf50a3af159a27acc945de3fffc269ab43f90022cbb878: 0xf8440280a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
  7. key 0xffba2a25bef4613a2f8a346412a8cdb7e6fecf4b2e28c13cd3c3aaab1e4513c2: 0xf8440280a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
  8. key 0xffbc30d5f2b1760ef20c9a79ac9f9597a0dae0c03168e0a4e9dfbf252e69d966: 0xf8440280a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
  9. key 0xffbc5ea5f2795f4e292a941a94541f54f842a006c17d1441bd380e65652547e8: 0xf8440280a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
Exiting after 10 values

Checking one of the account leafs, to figure out the storage trie:

[user@work go-ethereum]$ rlpdump -hex 0xf8440180a0f38f9f63c760d088d7dd04f743619b6291f63beebd8bdf530628f90e9cfa52d7a09e43cf7a6f14cf2afe778be08ecc23ee06f6cf70df2c8f01e995c4bf1ea77464
[
  01,
  "",
  f38f9f63c760d088d7dd04f743619b6291f63beebd8bdf530628f90e9cfa52d7,
  9e43cf7a6f14cf2afe778be08ecc23ee06f6cf70df2c8f01e995c4bf1ea77464,
]

And then diving into that storage trie:

[user@work go-ethereum]$ ./build/bin/geth --yolov3 db dumptrie  0xf38f9f63c760d088d7dd04f743619b6291f63beebd8bdf530628f90e9cfa52d7  0x00 10
INFO [03-25|11:43:23.935] Maximum peer count                       ETH=50 LES=0 total=50
INFO [03-25|11:43:23.935] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [03-25|11:43:23.935] Set global gas cap                       cap=25000000
INFO [03-25|11:43:23.936] Allocated cache and file handles         database=/home/user/.ethereum/yolo-v3/geth/chaindata cache=512.00MiB handles=262144 readonly=true
INFO [03-25|11:43:23.953] Opened ancient database                  database=/home/user/.ethereum/yolo-v3/geth/chaindata/ancient readonly=true
  0. key 0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6: 0x01

@holiman holiman changed the title cmd/geth: add db getslots command cmd/geth: add db dumptrie command Mar 25, 2021
cmd/geth/dbcmd.go Outdated Show resolved Hide resolved
@fjl fjl removed the status:triage label Mar 30, 2021
@holiman holiman merged commit 59ac3c9 into ethereum:master Mar 30, 2021
@holiman holiman added this to the 1.10.2 milestone Mar 30, 2021
atif-konasl pushed a commit to frozeman/pandora-execution-engine that referenced this pull request Oct 15, 2021
Adds the command "geth db dumptrie <root> <seek> <max>", to better help investigate the trie data
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.

3 participants