@@ -5,6 +5,10 @@ use reth_codecs::Compact;
55use reth_db_api:: { cursor:: DbDupCursorRO , database:: Database , tables, transaction:: DbTx } ;
66use reth_db_common:: DbTool ;
77use reth_node_builder:: NodeTypesWithDB ;
8+ use tracing:: info;
9+
10+ /// Log progress every 1 million slots
11+ const LOG_INTERVAL : usize = 1_000_000 ;
812
913/// The arguments for the `reth db account-storage` command
1014#[ derive( Parser , Debug ) ]
@@ -16,20 +20,31 @@ pub struct Command {
1620impl Command {
1721 /// Execute `db account-storage` command
1822 pub fn execute < N : NodeTypesWithDB > ( self , tool : & DbTool < N > ) -> eyre:: Result < ( ) > {
23+ let address = self . address ;
1924 let ( slot_count, plain_size) = tool. provider_factory . db_ref ( ) . view ( |tx| {
2025 let mut cursor = tx. cursor_dup_read :: < tables:: PlainStorageState > ( ) ?;
2126 let mut count = 0usize ;
2227 let mut total_value_bytes = 0usize ;
2328
2429 // Walk all storage entries for this address
25- let walker = cursor. walk_dup ( Some ( self . address ) , None ) ?;
30+ let walker = cursor. walk_dup ( Some ( address) , None ) ?;
2631 for entry in walker {
2732 let ( _, storage_entry) = entry?;
2833 count += 1 ;
2934 // StorageEntry encodes as: 32 bytes (key/subkey uncompressed) + compressed U256
3035 let mut buf = Vec :: new ( ) ;
3136 let entry_len = storage_entry. to_compact ( & mut buf) ;
3237 total_value_bytes += entry_len;
38+
39+ if count % LOG_INTERVAL == 0 {
40+ info ! (
41+ target: "reth::cli" ,
42+ address = %address,
43+ slots = count,
44+ key = %storage_entry. key,
45+ "Processing storage slots..."
46+ ) ;
47+ }
3348 }
3449
3550 // Add 20 bytes for the Address key (stored once per account in dupsort)
@@ -42,9 +57,9 @@ impl Command {
4257 let hashed_size_estimate = if slot_count > 0 { plain_size + 12 } else { 0 } ;
4358 let total_estimate = plain_size + hashed_size_estimate;
4459
45- let hashed_address = keccak256 ( self . address ) ;
60+ let hashed_address = keccak256 ( address) ;
4661
47- println ! ( "Account: {}" , self . address ) ;
62+ println ! ( "Account: {address}" ) ;
4863 println ! ( "Hashed address: {hashed_address}" ) ;
4964 println ! ( "Storage slots: {slot_count}" ) ;
5065 println ! ( "Plain storage size: {} (estimated)" , human_bytes( plain_size as f64 ) ) ;
0 commit comments