@@ -9,8 +9,8 @@ use ethrex_common::{
99} ; 
1010use  ethrex_trie:: { Nibbles ,  NodeHash ,  Trie } ; 
1111use  rocksdb:: { 
12-     BlockBasedOptions ,  BoundColumnFamily ,  Cache ,  ColumnFamilyDescriptor ,  MultiThreaded , 
13-     OptimisticTransactionDB ,  Options ,  WriteBatchWithTransaction , 
12+     BlockBasedOptions ,  BoundColumnFamily ,  Cache ,  ColumnFamilyDescriptor ,  DBWithThreadMode , 
13+     MultiThreaded ,  Options ,  WriteBatch , 
1414} ; 
1515use  std:: { collections:: HashSet ,  path:: Path ,  sync:: Arc } ; 
1616use  tracing:: info; 
@@ -103,7 +103,7 @@ const CF_INVALID_ANCESTORS: &str = "invalid_ancestors";
103103
104104#[ derive( Debug ) ]  
105105pub  struct  Store  { 
106-     db :  Arc < OptimisticTransactionDB < MultiThreaded > > , 
106+     db :  Arc < DBWithThreadMode < MultiThreaded > > , 
107107} 
108108
109109impl  Store  { 
@@ -112,7 +112,7 @@ impl Store {
112112        db_options. create_if_missing ( true ) ; 
113113        db_options. create_missing_column_families ( true ) ; 
114114
115-         let  cache = Cache :: new_lru_cache ( 4  *  1024  *  1024  *  1024 ) ;  // 4GB cache 
115+         let  cache = Cache :: new_lru_cache ( 4  *  1024  *  1024  *  1024 ) ;  // 4GB cache   
116116
117117        db_options. set_max_open_files ( -1 ) ; 
118118        db_options. set_max_file_opening_threads ( 16 ) ; 
@@ -166,18 +166,17 @@ impl Store {
166166        ] ; 
167167
168168        // Get existing column families to know which ones to drop later 
169-         let  existing_cfs =
170-             match  OptimisticTransactionDB :: < MultiThreaded > :: list_cf ( & db_options,  path)  { 
171-                 Ok ( cfs)  => { 
172-                     info ! ( "Found existing column families: {:?}" ,  cfs) ; 
173-                     cfs
174-                 } 
175-                 Err ( _)  => { 
176-                     // Database doesn't exist yet 
177-                     info ! ( "Database doesn't exist, will create with expected column families" ) ; 
178-                     vec ! [ "default" . to_string( ) ] 
179-                 } 
180-             } ; 
169+         let  existing_cfs = match  DBWithThreadMode :: < MultiThreaded > :: list_cf ( & db_options,  path)  { 
170+             Ok ( cfs)  => { 
171+                 info ! ( "Found existing column families: {:?}" ,  cfs) ; 
172+                 cfs
173+             } 
174+             Err ( _)  => { 
175+                 // Database doesn't exist yet 
176+                 info ! ( "Database doesn't exist, will create with expected column families" ) ; 
177+                 vec ! [ "default" . to_string( ) ] 
178+             } 
179+         } ; 
181180
182181        // Create descriptors for ALL existing CFs + expected ones (RocksDB requires opening all existing CFs) 
183182        let  mut  all_cfs_to_open = HashSet :: new ( ) ; 
@@ -208,7 +207,7 @@ impl Store {
208207                    cf_opts. set_compression_type ( rocksdb:: DBCompressionType :: Zstd ) ; 
209208                    cf_opts. set_write_buffer_size ( 128  *  1024  *  1024 ) ;  // 128MB 
210209                    cf_opts. set_max_write_buffer_number ( 4 ) ; 
211-                     cf_opts. set_target_file_size_base ( 256  *  1024  *  1024 ) ;  // 256MB 
210+                     cf_opts. set_target_file_size_base ( 256  *  1024  *  1024 ) ;  // 256MB   
212211
213212                    let  mut  block_opts = BlockBasedOptions :: default ( ) ; 
214213                    block_opts. set_block_cache ( & cache) ; 
@@ -220,7 +219,7 @@ impl Store {
220219                    cf_opts. set_compression_type ( rocksdb:: DBCompressionType :: Lz4 ) ; 
221220                    cf_opts. set_write_buffer_size ( 64  *  1024  *  1024 ) ;  // 64MB 
222221                    cf_opts. set_max_write_buffer_number ( 3 ) ; 
223-                     cf_opts. set_target_file_size_base ( 128  *  1024  *  1024 ) ;  // 128MB 
222+                     cf_opts. set_target_file_size_base ( 128  *  1024  *  1024 ) ;  // 128MB   
224223
225224                    let  mut  block_opts = BlockBasedOptions :: default ( ) ; 
226225                    block_opts. set_block_cache ( & cache) ; 
@@ -231,14 +230,14 @@ impl Store {
231230                } 
232231                CF_STATE_TRIE_NODES  | CF_STORAGE_TRIES_NODES  => { 
233232                    cf_opts. set_compression_type ( rocksdb:: DBCompressionType :: Lz4 ) ; 
234-                     cf_opts. set_write_buffer_size ( 512  *  1024  *  1024 ) ;  // 512MB 
233+                     cf_opts. set_write_buffer_size ( 512  *  1024  *  1024 ) ;  // 512MB   
235234                    cf_opts. set_max_write_buffer_number ( 6 ) ; 
236235                    cf_opts. set_min_write_buffer_number_to_merge ( 2 ) ; 
237-                     cf_opts. set_target_file_size_base ( 256  *  1024  *  1024 ) ;  // 256MB 
238-                     cf_opts. set_memtable_prefix_bloom_ratio ( 0.2 ) ;  // Bloom filter 
236+                     cf_opts. set_target_file_size_base ( 256  *  1024  *  1024 ) ;  // 256MB   
237+                     cf_opts. set_memtable_prefix_bloom_ratio ( 0.2 ) ;  // Bloom filter   
239238
240239                    let  mut  block_opts = BlockBasedOptions :: default ( ) ; 
241-                     block_opts. set_block_size ( 16  *  1024 ) ;  // 16KB 
240+                     block_opts. set_block_size ( 16  *  1024 ) ;  // 16KB   
242241                    block_opts. set_block_cache ( & cache) ; 
243242                    block_opts. set_bloom_filter ( 10.0 ,  false ) ;  // 10 bits per key 
244243                    block_opts. set_cache_index_and_filter_blocks ( true ) ; 
@@ -262,7 +261,7 @@ impl Store {
262261                    cf_opts. set_compression_type ( rocksdb:: DBCompressionType :: Lz4 ) ; 
263262                    cf_opts. set_write_buffer_size ( 64  *  1024  *  1024 ) ;  // 64MB 
264263                    cf_opts. set_max_write_buffer_number ( 3 ) ; 
265-                     cf_opts. set_target_file_size_base ( 128  *  1024  *  1024 ) ;  // 128MB 
264+                     cf_opts. set_target_file_size_base ( 128  *  1024  *  1024 ) ;  // 128MB   
266265
267266                    let  mut  block_opts = BlockBasedOptions :: default ( ) ; 
268267                    block_opts. set_block_size ( 16  *  1024 ) ; 
@@ -274,7 +273,7 @@ impl Store {
274273            cf_descriptors. push ( ColumnFamilyDescriptor :: new ( cf_name,  cf_opts) ) ; 
275274        } 
276275
277-         let  db = OptimisticTransactionDB :: < MultiThreaded > :: open_cf_descriptors ( 
276+         let  db = DBWithThreadMode :: < MultiThreaded > :: open_cf_descriptors ( 
278277            & db_options, 
279278            path, 
280279            cf_descriptors, 
@@ -367,7 +366,7 @@ impl Store {
367366        let  db = self . db . clone ( ) ; 
368367
369368        tokio:: task:: spawn_blocking ( move  || { 
370-             let  mut  batch = WriteBatchWithTransaction :: default ( ) ; 
369+             let  mut  batch = WriteBatch :: default ( ) ; 
371370
372371            for  ( cf_name,  key,  value)  in  batch_ops { 
373372                let  cf = db. cf_handle ( & cf_name) . ok_or_else ( || { 
@@ -464,7 +463,7 @@ impl StoreEngine for Store {
464463            ) ?; 
465464
466465            let  _span = tracing:: trace_span!( "Block DB update" ) . entered ( ) ; 
467-             let  mut  batch = WriteBatchWithTransaction :: default ( ) ; 
466+             let  mut  batch = WriteBatch :: default ( ) ; 
468467
469468            for  ( node_hash,  node_data)  in  update_batch. account_updates  { 
470469                batch. put_cf ( & cf_state,  node_hash. as_ref ( ) ,  node_data) ; 
@@ -534,7 +533,7 @@ impl StoreEngine for Store {
534533        let  db = self . db . clone ( ) ; 
535534
536535        tokio:: task:: spawn_blocking ( move  || { 
537-             let  mut  batch = WriteBatchWithTransaction :: default ( ) ; 
536+             let  mut  batch = WriteBatch :: default ( ) ; 
538537
539538            let  [ cf_headers,  cf_bodies,  cf_block_numbers,  cf_tx_locations]  = open_cfs ( 
540539                & db, 
@@ -643,7 +642,7 @@ impl StoreEngine for Store {
643642    } 
644643
645644    async  fn  remove_block ( & self ,  block_number :  BlockNumber )  -> Result < ( ) ,  StoreError >  { 
646-         let  mut  batch = WriteBatchWithTransaction :: default ( ) ; 
645+         let  mut  batch = WriteBatch :: default ( ) ; 
647646
648647        let  Some ( hash)  = self . get_canonical_block_hash_sync ( block_number) ? else  { 
649648            return  Ok ( ( ) ) ; 
@@ -937,7 +936,7 @@ impl StoreEngine for Store {
937936                . ok_or_else ( || StoreError :: Custom ( "Column family not found" . to_string ( ) ) ) ?; 
938937
939938            let  mut  iter = db. iterator_cf ( & cf,  rocksdb:: IteratorMode :: Start ) ; 
940-             let  mut  batch = WriteBatchWithTransaction :: default ( ) ; 
939+             let  mut  batch = WriteBatch :: default ( ) ; 
941940
942941            while  let  Some ( Ok ( ( key,  _) ) )  = iter. next ( )  { 
943942                batch. delete_cf ( & cf,  key) ; 
@@ -1161,7 +1160,7 @@ impl StoreEngine for Store {
11611160        let  db = self . db . clone ( ) ; 
11621161
11631162        tokio:: task:: spawn_blocking ( move  || { 
1164-             let  mut  batch = WriteBatchWithTransaction :: default ( ) ; 
1163+             let  mut  batch = WriteBatch :: default ( ) ; 
11651164
11661165            let  [ cf_canonical,  cf_chain_data]  =
11671166                open_cfs ( & db,  [ CF_CANONICAL_BLOCK_HASHES ,  CF_CHAIN_DATA ] ) ?; 
@@ -1436,7 +1435,7 @@ impl StoreEngine for Store {
14361435
14371436/// Open column families 
14381437fn  open_cfs < ' a ,  const  N :  usize > ( 
1439-     db :  & ' a  Arc < OptimisticTransactionDB < MultiThreaded > > , 
1438+     db :  & ' a  Arc < DBWithThreadMode < MultiThreaded > > , 
14401439    names :  [ & str ;  N ] , 
14411440)  -> Result < [ Arc < BoundColumnFamily < ' a > > ;  N ] ,  StoreError >  { 
14421441    let  mut  handles = Vec :: with_capacity ( N ) ; 
0 commit comments