Skip to content

Commit

Permalink
fix(l1): block gas limit (#1597)
Browse files Browse the repository at this point in the history
**Motivation**

The `block_gas_limit` is around 30M gas per block. The calculations
automatically adjust the gas limit if it changes. When using the `min`
function, the gas limit is consistently decremented. Consequently, if
the node runs for an extended period, it may eventually reach a point
where no transactions are accepted.

**Description**

Change `min` with `max`. With this change, the gas reaches 30M and stays
around it.
  • Loading branch information
fborello-lambda authored Jan 2, 2025
1 parent 75b0740 commit dd8e121
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/blockchain/payload.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{
cmp::{min, Ordering},
cmp::{max, Ordering},
collections::HashMap,
};

Expand Down Expand Up @@ -125,7 +125,7 @@ pub fn create_payload(args: &BuildPayloadArgs, storage: &Store) -> Result<Block,
fn calc_gas_limit(parent_gas_limit: u64, desired_limit: u64) -> u64 {
let delta = parent_gas_limit / GAS_LIMIT_BOUND_DIVISOR - 1;
let mut limit = parent_gas_limit;
let desired_limit = min(desired_limit, MIN_GAS_LIMIT);
let desired_limit = max(desired_limit, MIN_GAS_LIMIT);
if limit < desired_limit {
limit = parent_gas_limit + delta;
if limit > desired_limit {
Expand Down

0 comments on commit dd8e121

Please sign in to comment.