@@ -91,6 +91,8 @@ pub mod global_root_marker;
9191#[ allow( missing_docs) ]
9292pub mod metrics;
9393pub mod partial_block_hash;
94+ #[ cfg( feature = "os_input" ) ]
95+ pub mod state_commitment_infos;
9496pub mod storage_metrics;
9597// TODO(yair): Make the compression_utils module pub(crate) or extract it from the crate.
9698#[ doc( hidden) ]
@@ -186,6 +188,8 @@ use crate::header::StorageBlockHeader;
186188use crate :: metrics:: { register_metrics, STORAGE_COMMIT_LATENCY } ;
187189use crate :: mmap_file:: MMapFileStats ;
188190use crate :: state:: data:: IndexedDeprecatedContractClass ;
191+ #[ cfg( feature = "os_input" ) ]
192+ use crate :: state_commitment_infos:: StateCommitmentInfos ;
189193use crate :: storage_reader_server:: {
190194 create_storage_reader_server,
191195 ServerConfig ,
@@ -280,6 +284,8 @@ fn open_storage_internal(
280284 . create_simple_table ( "stateless_compiled_class_hash_v2" ) ?,
281285 #[ cfg( feature = "os_input" ) ]
282286 accessed_keys : db_writer. create_simple_table ( "accessed_keys" ) ?,
287+ #[ cfg( feature = "os_input" ) ]
288+ state_commitment_infos : db_writer. create_simple_table ( "state_commitment_infos" ) ?,
283289 } ) ;
284290 let ( file_writers, file_readers) = open_storage_files (
285291 & storage_config. db_config ,
@@ -993,7 +999,9 @@ struct_field_names! {
993999 stateless_compiled_class_hash_v2: TableIdentifier <ClassHash , NoVersionValueWrapper <CompiledClassHash >, SimpleTable >,
9941000
9951001 #[ cfg( feature = "os_input" ) ]
996- accessed_keys: TableIdentifier <BlockNumber , VersionZeroWrapper <LocationInFile >, SimpleTable >
1002+ accessed_keys: TableIdentifier <BlockNumber , VersionZeroWrapper <LocationInFile >, SimpleTable >,
1003+ #[ cfg( feature = "os_input" ) ]
1004+ state_commitment_infos: TableIdentifier <BlockNumber , VersionZeroWrapper <LocationInFile >, SimpleTable >
9971005 }
9981006}
9991007
@@ -1164,6 +1172,8 @@ struct FileHandlers<Mode: TransactionKind> {
11641172 transaction : FileHandler < VersionZeroWrapper < Transaction > , Mode > ,
11651173 #[ cfg( feature = "os_input" ) ]
11661174 accessed_keys : FileHandler < VersionZeroWrapper < AccessedKeys > , Mode > ,
1175+ #[ cfg( feature = "os_input" ) ]
1176+ state_commitment_infos : FileHandler < VersionZeroWrapper < StateCommitmentInfos > , Mode > ,
11671177}
11681178
11691179impl FileHandlers < RW > {
@@ -1206,6 +1216,14 @@ impl FileHandlers<RW> {
12061216 self . clone ( ) . accessed_keys . append ( accessed_keys)
12071217 }
12081218
1219+ #[ cfg( feature = "os_input" ) ]
1220+ fn append_state_commitment_infos (
1221+ & self ,
1222+ state_commitment_infos : & StateCommitmentInfos ,
1223+ ) -> LocationInFile {
1224+ self . clone ( ) . state_commitment_infos . append ( state_commitment_infos)
1225+ }
1226+
12091227 // TODO(dan): Consider 1. flushing only the relevant files, 2. flushing concurrently.
12101228 #[ latency_histogram( "storage_file_handler_flush_latency_seconds" , false ) ]
12111229 fn flush ( & self ) {
@@ -1218,6 +1236,8 @@ impl FileHandlers<RW> {
12181236 self . transaction . flush ( ) ;
12191237 #[ cfg( feature = "os_input" ) ]
12201238 self . accessed_keys . flush ( ) ;
1239+ #[ cfg( feature = "os_input" ) ]
1240+ self . state_commitment_infos . flush ( ) ;
12211241 }
12221242}
12231243
@@ -1233,6 +1253,8 @@ impl<Mode: TransactionKind> FileHandlers<Mode> {
12331253 ( "transaction" . to_string ( ) , self . transaction . stats ( ) ) ,
12341254 #[ cfg( feature = "os_input" ) ]
12351255 ( "accessed_keys" . to_string ( ) , self . accessed_keys . stats ( ) ) ,
1256+ #[ cfg( feature = "os_input" ) ]
1257+ ( "state_commitment_infos" . to_string ( ) , self . state_commitment_infos . stats ( ) ) ,
12361258 ] )
12371259 }
12381260
@@ -1302,6 +1324,17 @@ impl<Mode: TransactionKind> FileHandlers<Mode> {
13021324 msg : format ! ( "AccessedKeys at location {location:?} not found." ) ,
13031325 } )
13041326 }
1327+
1328+ #[ cfg( feature = "os_input" ) ]
1329+ // Returns the commitment infos at the given location or an error in case they don't exist.
1330+ pub ( crate ) fn get_state_commitment_infos_unchecked (
1331+ & self ,
1332+ location : LocationInFile ,
1333+ ) -> StorageResult < StateCommitmentInfos > {
1334+ self . state_commitment_infos . get ( location) ?. ok_or ( StorageError :: DBInconsistency {
1335+ msg : format ! ( "StateCommitmentInfos at location {location:?} not found." ) ,
1336+ } )
1337+ }
13051338}
13061339
13071340fn open_storage_files (
@@ -1340,6 +1373,9 @@ fn open_storage_files(
13401373 #[ cfg( feature = "os_input" ) ]
13411374 let ( accessed_keys_writer, accessed_keys_reader) =
13421375 open_storage_file ! ( "accessed_keys" , AccessedKeys ) ?;
1376+ #[ cfg( feature = "os_input" ) ]
1377+ let ( state_commitment_infos_writer, state_commitment_infos_reader) =
1378+ open_storage_file ! ( "state_commitment_infos" , StateCommitmentInfos ) ?;
13431379
13441380 Ok ( (
13451381 FileHandlers {
@@ -1351,6 +1387,8 @@ fn open_storage_files(
13511387 transaction : transaction_writer,
13521388 #[ cfg( feature = "os_input" ) ]
13531389 accessed_keys : accessed_keys_writer,
1390+ #[ cfg( feature = "os_input" ) ]
1391+ state_commitment_infos : state_commitment_infos_writer,
13541392 } ,
13551393 FileHandlers {
13561394 thin_state_diff : thin_state_diff_reader,
@@ -1361,6 +1399,8 @@ fn open_storage_files(
13611399 transaction : transaction_reader,
13621400 #[ cfg( feature = "os_input" ) ]
13631401 accessed_keys : accessed_keys_reader,
1402+ #[ cfg( feature = "os_input" ) ]
1403+ state_commitment_infos : state_commitment_infos_reader,
13641404 } ,
13651405 ) )
13661406}
@@ -1383,4 +1423,7 @@ pub enum OffsetKind {
13831423 /// An accessed-keys file.
13841424 #[ cfg( feature = "os_input" ) ]
13851425 AccessedKeys ,
1426+ /// A state-commitment-infos file.
1427+ #[ cfg( feature = "os_input" ) ]
1428+ StateCommitmentInfos ,
13861429}
0 commit comments