From c4140c29ee4b6009c14bfab32ead71d4ebbf3676 Mon Sep 17 00:00:00 2001 From: Elias Tazartes Date: Mon, 20 Jan 2025 16:16:04 +0100 Subject: [PATCH] fix comments --- cairo/ethereum/cancun/state.cairo | 4 ++-- cairo/ethereum/utils/numeric.cairo | 14 ++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cairo/ethereum/cancun/state.cairo b/cairo/ethereum/cancun/state.cairo index 389b0e11..52f29072 100644 --- a/cairo/ethereum/cancun/state.cairo +++ b/cairo/ethereum/cancun/state.cairo @@ -193,8 +193,8 @@ func move_ether{range_check_ptr, poseidon_ptr: PoseidonBuiltin*, state: State}( let sender_balance = sender_account.value.balance; let is_sender_balance_sufficient = U256_le(amount, sender_balance); - if (is_sender_balance_sufficient.value == 0) { - assert 0 = 1; + with_attr error_message("Sender has insufficient balance") { + assert is_sender_balance_sufficient.value = 1; } let new_sender_account_balance = U256_sub(sender_balance, amount); diff --git a/cairo/ethereum/utils/numeric.cairo b/cairo/ethereum/utils/numeric.cairo index 380ab4c2..86c5a35f 100644 --- a/cairo/ethereum/utils/numeric.cairo +++ b/cairo/ethereum/utils/numeric.cairo @@ -171,11 +171,11 @@ func U256_from_be_bytes20{range_check_ptr, bitwise_ptr: BitwiseBuiltin*}(bytes20 func U256_add{range_check_ptr}(a: U256, b: U256) -> U256 { alloc_locals; let (res, carry) = uint256_add([a.value], [b.value]); - if (carry != 0) { - with_attr error_message("OverflowError") { - assert 0 = 1; - } + + with_attr error_message("OverflowError") { + assert carry = 0; } + tempvar result = U256(new U256Struct(res.low, res.high)); return result; } @@ -184,10 +184,8 @@ func U256_add{range_check_ptr}(a: U256, b: U256) -> U256 { func U256_sub{range_check_ptr}(a: U256, b: U256) -> U256 { alloc_locals; let is_within_bounds = U256_le(b, a); - if (is_within_bounds.value == 0) { - with_attr error_message("OverflowError") { - assert 0 = 1; - } + with_attr error_message("OverflowError") { + assert is_within_bounds.value = 1; } let (result) = uint256_sub([a.value], [b.value]); tempvar res = U256(new U256Struct(result.low, result.high));