feat: implement table range checksums for reth db checksum#7623
feat: implement table range checksums for reth db checksum#7623Rjected merged 9 commits intoparadigmxyz:mainfrom
Conversation
There was a problem hiding this comment.
nice! I think this is in the right direction, although an eventual goal would be to use this in reth db stats --checksum. So I think it would be useful to document the units for each range, per table. For example, if you were to try to compare two nodes' HashedAccounts tables, how would you determine ranges? The tables that are indexed by block are slightly easier, because you can just go by some number of blocks, but that should still be documented
|
hey @AbnerZheng did my comment make sense / are you stuck on anything? |
It makes sense. But I am not familiar with these table, trying to sync a node on my server so that I could inspect these tables. |
btw it should be possible to test this with a testnet node, for example holesky, which is much smaller! lmk if you're still blocked or don't understand something - the table definitions are here reth/crates/storage/db/src/tables/mod.rs Lines 246 to 380 in 12873d5 |
|
@Rjected I have add another argument I can imagine the usage of this tool would like:
reth db checksum AccountsHistory --datadir ~/.local/share/reth/holesky --limit 100The result would be like: 2024-04-30T15:27:36.360619Z WARN This command should be run without the node running!
2024-04-30T15:27:36.360754Z INFO Hashed 0 entries.
2024-04-30T15:27:36.360870Z INFO Hashed 100 entries.
2024-04-30T15:27:36.360908Z INFO start-key: {"key":"0x0000000000000000000000000000000000000000","highest_block_number":30161}
2024-04-30T15:27:36.360919Z INFO end-key: {"key":"0x000000000000000000000000000000000000005e","highest_block_number":18446744073709551615}
2024-04-30T15:27:36.360934Z INFO Checksum for table `AccountsHistory`: 0x98f8199844a34072 (elapsed: 178.629µs)
reth db checksum AccountsHistory --datadir ~/.local/share/reth/holesky --limit 100 --start-key '{"key":"0x000000000000000000000000000000000000005e","highest_block_number":18446744073709551615}'We can get: 2024-04-30T15:32:01.614445Z WARN This command should be run without the node running!
2024-04-30T15:32:01.614565Z INFO start={"key":"0x000000000000000000000000000000000000005e","highest_block_number":18446744073709551615}
end=
2024-04-30T15:32:01.614625Z INFO Hashed 0 entries.
2024-04-30T15:32:01.614779Z INFO Hashed 100 entries.
2024-04-30T15:32:01.614813Z INFO start-key: {"key":"0x000000000000000000000000000000000000005e","highest_block_number":18446744073709551615}
2024-04-30T15:32:01.614820Z INFO end-key: {"key":"0x00000000000000000000000000000000000000c1","highest_block_number":18446744073709551615}
2024-04-30T15:32:01.614833Z INFO Checksum for table `AccountsHistory`: 0xadb85f752caba2fe (elapsed: 207.885µs)
So instead of documenting the unit, user can know how key would look like by running directly with limit setted and without setting |
|
@Rjected bump |
this sounds great! taking a look at the changes |
Rjected
left a comment
There was a problem hiding this comment.
some nits, otherwise this looks pretty good!
| @@ -41,10 +65,34 @@ impl<DB: Database> ChecksumViewer<'_, DB> { | |||
| let tx = provider.tx_ref(); | |||
|
|
|||
There was a problem hiding this comment.
Let's add a small info! message informing the user that the checksum is starting, and with which parameters (start, end, limit)
Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com>
Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com>
|
bump @Rjected |
Rjected
left a comment
There was a problem hiding this comment.
nice! this looks good to me, just tried it out:
dan@Dans-MacBook-Pro-4 ~/p/reth (issue-7561)> cargo run -- db checksum --chain holesky --end-key 0x000000000000c57cf0a1f923d44527e703f1ad70 PlainStorageState
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.34s
Running `target/debug/reth db checksum --chain holesky --end-key 0x000000000000c57cf0a1f923d44527e703f1ad70 PlainStorageState`
2024-05-22T21:45:25.181274Z WARN This command should be run without the node running!
2024-05-22T21:45:25.181992Z INFO Start computing checksum, start=None, end=Some("\"0x000000000000c57cf0a1f923d44527e703f1ad70\""), limit=None
2024-05-22T21:45:25.183467Z INFO Hashed 0 entries.
2024-05-22T21:45:25.183965Z INFO Hashed 142 entries.
2024-05-22T21:45:25.184330Z INFO start-key: "0x00000000000000447e69651d841bd8d104bed493"
2024-05-22T21:45:25.184366Z INFO end-key: "0x000000000000c57cf0a1f923d44527e703f1ad70"
2024-05-22T21:45:25.184396Z INFO Checksum for table `PlainStorageState`: 0x5b24949084bcf957 (elapsed: 1.119167ms)
dan@Dans-MacBook-Pro-4 ~/p/reth (issue-7561)> cargo run -- db checksum --chain holesky --limit 142 PlainStorageState
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.34s
Running `target/debug/reth db checksum --chain holesky --limit 142 PlainStorageState`
2024-05-22T21:45:57.432259Z WARN This command should be run without the node running!
2024-05-22T21:45:57.432980Z INFO Start computing checksum, start=None, end=None, limit=Some(142)
2024-05-22T21:45:57.434404Z INFO Hashed 0 entries.
2024-05-22T21:45:57.434888Z INFO Hashed 142 entries.
2024-05-22T21:45:57.435563Z INFO start-key: "0x00000000000000447e69651d841bd8d104bed493"
2024-05-22T21:45:57.435606Z INFO end-key: "0x000000000000c57cf0a1f923d44527e703f1ad70"
2024-05-22T21:45:57.435636Z INFO Checksum for table `PlainStorageState`: 0x5b24949084bcf957 (elapsed: 1.416042ms)
close #7561
Check whether it is in the right direction.
cargo run --bin reth db checksum HashedAccounts --datadir ~/.local/share/reth/holesky --start 0x005e54f1867fd030f90673b8b625ac8f0656e44a88cfc0b3af3e3f3c3d486960 --end 0x03089e01be9eb2af5ff5fa1c5983c6c6fb78dd734658d1f8f11d4f8d27a23fd5And here is the result: