@@ -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 ,
@@ -959,7 +965,9 @@ struct_field_names! {
959965 stateless_compiled_class_hash_v2: TableIdentifier <ClassHash , NoVersionValueWrapper <CompiledClassHash >, SimpleTable >,
960966
961967 #[ cfg( feature = "os_input" ) ]
962- accessed_keys: TableIdentifier <BlockNumber , VersionZeroWrapper <LocationInFile >, SimpleTable >
968+ accessed_keys: TableIdentifier <BlockNumber , VersionZeroWrapper <LocationInFile >, SimpleTable >,
969+ #[ cfg( feature = "os_input" ) ]
970+ state_commitment_infos: TableIdentifier <BlockNumber , VersionZeroWrapper <LocationInFile >, SimpleTable >
963971 }
964972}
965973
@@ -1130,6 +1138,8 @@ struct FileHandlers<Mode: TransactionKind> {
11301138 transaction : FileHandler < VersionZeroWrapper < Transaction > , Mode > ,
11311139 #[ cfg( feature = "os_input" ) ]
11321140 accessed_keys : FileHandler < VersionZeroWrapper < AccessedKeys > , Mode > ,
1141+ #[ cfg( feature = "os_input" ) ]
1142+ state_commitment_infos : FileHandler < VersionZeroWrapper < StateCommitmentInfos > , Mode > ,
11331143}
11341144
11351145impl FileHandlers < RW > {
@@ -1172,6 +1182,14 @@ impl FileHandlers<RW> {
11721182 self . clone ( ) . accessed_keys . append ( accessed_keys)
11731183 }
11741184
1185+ #[ cfg( feature = "os_input" ) ]
1186+ fn append_state_commitment_infos (
1187+ & self ,
1188+ state_commitment_infos : & StateCommitmentInfos ,
1189+ ) -> LocationInFile {
1190+ self . clone ( ) . state_commitment_infos . append ( state_commitment_infos)
1191+ }
1192+
11751193 // TODO(dan): Consider 1. flushing only the relevant files, 2. flushing concurrently.
11761194 #[ latency_histogram( "storage_file_handler_flush_latency_seconds" , false ) ]
11771195 fn flush ( & self ) {
@@ -1184,6 +1202,8 @@ impl FileHandlers<RW> {
11841202 self . transaction . flush ( ) ;
11851203 #[ cfg( feature = "os_input" ) ]
11861204 self . accessed_keys . flush ( ) ;
1205+ #[ cfg( feature = "os_input" ) ]
1206+ self . state_commitment_infos . flush ( ) ;
11871207 }
11881208}
11891209
@@ -1199,6 +1219,8 @@ impl<Mode: TransactionKind> FileHandlers<Mode> {
11991219 ( "transaction" . to_string ( ) , self . transaction . stats ( ) ) ,
12001220 #[ cfg( feature = "os_input" ) ]
12011221 ( "accessed_keys" . to_string ( ) , self . accessed_keys . stats ( ) ) ,
1222+ #[ cfg( feature = "os_input" ) ]
1223+ ( "state_commitment_infos" . to_string ( ) , self . state_commitment_infos . stats ( ) ) ,
12021224 ] )
12031225 }
12041226
@@ -1268,6 +1290,17 @@ impl<Mode: TransactionKind> FileHandlers<Mode> {
12681290 msg : format ! ( "AccessedKeys at location {location:?} not found." ) ,
12691291 } )
12701292 }
1293+
1294+ #[ cfg( feature = "os_input" ) ]
1295+ // Returns the commitment infos at the given location or an error in case they don't exist.
1296+ pub ( crate ) fn get_state_commitment_infos_unchecked (
1297+ & self ,
1298+ location : LocationInFile ,
1299+ ) -> StorageResult < StateCommitmentInfos > {
1300+ self . state_commitment_infos . get ( location) ?. ok_or ( StorageError :: DBInconsistency {
1301+ msg : format ! ( "StateCommitmentInfos at location {location:?} not found." ) ,
1302+ } )
1303+ }
12711304}
12721305
12731306fn open_storage_files (
@@ -1306,6 +1339,9 @@ fn open_storage_files(
13061339 #[ cfg( feature = "os_input" ) ]
13071340 let ( accessed_keys_writer, accessed_keys_reader) =
13081341 open_storage_file ! ( "accessed_keys" , AccessedKeys ) ?;
1342+ #[ cfg( feature = "os_input" ) ]
1343+ let ( state_commitment_infos_writer, state_commitment_infos_reader) =
1344+ open_storage_file ! ( "state_commitment_infos" , StateCommitmentInfos ) ?;
13091345
13101346 Ok ( (
13111347 FileHandlers {
@@ -1317,6 +1353,8 @@ fn open_storage_files(
13171353 transaction : transaction_writer,
13181354 #[ cfg( feature = "os_input" ) ]
13191355 accessed_keys : accessed_keys_writer,
1356+ #[ cfg( feature = "os_input" ) ]
1357+ state_commitment_infos : state_commitment_infos_writer,
13201358 } ,
13211359 FileHandlers {
13221360 thin_state_diff : thin_state_diff_reader,
@@ -1327,6 +1365,8 @@ fn open_storage_files(
13271365 transaction : transaction_reader,
13281366 #[ cfg( feature = "os_input" ) ]
13291367 accessed_keys : accessed_keys_reader,
1368+ #[ cfg( feature = "os_input" ) ]
1369+ state_commitment_infos : state_commitment_infos_reader,
13301370 } ,
13311371 ) )
13321372}
@@ -1349,4 +1389,7 @@ pub enum OffsetKind {
13491389 /// An accessed-keys file.
13501390 #[ cfg( feature = "os_input" ) ]
13511391 AccessedKeys ,
1392+ /// A state-commitment-infos file.
1393+ #[ cfg( feature = "os_input" ) ]
1394+ StateCommitmentInfos ,
13521395}
0 commit comments