diff --git a/src/zkevm_specs/evm_circuit/execution/begin_tx.py b/src/zkevm_specs/evm_circuit/execution/begin_tx.py index b89e8d02f..f06e61dd3 100644 --- a/src/zkevm_specs/evm_circuit/execution/begin_tx.py +++ b/src/zkevm_specs/evm_circuit/execution/begin_tx.py @@ -52,8 +52,7 @@ def begin_tx(instruction: Instruction): # Calculate gas fee tx_gas = instruction.tx_context_lookup(tx_id, TxContextFieldTag.Gas) tx_gas_price = instruction.tx_gas_price(tx_id) - gas_fee, carry = instruction.mul_word_by_u64(tx_gas_price, tx_gas) - instruction.constrain_zero(carry) + gas_fee = instruction.mul_word_by_u64(tx_gas_price, tx_gas) # intrinsic gas # G_0 = sum([G_txdatazero if CallData[i] == 0 else G_txdatanonzero for i in len(CallData)]) + diff --git a/src/zkevm_specs/evm_circuit/execution/end_tx.py b/src/zkevm_specs/evm_circuit/execution/end_tx.py index e00236860..09618a2cd 100644 --- a/src/zkevm_specs/evm_circuit/execution/end_tx.py +++ b/src/zkevm_specs/evm_circuit/execution/end_tx.py @@ -24,10 +24,7 @@ def end_tx(instruction: Instruction): # Add effective_refund * gas_price back to caller's balance tx_gas_price = instruction.tx_gas_price(tx_id) - value, carry = instruction.mul_word_by_u64( - tx_gas_price, instruction.curr.gas_left + effective_refund - ) - instruction.constrain_zero(carry) + value = instruction.mul_word_by_u64(tx_gas_price, instruction.curr.gas_left + effective_refund) tx_caller_address_word = instruction.tx_context_lookup_word( tx_id, TxContextFieldTag.CallerAddress ) @@ -37,8 +34,7 @@ def end_tx(instruction: Instruction): # Add gas_used * effective_tip to coinbase's balance base_fee = instruction.block_context_lookup_word(BlockContextFieldTag.BaseFee) effective_tip, _ = instruction.sub_word(tx_gas_price, base_fee) - reward, carry = instruction.mul_word_by_u64(effective_tip, gas_used) - instruction.constrain_zero(carry) + reward = instruction.mul_word_by_u64(effective_tip, gas_used) coinbase_word = instruction.block_context_lookup_word(BlockContextFieldTag.Coinbase) coinbase = instruction.word_to_address(coinbase_word) instruction.add_balance(coinbase, [reward]) diff --git a/src/zkevm_specs/evm_circuit/instruction.py b/src/zkevm_specs/evm_circuit/instruction.py index 4e60a5147..8cbf85a4d 100644 --- a/src/zkevm_specs/evm_circuit/instruction.py +++ b/src/zkevm_specs/evm_circuit/instruction.py @@ -575,9 +575,11 @@ def mul_word_by_u64(self, multiplicand: Word, multiplier: Expression) -> Tuple[W (multiplicand_hi * multiplier.expr() + quotient_lo).n, 1 << 128 ) + self.constrain_zero(FQ(quotient_hi)) + product_bytes = product_lo.to_bytes(16, "little") + product_hi.to_bytes(16, "little") - return Word((FQ(product_lo), FQ(product_hi))), FQ(quotient_hi) + return Word(product_bytes) def mul_add_words(self, a: Word, b: Word, c: Word, d: Word) -> FQ: """