Skip to content

Commit 25f96b3

Browse files
committed
change last_aggregated_block
1 parent b949475 commit 25f96b3

6 files changed

Lines changed: 25 additions & 25 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ batcher/aligned/batch_inclusion_responses/*
1212
**/broadcast
1313
volume
1414
config-files/*.last_processed_batch.json
15-
config-files/*.last_processed_block.json
15+
config-files/*.last_aggregated_block.json
1616

1717
nonce_*.bin
1818

aggregation_mode/src/backend/config.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ pub struct ECDSAConfig {
88
}
99

1010
#[derive(Debug, Deserialize, Serialize)]
11-
pub struct LastProcessedBlock {
12-
pub last_processed_block: u64,
11+
pub struct LastAggregatedBlock {
12+
pub last_aggregated_block: u64,
1313
}
1414

1515
#[derive(Debug, Deserialize, Serialize)]
@@ -19,7 +19,7 @@ pub struct Config {
1919
pub max_proofs_in_queue: u16,
2020
pub proof_aggregation_service_address: String,
2121
pub aligned_service_manager_address: String,
22-
pub last_processed_block_filepath: String,
22+
pub last_aggregated_block_filepath: String,
2323
pub ecdsa: ECDSAConfig,
2424
}
2525

@@ -32,34 +32,34 @@ impl Config {
3232
Ok(config)
3333
}
3434

35-
pub fn get_last_processed_block(&self) -> Result<u64, Box<dyn std::error::Error>> {
36-
match File::open(&self.last_processed_block_filepath) {
35+
pub fn get_last_aggregated_block(&self) -> Result<u64, Box<dyn std::error::Error>> {
36+
match File::open(&self.last_aggregated_block_filepath) {
3737
Err(_) => {
3838
// if file doesn't exist, default 0
3939
Ok(0)
4040
}
4141
Ok(mut file) => {
4242
let mut contents = String::new();
4343
file.read_to_string(&mut contents)?;
44-
let lpb: LastProcessedBlock = serde_json::from_str(&contents)?;
45-
Ok(lpb.last_processed_block)
44+
let lpb: LastAggregatedBlock = serde_json::from_str(&contents)?;
45+
Ok(lpb.last_aggregated_block)
4646
}
4747
}
4848
}
4949

50-
pub fn update_last_processed_block(
50+
pub fn update_last_aggregated_block(
5151
&self,
52-
last_processed_block: u64,
52+
last_aggregated_block: u64,
5353
) -> Result<(), Box<dyn std::error::Error>> {
54-
let last_processed_block_struct = LastProcessedBlock {
55-
last_processed_block,
54+
let last_processed_block_struct = LastAggregatedBlock {
55+
last_aggregated_block,
5656
};
5757

5858
let mut file = OpenOptions::new()
5959
.write(true)
6060
.truncate(true)
6161
.create(true)
62-
.open(&self.last_processed_block_filepath)?;
62+
.open(&self.last_aggregated_block_filepath)?;
6363

6464
let content = serde_json::to_string(&last_processed_block_struct)?;
6565
file.write_all(content.as_bytes())?;

aggregation_mode/src/backend/fetcher.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub enum ProofsFetcherError {
2424
pub struct ProofsFetcher {
2525
rpc_provider: RPCProvider,
2626
aligned_service_manager: AlignedLayerServiceManagerContract,
27-
last_processed_block: u64,
27+
last_aggregated_block: u64,
2828
}
2929

3030
impl ProofsFetcher {
@@ -37,12 +37,12 @@ impl ProofsFetcher {
3737
rpc_provider.clone(),
3838
);
3939

40-
let last_processed_block = config.get_last_processed_block().unwrap();
40+
let last_aggregated_block = config.get_last_aggregated_block().unwrap();
4141

4242
Self {
4343
rpc_provider,
4444
aligned_service_manager,
45-
last_processed_block,
45+
last_aggregated_block,
4646
}
4747
}
4848

@@ -54,22 +54,22 @@ impl ProofsFetcher {
5454
.await
5555
.map_err(|e| ProofsFetcherError::GetBlockNumber(e.to_string()))?;
5656

57-
if current_block < self.last_processed_block {
57+
if current_block < self.last_aggregated_block {
5858
return Err(ProofsFetcherError::GetBlockNumber(
5959
"Invalid last processed block".to_string(),
6060
));
6161
}
6262

6363
info!(
6464
"Fetching proofs from batch logs starting from block number {} upto {}",
65-
self.last_processed_block, current_block
65+
self.last_aggregated_block, current_block
6666
);
6767

6868
// Subscribe to NewBatch event from AlignedServiceManager
6969
let logs = self
7070
.aligned_service_manager
7171
.NewBatchV3_filter()
72-
.from_block(self.last_processed_block)
72+
.from_block(self.last_aggregated_block)
7373
.to_block(current_block)
7474
.query()
7575
.await
@@ -78,7 +78,7 @@ impl ProofsFetcher {
7878
info!("Logs collected {}", logs.len());
7979

8080
// Update last processed block after collecting logs
81-
self.last_processed_block = current_block;
81+
self.last_aggregated_block = current_block;
8282

8383
let mut proofs = vec![];
8484

@@ -136,7 +136,7 @@ impl ProofsFetcher {
136136
Ok(proofs)
137137
}
138138

139-
pub fn get_last_processed_block(&self) -> u64 {
140-
self.last_processed_block
139+
pub fn get_last_aggregated_block(&self) -> u64 {
140+
self.last_aggregated_block
141141
}
142142
}

aggregation_mode/src/backend/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl ProofAggregator {
7878
match res {
7979
Ok(()) => {
8080
config
81-
.update_last_processed_block(self.fetcher.get_last_processed_block())
81+
.update_last_aggregated_block(self.fetcher.get_last_aggregated_block())
8282
.unwrap();
8383
info!("Process finished successfully");
8484
}

config-files/config-proof-aggregator-mock.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ eth_ws_url: ws://localhost:8545
33
max_proofs_in_queue: 1000
44
proof_aggregation_service_address: 0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07
55
aligned_service_manager_address: 0x851356ae760d987E095750cCeb3bC6014560891C
6-
last_processed_block_filepath: config-files/proof-aggregator.last_processed_block.json
6+
last_aggregated_block_filepath: config-files/proof-aggregator.last_aggregated_block.json
77
ecdsa:
88
private_key_store_path: config-files/anvil.proof-aggregator.ecdsa.key.json
99
private_key_store_password: ''

config-files/config-proof-aggregator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ proof_aggregation_service_address: "0xcbEAF3BDe82155F56486Fb5a1072cb8baAf547cc"
33
eth_rpc_url: "http://localhost:8545"
44
eth_ws_url: "ws://localhost:8545"
55
max_proofs_in_queue: 1000
6-
last_processed_block_filepath: config-files/proof-aggregator.last_processed_block.json
6+
last_aggregated_block_filepath: config-files/proof-aggregator.last_aggregated_block.json
77

88
ecdsa:
99
private_key_store_path: "config-files/anvil.proof-aggregator.ecdsa.key.json"

0 commit comments

Comments
 (0)