File tree Expand file tree Collapse file tree 2 files changed +8
-12
lines changed
aggregation_mode/proof_aggregator/src/backend Expand file tree Collapse file tree 2 files changed +8
-12
lines changed Original file line number Diff line number Diff line change 11use alloy:: primitives:: { utils:: parse_ether, U256 } ;
22use std:: time:: Duration ;
33
4+ // We assume a fixed gas cost of 300,000 for each of the 2 transactions
5+ const ON_CHAIN_COST_IN_GAS_UNITS : u64 = 600_000u64 ;
6+
47/// Decides whether to send the aggregated proof to be verified on-chain based on
58/// time elapsed since last submission and monthly ETH budget.
69/// We make a linear function with the eth to spend this month and the time elapsed since last submission.
@@ -10,15 +13,12 @@ pub fn should_send_proof_to_verify_on_chain(
1013 monthly_eth_budget : f64 ,
1114 network_gas_price : U256 ,
1215) -> bool {
13- // We assume a fixed gas cost of 300,000 for each of the 2 transactions
14- const ON_CHAIN_COST_IN_GAS_UNITS : u64 = 600_000u64 ;
15-
1616 let on_chain_cost_in_gas: U256 = U256 :: from ( ON_CHAIN_COST_IN_GAS_UNITS ) ;
17- let max_to_spend_in_wei = max_to_spend_in_wei ( time_elapsed, monthly_eth_budget) ;
17+ let max_to_spend_wei = max_to_spend_in_wei ( time_elapsed, monthly_eth_budget) ;
1818
1919 let expected_cost_in_wei = network_gas_price * on_chain_cost_in_gas;
2020
21- expected_cost_in_wei <= max_to_spend_in_wei
21+ expected_cost_in_wei <= max_to_spend_wei
2222}
2323
2424fn max_to_spend_in_wei ( time_elapsed : Duration , monthly_eth_budget : f64 ) -> U256 {
Original file line number Diff line number Diff line change @@ -179,11 +179,7 @@ impl ProofAggregator {
179179 ) ;
180180
181181 let receipt = self
182- . bump_and_send_proof_to_verify_on_chain_retryable (
183- blob,
184- blob_versioned_hash,
185- aggregated_proof,
186- )
182+ . wait_and_send_proof_on_chain_retryable ( blob, blob_versioned_hash, aggregated_proof)
187183 . await ?;
188184 info ! (
189185 "Proof sent and verified, tx hash {:?}" ,
@@ -214,7 +210,7 @@ impl ProofAggregator {
214210 Ok ( ( ) )
215211 }
216212
217- async fn bump_and_send_proof_to_verify_on_chain_retryable (
213+ async fn wait_and_send_proof_on_chain_retryable (
218214 & self ,
219215 blob : BlobTransactionSidecar ,
220216 blob_versioned_hash : [ u8 ; 32 ] ,
@@ -239,7 +235,7 @@ impl ProofAggregator {
239235 )
240236 . await
241237 . map_err ( |e| {
242- error ! ( "Could 't get nonce: {:?}" , e) ;
238+ error ! ( "Couldn 't get nonce: {:?}" , e) ;
243239 e. inner ( )
244240 } )
245241 }
You can’t perform that action at this time.
0 commit comments