@@ -135,13 +135,13 @@ pub async fn estimate_fee(
135135) -> Result < U256 , errors:: FeeEstimateError > {
136136 match fee_estimation_type {
137137 FeeEstimationType :: Default => {
138- calculate_fee_per_proof_for_batch_of_size ( eth_rpc_url , DEFAULT_MAX_FEE_BATCH_SIZE ) . await
138+ estimate_fee_per_proof_with_rpc ( DEFAULT_MAX_FEE_BATCH_SIZE , eth_rpc_url ) . await
139139 }
140140 FeeEstimationType :: Instant => {
141- calculate_fee_per_proof_for_batch_of_size ( eth_rpc_url , INSTANT_MAX_FEE_BATCH_SIZE ) . await
141+ estimate_fee_per_proof_with_rpc ( INSTANT_MAX_FEE_BATCH_SIZE , eth_rpc_url ) . await
142142 }
143143 FeeEstimationType :: Custom ( n) => {
144- calculate_fee_per_proof_for_batch_of_size ( eth_rpc_url , n ) . await
144+ estimate_fee_per_proof_with_rpc ( n , eth_rpc_url ) . await
145145 }
146146 }
147147}
@@ -161,17 +161,17 @@ pub async fn estimate_fee(
161161/// # Errors
162162/// * `EthereumProviderError` if there is an error in the connection with the RPC provider.
163163/// * `EthereumGasPriceError` if there is an error retrieving the Ethereum gas price.
164- pub async fn calculate_fee_per_proof_for_batch_of_size (
165- eth_rpc_url : & str ,
164+ pub async fn estimate_fee_per_proof_with_rpc (
166165 num_proofs_in_batch : usize ,
166+ eth_rpc_url : & str ,
167167) -> Result < U256 , errors:: FeeEstimateError > {
168168 let eth_rpc_provider =
169169 Provider :: < Http > :: try_from ( eth_rpc_url) . map_err ( |e : url:: ParseError | {
170170 errors:: FeeEstimateError :: EthereumProviderError ( e. to_string ( ) )
171171 } ) ?;
172172 let gas_price = fetch_gas_price ( & eth_rpc_provider) . await ?;
173173
174- let fee_per_proof = compute_fee_per_proof_formula ( num_proofs_in_batch, gas_price) ;
174+ let fee_per_proof = calculate_fee_per_proof_with_gas_price ( num_proofs_in_batch, gas_price) ;
175175 Ok ( fee_per_proof)
176176}
177177
@@ -196,7 +196,7 @@ pub async fn calculate_fee_per_proof_for_batch_of_size(
196196///
197197/// # Panics
198198/// This function panics if `num_proofs_in_batch` is 0 due to division by zero.
199- pub fn compute_fee_per_proof_formula ( num_proofs_in_batch : usize , gas_price : U256 ) -> U256 {
199+ pub fn calculate_fee_per_proof_with_gas_price ( num_proofs_in_batch : usize , gas_price : U256 ) -> U256 {
200200 // Gas cost for `num_proofs_per_batch` proofs
201201 let estimated_gas_per_proof = ( DEFAULT_CONSTANT_GAS_COST
202202 + ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF * num_proofs_in_batch as u128 )
@@ -839,10 +839,10 @@ mod test {
839839
840840 #[ tokio:: test]
841841 async fn computed_max_fee_for_larger_batch_is_smaller ( ) {
842- let small_fee = calculate_fee_per_proof_for_batch_of_size ( HOLESKY_PUBLIC_RPC_URL , 5 )
842+ let small_fee = estimate_fee_per_proof_with_rpc ( 5 , HOLESKY_PUBLIC_RPC_URL )
843843 . await
844844 . unwrap ( ) ;
845- let large_fee = calculate_fee_per_proof_for_batch_of_size ( HOLESKY_PUBLIC_RPC_URL , 2 )
845+ let large_fee = estimate_fee_per_proof_with_rpc ( 2 , HOLESKY_PUBLIC_RPC_URL )
846846 . await
847847 . unwrap ( ) ;
848848
@@ -851,10 +851,10 @@ mod test {
851851
852852 #[ tokio:: test]
853853 async fn computed_max_fee_for_more_proofs_larger_than_for_less_proofs ( ) {
854- let small_fee = calculate_fee_per_proof_for_batch_of_size ( HOLESKY_PUBLIC_RPC_URL , 20 )
854+ let small_fee = estimate_fee_per_proof_with_rpc ( 20 , HOLESKY_PUBLIC_RPC_URL )
855855 . await
856856 . unwrap ( ) ;
857- let large_fee = calculate_fee_per_proof_for_batch_of_size ( HOLESKY_PUBLIC_RPC_URL , 10 )
857+ let large_fee = estimate_fee_per_proof_with_rpc ( 10 , HOLESKY_PUBLIC_RPC_URL )
858858 . await
859859 . unwrap ( ) ;
860860
0 commit comments