Skip to content

Commit d0bf1e1

Browse files
Move the get gas price fn to the ProofAggregator
1 parent 4450ac1 commit d0bf1e1

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

aggregation_mode/src/backend/fetcher.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use tracing::{error, info};
2424
pub enum ProofsFetcherError {
2525
GetLogs(String),
2626
GetBlockNumber(String),
27-
GasPriceError(String),
2827
}
2928

3029
pub struct ProofsFetcher {
@@ -189,15 +188,4 @@ impl ProofsFetcher {
189188
pub fn get_last_aggregated_block(&self) -> u64 {
190189
self.last_aggregated_block
191190
}
192-
193-
/// Try to obtain a sensible gas price from two providers.
194-
/// Tries `primary` first, falls back to `fallback` if the first fails.
195-
pub async fn get_gas_price(&self) -> Result<u128, ProofsFetcherError> {
196-
match self.rpc_provider.get_gas_price().await {
197-
Ok(price) => Ok(price),
198-
Err(e1) => Err(ProofsFetcherError::GasPriceError(format!(
199-
"gas price error: {e1}"
200-
))),
201-
}
202-
}
203191
}

aggregation_mode/src/backend/mod.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ mod s3;
66
mod types;
77
mod utils;
88

9-
use crate::backend::AggregatedProofSubmissionError::FetchingProofs;
10-
119
use crate::aggregators::{AlignedProof, ProofAggregationError, ZKVMEngine};
1210

1311
use alloy::{
@@ -42,13 +40,15 @@ pub enum AggregatedProofSubmissionError {
4240
ZKVMAggregation(ProofAggregationError),
4341
BuildingMerkleRoot,
4442
MerkleRootMisMatch,
43+
GasPriceError(String),
4544
}
4645

4746
pub struct ProofAggregator {
4847
engine: ZKVMEngine,
4948
proof_aggregation_service: AlignedProofAggregationServiceContract,
5049
fetcher: ProofsFetcher,
5150
config: Config,
51+
rpc_provider: dyn Provider<EthereumWallet>,
5252
}
5353

5454
impl ProofAggregator {
@@ -64,7 +64,7 @@ impl ProofAggregator {
6464
let proof_aggregation_service = AlignedProofAggregationService::new(
6565
Address::from_str(&config.proof_aggregation_service_address)
6666
.expect("AlignedProofAggregationService address should be valid"),
67-
rpc_provider,
67+
rpc_provider.clone(),
6868
);
6969

7070
let engine =
@@ -76,6 +76,7 @@ impl ProofAggregator {
7676
proof_aggregation_service,
7777
fetcher,
7878
config,
79+
rpc_provider,
7980
}
8081
}
8182

@@ -148,7 +149,7 @@ impl ProofAggregator {
148149
// We add 24 hours because the proof aggregator runs once a day, so the time elapsed
149150
// should be considered over a 24h period.
150151

151-
let gas_price = self.fetcher.get_gas_price().await.map_err(FetchingProofs)?;
152+
let gas_price = self.get_gas_price().await?;
152153

153154
if self.should_send_proof_to_verify_on_chain(
154155
time_elapsed,
@@ -334,6 +335,17 @@ impl ProofAggregator {
334335

335336
Ok((blob, blob_versioned_hash))
336337
}
338+
339+
/// Try to obtain a sensible gas price from two providers.
340+
/// Tries `primary` first, falls back to `fallback` if the first fails.
341+
pub async fn get_gas_price(&self) -> Result<u128, AggregatedProofSubmissionError> {
342+
match self.rpc_provider.get_gas_price().await {
343+
Ok(price) => Ok(price),
344+
Err(e1) => Err(AggregatedProofSubmissionError::GasPriceError(format!(
345+
"gas price error: {e1}"
346+
))),
347+
}
348+
}
337349
}
338350

339351
#[cfg(test)]

0 commit comments

Comments
 (0)