Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix(tee): Introduce a 1 second delay in the batch poll (matter-labs#2398
Browse files Browse the repository at this point in the history
)

## What ❔

Introduce a 1 second delay in the batch poll.

## Why ❔

We don't want to poll the batches too often if they are unavailable, as
it wastes CPU resources.

## Checklist

- [x] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [ ] Tests for the changes have been added / updated.
- [ ] Documentation comments have been added / updated.
- [x] Code has been formatted via `zk fmt` and `zk lint`.
  • Loading branch information
pbeza authored Jul 8, 2024
1 parent 50422b8 commit 312defe
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions core/bin/zksync_tee_prover/src/tee_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl Task for TeeProver {
return Ok(());
}
let result = self.step().await;
match result {
let need_to_sleep = match result {
Ok(batch_number) => {
retries = 1;
backoff = self.config.initial_retry_backoff;
Expand All @@ -191,6 +191,9 @@ impl Task for TeeProver {
METRICS
.last_batch_number_processed
.set(batch_number.0 as u64);
false
} else {
true
}
}
Err(err) => {
Expand All @@ -200,14 +203,17 @@ impl Task for TeeProver {
}
retries += 1;
tracing::warn!(%err, "Failed TEE prover step function {retries}/{}, retrying in {} milliseconds.", self.config.max_retries, backoff.as_millis());
tokio::time::timeout(backoff, stop_receiver.0.changed())
.await
.ok();
backoff = std::cmp::min(
backoff.mul_f32(self.config.retry_backoff_multiplier),
self.config.max_backoff,
);
true
}
};
if need_to_sleep {
tokio::time::timeout(backoff, stop_receiver.0.changed())
.await
.ok();
}
}
}
Expand Down

0 comments on commit 312defe

Please sign in to comment.