Skip to content

Commit 098356b

Browse files
committed
Graceful handling of gas limit check
1 parent 8950a35 commit 098356b

File tree

1 file changed

+4
-1
lines changed
  • monad-eth-block-validator/src

1 file changed

+4
-1
lines changed

monad-eth-block-validator/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,10 @@ where
290290
}
291291

292292
// early return if sum of transaction gas limits exceed block gas limit
293-
let total_gas: u64 = transactions.iter().map(|tx| tx.gas_limit()).sum();
293+
let total_gas: u64 = transactions
294+
.iter()
295+
.try_fold(0u64, |acc, tx| acc.checked_add(tx.gas_limit()))
296+
.ok_or(BlockValidationError::TxnError)?;
294297
if total_gas > chain_params.proposal_gas_limit {
295298
return Err(BlockValidationError::TxnError);
296299
}

0 commit comments

Comments
 (0)