Skip to content

Commit

Permalink
Batch len fix (#1224)
Browse files Browse the repository at this point in the history
  • Loading branch information
MauroToscano authored Oct 11, 2024
1 parent d7c442f commit 07f682c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
1 change: 0 additions & 1 deletion batcher/aligned-batcher/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ impl NonPayingConfig {
#[derive(Debug, Deserialize)]
pub struct BatcherConfigFromYaml {
pub block_interval: u64,
pub batch_size_interval: usize,
pub max_proof_size: usize,
pub max_batch_size: usize,
pub eth_ws_reconnects: usize,
Expand Down
17 changes: 8 additions & 9 deletions batcher/aligned-batcher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ pub struct Batcher {
payment_service_fallback: BatcherPaymentService,
batch_state: Mutex<BatchState>,
max_block_interval: u64,
min_batch_len: usize,
max_proof_size: usize,
max_batch_size: usize,
last_uploaded_batch_block: Mutex<u64>,
Expand Down Expand Up @@ -194,7 +193,6 @@ impl Batcher {
payment_service,
payment_service_fallback,
max_block_interval: config.batcher.block_interval,
min_batch_len: config.batcher.batch_size_interval,
max_proof_size: config.batcher.max_proof_size,
max_batch_size: config.batcher.max_batch_size,
last_uploaded_batch_block: Mutex::new(last_uploaded_batch_block),
Expand Down Expand Up @@ -750,17 +748,18 @@ impl Batcher {
let current_batch_len = batch_state_lock.batch_queue.len();
let last_uploaded_batch_block_lock = self.last_uploaded_batch_block.lock().await;

if current_batch_len == 0 {
info!("Current batch is empty. Waiting for more proofs...");
if current_batch_len < 2 {
info!(
"Current batch has {} proof. Waiting for more proofs...",
current_batch_len
);
return None;
}

if batch_state_lock.batch_queue.len() < self.min_batch_len
&& block_number < *last_uploaded_batch_block_lock + self.max_block_interval
{
if block_number < *last_uploaded_batch_block_lock + self.max_block_interval {
info!(
"Current batch not ready to be posted. Current block: {} - Last uploaded block: {}. Current batch length: {} - Minimum batch length: {}",
block_number, *last_uploaded_batch_block_lock, batch_state_lock.batch_queue.len(), self.min_batch_len
"Current batch not ready to be posted. Minimium amount of {} blocks have not passed. Block passed: {}", self.max_block_interval,
block_number - *last_uploaded_batch_block_lock,
);
return None;
}
Expand Down

0 comments on commit 07f682c

Please sign in to comment.