Skip to content

Commit

Permalink
refactor(levm): safe mod implementation (#1338)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilitteri authored Nov 28, 2024
1 parent f496c7c commit 2da9af5
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions crates/vm/levm/src/opcode_handlers/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,9 @@ impl VM {

let dividend = current_call_frame.stack.pop()?;
let divisor = current_call_frame.stack.pop()?;
if divisor.is_zero() {
current_call_frame.stack.push(U256::zero())?;
return Ok(OpcodeSuccess::Continue);
}
let remainder = dividend.checked_rem(divisor).ok_or(VMError::Internal(
InternalError::ArithmeticOperationDividedByZero,
))?; // Cannot be zero bc if above;

let remainder = dividend.checked_rem(divisor).unwrap_or_default();

current_call_frame.stack.push(remainder)?;

Ok(OpcodeSuccess::Continue)
Expand Down

0 comments on commit 2da9af5

Please sign in to comment.