Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions aggregation_mode/src/backend/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub struct Config {
pub last_aggregated_block_filepath: String,
pub ecdsa: ECDSAConfig,
pub proofs_per_chunk: u16,
pub total_proofs_limit: u16,
}

impl Config {
Expand Down
21 changes: 17 additions & 4 deletions aggregation_mode/src/backend/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ impl ProofsFetcher {
pub async fn fetch(
&mut self,
engine: ZKVMEngine,
limit: u16,
) -> Result<Vec<AlignedProof>, ProofsFetcherError> {
// Get current block
let current_block = self
Expand Down Expand Up @@ -86,12 +87,9 @@ impl ProofsFetcher {

info!("Logs collected {}", logs.len());

// Update last processed block after collecting logs
self.last_aggregated_block = current_block;

let mut proofs = vec![];

for (batch, _) in logs {
for (batch, log) in logs {
info!(
"New batch submitted, about to process. Batch merkle root {}...",
batch.batchMerkleRoot
Expand Down Expand Up @@ -153,6 +151,18 @@ impl ProofsFetcher {
proofs_to_add.len()
);

if (proofs.len() + proofs_to_add.len()) > (limit as usize) {
let log_block_number = log.block_number.unwrap();
info!(
"Limit of {} proofs reached, stopping at block number {}, which is {} from current block",
limit, log_block_number, current_block - log_block_number
);
// Update last processed block to this log block number
// So the next aggregation starts at this block
self.last_aggregated_block = log_block_number;
return Ok(proofs);
}

// try to add them to the queue
for proof in proofs_to_add {
if let Err(err) = proof.verify() {
Expand All @@ -164,6 +174,9 @@ impl ProofsFetcher {
}
}

// Update last processed block after collecting logs
self.last_aggregated_block = current_block;

Ok(proofs)
}

Expand Down
2 changes: 1 addition & 1 deletion aggregation_mode/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl ProofAggregator {
) -> Result<(), AggregatedProofSubmissionError> {
let proofs = self
.fetcher
.fetch(self.engine.clone())
.fetch(self.engine.clone(), self.config.total_proofs_limit)
.await
.map_err(AggregatedProofSubmissionError::FetchingProofs)?;

Expand Down
5 changes: 5 additions & 0 deletions config-files/config-proof-aggregator-ethereum-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ eth_ws_url: "ws://localhost:8546"
max_proofs_in_queue: 1000
last_aggregated_block_filepath: config-files/proof-aggregator.last_aggregated_block.json
proofs_per_chunk: 512 # Amount of proofs to process per chunk
# This number comes from the blob data limit
# Since each blob has a capacity of (4096 * 32) = 131.072 bytes
# Since each proof commitments takes 32 bytes hash + 1 byte for padding
# We can aggregate as much proofs as 131.072 / 33 ~= 3971 per blob
total_proofs_limit: 3970

ecdsa:
private_key_store_path: "config-files/anvil.proof-aggregator.ecdsa.key.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ eth_ws_url: "ws://localhost:8546"
max_proofs_in_queue: 1000
last_aggregated_block_filepath: config-files/proof-aggregator.last_aggregated_block.json
proofs_per_chunk: 512 # Amount of proofs to process per chunk
# This number comes from the blob data limit
# Since each blob has a capacity of (4096 * 32) = 131.072 bytes
# Since each proof commitments takes 32 bytes hash + 1 byte for padding
# We can aggregate as much proofs as 131.072 / 33 ~= 3971 per blob
total_proofs_limit: 3970

ecdsa:
private_key_store_path: "config-files/anvil.proof-aggregator.ecdsa.key.json"
Expand Down
5 changes: 5 additions & 0 deletions config-files/config-proof-aggregator-mock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ eth_ws_url: "ws://localhost:8545"
max_proofs_in_queue: 1000
last_aggregated_block_filepath: config-files/proof-aggregator.last_aggregated_block.json
proofs_per_chunk: 512 # Amount of proofs to process per chunk
# This number comes from the blob data limit
# Since each blob has a capacity of (4096 * 32) = 131.072 bytes
# Since each proof commitments takes 32 bytes hash + 1 byte for padding
# We can aggregate as much proofs as 131.072 / 33 ~= 3971 per blob
total_proofs_limit: 3970

ecdsa:
private_key_store_path: "config-files/anvil.proof-aggregator.ecdsa.key.json"
Expand Down
5 changes: 5 additions & 0 deletions config-files/config-proof-aggregator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ eth_ws_url: "ws://localhost:8545"
max_proofs_in_queue: 1000
last_aggregated_block_filepath: config-files/proof-aggregator.last_aggregated_block.json
proofs_per_chunk: 512 # Amount of proofs to process per chunk
# This number comes from the blob data limit
# Since each blob has a capacity of (4096 * 32) = 131.072 bytes
# Since each proof commitments takes 32 bytes hash + 1 byte for padding
# We can aggregate as much proofs as 131.072 / 33 ~= 3971 per blob
total_proofs_limit: 3970

ecdsa:
private_key_store_path: "config-files/anvil.proof-aggregator.ecdsa.key.json"
Expand Down
Loading