@@ -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) ]
@@ -184,6 +186,8 @@ use crate::header::StorageBlockHeader;
184186use crate :: metrics:: { register_metrics, STORAGE_COMMIT_LATENCY } ;
185187use crate :: mmap_file:: MMapFileStats ;
186188use crate :: state:: data:: IndexedDeprecatedContractClass ;
189+ #[ cfg( feature = "os_input" ) ]
190+ use crate :: state_commitment_infos:: StateCommitmentInfos ;
187191use crate :: storage_reader_server:: {
188192 create_storage_reader_server,
189193 ServerConfig ,
@@ -278,6 +282,8 @@ fn open_storage_internal(
278282 . create_simple_table ( "stateless_compiled_class_hash_v2" ) ?,
279283 #[ cfg( feature = "os_input" ) ]
280284 accessed_keys : db_writer. create_simple_table ( "accessed_keys" ) ?,
285+ #[ cfg( feature = "os_input" ) ]
286+ state_commitment_infos : db_writer. create_simple_table ( "state_commitment_infos" ) ?,
281287 } ) ;
282288 let ( file_writers, file_readers) = open_storage_files (
283289 & storage_config. db_config ,
@@ -712,7 +718,9 @@ struct_field_names! {
712718 stateless_compiled_class_hash_v2: TableIdentifier <ClassHash , NoVersionValueWrapper <CompiledClassHash >, SimpleTable >,
713719
714720 #[ cfg( feature = "os_input" ) ]
715- accessed_keys: TableIdentifier <BlockNumber , VersionZeroWrapper <LocationInFile >, SimpleTable >
721+ accessed_keys: TableIdentifier <BlockNumber , VersionZeroWrapper <LocationInFile >, SimpleTable >,
722+ #[ cfg( feature = "os_input" ) ]
723+ state_commitment_infos: TableIdentifier <BlockNumber , VersionZeroWrapper <LocationInFile >, SimpleTable >
716724 }
717725}
718726
@@ -879,6 +887,8 @@ struct FileHandlers<Mode: TransactionKind> {
879887 transaction : FileHandler < VersionZeroWrapper < Transaction > , Mode > ,
880888 #[ cfg( feature = "os_input" ) ]
881889 accessed_keys : FileHandler < VersionZeroWrapper < AccessedKeys > , Mode > ,
890+ #[ cfg( feature = "os_input" ) ]
891+ state_commitment_infos : FileHandler < VersionZeroWrapper < StateCommitmentInfos > , Mode > ,
882892}
883893
884894impl FileHandlers < RW > {
@@ -921,6 +931,14 @@ impl FileHandlers<RW> {
921931 self . clone ( ) . accessed_keys . append ( accessed_keys)
922932 }
923933
934+ #[ cfg( feature = "os_input" ) ]
935+ fn append_state_commitment_infos (
936+ & self ,
937+ state_commitment_infos : & StateCommitmentInfos ,
938+ ) -> LocationInFile {
939+ self . clone ( ) . state_commitment_infos . append ( state_commitment_infos)
940+ }
941+
924942 // TODO(dan): Consider 1. flushing only the relevant files, 2. flushing concurrently.
925943 #[ latency_histogram( "storage_file_handler_flush_latency_seconds" , false ) ]
926944 fn flush ( & self ) {
@@ -933,6 +951,8 @@ impl FileHandlers<RW> {
933951 self . transaction . flush ( ) ;
934952 #[ cfg( feature = "os_input" ) ]
935953 self . accessed_keys . flush ( ) ;
954+ #[ cfg( feature = "os_input" ) ]
955+ self . state_commitment_infos . flush ( ) ;
936956 }
937957}
938958
@@ -948,6 +968,8 @@ impl<Mode: TransactionKind> FileHandlers<Mode> {
948968 ( "transaction" . to_string ( ) , self . transaction . stats ( ) ) ,
949969 #[ cfg( feature = "os_input" ) ]
950970 ( "accessed_keys" . to_string ( ) , self . accessed_keys . stats ( ) ) ,
971+ #[ cfg( feature = "os_input" ) ]
972+ ( "state_commitment_infos" . to_string ( ) , self . state_commitment_infos . stats ( ) ) ,
951973 ] )
952974 }
953975
@@ -1017,6 +1039,17 @@ impl<Mode: TransactionKind> FileHandlers<Mode> {
10171039 msg : format ! ( "AccessedKeys at location {location:?} not found." ) ,
10181040 } )
10191041 }
1042+
1043+ #[ cfg( feature = "os_input" ) ]
1044+ // Returns the commitment infos at the given location or an error in case they don't exist.
1045+ pub ( crate ) fn get_state_commitment_infos_unchecked (
1046+ & self ,
1047+ location : LocationInFile ,
1048+ ) -> StorageResult < StateCommitmentInfos > {
1049+ self . state_commitment_infos . get ( location) ?. ok_or ( StorageError :: DBInconsistency {
1050+ msg : format ! ( "StateCommitmentInfos at location {location:?} not found." ) ,
1051+ } )
1052+ }
10201053}
10211054
10221055fn open_storage_files (
@@ -1055,6 +1088,9 @@ fn open_storage_files(
10551088 #[ cfg( feature = "os_input" ) ]
10561089 let ( accessed_keys_writer, accessed_keys_reader) =
10571090 open_storage_file ! ( "accessed_keys" , AccessedKeys ) ?;
1091+ #[ cfg( feature = "os_input" ) ]
1092+ let ( state_commitment_infos_writer, state_commitment_infos_reader) =
1093+ open_storage_file ! ( "state_commitment_infos" , StateCommitmentInfos ) ?;
10581094
10591095 Ok ( (
10601096 FileHandlers {
@@ -1066,6 +1102,8 @@ fn open_storage_files(
10661102 transaction : transaction_writer,
10671103 #[ cfg( feature = "os_input" ) ]
10681104 accessed_keys : accessed_keys_writer,
1105+ #[ cfg( feature = "os_input" ) ]
1106+ state_commitment_infos : state_commitment_infos_writer,
10691107 } ,
10701108 FileHandlers {
10711109 thin_state_diff : thin_state_diff_reader,
@@ -1076,6 +1114,8 @@ fn open_storage_files(
10761114 transaction : transaction_reader,
10771115 #[ cfg( feature = "os_input" ) ]
10781116 accessed_keys : accessed_keys_reader,
1117+ #[ cfg( feature = "os_input" ) ]
1118+ state_commitment_infos : state_commitment_infos_reader,
10791119 } ,
10801120 ) )
10811121}
@@ -1098,4 +1138,7 @@ pub enum OffsetKind {
10981138 /// An accessed-keys file.
10991139 #[ cfg( feature = "os_input" ) ]
11001140 AccessedKeys ,
1141+ /// A state-commitment-infos file.
1142+ #[ cfg( feature = "os_input" ) ]
1143+ StateCommitmentInfos ,
11011144}
0 commit comments