@@ -137,6 +137,7 @@ impl StarknetResources {
137137 state_resources : StateResources ,
138138 l1_handler_payload_size : Option < usize > ,
139139 execution_summary_without_fee_transfer : ExecutionSummary ,
140+ // TODO(AvivG): Add proof_facts_length as a parameter.
140141 ) -> Self {
141142 // TODO(Yoni): store the entire summary.
142143 Self {
@@ -145,6 +146,7 @@ impl StarknetResources {
145146 calldata_length,
146147 signature_length,
147148 code_size,
149+ proof_facts_length : 0 ,
148150 } ,
149151 messages : MessageResources :: new (
150152 execution_summary_without_fee_transfer. l2_to_l1_payload_lengths ,
@@ -250,6 +252,7 @@ pub struct ArchivalDataResources {
250252 pub calldata_length : usize ,
251253 pub signature_length : usize ,
252254 pub code_size : usize ,
255+ pub proof_facts_length : usize ,
253256}
254257
255258impl ArchivalDataResources {
@@ -263,6 +266,7 @@ impl ArchivalDataResources {
263266 [
264267 self . get_calldata_and_signature_gas_cost ( versioned_constants, mode) ,
265268 self . get_code_gas_cost ( versioned_constants, mode) ,
269+ self . get_client_side_proof_gas_cost ( versioned_constants, mode) ,
266270 self . event_summary . to_gas_vector ( versioned_constants, mode) ,
267271 ]
268272 . into_iter ( )
@@ -315,6 +319,36 @@ impl ArchivalDataResources {
315319 GasVectorComputationMode :: NoL2Gas => GasVector :: from_l1_gas ( gas_amount) ,
316320 }
317321 }
322+
323+ fn get_client_side_proof_gas_cost (
324+ & self ,
325+ versioned_constants : & VersionedConstants ,
326+ mode : & GasVectorComputationMode ,
327+ ) -> GasVector {
328+ if self . proof_facts_length == 0 {
329+ return GasVector :: ZERO ;
330+ }
331+
332+ let archival_gas_costs = versioned_constants. get_archival_data_gas_costs ( mode) ;
333+
334+ let proof_facts_gas: GasAmount = ( archival_gas_costs. gas_per_data_felt
335+ * u64_from_usize ( self . proof_facts_length ) )
336+ . to_integer ( )
337+ . into ( ) ;
338+
339+ // Client-side proofs currently have a fixed gas cost. This cost corresponds to the
340+ // current proof version (reflected in the first proof fact).
341+ let proof_gas: GasAmount = archival_gas_costs. gas_per_proof . to_integer ( ) . into ( ) ;
342+
343+ let total: GasAmount = proof_facts_gas
344+ . checked_add ( proof_gas)
345+ . expect ( "client-side proof gas amount overflowed" ) ;
346+
347+ match mode {
348+ GasVectorComputationMode :: All => GasVector :: from_l2_gas ( total) ,
349+ GasVectorComputationMode :: NoL2Gas => GasVector :: from_l1_gas ( total) ,
350+ }
351+ }
318352}
319353
320354/// Contains L1->L2 and L2->L1 message resources.
0 commit comments