@@ -4,6 +4,7 @@ mod merkle_tree;
44mod retry;
55mod s3;
66mod types;
7+ mod utils;
78
89use crate :: backend:: AggregatedProofSubmissionError :: FetchingProofs ;
910
@@ -21,7 +22,6 @@ use alloy::{
2122} ;
2223use config:: Config ;
2324use ethers:: types:: U256 ;
24- use ethers:: utils:: parse_ether;
2525use fetcher:: { ProofsFetcher , ProofsFetcherError } ;
2626use merkle_tree:: compute_proofs_merkle_root;
2727use risc0_ethereum_contracts:: encode_seal;
@@ -178,19 +178,6 @@ impl ProofAggregator {
178178 Ok ( ( ) )
179179 }
180180
181- fn max_to_spend_in_wei ( time_elapsed : Duration , monthly_eth_budget : f64 ) -> U256 {
182- const SECONDS_PER_MONTH : u64 = 30 * 24 * 60 * 60 ;
183-
184- // Note: this unwrap is safe because parse_ether only fails for negative numbers or invalid strings
185- let monthly_budget_in_wei = parse_ether ( monthly_eth_budget) . unwrap_or ( U256 :: zero ( ) ) ;
186-
187- let elapsed_seconds = U256 :: from ( time_elapsed. as_secs ( ) ) ;
188-
189- let budget_available_per_second_in_wei = monthly_budget_in_wei / SECONDS_PER_MONTH ;
190-
191- budget_available_per_second_in_wei * elapsed_seconds
192- }
193-
194181 /// Decides whether to send the aggregated proof to be verified on-chain based on
195182 /// time elapsed since last submission and monthly ETH budget.
196183 /// We make a linear function with the eth to spend this month and the time elapsed since last submission.
@@ -205,7 +192,7 @@ impl ProofAggregator {
205192 const ON_CHAIN_COST_IN_GAS_UNITS : u64 = 600_000u64 ;
206193
207194 let on_chain_cost_in_gas: U256 = U256 :: from ( ON_CHAIN_COST_IN_GAS_UNITS ) ;
208- let max_to_spend_in_wei = Self :: max_to_spend_in_wei ( time_elapsed, monthly_eth_budget) ;
195+ let max_to_spend_in_wei = utils :: max_to_spend_in_wei ( time_elapsed, monthly_eth_budget) ;
209196
210197 let expected_cost_in_wei = network_gas_price * on_chain_cost_in_gas;
211198
0 commit comments