Skip to content

Commit

Permalink
fix(gas-adjuster): Do not unwrap in gas-adjuster (#1400)
Browse files Browse the repository at this point in the history
## What ❔

Do not unwrap in gas-adjuster

## Why ❔

Avoid panics

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [ ] 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.
- [ ] Code has been formatted via `zk fmt` and `zk lint`.
- [ ] Spellcheck has been run via `zk spellcheck`.
- [ ] Linkcheck has been run via `zk linkcheck`.
  • Loading branch information
perekopskiy committed Mar 11, 2024
1 parent a040001 commit 269812e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions core/lib/zksync_core/src/l1_gas_price/gas_adjuster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@ impl GasAdjuster {
)
.await?;

METRICS
.current_base_fee_per_gas
.set(*base_fee_history.last().unwrap());
// We shouldn't rely on L1 provider to return consistent results, so we check that we have at least one new sample.
if let Some(current_base_fee_per_gas) = base_fee_history.last() {
METRICS
.current_base_fee_per_gas
.set(*current_base_fee_per_gas);
}
self.base_fee_statistics.add_samples(&base_fee_history);

if let Some(current_blob_base_fee) = blob_base_fee_history.last() {
Expand Down

0 comments on commit 269812e

Please sign in to comment.