Skip to content

fix: propagate cumulative gas overflow in block executor (#42 follow-up)#193

Open
crazywriter1 wants to merge 1 commit into
circlefin:mainfrom
crazywriter1:fix/executor-cumulative-gas-overflow
Open

fix: propagate cumulative gas overflow in block executor (#42 follow-up)#193
crazywriter1 wants to merge 1 commit into
circlefin:mainfrom
crazywriter1:fix/executor-cumulative-gas-overflow

Conversation

@crazywriter1

Copy link
Copy Markdown
Contributor

Summary

Completes the defensive gas accounting started in #42 and extended in #135. ArcBlockExecutor::commit_transaction still used checked_add(...).expect("cumulative gas overflow"), which would abort block execution if cumulative gas accounting ever overflowed.

Although this overflow is theoretically unreachable in production (gas_used is bounded by the block gas limit, far below u64::MAX), propagating the error is consistent with the project's existing overflow-handling strategy and removes an unnecessary panic path.

Changes

crates/evm/src/executor.rs

  • Add ERR_CUMULATIVE_GAS_OVERFLOW.
  • Replace checked_add(...).expect("cumulative gas overflow") with ok_or_else(|| BlockExecutionError::msg(ERR_CUMULATIVE_GAS_OVERFLOW))?.
  • Return a BlockExecutionError instead of panicking if cumulative gas accounting overflows.

Context

This PR applies the same defensive overflow handling to the block execution path, keeping overflow behavior consistent across the codebase.

Test Plan

  • cargo fmt -p arc-evm -- --check
  • cargo clippy -p arc-evm --all-targets -- -D warnings
  • cargo test -p arc-evm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant