From c36b542030b42781683079782bee70fb7e9b21f0 Mon Sep 17 00:00:00 2001 From: Naman Garg <0708ng@gmail.com> Date: Fri, 19 Jul 2024 17:12:38 +0530 Subject: [PATCH] chore(sidecar): refactor excess gas check Co-authored-by: Lorenzo --- bolt-sidecar/src/state/execution.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bolt-sidecar/src/state/execution.rs b/bolt-sidecar/src/state/execution.rs index c5aff4f76..dcc910029 100644 --- a/bolt-sidecar/src/state/execution.rs +++ b/bolt-sidecar/src/state/execution.rs @@ -224,15 +224,14 @@ impl ExecutionState { self.slot, self.max_committed_gas_per_slot.get(), )); - } - } else if req.tx.gas_limit() >= self.max_committed_gas_per_slot.get() { - // Check if the committed gas limit itself exceeds the maximum when template is None + // Check if the committed gas exceeds the maximum + let template_committed_gas = self.get_block_template(target_slot).map(|t| t.committed_gas()).unwrap_or(0); + if template_committed_gas + req.tx.gas_limit() >= self.max_committed_gas_per_slot.get() { return Err(ValidationError::MaxCommittedGasReachedForSlot( self.slot, self.max_committed_gas_per_slot.get(), )); } - // Check if the transaction size exceeds the maximum if req.tx.size() > self.validation_params.max_tx_input_bytes { return Err(ValidationError::TransactionSizeTooHigh);