diff --git a/.env b/.env index 29111e064..8d0547a55 100644 --- a/.env +++ b/.env @@ -5,7 +5,7 @@ CPU_CIRCUIT_SIZE=8..21 KECCAK_CIRCUIT_SIZE=4..20 KECCAK_SPONGE_CIRCUIT_SIZE=8..17 LOGIC_CIRCUIT_SIZE=4..21 -MEMORY_CIRCUIT_SIZE=17..24 +MEMORY_CIRCUIT_SIZE=16..24 MEMORY_BEFORE_CIRCUIT_SIZE=16..23 MEMORY_AFTER_CIRCUIT_SIZE=7..23 POSEIDON_CIRCUIT_SIZE=4..25 diff --git a/book/src/cpu_execution/privileged_instructions.md b/book/src/cpu_execution/privileged_instructions.md index af613346c..8451e53cf 100644 --- a/book/src/cpu_execution/privileged_instructions.md +++ b/book/src/cpu_execution/privileged_instructions.md @@ -50,17 +50,22 @@ ecPairing precompiles. resetting memory sections (by calling MSTORE_32BYTES_32 with the value 0). -7. `PROVER_INPUT`. Pushes a single prover input onto the stack. +7. `INCR`. Reads the `N`th element of the stack, and increments it in-place + by one without pushing or popping. There are 4 INCR operations, namely + INCR1, INCR2, INCR3, INCR4 to increment respectively the 1st, 2nd, 3rd + and 4th stack elements. -8. `GET_CONTEXT`. Pushes the current context onto the stack. The kernel +8. `PROVER_INPUT`. Pushes a single prover input onto the stack. + +9. `GET_CONTEXT`. Pushes the current context onto the stack. The kernel always has context 0. -9. `SET_CONTEXT`. Pops the top element of the stack and updates the +10. `SET_CONTEXT`. Pops the top element of the stack and updates the current context to this value. It is usually used when calling another contract or precompile, to distinguish the caller from the callee. -10. `MLOAD_32BYTES`. Pops 2 elements from the stack (a Memory address, +11. `MLOAD_32BYTES`. Pops 2 elements from the stack (a Memory address, and then a length $\ell$), and pushes a value onto the stack. The pushed value corresponds to the U256 integer read from the big-endian sequence of length $\ell$ from the memory address being @@ -68,19 +73,19 @@ ecPairing precompiles. greater than 32 (as a U256 consists in at most 32 bytes). Missing these conditions will result in an unverifiable proof. -11. `EXIT_KERNEL`. Pops 1 element from the stack. This instruction is +12. `EXIT_KERNEL`. Pops 1 element from the stack. This instruction is used at the end of a syscall, before proceeding to the rest of the execution logic. The popped element, *kexit_info*, contains several pieces of information like the current program counter, the current amount of gas used, and whether we are in kernel (i.e. privileged) mode or not. -12. `MLOAD_GENERAL`. Pops 1 elements (a Memory address), and pushes the +13. `MLOAD_GENERAL`. Pops 1 elements (a Memory address), and pushes the value stored at this memory address onto the stack. It can read any memory location, general (similarly to MLOAD (0x51) instruction) or privileged. -13. `MSTORE_GENERAL`. Pops 2 elements (a value and a Memory address), +14. `MSTORE_GENERAL`. Pops 2 elements (a value and a Memory address), and writes the popped value from the stack at the fetched address. It can write to any memory location, general (similarly to MSTORE (0x52) / MSTORE8 (0x53) instructions) or privileged. diff --git a/evm_arithmetization/src/all_stark.rs b/evm_arithmetization/src/all_stark.rs index 41f4010fe..36157be75 100644 --- a/evm_arithmetization/src/all_stark.rs +++ b/evm_arithmetization/src/all_stark.rs @@ -174,8 +174,10 @@ pub(crate) fn all_cross_table_lookups() -> Vec> { /// `CrossTableLookup` for `ArithmeticStark`, to connect it with the `Cpu` /// module. fn ctl_arithmetic() -> CrossTableLookup { + let cpu_arithmetic_looking = cpu_stark::ctl_arithmetic_base_rows(); + let cpu_increment_looking = cpu_stark::ctl_arithmetic_incr_op(); CrossTableLookup::new( - vec![cpu_stark::ctl_arithmetic_base_rows()], + vec![cpu_arithmetic_looking, cpu_increment_looking], arithmetic_stark::ctl_arithmetic_rows(), ) } diff --git a/evm_arithmetization/src/cpu/columns/ops.rs b/evm_arithmetization/src/cpu/columns/ops.rs index 5e91457e9..bf2082b69 100644 --- a/evm_arithmetization/src/cpu/columns/ops.rs +++ b/evm_arithmetization/src/cpu/columns/ops.rs @@ -39,6 +39,8 @@ pub(crate) struct OpsColumnsView { pub m_op_general: T, /// Combines PC and PUSH0 pub pc_push0: T, + /// Flag for INCR_N instructions. + pub incr: T, /// Flag for syscalls. pub syscall: T, diff --git a/evm_arithmetization/src/cpu/contextops.rs b/evm_arithmetization/src/cpu/contextops.rs index 11ffe0da3..7f6d3bf31 100644 --- a/evm_arithmetization/src/cpu/contextops.rs +++ b/evm_arithmetization/src/cpu/contextops.rs @@ -33,6 +33,7 @@ const KEEPS_CONTEXT: OpsColumnsView = OpsColumnsView { m_op_32bytes: true, exit_kernel: true, m_op_general: true, + incr: true, syscall: true, exception: true, }; diff --git a/evm_arithmetization/src/cpu/cpu_stark.rs b/evm_arithmetization/src/cpu/cpu_stark.rs index a0dd45e1e..33955eeaf 100644 --- a/evm_arithmetization/src/cpu/cpu_stark.rs +++ b/evm_arithmetization/src/cpu/cpu_stark.rs @@ -15,14 +15,14 @@ use starky::lookup::{Column, Filter}; use starky::stark::Stark; use super::columns::CpuColumnsView; -use super::halt; use super::kernel::constants::context_metadata::ContextMetadata; +use super::kernel::opcodes::get_opcode; use super::membus::{NUM_CHANNELS, NUM_GP_CHANNELS}; use crate::all_stark::{EvmStarkFrame, Table}; use crate::cpu::columns::{COL_MAP, NUM_CPU_COLUMNS}; use crate::cpu::{ - byte_unpacking, clock, contextops, control_flow, decode, dup_swap, gas, jumps, membus, memio, - modfp254, pc, push0, shift, simple_logic, stack, syscalls_exceptions, + byte_unpacking, clock, contextops, control_flow, decode, dup_swap, gas, halt, incr, jumps, + membus, memio, modfp254, pc, push0, shift, simple_logic, stack, syscalls_exceptions, }; use crate::memory::segments::Segment; use crate::memory::VALUE_LIMBS; @@ -131,6 +131,39 @@ pub(crate) fn ctl_arithmetic_base_rows() -> TableWithColumns { ) } +/// Returns the `TableWithColumns` for the CPU rows calling arithmetic +/// `ADD` operations through the `INCR` privileged instructions. +pub(crate) fn ctl_arithmetic_incr_op() -> TableWithColumns { + // Instead of taking single columns, we reconstruct the entire opcode value + // directly. + let mut columns = vec![Column::constant(F::from_canonical_u8(get_opcode("ADD")))]; + + // Read value + columns.extend(Column::singles(COL_MAP.mem_channels[1].value)); + + // Fixed second operand (`U256::one()`) + { + columns.push(Column::constant(F::ONE)); + for _ in 1..VALUE_LIMBS { + columns.push(Column::constant(F::ZERO)); + } + } + + // Ignored third operand, `ADD` is a binary operation + for _ in 0..VALUE_LIMBS { + columns.push(Column::constant(F::ZERO)); + } + + // Returned value + columns.extend(Column::singles(COL_MAP.mem_channels[2].value)); + + TableWithColumns::new( + *Table::Cpu, + columns, + Filter::new_simple(Column::single(COL_MAP.op.incr)), + ) +} + /// Returns a column containing stale contexts. pub(crate) fn ctl_context_pruning_looked() -> TableWithColumns { TableWithColumns::new( @@ -612,6 +645,7 @@ impl, const D: usize> Stark for CpuStark, const D: usize> Stark for CpuStark, const D: usize>( /// /// `offset` is the stack index before this instruction is executed, e.g. `0` /// for the top of the stack. -fn constrain_channel_packed( +pub(crate) fn constrain_channel_packed( is_read: bool, filter: P, offset: P, @@ -64,7 +64,7 @@ fn constrain_channel_packed( /// /// `offset` is the stack index before this instruction is executed, e.g. `0` /// for the top of the stack. -fn constrain_channel_ext_circuit, const D: usize>( +pub(crate) fn constrain_channel_ext_circuit, const D: usize>( builder: &mut CircuitBuilder, is_read: bool, filter: ExtensionTarget, diff --git a/evm_arithmetization/src/cpu/gas.rs b/evm_arithmetization/src/cpu/gas.rs index 7c036ae9b..0544ebbb6 100644 --- a/evm_arithmetization/src/cpu/gas.rs +++ b/evm_arithmetization/src/cpu/gas.rs @@ -37,6 +37,7 @@ const SIMPLE_OPCODES: OpsColumnsView> = OpsColumnsView { m_op_32bytes: KERNEL_ONLY_INSTR, exit_kernel: None, m_op_general: KERNEL_ONLY_INSTR, + incr: KERNEL_ONLY_INSTR, syscall: None, exception: None, }; diff --git a/evm_arithmetization/src/cpu/incr.rs b/evm_arithmetization/src/cpu/incr.rs new file mode 100644 index 000000000..9104a7c62 --- /dev/null +++ b/evm_arithmetization/src/cpu/incr.rs @@ -0,0 +1,76 @@ +use plonky2::field::extension::Extendable; +use plonky2::field::packed::PackedField; +use plonky2::field::types::Field; +use plonky2::hash::hash_types::RichField; +use plonky2::iop::ext_target::ExtensionTarget; +use plonky2::plonk::circuit_builder::CircuitBuilder; +use starky::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer}; + +use super::dup_swap::{constrain_channel_ext_circuit, constrain_channel_packed}; +use crate::cpu::columns::CpuColumnsView; + +/// Evaluates the constraints for the DUP and SWAP opcodes. +pub(crate) fn eval_packed( + lv: &CpuColumnsView

, + nv: &CpuColumnsView

, + yield_constr: &mut ConstraintConsumer

, +) { + let filter = lv.op.incr; + + let n = lv.opcode_bits[0] + + lv.opcode_bits[1] * P::Scalar::from_canonical_u64(2) + + lv.opcode_bits[2] * P::Scalar::from_canonical_u64(4); + + // Disable the partial channel. + yield_constr.constraint(lv.op.incr * lv.partial_channel.used); + + // Constrain the input channel's address, `is_read` and `used` fields. + let read_channel = &lv.mem_channels[1]; + constrain_channel_packed(true, filter, n, read_channel, lv, yield_constr); + + // Constrain the output channel's address, `is_read` and `used` fields. + let write_channel = &lv.mem_channels[2]; + constrain_channel_packed(false, filter, n, write_channel, lv, yield_constr); + + // Constrain the unchanged stack len. + yield_constr.constraint_transition(filter * (nv.stack_len - lv.stack_len)); +} + +/// Circuit version of `eval_packed`. +/// Evaluates the constraints for the DUP and SWAP opcodes. +pub(crate) fn eval_ext_circuit, const D: usize>( + builder: &mut CircuitBuilder, + lv: &CpuColumnsView>, + nv: &CpuColumnsView>, + yield_constr: &mut RecursiveConstraintConsumer, +) { + let filter = lv.op.incr; + + let n = lv.opcode_bits[..3].iter().enumerate().fold( + builder.zero_extension(), + |cumul, (i, &bit)| { + builder.mul_const_add_extension(F::from_canonical_u64(1 << i), bit, cumul) + }, + ); + + // Disable the partial channel. + { + let constr = builder.mul_extension(lv.op.incr, lv.partial_channel.used); + yield_constr.constraint(builder, constr); + } + + // Constrain the input channel's address, `is_read` and `used` fields. + let read_channel = &lv.mem_channels[1]; + constrain_channel_ext_circuit(builder, true, filter, n, read_channel, lv, yield_constr); + + // Constrain the output channel's address, `is_read` and `used` fields. + let write_channel = &lv.mem_channels[2]; + constrain_channel_ext_circuit(builder, false, filter, n, write_channel, lv, yield_constr); + + // Constrain the unchanged stack len. + { + let diff = builder.sub_extension(nv.stack_len, lv.stack_len); + let constr = builder.mul_extension(filter, diff); + yield_constr.constraint_transition(builder, constr); + } +} diff --git a/evm_arithmetization/src/cpu/kernel/asm/balance.asm b/evm_arithmetization/src/cpu/kernel/asm/balance.asm index d39f66063..3774a5b24 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/balance.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/balance.asm @@ -30,7 +30,7 @@ global balance: %mpt_read_state_trie // stack: account_ptr, retdest DUP1 ISZERO %jumpi(retzero) // If the account pointer is null, return 0. - %add_const(1) + INCR1 // stack: balance_ptr, retdest %mload_trie_data // stack: balance, retdest diff --git a/evm_arithmetization/src/cpu/kernel/asm/bignum/add.asm b/evm_arithmetization/src/cpu/kernel/asm/bignum/add.asm index 4433ab224..3babfef95 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/bignum/add.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/bignum/add.asm @@ -40,12 +40,10 @@ add_loop: // stack: a_cur_addr, c[cur], carry_new, base_addr, i, a_cur_loc, b_cur_loc, retdest %swap_mstore // stack: carry_new, base_addr, i, a_cur_loc, b_cur_loc, retdest - SWAP3 - %increment - SWAP3 + INCR4 // stack: carry_new, base_addr, i, a_cur_loc + 1, b_cur_loc, retdest SWAP4 - %increment + INCR1 SWAP4 // stack: carry_new, base_addr, i, a_cur_loc + 1, b_cur_loc + 1, retdest SWAP2 diff --git a/evm_arithmetization/src/cpu/kernel/asm/bignum/addmul.asm b/evm_arithmetization/src/cpu/kernel/asm/bignum/addmul.asm index 9cdf904e1..44aeef826 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/bignum/addmul.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/bignum/addmul.asm @@ -87,11 +87,11 @@ addmul_loop: // stack: i-1, base_addr, carry_limb, a_cur_loc, b_cur_loc, val, retdest SWAP3 // stack: a_cur_loc, base_addr, carry_limb, i-1, b_cur_loc, val, retdest - %increment + INCR1 // stack: a_cur_loc+1, base_addr, carry_limb, i-1, b_cur_loc, val, retdest SWAP4 // stack: b_cur_loc, base_addr, carry_limb, i-1, a_cur_loc+1, val, retdest - %increment + INCR1 // stack: b_cur_loc+1, base_addr, carry_limb, i-1, a_cur_loc+1, val, retdest %stack (b, addr, c, i, a) -> (c, addr, i, a, b) // stack: carry_limb, base_addr, i-1, a_cur_loc+1, b_cur_loc+1, val, retdest diff --git a/evm_arithmetization/src/cpu/kernel/asm/bignum/isone.asm b/evm_arithmetization/src/cpu/kernel/asm/bignum/isone.asm index 7aaf32f45..fe36cf4dc 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/bignum/isone.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/bignum/isone.asm @@ -28,8 +28,6 @@ starts_with_one: // Starts with one, so check that the remaining limbs are zero. // stack: len, start_loc, retdest %decrement - SWAP1 - %increment - SWAP1 + INCR2 // stack: len-1, start_loc+1, retdest %jump(iszero_bignum) diff --git a/evm_arithmetization/src/cpu/kernel/asm/bignum/iszero.asm b/evm_arithmetization/src/cpu/kernel/asm/bignum/iszero.asm index a6027b611..3e2e81d70 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/bignum/iszero.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/bignum/iszero.asm @@ -21,7 +21,7 @@ iszero_loop: // stack: cur_val, cur_loc, end_loc, retdest %jumpi(neqzero) // stack: cur_loc, end_loc, retdest - %increment + INCR1 // stack: cur_loc + 1, end_loc, retdest %stack (vals: 2) -> (vals, vals) // stack: cur_loc + 1, end_loc, cur_loc + 1, end_loc, retdest diff --git a/evm_arithmetization/src/cpu/kernel/asm/bignum/modmul.asm b/evm_arithmetization/src/cpu/kernel/asm/bignum/modmul.asm index 9735f6108..17b770816 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/bignum/modmul.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/bignum/modmul.asm @@ -36,7 +36,7 @@ modmul_remainder_loop: DUP4 ADD // out_addr_i %swap_mstore // stack: i, base_addr, len, a_loc, b_loc, m_loc, out_loc, s1, s2, s3, retdest - %increment + INCR1 DUP3 DUP2 // stack: i+1, len, i+1, base_addr, len, a_loc, b_loc, m_loc, out_loc, s1, s2, s3, retdest @@ -89,7 +89,7 @@ modmul_quotient_loop: DUP4 ADD // s1_addr_i %swap_mstore // stack: i, base_addr, 2*len, len, a_loc, b_loc, m_loc, out_loc, s1, s2, s3, retdest - %increment + INCR1 DUP3 DUP2 // stack: i+1, 2*len, i+1, base_addr, 2*len, len, a_loc, b_loc, m_loc, out_loc, s1, s2, s3, retdest @@ -156,13 +156,12 @@ modmul_check_loop: SWAP1 %decrement // stack: n-1, base_addr, i, j, retdest + INCR3 SWAP2 - %increment // stack: i+1, base_addr, n-1, j, retdest - SWAP3 - %increment - // stack: j+1, base_addr, n-1, i+1, retdest - %stack (j, addr, n, i) -> (n, addr, n, i, j) + INCR4 + // stack: i+1, base_addr, n-1, j+1, retdest + %stack (i, addr, n) -> (n, addr, n, i) // stack: n-1, base_addr, n-1, i+1, j+1, retdest %jumpi(modmul_check_loop) // end of modmul_check_loop diff --git a/evm_arithmetization/src/cpu/kernel/asm/bignum/mul.asm b/evm_arithmetization/src/cpu/kernel/asm/bignum/mul.asm index b3269f73a..141d8a8b3 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/bignum/mul.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/bignum/mul.asm @@ -47,11 +47,11 @@ mul_addmul_return: %decrement // stack: n-1, base_addr, len, a_start_loc, bi, output_cur, retdest SWAP4 - %increment + INCR1 SWAP4 // stack: n-1, base_addr, len, a_start_loc, bi+1, output_cur, retdest SWAP5 - %increment + INCR1 SWAP5 // stack: n-1, base_addr, len, a_start_loc, bi+1, output_cur+1, retdest DUP1 diff --git a/evm_arithmetization/src/cpu/kernel/asm/bloom_filter.asm b/evm_arithmetization/src/cpu/kernel/asm/bloom_filter.asm index 35a4ebd76..c80a9fd99 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/bloom_filter.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/bloom_filter.asm @@ -53,7 +53,7 @@ logs_bloom_loop: // stack: log_payload_len_ptr, i, logs_len, retdest // Add address to bloom filter. - %increment + INCR1 // stack: addr_ptr, i, logs_len, retdest PUSH @SEGMENT_LOGS_DATA %build_kernel_address DUP1 @@ -63,12 +63,12 @@ logs_bloom_loop: // stack: is_topic, addr, full_addr_ptr, i, logs_len, retdest %add_to_bloom // stack: full_addr_ptr, i, logs_len, retdest - %increment + INCR1 // stack: full_num_topics_ptr, i, logs_len, retdest DUP1 MLOAD_GENERAL // stack: num_topics, full_num_topics_ptr, i, logs_len, retdest - SWAP1 %increment + INCR2 SWAP1 // stack: full_topics_ptr, num_topics, i, logs_len, retdest PUSH 0 @@ -85,13 +85,13 @@ logs_bloom_topic_loop: // stack: is_topic, topic, j, topics_ptr, num_topics, i, logs_len, retdest %add_to_bloom // stack: j, topics_ptr, num_topics, i, logs_len, retdest - %increment + INCR1 %jump(logs_bloom_topic_loop) logs_bloom_topic_end: // stack: num_topics, topics_ptr, num_topics, i, logs_len, retdest %pop3 - %increment + INCR1 %jump(logs_bloom_loop) logs_bloom_end: diff --git a/evm_arithmetization/src/cpu/kernel/asm/core/access_lists.asm b/evm_arithmetization/src/cpu/kernel/asm/core/access_lists.asm index 84cc4077b..d884e3e10 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/core/access_lists.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/core/access_lists.asm @@ -21,13 +21,13 @@ global init_access_lists: DUP1 %mstore_u256_max // Store @SEGMENT_ACCESSED_ADDRESSES at address 1 - %increment + INCR1 DUP1 PUSH @SEGMENT_ACCESSED_ADDRESSES MSTORE_GENERAL // Store the segment scaled length - %increment + INCR1 %mstore_global_metadata(@GLOBAL_METADATA_ACCESSED_ADDRESSES_LEN) // stack: (empty) @@ -43,7 +43,7 @@ global init_access_lists: MSTORE_GENERAL // Store the segment scaled length - %increment + INCR1 %mstore_global_metadata(@GLOBAL_METADATA_ACCESSED_STORAGE_KEYS_LEN) // Reset the access lists pointers in the `GenerationState` @@ -117,7 +117,7 @@ global insert_accessed_addresses: // stack: pred_ptr, addr, retdest // Check that this is not a deleted node - %increment + INCR1 MLOAD_GENERAL %jump_neq_const(@U256_MAX, address_found) // We should have found the address. @@ -131,7 +131,7 @@ insert_new_address: // stack: pred_addr, pred_ptr, addr, retdest POP // get the value of the next address - %increment + INCR1 // stack: next_ptr_ptr, addr, retdest %mload_global_metadata(@GLOBAL_METADATA_ACCESSED_ADDRESSES_LEN) DUP2 @@ -158,13 +158,13 @@ insert_new_address: DUP4 MSTORE_GENERAL // stack: new_ptr, next_ptr, addr, retdest - %increment + INCR1 DUP1 // stack: new_next_ptr, new_next_ptr, next_ptr, addr, retdest SWAP2 MSTORE_GENERAL // stack: new_next_ptr, addr, retdest - %increment + INCR1 %mstore_global_metadata(@GLOBAL_METADATA_ACCESSED_ADDRESSES_LEN) // stack: addr, retdest %journal_add_account_loaded @@ -185,7 +185,7 @@ global remove_accessed_addresses: // stack: pred_ptr/2, addr, retdest %get_valid_addr_ptr // stack: pred_ptr, addr, retdest - %increment + INCR1 // stack: next_ptr_ptr, addr, retdest DUP1 MLOAD_GENERAL @@ -196,7 +196,7 @@ global remove_accessed_addresses: DUP4 %assert_eq // stack: next_ptr, next_ptr_ptr, addr, retdest - %increment + INCR1 // stack: next_next_ptr_ptr, next_ptr_ptr, addr, retdest DUP1 MLOAD_GENERAL @@ -255,7 +255,7 @@ global insert_accessed_storage_keys: %assert_eq // stack: pred_ptr, addr, key, retdest DUP1 - %increment + INCR1 MLOAD_GENERAL // stack: pred_key, pred_ptr, addr, key, retdest DUP1 DUP5 @@ -308,7 +308,7 @@ insert_storage_key: SWAP2 EQ // stack: next_val == addr, addr < next_val, next_ptr, new_ptr, next_ptr_ptr, addr, key, retdest - DUP3 %increment + DUP3 INCR1 MLOAD_GENERAL DUP8 LT @@ -325,17 +325,17 @@ insert_storage_key: DUP4 MSTORE_GENERAL // store addr // stack: new_ptr, next_ptr, addr, key, retdest - %increment + INCR1 DUP1 // stack: new_ptr+1, new_ptr+1, next_ptr, addr, key, retdest DUP5 // stack: key, new_ptr+1, new_ptr+1, next_ptr, addr, key, retdest MSTORE_GENERAL // store key // stack: new_ptr+1, next_ptr, addr, key, retdest - %increment + INCR1 DUP1 // stack: new_ptr+2, value_ptr, next_ptr, addr, key, retdest - %increment + INCR1 DUP1 // stack: new_next_ptr, new_next_ptr, value_ptr, next_ptr, addr, key, retdest SWAP3 @@ -344,7 +344,7 @@ insert_storage_key: // stack: value_ptr, new_next_ptr, addr, key, retdest SWAP1 // stack: new_next_ptr, value_ptr, addr, key, retdest - %increment + INCR1 %mstore_global_metadata(@GLOBAL_METADATA_ACCESSED_STORAGE_KEYS_LEN) // stack: value_ptr, addr, key, retdest %stack (value_ptr, addr, key, retdest) -> (addr, key, retdest, 1, value_ptr) @@ -365,7 +365,7 @@ global remove_accessed_storage_keys: MLOAD_GENERAL // stack: next_ptr, next_ptr_ptr, addr, key, retdest DUP1 - %increment + INCR1 MLOAD_GENERAL // stack: next_key, next_ptr, next_ptr_ptr, addr, key, retdest DUP5 diff --git a/evm_arithmetization/src/cpu/kernel/asm/core/create_addresses.asm b/evm_arithmetization/src/cpu/kernel/asm/core/create_addresses.asm index cf7b97b28..40c00e833 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/core/create_addresses.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/core/create_addresses.asm @@ -43,7 +43,7 @@ global get_create2_address: PUSH 0xff MSTORE_GENERAL // stack: addr, sender, code_hash, salt, retdest - %increment + INCR1 %stack (addr, sender, code_hash, salt, retdest) -> (addr, sender, salt, code_hash, retdest) MSTORE_32BYTES_20 // stack: addr, salt, code_hash, retdest diff --git a/evm_arithmetization/src/cpu/kernel/asm/core/create_contract_account.asm b/evm_arithmetization/src/cpu/kernel/asm/core/create_contract_account.asm index a614f9fa8..fb2d1409b 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/core/create_contract_account.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/core/create_contract_account.asm @@ -72,6 +72,6 @@ // stack: nb_created_contracts, address, nb_created_contracts %mstore_kernel(@SEGMENT_CREATED_CONTRACTS) // stack: nb_created_contracts - %increment + INCR1 %mstore_global_metadata(@GLOBAL_METADATA_CREATED_CONTRACTS_LEN) %endmacro diff --git a/evm_arithmetization/src/cpu/kernel/asm/core/create_receipt.asm b/evm_arithmetization/src/cpu/kernel/asm/core/create_receipt.asm index edcd3f329..4fe059073 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/core/create_receipt.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/core/create_receipt.asm @@ -122,14 +122,14 @@ process_receipt_logs_loop: %append_to_trie_data // stack: log_ptr, i, num_logs, receipt_ptr, txn_nb, new_cum_gas, txn_nb, num_nibbles, retdest // Write address. - %increment + INCR1 // stack: addr_ptr, i, num_logs, receipt_ptr, txn_nb, new_cum_gas, txn_nb, num_nibbles, retdest DUP1 MLOAD_GENERAL %append_to_trie_data // stack: addr_ptr, i, num_logs, receipt_ptr, txn_nb, new_cum_gas, txn_nb, num_nibbles, retdest // Write num_topics. - %increment + INCR1 // stack: num_topics_ptr, i, num_logs, receipt_ptr, txn_nb, new_cum_gas, txn_nb, num_nibbles, retdest DUP1 MLOAD_GENERAL @@ -137,7 +137,7 @@ process_receipt_logs_loop: DUP1 %append_to_trie_data // stack: num_topics, num_topics_ptr, i, num_logs, receipt_ptr, txn_nb, new_cum_gas, txn_nb, num_nibbles, retdest - SWAP1 %increment SWAP1 + INCR2 // stack: num_topics, topics_ptr, i, num_logs, receipt_ptr, txn_nb, new_cum_gas, txn_nb, num_nibbles, retdest PUSH 0 @@ -155,7 +155,7 @@ process_receipt_topics_loop: MLOAD_GENERAL %append_to_trie_data // stack: j, num_topics, topics_ptr, i, num_logs, receipt_ptr, txn_nb, new_cum_gas, txn_nb, num_nibbles, retdest - %increment + INCR1 %jump(process_receipt_topics_loop) process_receipt_topics_end: @@ -170,7 +170,7 @@ process_receipt_topics_end: DUP1 %append_to_trie_data // stack: data_len, data_len_ptr, i, num_logs, receipt_ptr, txn_nb, new_cum_gas, txn_nb, num_nibbles, retdest - SWAP1 %increment SWAP1 + INCR2 // stack: data_len, data_ptr, i, num_logs, receipt_ptr, txn_nb, new_cum_gas, txn_nb, num_nibbles, retdest PUSH 0 @@ -188,13 +188,13 @@ process_receipt_data_loop: MLOAD_GENERAL %append_to_trie_data // stack: j, data_len, data_ptr, i, num_logs, receipt_ptr, txn_nb, new_cum_gas, txn_nb, num_nibbles, retdest - %increment + INCR1 %jump(process_receipt_data_loop) process_receipt_data_end: // stack: data_len, data_len, data_ptr, i, num_logs, receipt_ptr, txn_nb, new_cum_gas, txn_nb, num_nibbles, retdest + INCR4 %pop3 - %increment %jump(process_receipt_logs_loop) process_receipt_after_write: diff --git a/evm_arithmetization/src/cpu/kernel/asm/core/exception.asm b/evm_arithmetization/src/cpu/kernel/asm/core/exception.asm index bea641c2e..1de3eac3f 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/core/exception.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/core/exception.asm @@ -228,7 +228,7 @@ global exc_stop: DUP3 %shr_const(32) MOD // stack: is_kernel_mode, addr_registers, trap_info - DUP2 %increment + DUP2 INCR1 MLOAD_GENERAL %assert_eq @@ -415,7 +415,12 @@ min_stack_len_for_opcode: BYTES 4 %endrep - %rep 16 // 0xe0-0xef, invalid + BYTES 1 // 0xe0, INCR1 + BYTES 2 // 0xe1, INCR2 + BYTES 3 // 0xe2, INCR3 + BYTES 4 // 0xe3, INCR4 + + %rep 12 // 0xe5-0xef, invalid BYTES 0 %endrep diff --git a/evm_arithmetization/src/cpu/kernel/asm/core/intrinsic_gas.asm b/evm_arithmetization/src/cpu/kernel/asm/core/intrinsic_gas.asm index bb7a21b5d..fba52aa0c 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/core/intrinsic_gas.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/core/intrinsic_gas.asm @@ -20,9 +20,8 @@ count_zeros_loop: %stack (data_i_is_zero, i, zeros) -> (data_i_is_zero, zeros, i) ADD // stack: zeros', i, retdest + INCR2 SWAP1 - // stack: i, zeros', retdest - %increment // stack: i', zeros', retdest %jump(count_zeros_loop) diff --git a/evm_arithmetization/src/cpu/kernel/asm/core/log.asm b/evm_arithmetization/src/cpu/kernel/asm/core/log.asm index f23d5e174..c9466efe0 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/core/log.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/core/log.asm @@ -106,22 +106,22 @@ global log_n_entry: // stack: log_ptr, logs_len, log_ptr, logs_len, address, num_topics, topics, data_len, data_offset, retdest %mstore_kernel(@SEGMENT_LOGS) // stack: log_ptr, logs_len, address, num_topics, topics, data_len, data_offset, retdest - SWAP1 %increment + INCR2 SWAP1 %mstore_global_metadata(@GLOBAL_METADATA_LOGS_LEN) // stack: log_ptr, address, num_topics, topics, data_len, data_offset, retdest - %increment + INCR1 // stack: addr_ptr, address, num_topics, topics, data_len, data_offset, retdest // Store the address. DUP2 DUP2 %mstore_kernel(@SEGMENT_LOGS_DATA) - %increment + INCR1 // stack: num_topics_ptr, address, num_topics, topics, data_len, data_offset, retdest SWAP1 POP // stack: num_topics_ptr, num_topics, topics, data_len, data_offset, retdest // Store num_topics. DUP2 DUP2 %mstore_kernel(@SEGMENT_LOGS_DATA) - %increment + INCR1 // stack: topics_ptr, num_topics, topics, data_len, data_offset, retdest DUP2 // stack: num_topics, topics_ptr, num_topics, topics, data_len, data_offset, retdest @@ -131,7 +131,7 @@ global log_n_entry: // Store the first topic. DUP3 DUP2 %mstore_kernel(@SEGMENT_LOGS_DATA) - %increment + INCR1 %stack (curr_topic_ptr, num_topics, topic1) -> (curr_topic_ptr, num_topics) DUP2 %eq_const(1) %jumpi(log_after_topics) @@ -139,7 +139,7 @@ global log_n_entry: // Store the second topic. DUP3 DUP2 %mstore_kernel(@SEGMENT_LOGS_DATA) - %increment + INCR1 %stack (curr_topic_ptr, num_topics, topic2) -> (curr_topic_ptr, num_topics) DUP2 %eq_const(2) %jumpi(log_after_topics) @@ -147,7 +147,7 @@ global log_n_entry: // Store the third topic. DUP3 DUP2 %mstore_kernel(@SEGMENT_LOGS_DATA) - %increment + INCR1 %stack (curr_topic_ptr, num_topics, topic3) -> (curr_topic_ptr, num_topics) DUP2 %eq_const(3) %jumpi(log_after_topics) @@ -155,7 +155,7 @@ global log_n_entry: // Store the fourth topic. DUP3 DUP2 %mstore_kernel(@SEGMENT_LOGS_DATA) - %increment + INCR1 %stack (data_len_ptr, num_topics, topic4) -> (data_len_ptr, num_topics) DUP2 %eq_const(4) %jumpi(log_after_topics) @@ -196,7 +196,7 @@ log_after_topics: // Store data_len. DUP3 DUP2 %mstore_kernel(@SEGMENT_LOGS_DATA) - %increment + INCR1 // stack: data_ptr, num_topics, data_len, data_offset, retdest SWAP1 POP // stack: data_ptr, data_len, data_offset, retdest @@ -225,9 +225,9 @@ store_log_data_loop: DUP2 %mstore_kernel(@SEGMENT_LOGS_DATA) // stack: cur_data_ptr, next_log_ptr, cur_data_addr, retdest - SWAP2 %increment SWAP2 + INCR3 // stack: cur_data_ptr, next_log_ptr, next_data_addr, retdest - %increment + INCR1 %jump(store_log_data_loop) store_log_data_loop_end: diff --git a/evm_arithmetization/src/cpu/kernel/asm/core/nonce.asm b/evm_arithmetization/src/cpu/kernel/asm/core/nonce.asm index 48486be9e..2372e4363 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/core/nonce.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/core/nonce.asm @@ -31,7 +31,7 @@ global increment_nonce: // stack: nonce, nonce_ptr, address, retdest DUP1 DUP4 %journal_add_nonce_change // stack: nonce, nonce_ptr, address, retdest - %increment + INCR1 SWAP1 // stack: nonce_ptr, nonce', address, retdest %mstore_trie_data diff --git a/evm_arithmetization/src/cpu/kernel/asm/core/precompiles/expmod.asm b/evm_arithmetization/src/cpu/kernel/asm/core/precompiles/expmod.asm index 684c80810..e138134b8 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/core/precompiles/expmod.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/core/precompiles/expmod.asm @@ -63,7 +63,7 @@ store_limbs: // stack: offset, limb[num_limbs - 1], offset, retdest, num_limbs, limb[num_limbs - 2], ..limb[0] %mstore_current_general // stack: offset, retdest, num_limbs, limb[num_limbs - 2], ..limb[0] - %increment + INCR1 SWAP2 %decrement SWAP2 diff --git a/evm_arithmetization/src/cpu/kernel/asm/core/precompiles/snarkv.asm b/evm_arithmetization/src/cpu/kernel/asm/core/precompiles/snarkv.asm index 295acd029..301dcee6d 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/core/precompiles/snarkv.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/core/precompiles/snarkv.asm @@ -103,7 +103,7 @@ loading_loop_contd6: DUP3 // stack: i, y, x, i, k, kexit_info %mul_const(6) %add_const(@SNARKV_INP) - %add_const(1) + INCR1 %mstore_bn254_pairing // stack: x, i, k, kexit_info DUP2 @@ -111,7 +111,7 @@ loading_loop_contd6: %mul_const(6) %add_const(@SNARKV_INP) %mstore_bn254_pairing // stack: i, k, kexit_info - %increment + INCR1 %jump(loading_loop) loading_done: diff --git a/evm_arithmetization/src/cpu/kernel/asm/core/selfdestruct_list.asm b/evm_arithmetization/src/cpu/kernel/asm/core/selfdestruct_list.asm index 05e158c34..8c339bc13 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/core/selfdestruct_list.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/core/selfdestruct_list.asm @@ -9,7 +9,7 @@ %stack (write_addr, len, addr) -> (addr, write_addr, len) MSTORE_GENERAL // Store new address at the end of the array. // stack: len - %increment + INCR1 %mstore_global_metadata(@GLOBAL_METADATA_SELFDESTRUCT_LIST_LEN) // Store new length. %endmacro @@ -32,7 +32,7 @@ remove_selfdestruct_list_loop: // stack: addr, loaded_addr, i, len, addr, retdest EQ %jumpi(remove_selfdestruct_list_found) // stack: i, len, addr, retdest - %increment + INCR1 %jump(remove_selfdestruct_list_loop) remove_selfdestruct_list_found: %stack (i, len, addr, retdest) -> (len, 1, i, retdest) @@ -65,11 +65,11 @@ delete_all_selfdestructed_addresses_loop: // stack: loaded_addr, i, len, retdest DUP1 %is_non_existent ISZERO %jumpi(bingo) // stack: loaded_addr, i, len, retdest - POP %increment %jump(delete_all_selfdestructed_addresses_loop) + POP INCR1 %jump(delete_all_selfdestructed_addresses_loop) bingo: // stack: loaded_addr, i, len, retdest %delete_account - %increment %jump(delete_all_selfdestructed_addresses_loop) + INCR1 %jump(delete_all_selfdestructed_addresses_loop) delete_all_selfdestructed_addresses_done: // stack: i, len, retdest %pop2 JUMP diff --git a/evm_arithmetization/src/cpu/kernel/asm/core/syscall.asm b/evm_arithmetization/src/cpu/kernel/asm/core/syscall.asm index 7677654e2..bde45e2e9 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/core/syscall.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/core/syscall.asm @@ -141,9 +141,14 @@ global syscall_jumptable: JUMPTABLE panic // mstore_32bytes_1-32 are implemented natively %endrep - // 0xe0-0xef - %rep 16 - JUMPTABLE panic // 0xe0-0xef are invalid opcodes + // 0xe0-0xe3 + %rep 4 + JUMPTABLE panic // incr1-incr4 are implemented natively + %endrep + + // 0xe4-0xef + %rep 12 + JUMPTABLE panic // 0xe4-0xef are invalid opcodes %endrep // 0xf0-0xff diff --git a/evm_arithmetization/src/cpu/kernel/asm/core/terminate.asm b/evm_arithmetization/src/cpu/kernel/asm/core/terminate.asm index 2e3482ea3..4d9f19d64 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/core/terminate.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/core/terminate.asm @@ -91,7 +91,7 @@ global sys_selfdestruct: // stack: 0, balance, address, recipient, kexit_info DUP3 %mpt_read_state_trie // stack: account_ptr, 0, balance, address, recipient, kexit_info - %add_const(1) + INCR1 // stack: balance_ptr, 0, balance, address, recipient, kexit_info %mstore_trie_data @@ -287,7 +287,7 @@ global terminate_common: // stack: addr, addr_created_contract, i, nb_created_contracts, addr EQ %jumpi(%%contract_just_created_true) // stack: i, nb_created_contracts, addr - %increment + INCR1 %jump(%%contract_just_created_loop) %%contract_just_created_true: // stack: i, nb_created_contracts, addr diff --git a/evm_arithmetization/src/cpu/kernel/asm/core/touched_addresses.asm b/evm_arithmetization/src/cpu/kernel/asm/core/touched_addresses.asm index a8e926e77..78161e2b5 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/core/touched_addresses.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/core/touched_addresses.asm @@ -28,7 +28,7 @@ insert_touched_addresses_loop: // stack: addr, loaded_addr, i, len, addr, retdest EQ %jumpi(insert_touched_addresses_found) // stack: i, len, addr, retdest - %increment + INCR1 %jump(insert_touched_addresses_loop) insert_address: @@ -37,7 +37,7 @@ insert_address: %swap_mstore // Store new address at the end of the array. // stack: len, segment, retdest SUB // unscale - %increment + INCR1 %mstore_global_metadata(@GLOBAL_METADATA_TOUCHED_ADDRESSES_LEN) // Store new length. JUMP @@ -64,7 +64,7 @@ remove_touched_addresses_loop: // stack: addr, loaded_addr, i, len, addr, retdest EQ %jumpi(remove_touched_addresses_found) // stack: i, len, addr, retdest - %increment + INCR1 %jump(remove_touched_addresses_loop) remove_touched_addresses_found: %stack (i, len, addr, retdest) -> (len, 1, i, retdest) @@ -94,11 +94,11 @@ delete_all_touched_addresses_loop: // stack: loaded_addr, i, len, retdest DUP1 %is_empty %jumpi(bingo) // stack: loaded_addr, i, len, retdest - POP %increment %jump(delete_all_touched_addresses_loop) + POP INCR1 %jump(delete_all_touched_addresses_loop) bingo: // stack: loaded_addr, i, len, retdest %delete_account - %increment %jump(delete_all_touched_addresses_loop) + INCR1 %jump(delete_all_touched_addresses_loop) delete_all_touched_addresses_done: // stack: i, len, retdest %pop2 JUMP diff --git a/evm_arithmetization/src/cpu/kernel/asm/core/transfer.asm b/evm_arithmetization/src/cpu/kernel/asm/core/transfer.asm index b21828f5e..16b3d6a88 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/core/transfer.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/core/transfer.asm @@ -32,7 +32,7 @@ global deduct_eth: %mpt_read_state_trie // stack: account_ptr, amount, retdest DUP1 ISZERO %jumpi(deduct_eth_no_such_account) // If the account pointer is null, return 1. - %add_const(1) + INCR1 // stack: balance_ptr, amount, retdest DUP1 %mload_trie_data // stack: balance, balance_ptr, amount, retdest @@ -71,7 +71,7 @@ global add_eth: DUP1 %mpt_read_state_trie // stack: account_ptr, addr, amount, retdest DUP1 ISZERO %jumpi(add_eth_new_account) // If the account pointer is null, we need to create the account. - %add_const(1) + INCR1 // stack: balance_ptr, addr, amount, retdest DUP1 %mload_trie_data // stack: balance, balance_ptr, addr, amount, retdest diff --git a/evm_arithmetization/src/cpu/kernel/asm/core/util.asm b/evm_arithmetization/src/cpu/kernel/asm/core/util.asm index 3a86d75fd..17042786d 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/core/util.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/core/util.asm @@ -70,7 +70,7 @@ DUP1 %mload_trie_data // stack: nonce, account_ptr ISZERO %not_bit %jumpi(%%false) - %increment DUP1 %mload_trie_data + INCR1 DUP1 %mload_trie_data // stack: balance, balance_ptr ISZERO %not_bit %jumpi(%%false) %add_const(2) %mload_trie_data @@ -112,7 +112,7 @@ %macro set_and_prune_ctx // stack: context - PUSH 1 ADD + INCR1 SET_CONTEXT // stack: (empty) %endmacro diff --git a/evm_arithmetization/src/cpu/kernel/asm/curve/bn254/curve_arithmetic/miller_loop.asm b/evm_arithmetization/src/cpu/kernel/asm/curve/bn254/curve_arithmetic/miller_loop.asm index 99cf24e71..70420bd8d 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/curve/bn254/curve_arithmetic/miller_loop.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/curve/bn254/curve_arithmetic/miller_loop.asm @@ -228,7 +228,7 @@ after_add: // stack: (2py)qy, addr20, addr14, -3px^2, qx_, 2py, qy_ MSTORE_GENERAL // stack: addr14, -3px^2, qx_, 2py, qy_ - %add_const(1) SWAP2 + SWAP2 INCR3 // stack: qx_, -3px^2, addr15, 2py, qy_ MULFP254 // stack: (-3px^2)*qx_, addr15, 2py, qy_ @@ -297,11 +297,11 @@ after_add: // stack: addr12 DUP1 %add_const(2) // stack: addr14, addr12 - DUP1 %add_const(1) + DUP1 INCR1 // stack: addr15, addr14, addr12 DUP1 %add_const(5) // stack: addr20, addr15, addr14, addr12 - DUP1 %add_const(1) + DUP1 INCR1 // stack: addr21, addr20, addr15, addr14, addr12 %rep 5 PUSH 0 MSTORE_GENERAL diff --git a/evm_arithmetization/src/cpu/kernel/asm/curve/bn254/curve_arithmetic/msm.asm b/evm_arithmetization/src/cpu/kernel/asm/curve/bn254/curve_arithmetic/msm.asm index af350dd8f..d7f2e2e6c 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/curve/bn254/curve_arithmetic/msm.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/curve/bn254/curve_arithmetic/msm.asm @@ -19,7 +19,7 @@ msm_loop_contd: %stack (accx, accy, i, retdest) -> (i, i, accx, accy, retdest) // TODO: the GLV scalars for the BN curve are 127-bit, so could use 127 here. But this would require modifying `wnaf.asm`. Not sure it's worth it... %eq_const(129) %jumpi(msm_end) - %increment + INCR1 // stack: i+1, accx, accy, retdest %stack (i, accx, accy, retdest) -> (accx, accy, bn_msm_loop, i, retdest) %jump(bn_double) diff --git a/evm_arithmetization/src/cpu/kernel/asm/curve/bn254/field_arithmetic/util.asm b/evm_arithmetization/src/cpu/kernel/asm/curve/bn254/field_arithmetic/util.asm index ee9dd7ffa..cb261e735 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/curve/bn254/field_arithmetic/util.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/curve/bn254/field_arithmetic/util.asm @@ -52,7 +52,7 @@ // stack: ptr %create_bn254_pairing_address DUP1 - %add_const(1) + INCR1 // stack: addr1, addr MLOAD_GENERAL // stack: x1, addr @@ -185,7 +185,7 @@ MLOAD_GENERAL // stack: x2, addr DUP2 - %add_const(1) + INCR1 // stack: addr1, x2, addr MLOAD_GENERAL // stack: x1, x2, addr @@ -221,7 +221,7 @@ MLOAD_GENERAL // stack: x2, x3, x4, addr DUP4 - %add_const(1) + INCR1 // stack: addr1, x2, x3, x4, addr MLOAD_GENERAL // stack: x1, x2, x3, x4, addr @@ -258,7 +258,7 @@ %swap_mstore // stack: x1, x2, x3, addr, x5 DUP4 - %add_const(1) + INCR1 // stack: addr1, x1, x2, x3, addr, x5 %swap_mstore // stack: x2, x3, addr, x5 @@ -302,7 +302,7 @@ MULFP254 // stack: 2*x1, x2, x3, x4, addr DUP5 - %add_const(1) + INCR1 // stack: addr1, 2*x1, x2, x3, x4, addr %swap_mstore // stack: x2, x3, x4, addr @@ -350,17 +350,17 @@ // stack: addr2, addr2, x0, x1, x2, x3, x4, x5 SWAP2 MSTORE_GENERAL // stack: addr2, x1, x2, x3, x4, x5 - %add_const(1) + INCR1 DUP1 // stack: addr3, addr3, x1, x2, x3, x4, x5 SWAP2 MSTORE_GENERAL // stack: addr3, x2, x3, x4, x5 - %add_const(1) + INCR1 DUP1 // stack: addr4, addr4, x2, x3, x4, x5 SWAP2 MSTORE_GENERAL // stack: addr4, x3, x4, x5 - %add_const(1) + INCR1 // stack: addr5, x3, x4, x5 %swap_mstore // stack: x4, x5 @@ -369,7 +369,7 @@ PUSH $ptr %create_bn254_pairing_address DUP1 - %add_const(1) + INCR1 // stack: addr1, addr, y5, y4 SWAP3 MSTORE_GENERAL @@ -996,7 +996,7 @@ MLOAD_GENERAL // stack: x02, x03, x04, x05, x06, x07, x08, x09, x10, addr DUP10 - %add_const(1) + INCR1 // stack: addr01, x02, x03, x04, x05, x06, x07, x08, x09, x10, addr MLOAD_GENERAL // stack: x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, addr @@ -1098,12 +1098,12 @@ %swap_mstore // stack: SRC, DEST DUP1 - %add_const(1) + INCR1 // stack: addr01, SRC, DEST MLOAD_GENERAL // stack: x01, SRC, DEST DUP3 - %add_const(1) + INCR1 // stack: addr01', x01, SRC, DEST %swap_mstore // stack: SRC, DEST diff --git a/evm_arithmetization/src/cpu/kernel/asm/curve/secp256k1/ecrecover.asm b/evm_arithmetization/src/cpu/kernel/asm/curve/secp256k1/ecrecover.asm index b633feaeb..196891efc 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/curve/secp256k1/ecrecover.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/curve/secp256k1/ecrecover.asm @@ -86,7 +86,7 @@ ecdsa_after_precompute_loop: SHR MOD // mod 2 %mul_const(2) ADD %mul_const(2) ADD %mul_const(2) ADD %stack (index, i, accx, accy, a0, a1, b0, b1, retdest) -> (index, index, i, accx, accy, a0, a1, b0, b1, retdest) - %mul_const(2) %add_const(1) + %mul_const(2) INCR1 %mload_current(@SEGMENT_ECDSA_TABLE) SWAP1 %mul_const(2) %mload_current(@SEGMENT_ECDSA_TABLE) diff --git a/evm_arithmetization/src/cpu/kernel/asm/curve/secp256k1/precomputation.asm b/evm_arithmetization/src/cpu/kernel/asm/curve/secp256k1/precomputation.asm index b6bed1b0a..314c85e7c 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/curve/secp256k1/precomputation.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/curve/secp256k1/precomputation.asm @@ -38,7 +38,7 @@ precompute_table_contd: // Use a loop to store a*G ± b*phi(G) + c*Q ± d*phi(Q) for a,b,c,d in {0,1}^4. precompute_table_loop: // stack: i, retdest - DUP1 %increment %mload_current(@SEGMENT_ECDSA_TABLE) + DUP1 INCR1 %mload_current(@SEGMENT_ECDSA_TABLE) %stack (y, i, retdest) -> (i, y, i, retdest) %mload_current(@SEGMENT_ECDSA_TABLE) PUSH precompute_table_loop_contd diff --git a/evm_arithmetization/src/cpu/kernel/asm/curve/wnaf.asm b/evm_arithmetization/src/cpu/kernel/asm/curve/wnaf.asm index fb9d5e251..d6485402c 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/curve/wnaf.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/curve/wnaf.asm @@ -66,7 +66,7 @@ trailing_zeros_loop: // stack: x&1, count, x, retdest %jumpi(trailing_zeros_end) // stack: count, x, retdest - %increment SWAP1 PUSH 1 SHR SWAP1 + INCR1 SWAP1 PUSH 1 SHR SWAP1 // stack: count, x>>1, retdest %jump(trailing_zeros_loop) trailing_zeros_end: diff --git a/evm_arithmetization/src/cpu/kernel/asm/hash/blake2/blake2_f.asm b/evm_arithmetization/src/cpu/kernel/asm/hash/blake2/blake2_f.asm index aa9951997..7b298ec93 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/hash/blake2/blake2_f.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/hash/blake2/blake2_f.asm @@ -9,7 +9,7 @@ global blake2_f: %stack (addr, rounds, h_i) -> (h_i, addr, addr, rounds) // stack: h_i, addr, addr, rounds, ... MSTORE_GENERAL - %increment + INCR1 %endrep // stack: addr, rounds, m0...m15, t0, t1, flag, retdest @@ -24,7 +24,7 @@ global blake2_f: %stack (message_addr, rounds, m_i) -> (m_i, message_addr, message_addr, rounds) // stack: m_i, message_addr, message_addr, rounds, ... MSTORE_GENERAL - %increment + INCR1 %endrep // stack: message_addr, rounds, t0, t1, flag, retdest @@ -58,7 +58,7 @@ global blake2_f: DUP1 SWAP2 MSTORE_GENERAL - %increment + INCR1 %endrep // stack: start + 8, rounds, t0, t1, flag, retdest @@ -69,9 +69,7 @@ global blake2_f: // stack: i, addr, ... DUP2 // stack: addr, i, addr, ... - %increment - // stack: addr + 1, i, addr, ... - SWAP2 + INCR3 // stack: addr, i, addr + 1, ... DUP2 // stack: i, addr, i, addr + 1, ... @@ -79,7 +77,7 @@ global blake2_f: // stack: IV_i, addr, i, addr + 1, ... MSTORE_GENERAL // stack: i, addr + 1, ... - %increment + INCR1 // stack: i + 1, addr + 1,... %endrep // stack: 4, start + 12, rounds, t0, t1, flag, retdest @@ -107,15 +105,15 @@ global blake2_f: // stack: val ^ IV_i, addr, i, addr, val, next_val,... MSTORE_GENERAL // stack: i, addr, val, next_val,... - %increment + INCR1 // stack: i + 1, addr, val, next_val,... SWAP2 // stack: val, addr, i + 1, next_val,... POP // stack: addr, i + 1, next_val,... - %increment - // stack: addr + 1, i + 1, next_val,... SWAP1 + // stack: i + 1, addr, next_val,... + INCR2 // stack: i + 1, addr + 1, next_val,... %endrep // stack: 8, start + 16, rounds, retdest diff --git a/evm_arithmetization/src/cpu/kernel/asm/hash/blake2/blake2b.asm b/evm_arithmetization/src/cpu/kernel/asm/hash/blake2/blake2b.asm index e3daed263..8b6cc8593 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/hash/blake2/blake2b.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/hash/blake2/blake2b.asm @@ -8,7 +8,7 @@ global blake2b: // stack: virt, num_blocks, virt, num_bytes, retdest %mstore_current_general // stack: virt, num_bytes, retdest - %add_const(1) + INCR1 %mstore_current_general // stack: retdest %jump(blake2_compression) diff --git a/evm_arithmetization/src/cpu/kernel/asm/hash/blake2/compression.asm b/evm_arithmetization/src/cpu/kernel/asm/hash/blake2/compression.asm index ba9ffc134..5f71c3c9c 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/hash/blake2/compression.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/hash/blake2/compression.asm @@ -15,7 +15,7 @@ compression_loop: SWAP1 DUP2 %mstore_current_general - %increment + INCR1 %endrep // stack: addr, cur_block, retdest @@ -44,7 +44,7 @@ compression_loop: // stack: is_last_block * num_bytes, cur_block, is_last_block, retdest DUP2 // stack: cur_block, is_last_block * num_bytes, cur_block, is_last_block, retdest - %increment + INCR1 %block_size // stack: (cur_block + 1) * 128, is_last_block * num_bytes, cur_block, is_last_block, retdest DUP4 @@ -76,7 +76,7 @@ compression_loop: // stack: cur_message_addr, m_i, cur_message_addr, cur_block_byte, ... %mstore_current_general // stack: cur_message_addr, cur_block_byte, ... - %increment + INCR1 // stack: cur_message_addr + 1, cur_block_byte, ... SWAP1 // stack: cur_block_byte, cur_message_addr + 1, ... @@ -119,7 +119,7 @@ compression_loop: SWAP1 DUP2 %mstore_current_general - %increment + INCR1 %endrep // stack: start + 8, invert_if_last_block, t, cur_block, retdest @@ -136,10 +136,8 @@ compression_loop: // stack: loc, IV_i, i, loc, ... %mstore_current_general // stack: i, loc, ... - %increment - SWAP1 - %increment - SWAP1 + INCR1 + INCR2 // stack: i + 1, loc + 1,... %endrep // stack: 4, start + 12, invert_if_last_block, t, cur_block, retdest @@ -170,13 +168,13 @@ compression_loop: // stack: loc, val ^ IV_i, i, loc, val, next_val,... %mstore_current_general // stack: i, loc, val, next_val,... - %increment + INCR1 // stack: i + 1, loc, val, next_val,... SWAP2 // stack: val, loc, i + 1, next_val,... POP // stack: loc, i + 1, next_val,... - %increment + INCR1 // stack: loc + 1, i + 1, next_val,... SWAP1 // stack: i + 1, loc + 1, next_val,... @@ -204,11 +202,11 @@ hash_generate_return: // stack: h_0', h_1', h_2', h_3', h_4', h_5', h_6', h_7', cur_block, retdest DUP9 // stack: cur_block, h_0', h_1', h_2', h_3', h_4', h_5', h_6', h_7', cur_block, retdest - %increment + INCR1 // stack: cur_block + 1, h_0', h_1', h_2', h_3', h_4', h_5', h_6', h_7', cur_block, retdest SWAP9 // stack: cur_block, h_0', h_1', h_2', h_3', h_4', h_5', h_6', h_7', cur_block + 1, retdest - %increment + INCR1 // stack: cur_block + 1, h_0', h_1', h_2', h_3', h_4', h_5', h_6', h_7', cur_block + 1, retdest PUSH 0 %mload_current_general diff --git a/evm_arithmetization/src/cpu/kernel/asm/hash/blake2/g_functions.asm b/evm_arithmetization/src/cpu/kernel/asm/hash/blake2/g_functions.asm index 33bf5cb1e..4e00b4d5f 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/hash/blake2/g_functions.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/hash/blake2/g_functions.asm @@ -150,7 +150,7 @@ global run_rounds_g_function: %call_blake2_g_function(2, 7, 8, 13, 12, 13) %call_blake2_g_function(3, 4, 9, 14, 14, 15) // stack: current_round, start, rounds, retdest - %increment + INCR1 // stack: current_round + 1, start, rounds, retdest %jump(run_rounds_g_function) run_rounds_g_function_end: diff --git a/evm_arithmetization/src/cpu/kernel/asm/hash/ripemd/update.asm b/evm_arithmetization/src/cpu/kernel/asm/hash/ripemd/update.asm index c5783cc71..a05a36d69 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/hash/ripemd/update.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/hash/ripemd/update.asm @@ -119,9 +119,9 @@ buffer_update: // stack: get, set, get , set , times , retdest %mupdate_current_general // stack: get , set , times , retdest - %increment + INCR1 + INCR2 SWAP1 - %increment SWAP1 SWAP2 %decrement diff --git a/evm_arithmetization/src/cpu/kernel/asm/hash/sha2/compression.asm b/evm_arithmetization/src/cpu/kernel/asm/hash/sha2/compression.asm index 6ff84301b..5225a8623 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/hash/sha2/compression.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/hash/sha2/compression.asm @@ -92,7 +92,7 @@ compression_loop: // stack: a[i+1], b[i+1], c[i+1], d[i+1], e[i+1], f[i+1], g[i+1], h[i+1], num_blocks, scratch_space_addr, message_schedule_addr, i, a[0]..h[0], retdest DUP12 // stack: i, a[i+1], b[i+1], c[i+1], d[i+1], e[i+1], f[i+1], g[i+1], h[i+1], num_blocks, scratch_space_addr, message_schedule_addr, i, a[0]..h[0], retdest - %increment + INCR1 // stack: i+1, a[i+1], b[i+1], c[i+1], d[i+1], e[i+1], f[i+1], g[i+1], h[i+1], num_blocks, scratch_space_addr, message_schedule_addr, i, a[0]..h[0], retdest DUP1 // stack: i+1, i+1, a[i+1], b[i+1], c[i+1], d[i+1], e[i+1], f[i+1], g[i+1], h[i+1], num_blocks, scratch_space_addr, message_schedule_addr, i, a[0]..h[0], retdest diff --git a/evm_arithmetization/src/cpu/kernel/asm/hash/sha2/main.asm b/evm_arithmetization/src/cpu/kernel/asm/hash/sha2/main.asm index 53967f8a1..9aeb185a3 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/hash/sha2/main.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/hash/sha2/main.asm @@ -23,7 +23,7 @@ global sha2_pad: // stack: 128, num_bytes, retdest DUP2 // stack: num_bytes, 128, num_bytes, retdest - %increment + INCR1 // stack: num_bytes+1, 128, num_bytes, retdest %mstore_current_general // stack: num_bytes, retdest @@ -33,7 +33,7 @@ global sha2_pad: %add_const(8) %shr_const(6) - %increment + INCR1 // stack: num_blocks = (num_bytes+8)//64 + 1, num_bytes, retdest // STEP 3: calculate length := num_bytes*8 SWAP1 diff --git a/evm_arithmetization/src/cpu/kernel/asm/hash/sha2/message_schedule.asm b/evm_arithmetization/src/cpu/kernel/asm/hash/sha2/message_schedule.asm index 3bcd7dbfc..ecbe0ab11 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/hash/sha2/message_schedule.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/hash/sha2/message_schedule.asm @@ -174,8 +174,8 @@ global sha2_gen_all_message_schedules: // stack: base_addr, base_addr, output_addr, output_addr, retdest MLOAD_GENERAL // stack: num_blocks, base_addr, output_addr, output_addr, retdest + INCR2 SWAP1 - %increment // stack: cur_addr (offset = 1), counter = num_blocks, output_addr, output_addr, retdest gen_all_message_schedules_loop: // stack: cur_addr, counter, cur_output_addr, output_addr, retdest diff --git a/evm_arithmetization/src/cpu/kernel/asm/journal/account_destroyed.asm b/evm_arithmetization/src/cpu/kernel/asm/journal/account_destroyed.asm index d62f3d422..ddbbf23c1 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/journal/account_destroyed.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/journal/account_destroyed.asm @@ -20,7 +20,7 @@ revert_account_destroyed_contd: // stack: target_payload_ptr, address, prev_balance, retdest DUP1 %assert_nonzero - %add_const(1) + INCR1 // stack: target_balance_ptr, address, prev_balance, retdest DUP3 DUP2 %mload_trie_data @@ -32,7 +32,7 @@ revert_account_destroyed_contd: // stack: account_payload_ptr, prev_balance, retdest DUP1 %assert_nonzero - %increment + INCR1 // stack: account_balance_payload_ptr, prev_balance, retdest %mstore_trie_data JUMP diff --git a/evm_arithmetization/src/cpu/kernel/asm/journal/journal.asm b/evm_arithmetization/src/cpu/kernel/asm/journal/journal.asm index 96fa8aae8..057f94e7c 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/journal/journal.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/journal/journal.asm @@ -22,7 +22,7 @@ // stack: journal_size, pointer, journal_size %mstore_journal // stack: journal_size - %increment + INCR1 %mstore_global_metadata(@GLOBAL_METADATA_JOURNAL_LEN) // stack: (empty) %endmacro @@ -51,7 +51,7 @@ // stack: size, value, size %mstore_journal_data // stack: size - %increment + INCR1 %mstore_global_metadata(@GLOBAL_METADATA_JOURNAL_DATA_LEN) %endmacro @@ -119,7 +119,7 @@ %macro journal_load_1 // ptr - %add_const(1) + INCR1 %mload_journal_data // w %endmacro @@ -130,8 +130,8 @@ %add_const(2) %mload_journal_data // x, ptr + INCR2 SWAP1 - %add_const(1) %mload_journal_data // w, x %endmacro @@ -148,8 +148,8 @@ %add_const(2) %mload_journal_data // x, ptr, y + INCR2 SWAP1 - %add_const(1) %mload_journal_data // w, x, y %endmacro @@ -172,8 +172,8 @@ %add_const(2) %mload_journal_data // x, ptr, y, z + INCR2 SWAP1 - %add_const(1) %mload_journal_data // w, x, y, z %endmacro @@ -197,10 +197,10 @@ // stack: i, current_checkpoint DUP2 DUP2 %mstore_current(@SEGMENT_CONTEXT_CHECKPOINTS) // stack: i, current_checkpoint - %increment + INCR1 %mstore_context_metadata(@CTX_METADATA_CHECKPOINTS_LEN) // stack: current_checkpoint - %increment + INCR1 %mstore_global_metadata(@GLOBAL_METADATA_CURRENT_CHECKPOINT) // stack: (empty) %endmacro diff --git a/evm_arithmetization/src/cpu/kernel/asm/main.asm b/evm_arithmetization/src/cpu/kernel/asm/main.asm index cb170ef24..2e8e7e5da 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/main.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/main.asm @@ -48,7 +48,7 @@ global init: // Construct `kexit_info`. DUP1 MLOAD_GENERAL // stack: program_counter, addr_registers - DUP2 %increment + DUP2 INCR1 MLOAD_GENERAL // stack: is_kernel, program_counter, addr_registers %shl_const(32) ADD @@ -102,7 +102,7 @@ global hash_initial_tries: // stack: actual_nb_accounts // The initial payloads are written twice, and each payload requires 4 elements. PUSH 8 MUL - %increment + INCR1 // stack: init_trie_data_len PUSH @INITIAL_RLP_ADDR // stack: rlp_start, init_trie_data_len @@ -170,7 +170,7 @@ global txn_loop_after: %process_receipt // stack: new_cum_gas, txn_counter, num_nibbles, txn_nb - SWAP3 %increment SWAP3 + INCR4 // Re-initialize memory values before processing the next txn. %reinitialize_memory_pre_txn diff --git a/evm_arithmetization/src/cpu/kernel/asm/memory/core.asm b/evm_arithmetization/src/cpu/kernel/asm/memory/core.asm index 9e18bc3e3..90ef4eab1 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/memory/core.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/memory/core.asm @@ -12,7 +12,7 @@ MLOAD_GENERAL // stack: c0, addr DUP2 - %increment + INCR1 MLOAD_GENERAL %shl_const(8) ADD diff --git a/evm_arithmetization/src/cpu/kernel/asm/memory/memcpy.asm b/evm_arithmetization/src/cpu/kernel/asm/memory/memcpy.asm index 09f686965..b61262ce4 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/memory/memcpy.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/memory/memcpy.asm @@ -18,11 +18,9 @@ global memcpy: // stack: DST, SRC, count, retdest // Increment dst_addr. - %increment + INCR1 // Increment src_addr. - SWAP1 - %increment - SWAP1 + INCR2 // Decrement count. PUSH 1 DUP4 SUB SWAP3 POP diff --git a/evm_arithmetization/src/cpu/kernel/asm/memory/metadata.asm b/evm_arithmetization/src/cpu/kernel/asm/memory/metadata.asm index 5ac85f1b3..89ddaccc5 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/memory/metadata.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/memory/metadata.asm @@ -340,7 +340,7 @@ global blockhash: // Check for an overflow, since we're incrementing `block_number` afterwards. DUP2 %eq_const(@U256_MAX) %jumpi(zero_hash) // stack: cur_block_number, block_number, retdest - DUP1 DUP3 %increment GT %jumpi(zero_hash) // if block_number >= cur_block_number + DUP1 DUP3 INCR1 GT %jumpi(zero_hash) // if block_number >= cur_block_number // stack: cur_block_number, block_number, retdest DUP2 PUSH 256 ADD // stack: block_number+256, cur_block_number, block_number, retdest @@ -475,7 +475,7 @@ zero_hash: %macro increment_call_depth %mload_global_metadata(@GLOBAL_METADATA_CALL_STACK_DEPTH) - %increment + INCR1 %mstore_global_metadata(@GLOBAL_METADATA_CALL_STACK_DEPTH) %endmacro diff --git a/evm_arithmetization/src/cpu/kernel/asm/memory/packing.asm b/evm_arithmetization/src/cpu/kernel/asm/memory/packing.asm index a1bf5a09a..f3d0e5ce8 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/memory/packing.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/memory/packing.asm @@ -4,7 +4,7 @@ global mload_packing_u64_LE: // stack: addr, retdest DUP1 MLOAD_GENERAL - DUP2 %add_const(1) MLOAD_GENERAL %shl_const( 8) ADD + DUP2 INCR1 MLOAD_GENERAL %shl_const( 8) ADD DUP2 %add_const(2) MLOAD_GENERAL %shl_const(16) ADD DUP2 %add_const(3) MLOAD_GENERAL %shl_const(24) ADD DUP2 %add_const(4) MLOAD_GENERAL %shl_const(32) ADD @@ -284,7 +284,7 @@ global mstore_unpacking_u64_LE: %stack (addr, value) -> (0xff, value, addr, addr, value) AND MSTORE_GENERAL // First byte - DUP1 %add_const(1) + DUP1 INCR1 %stack (new_addr, addr, value) -> (0xff00, value, new_addr, addr, value) AND %shr_const(8) MSTORE_GENERAL // Second byte diff --git a/evm_arithmetization/src/cpu/kernel/asm/memory/syscalls.asm b/evm_arithmetization/src/cpu/kernel/asm/memory/syscalls.asm index d2148de91..41b40c37f 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/memory/syscalls.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/memory/syscalls.asm @@ -43,7 +43,7 @@ global sys_mstore8: // stack: kexit_info, offset, value %charge_gas_const(@GAS_VERYLOW) // stack: kexit_info, offset, value - DUP2 %increment + DUP2 INCR1 // stack: expanded_num_bytes, kexit_info, offset, value %update_mem_bytes // stack: kexit_info, offset, value diff --git a/evm_arithmetization/src/cpu/kernel/asm/memory/transient_storage.asm b/evm_arithmetization/src/cpu/kernel/asm/memory/transient_storage.asm index 8aa32c3e2..54d79c244 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/memory/transient_storage.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/memory/transient_storage.asm @@ -47,7 +47,7 @@ search_transient_storage_loop: // Addresses match, but we need to check for keys as well DUP1 - %increment + INCR1 MLOAD_GENERAL // stack: loaded_key, i, len, addr, key, retdest DUP5 @@ -56,7 +56,7 @@ search_transient_storage_loop: %jumpi(search_transient_storage_found) increment_and_loop: // stack: i, len, addr, key, retdest - %increment + INCR1 %jump(search_transient_storage_loop) search_transient_storage_not_found: @@ -123,11 +123,11 @@ global sys_tstore: DUP1 DUP3 // stack: addr, pos, pos, addr, original_value, slot, value, kexit_info MSTORE_GENERAL - %increment DUP1 + INCR1 DUP1 DUP5 // stack: slot, pos', pos', addr, original_value, slot, value, kexit_info MSTORE_GENERAL - %increment DUP1 + INCR1 DUP1 DUP6 // stack: value, pos'', pos'', addr, original_value, slot, value, kexit_info MSTORE_GENERAL @@ -156,7 +156,7 @@ add_to_journal: new_transient_storage_len: // Store the new (unscaled) length. // stack: pos, addr, original_value, slot, value, kexit_info - %increment + INCR1 // stack: pos + 1, addr, original_value, slot, value, kexit_info %mstore_global_metadata(@GLOBAL_METADATA_TRANSIENT_STORAGE_LEN) // stack: addr, original_value, slot, value, kexit_info diff --git a/evm_arithmetization/src/cpu/kernel/asm/mpt/accounts.asm b/evm_arithmetization/src/cpu/kernel/asm/mpt/accounts.asm index e1fa20c08..19d5eb45f 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/mpt/accounts.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/mpt/accounts.asm @@ -7,19 +7,19 @@ // Balance %mload_trie_data %append_to_trie_data - %increment + INCR1 // Nonce - %increment + INCR1 DUP1 %mload_trie_data %append_to_trie_data // Storage trie root - %increment + INCR1 DUP1 %mload_trie_data %append_to_trie_data // Codehash - %increment + INCR1 %mload_trie_data %append_to_trie_data // stack: cloned_account_ptr diff --git a/evm_arithmetization/src/cpu/kernel/asm/mpt/delete/delete.asm b/evm_arithmetization/src/cpu/kernel/asm/mpt/delete/delete.asm index c878ae812..b58ef3893 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/mpt/delete/delete.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/mpt/delete/delete.asm @@ -8,7 +8,7 @@ global mpt_delete: DUP1 %mload_trie_data // stack: node_type, node_ptr, num_nibbles, key, retdest // Increment node_ptr, so it points to the node payload instead of its type. - SWAP1 %increment SWAP1 + INCR2 // stack: node_type, node_payload_ptr, num_nibbles, key, retdest DUP1 %eq_const(@MPT_NODE_BRANCH) %jumpi(mpt_delete_branch) diff --git a/evm_arithmetization/src/cpu/kernel/asm/mpt/delete/delete_branch.asm b/evm_arithmetization/src/cpu/kernel/asm/mpt/delete/delete_branch.asm index f67861d6f..e77e59b90 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/mpt/delete/delete_branch.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/mpt/delete/delete_branch.asm @@ -57,17 +57,17 @@ loop: DUP1 %eq_const(16) %jumpi(loop_end) DUP1 DUP5 ADD %mload_trie_data %mload_trie_data ISZERO ISZERO %jumpi(loop_non_empty) // stack: i, updated_child_ptr, first_nibble, node_payload_ptr, retdest - %increment %jump(loop) + INCR1 %jump(loop) loop_eq_first_nibble: // stack: i, updated_child_ptr, first_nibble, node_payload_ptr, retdest - %increment %jump(loop) + INCR1 %jump(loop) loop_non_empty: // stack: i, updated_child_ptr, first_nibble, node_payload_ptr, retdest - %mload_kernel_no_offset(@SEGMENT_KERNEL_GENERAL) %increment %mstore_kernel_no_offset(@SEGMENT_KERNEL_GENERAL) + %mload_kernel_no_offset(@SEGMENT_KERNEL_GENERAL) INCR1 %mstore_kernel_no_offset(@SEGMENT_KERNEL_GENERAL) PUSH 1 PUSH @SEGMENT_KERNEL_GENERAL %build_kernel_address DUP2 MSTORE_GENERAL - %increment %jump(loop) + INCR1 %jump(loop) loop_end: // stack: i, updated_child_ptr, first_nibble, node_payload_ptr, retdest POP @@ -109,7 +109,7 @@ maybe_normalize_branch_branchhash: // For that, return the modified child as the new node. maybe_normalize_branch_leafext: // stack: only_child_ptr, updated_child_ptr, first_nibble, node_payload_ptr, retdest - DUP1 %increment %mload_trie_data + DUP1 INCR1 %mload_trie_data // stack: child_len, only_child_ptr, updated_child_ptr, first_nibble, node_payload_ptr, retdest DUP2 %add_const(2) %mload_trie_data // stack: child_key, child_len, only_child_ptr, updated_child_ptr, first_nibble, node_payload_ptr, retdest @@ -122,7 +122,7 @@ maybe_normalize_branch_leafext: // stack: node_ptr, len, key, only_child_ptr, retdest SWAP1 DUP2 // stack: node_ptr, len, node_ptr, key, only_child_ptr, retdest - %increment %mstore_trie_data // Change len in the child node + INCR1 %mstore_trie_data // Change len in the child node // stack: node_ptr, key, only_child_ptr, retdest %add_const(2) %mstore_trie_data // Change key in the child node // stack: node_ptr, retdest diff --git a/evm_arithmetization/src/cpu/kernel/asm/mpt/delete/delete_extension.asm b/evm_arithmetization/src/cpu/kernel/asm/mpt/delete/delete_extension.asm index 0627fcba6..17189f2eb 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/mpt/delete/delete_extension.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/mpt/delete/delete_extension.asm @@ -11,7 +11,7 @@ global mpt_delete_extension: // stack: node_payload_ptr, num_nibbles, key, retdest DUP1 %mload_trie_data // stack: node_len, node_payload_ptr, num_nibbles, key, retdest - DUP2 %increment %mload_trie_data + DUP2 INCR1 %mload_trie_data %stack (node_key, node_len, node_payload_ptr, num_nibbles, key, retdest) -> (node_len, num_nibbles, key, node_payload_ptr, node_len, node_key, retdest) %truncate_nibbles @@ -47,14 +47,14 @@ after_mpt_delete_extension_extension: // stack: child_type, updated_child_node_ptr, node_payload_ptr, node_len, node_key, retdest POP SWAP1 POP // stack: updated_child_node_ptr, node_len, node_key, retdest - DUP1 %increment %mload_trie_data + DUP1 INCR1 %mload_trie_data // stack: child_len, updated_child_node_ptr, node_len, node_key, retdest DUP2 %add_const(2) %mload_trie_data // stack: child_key, child_len, updated_child_node_ptr, node_len, node_key, retdest %stack (child_key, child_len, updated_child_node_ptr, node_len, node_key) -> (node_len, node_key, child_len, child_key, updated_child_node_ptr) %merge_nibbles // stack: len, key, updated_child_node_ptr, retdest - DUP3 %increment %mstore_trie_data // Change len + DUP3 INCR1 %mstore_trie_data // Change len // stack: key, updated_child_node_ptr, retdest DUP2 %add_const(2) %mstore_trie_data // Change key // stack: extension_ptr, retdest @@ -65,14 +65,14 @@ after_mpt_delete_extension_leaf: // stack: child_type, updated_child_node_ptr, node_payload_ptr, node_len, node_key, retdest POP SWAP1 POP // stack: updated_child_node_ptr, node_len, node_key, retdest - DUP1 %increment %mload_trie_data + DUP1 INCR1 %mload_trie_data // stack: child_len, updated_child_node_ptr, node_len, node_key, retdest DUP2 %add_const(2) %mload_trie_data // stack: child_key, child_len, updated_child_node_ptr, node_len, node_key, retdest %stack (child_key, child_len, updated_child_node_ptr, node_len, node_key) -> (node_len, node_key, child_len, child_key, updated_child_node_ptr) %merge_nibbles // stack: len, key, updated_child_node_ptr, retdest - DUP3 %increment %mstore_trie_data // Change len + DUP3 INCR1 %mstore_trie_data // Change len // stack: key, updated_child_node_ptr, retdest DUP2 %add_const(2) %mstore_trie_data // Change key // stack: updated_child_node_ptr, retdest diff --git a/evm_arithmetization/src/cpu/kernel/asm/mpt/hash/hash.asm b/evm_arithmetization/src/cpu/kernel/asm/mpt/hash/hash.asm index 37f9fc670..d06dbce76 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/mpt/hash/hash.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/mpt/hash/hash.asm @@ -62,17 +62,16 @@ global encode_or_hash_node: // If we got here, node_type == @MPT_NODE_HASH. // Load the hash and return (hash, 32). // stack: node_type, node_ptr, rlp_start, encode_value, cur_len, retdest + INCR2 // Skip over node type prefix POP - - // stack: node_ptr, rlp_start, encode_value, cur_len, retdest - %increment // Skip over node type prefix // stack: hash_ptr, rlp_start, encode_value, cur_len, retdest %mload_trie_data // stack: hash, rlp_start, encode_value, cur_len, retdest // Update the length of the `TrieData` segment: there are only two // elements in a hash node. - SWAP3 %add_const(2) - %stack (cur_len, rlp_start, encode_value, hash, retdest) -> (retdest, hash, 32, cur_len) + INCR4 + INCR4 + %stack (hash, rlp_start, encode_value, cur_len, retdest) -> (retdest, hash, 32, cur_len) JUMP encode_or_hash_concrete_node: %stack (node_type, node_ptr, rlp_start, encode_value, cur_len) -> (node_type, node_ptr, rlp_start, encode_value, cur_len, maybe_hash_node) @@ -104,7 +103,7 @@ after_packed_small_rlp: encode_node: // stack: node_type, node_ptr, rlp_start, encode_value, cur_len, retdest // Increment node_ptr, so it points to the node payload instead of its type. - SWAP1 %increment SWAP1 + INCR2 // stack: node_type, node_payload_ptr, rlp_start, encode_value, cur_len, retdest DUP1 %eq_const(@MPT_NODE_EMPTY) %jumpi(encode_node_empty) @@ -158,7 +157,7 @@ global encode_node_branch: %stack (value_ptr, rlp_pos, rlp_start, encode_value) -> (0x80, rlp_pos, rlp_pos, rlp_start) MSTORE_GENERAL // stack: rlp_pos', rlp_start, cur_len, retdest - %increment + INCR1 // stack: rlp_pos'', rlp_start, cur_len, retdest %jump(encode_node_branch_prepend_prefix) encode_node_branch_with_value: @@ -198,7 +197,7 @@ encode_node_branch_prepend_prefix: DUP4 // rlp_pos PUSH 160 MSTORE_GENERAL - SWAP3 %increment SWAP3 // rlp_pos += 1 + INCR4 // rlp_pos += 1 %%unpack: %stack (result_len, result, cur_len, rlp_pos, rlp_start, node_payload_ptr, encode_value, old_len, retdest) -> (rlp_pos, result, result_len, %%after_unpacking, @@ -225,7 +224,7 @@ encode_node_extension_after_encode_child: PUSH encode_node_extension_after_hex_prefix // retdest PUSH 0 // terminated // stack: terminated, encode_node_extension_after_hex_prefix, rlp_start, result, result_len, node_payload_ptr, cur_len, retdest - DUP6 %increment %mload_trie_data // Load the packed_nibbles field, which is at index 1. + DUP6 INCR1 %mload_trie_data // Load the packed_nibbles field, which is at index 1. // stack: packed_nibbles, terminated, encode_node_extension_after_hex_prefix, rlp_start, result, result_len, node_payload_ptr, cur_len, retdest DUP7 %mload_trie_data // Load the num_nibbles field, which is at index 0. // stack: num_nibbles, packed_nibbles, terminated, encode_node_extension_after_hex_prefix, rlp_start, result, result_len, node_payload_ptr, cur_len, retdest @@ -241,7 +240,7 @@ encode_node_extension_after_hex_prefix: DUP1 // rlp_pos PUSH 160 MSTORE_GENERAL - %increment // rlp_pos += 1 + INCR1 // rlp_pos += 1 encode_node_extension_unpack: %stack (rlp_pos, rlp_start, result, result_len, node_payload_ptr, cur_len) -> (rlp_pos, result, result_len, encode_node_extension_after_unpacking, rlp_start, cur_len) @@ -264,7 +263,7 @@ global encode_node_leaf: PUSH encode_node_leaf_after_hex_prefix // retdest PUSH 1 // terminated // stack: terminated, encode_node_leaf_after_hex_prefix, rlp_start, node_payload_ptr, encode_value, cur_len, retdest - DUP4 %increment %mload_trie_data // Load the packed_nibbles field, which is at index 1. + DUP4 INCR1 %mload_trie_data // Load the packed_nibbles field, which is at index 1. // stack: packed_nibbles, terminated, encode_node_leaf_after_hex_prefix, rlp_start, node_payload_ptr, encode_value, cur_len, retdest DUP5 %mload_trie_data // Load the num_nibbles field, which is at index 0. // stack: num_nibbles, packed_nibbles, terminated, encode_node_leaf_after_hex_prefix, rlp_start, node_payload_ptr, encode_value, cur_len, retdest diff --git a/evm_arithmetization/src/cpu/kernel/asm/mpt/hash/hash_trie_specific.asm b/evm_arithmetization/src/cpu/kernel/asm/mpt/hash/hash_trie_specific.asm index 31fa192fa..9b351e443 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/mpt/hash/hash_trie_specific.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/mpt/hash/hash_trie_specific.asm @@ -80,7 +80,7 @@ global encode_account: DUP2 %mload_trie_data // nonce = value[0] %rlp_scalar_len // stack: nonce_rlp_len, rlp_addr, value_ptr, cur_len, retdest - DUP3 %increment %mload_trie_data // balance = value[1] + DUP3 INCR1 %mload_trie_data // balance = value[1] %rlp_scalar_len // stack: balance_rlp_len, nonce_rlp_len, rlp_addr, value_ptr, cur_len, retdest PUSH 66 // storage_root and code_hash fields each take 1 + 32 bytes @@ -100,7 +100,7 @@ global encode_account: // stack: nonce, rlp_pos_3, value_ptr, cur_len, retdest SWAP1 %encode_rlp_scalar // stack: rlp_pos_4, value_ptr, cur_len, retdest - DUP2 %increment %mload_trie_data // balance = value[1] + DUP2 INCR1 %mload_trie_data // balance = value[1] // stack: balance, rlp_pos_4, value_ptr, cur_len, retdest SWAP1 %encode_rlp_scalar // stack: rlp_pos_5, value_ptr, cur_len, retdest @@ -130,10 +130,10 @@ global encode_txn: DUP2 %mload_trie_data // stack: txn_rlp_len, rlp_addr, value_ptr, cur_len, retdest // We need to add 1+txn_rlp_len to the length of the trie data. - SWAP3 DUP4 %increment ADD + INCR4 SWAP3 DUP4 ADD // stack: new_len, rlp_addr, value_ptr, txn_rlp_len, retdest SWAP3 - SWAP2 %increment + INCR3 SWAP2 // stack: txn_rlp_ptr=value_ptr+1, rlp_addr, txn_rlp_len, new_len, retdest %stack (txn_rlp_ptr, rlp_addr, txn_rlp_len) -> (rlp_addr, txn_rlp_len, txn_rlp_len, txn_rlp_ptr) @@ -190,7 +190,7 @@ encode_receipt_after_type: SWAP1 %encode_rlp_list_prefix // stack: rlp_addr, payload_len_ptr, cur_len, retdest // Encode status. - DUP2 %increment %mload_trie_data + DUP2 INCR1 %mload_trie_data // stack: status, rlp_addr, payload_len_ptr, cur_len, retdest SWAP1 %encode_rlp_scalar // stack: rlp_addr, payload_len_ptr, cur_len, retdest @@ -235,7 +235,7 @@ encode_receipt_logs_loop: SWAP1 %encode_rlp_list_prefix // stack: rlp_addr, current_log_ptr, i, num_logs, current_log_ptr, old_rlp_pos, payload_len_ptr, cur_len, retdest // Encode address. - DUP2 %increment %mload_trie_data + DUP2 INCR1 %mload_trie_data // stack: address, rlp_addr, current_log_ptr, i, num_logs, current_log_ptr, old_rlp_pos, payload_len_ptr, cur_len, retdest SWAP1 %encode_rlp_160 // stack: rlp_addr, current_log_ptr, i, num_logs, current_log_ptr, old_rlp_pos, payload_len_ptr, cur_len, retdest @@ -272,9 +272,10 @@ encode_receipt_topics_loop: // stack: rlp_addr, current_topic, j, topics_ptr, rlp_addr, num_topics, i, num_logs, current_log_ptr, old_rlp_pos, payload_len_ptr, cur_len', retdest %encode_rlp_256 // stack: new_rlp_pos, j, topics_ptr, rlp_addr, num_topics, i, num_logs, current_log_ptr, old_rlp_pos, payload_len_ptr, cur_len', retdest + INCR2 + // stack: new_rlp_pos, j', topics_ptr, rlp_addr, num_topics, i, num_logs, current_log_ptr, old_rlp_pos, payload_len_ptr, cur_len', retdest SWAP3 POP - // stack: j, topics_ptr, new_rlp_pos, num_topics, i, num_logs, current_log_ptr, old_rlp_pos, payload_len_ptr, cur_len', retdest - %increment + // stack: j', topics_ptr, new_rlp_pos, num_topics, i, num_logs, current_log_ptr, old_rlp_pos, payload_len_ptr, cur_len', retdest %jump(encode_receipt_topics_loop) encode_receipt_topics_end: @@ -295,9 +296,9 @@ encode_receipt_topics_end: DUP1 SWAP7 ADD SWAP6 // stack: data_len, i, num_logs, data_len_ptr, rlp_addr, payload_len_ptr, cur_len'', retdest - DUP4 %increment DUP2 ADD + DUP4 INCR1 DUP2 ADD // stack: next_log_ptr, data_len, i, num_logs, data_len_ptr, rlp_addr, payload_len_ptr, cur_len'', retdest - SWAP4 %increment + SWAP4 INCR1 // stack: data_ptr, data_len, i, num_logs, next_log_ptr, rlp_addr, payload_len_ptr, cur_len'', retdest PUSH @SEGMENT_TRIE_DATA %build_kernel_address // stack: SRC, data_len, i, num_logs, next_log_ptr, rlp_addr, payload_len_ptr, cur_len'', retdest @@ -305,9 +306,10 @@ encode_receipt_topics_end: // stack: rlp_addr, SRC, data_len, i, num_logs, next_log_ptr, rlp_addr, payload_len_ptr, cur_len'', retdest %encode_rlp_string // stack: new_rlp_pos, i, num_logs, next_log_ptr, rlp_addr, payload_len_ptr, cur_len'', retdest + INCR2 + // stack: new_rlp_pos, i', num_logs, next_log_ptr, rlp_addr, payload_len_ptr, cur_len'', retdest SWAP4 POP - // stack: i, num_logs, next_log_ptr, new_rlp_pos, payload_len_ptr, cur_len'', retdest - %increment + // stack: i', num_logs, next_log_ptr, new_rlp_pos, payload_len_ptr, cur_len'', retdest %jump(encode_receipt_logs_loop) encode_receipt_end: @@ -322,22 +324,22 @@ encode_receipt_end: encode_nonzero_receipt_type: // stack: txn_type, rlp_addr, value_ptr, cur_len, retdest // We have a nonlegacy receipt, so the type is also stored in the trie data segment. - SWAP3 %increment SWAP3 + INCR4 // stack: txn_type, rlp_addr, value_ptr, cur_len, retdest - DUP3 %increment %mload_trie_data + DUP3 INCR1 %mload_trie_data // stack: payload_len, txn_type, rlp_addr, value_ptr, retdest // The transaction type is encoded in 1 byte - %increment %rlp_list_len + INCR1 %rlp_list_len // stack: rlp_receipt_len, txn_type, rlp_addr, value_ptr, retdest DUP3 %encode_rlp_multi_byte_string_prefix // stack: rlp_addr, txn_type, old_rlp_addr, value_ptr, retdest DUP1 DUP3 MSTORE_GENERAL - %increment + INCR1 // stack: rlp_addr, txn_type, old_rlp_addr, value_ptr, retdest %stack (rlp_addr, txn_type, old_rlp_addr, value_ptr, retdest) -> (rlp_addr, value_ptr, retdest) // We replace `value_ptr` with `paylaod_len_ptr` so we can encode the rest of the data more easily - SWAP1 %increment SWAP1 + INCR2 // stack: rlp_addr, payload_len_ptr, retdest %jump(encode_receipt_after_type) @@ -346,7 +348,7 @@ global encode_storage_value: SWAP1 %mload_trie_data SWAP1 // A storage value is a scalar, so we only need to add 1 to the trie data length. - SWAP2 %increment SWAP2 + INCR3 // stack: rlp_addr, value, cur_len, retdest // The YP says storage trie is a map "... to the RLP-encoded 256-bit integer values" diff --git a/evm_arithmetization/src/cpu/kernel/asm/mpt/hex_prefix.asm b/evm_arithmetization/src/cpu/kernel/asm/mpt/hex_prefix.asm index 3e8a783ab..9e9034304 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/mpt/hex_prefix.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/mpt/hex_prefix.asm @@ -11,7 +11,7 @@ global hex_prefix_rlp: PUSH 2 DUP3 DIV // Compute the length of the hex-prefix string, in bytes: // hp_len = num_nibbles / 2 + 1 = i + 1 - %increment + INCR1 // stack: hp_len, rlp_addr, num_nibbles, packed_nibbles, terminated, retdest // Write the RLP header. @@ -51,7 +51,7 @@ first_byte: // stack: first_byte, rlp_addr, retdest DUP2 %swap_mstore - %increment + INCR1 // stack: rlp_addr', retdest SWAP1 JUMP @@ -91,7 +91,7 @@ rlp_header_medium: %swap_mstore // stack: rlp_addr, num_nibbles, packed_nibbles, terminated, retdest // rlp_addr += 1 - %increment + INCR1 // stack: rlp_addr, num_nibbles, packed_nibbles, terminated, retdest SWAP3 DUP3 DUP3 @@ -113,7 +113,7 @@ rlp_header_large: MSTORE_GENERAL // stack: hp_len, rlp_addr, num_nibbles, packed_nibbles, terminated, retdest - DUP2 %increment + DUP2 INCR1 %swap_mstore // stack: rlp_addr, num_nibbles, packed_nibbles, terminated, retdest diff --git a/evm_arithmetization/src/cpu/kernel/asm/mpt/insert/insert.asm b/evm_arithmetization/src/cpu/kernel/asm/mpt/insert/insert.asm index 83a12b4b0..2553b3352 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/mpt/insert/insert.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/mpt/insert/insert.asm @@ -7,7 +7,7 @@ global mpt_insert: DUP1 %mload_trie_data // stack: node_type, node_ptr, num_nibbles, key, value_ptr, retdest // Increment node_ptr, so it points to the node payload instead of its type. - SWAP1 %increment SWAP1 + INCR2 // stack: node_type, node_payload_ptr, num_nibbles, key, value_ptr, retdest DUP1 %eq_const(@MPT_NODE_EMPTY) %jumpi(mpt_insert_empty) diff --git a/evm_arithmetization/src/cpu/kernel/asm/mpt/insert/insert_extension.asm b/evm_arithmetization/src/cpu/kernel/asm/mpt/insert/insert_extension.asm index 21a4b7558..8de672984 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/mpt/insert/insert_extension.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/mpt/insert/insert_extension.asm @@ -45,7 +45,7 @@ global mpt_insert_extension: %stack (node_child_ptr, node_payload_ptr, insert_len, insert_key) -> (node_payload_ptr, insert_len, insert_key, node_child_ptr) // stack: node_payload_ptr, insert_len, insert_key, node_child_ptr, insert_value_ptr, retdest - DUP1 %increment %mload_trie_data + DUP1 INCR1 %mload_trie_data // stack: node_key, node_payload_ptr, insert_len, insert_key, node_child_ptr, insert_value_ptr, retdest SWAP1 %mload_trie_data // stack: node_len, node_key, insert_len, insert_key, node_child_ptr, insert_value_ptr, retdest @@ -103,7 +103,7 @@ process_node_child: // stack: new_node_ptr, common_len, common_key, node_len, node_key, insert_len, insert_key, node_child_ptr, insert_value_ptr, retdest DUP8 // node_child_ptr DUP2 // new_node_ptr - %increment + INCR1 DUP7 // node_key ADD %mstore_trie_data @@ -135,7 +135,7 @@ node_key_continues_multiple_nibbles: // stack: node_key_first, ext_node_ptr, new_node_ptr, ... DUP3 // new_node_ptr ADD - %increment + INCR1 // stack: new_node_ptr + node_key_first + 1, ext_node_ptr, new_node_ptr, ... %mstore_trie_data %jump(process_inserted_entry) @@ -178,7 +178,7 @@ insert_key_continues: // stack: insert_key_first, leaf_node_ptr, new_node_ptr, ... DUP3 // new_node_ptr ADD - %increment + INCR1 // stack: new_node_ptr + insert_key_first + 1, leaf_node_ptr, new_node_ptr, ... %mstore_trie_data %jump(maybe_add_extension_for_common_key) diff --git a/evm_arithmetization/src/cpu/kernel/asm/mpt/insert/insert_leaf.asm b/evm_arithmetization/src/cpu/kernel/asm/mpt/insert/insert_leaf.asm index 806fc0ddb..bcd77f27f 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/mpt/insert/insert_leaf.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/mpt/insert/insert_leaf.asm @@ -37,7 +37,7 @@ global mpt_insert_leaf: // stack: node_payload_ptr, insert_len, insert_key, insert_value_ptr, retdest %stack (node_payload_ptr, insert_len, insert_key) -> (insert_len, insert_key, node_payload_ptr) // stack: insert_len, insert_key, node_payload_ptr, insert_value_ptr, retdest - DUP3 %increment %mload_trie_data + DUP3 INCR1 %mload_trie_data // stack: node_key, insert_len, insert_key, node_payload_ptr, insert_value_ptr, retdest DUP4 %mload_trie_data // stack: node_len, node_key, insert_len, insert_key, node_payload_ptr, insert_value_ptr, retdest @@ -154,7 +154,7 @@ node_key_continues: // stack: leaf_ptr, node_key_first, node_len, node_key, branch_ptr, ... SWAP1 DUP5 // branch_ptr - %increment // Skip over node type field + INCR1 // Skip over node type field ADD // Add node_key_first %mstore_trie_data // stack: node_len, node_key, branch_ptr, ... @@ -178,7 +178,7 @@ insert_key_continues: // stack: leaf_ptr, insert_key_first, insert_len, insert_key, branch_ptr, ... SWAP1 DUP5 // branch_ptr - %increment // Skip over node type field + INCR1 // Skip over node type field ADD // Add insert_key_first %mstore_trie_data // stack: insert_len, insert_key, branch_ptr, ... diff --git a/evm_arithmetization/src/cpu/kernel/asm/mpt/linked_list/final_tries.asm b/evm_arithmetization/src/cpu/kernel/asm/mpt/linked_list/final_tries.asm index 53093f4f4..52d9cc2f3 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/mpt/linked_list/final_tries.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/mpt/linked_list/final_tries.asm @@ -14,7 +14,7 @@ global insert_all_accounts: %jumpi(no_more_accounts) // stack: key, storage_ptr_ptr, root_ptr, account_ptr_ptr, retdest DUP4 - %increment + INCR1 MLOAD_GENERAL // stack: account_ptr, key, storage_ptr_ptr, root_ptr, account_ptr_ptr, retdest %add_const(2) @@ -32,7 +32,7 @@ after_insert_all_slots: %mstore_trie_data // stack: storage_ptr_ptr', key, root_ptr, account_ptr_ptr, retdest DUP4 - %increment + INCR1 MLOAD_GENERAL %stack (payload_ptr, storage_ptr_ptr_p, key, root_ptr, account_ptr_ptr) -> @@ -67,7 +67,7 @@ global insert_all_slots: insert_next_slot: // stack: addr, storage_ptr_ptr, root_ptr, retdest DUP2 - %increment + INCR1 MLOAD_GENERAL // stack: key, addr, storage_ptr_ptr, root_ptr, retdest DUP3 @@ -122,7 +122,7 @@ global delete_removed_accounts: %mload_trie_data // stack: storage_root_ptr, key, account_ptr_ptr, root_ptr, storage_ptr_ptr, retdest DUP3 - %increment + INCR1 MLOAD_GENERAL // get dynamic payload_ptr %add_const(2) // storage_root_ptr_ptr = dyn_payload_ptr + 2 %stack @@ -196,7 +196,7 @@ maybe_delete_this_slot: delete_this_slot: // stack: addr, root_ptr, storage_ptr_ptr, retdest DUP3 - %increment + INCR1 MLOAD_GENERAL %stack (key, addr, root_ptr, storage_ptr_ptr) -> (root_ptr, 64, key, after_mpt_delete_slot, addr, storage_ptr_ptr) %jump(mpt_delete) diff --git a/evm_arithmetization/src/cpu/kernel/asm/mpt/linked_list/initial_tries.asm b/evm_arithmetization/src/cpu/kernel/asm/mpt/linked_list/initial_tries.asm index df4762a51..2a41f9761 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/mpt/linked_list/initial_tries.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/mpt/linked_list/initial_tries.asm @@ -1,4 +1,3 @@ - global set_initial_state_trie: // stack: retdest PUSH set_initial_state_trie_after @@ -101,7 +100,7 @@ global insert_all_initial_slots: insert_next_slot: // stack: addr, storage_ptr_ptr, root_ptr, retdest DUP2 - %increment + INCR1 MLOAD_GENERAL // stack: key, addr, storage_ptr_ptr, root_ptr, retdest DUP3 diff --git a/evm_arithmetization/src/cpu/kernel/asm/mpt/linked_list/linked_list.asm b/evm_arithmetization/src/cpu/kernel/asm/mpt/linked_list/linked_list.asm index 650d69db2..876f3e341 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/mpt/linked_list/linked_list.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/mpt/linked_list/linked_list.asm @@ -69,23 +69,23 @@ loop_store_initial_accounts: %get_trie_data_size // stack: cpy_ptr, current_node_ptr, cur_len, retdest DUP2 - %increment + INCR1 MLOAD_GENERAL // stack: nonce_ptr, cpy_ptr, current_node_ptr, cur_len, retdest DUP1 %mload_trie_data // nonce %append_to_trie_data - %increment + INCR1 // stack: balance_ptr, cpy_ptr, current_node_ptr, cur_len, retdest DUP1 %mload_trie_data // balance %append_to_trie_data - %increment // The storage_root_ptr is not really necessary + INCR1 // The storage_root_ptr is not really necessary // stack: storage_root_ptr_ptr, cpy_ptr, current_node_ptr, cur_len, retdest DUP1 %mload_trie_data // storage_root_ptr %append_to_trie_data - %increment + INCR1 // stack: code_hash_ptr, cpy_ptr, current_node_ptr, cur_len, retdest %mload_trie_data // code_hash %append_to_trie_data @@ -148,7 +148,7 @@ store_initial_accounts_end: DUP2 %mul_const(4) // stack: ptr, @SEGMENT_ACCOUNTS_LINKED_LIST, ptr/4 - %increment %assert_gt + INCR1 %assert_gt // stack: ptr/4 DUP1 PUSH 4 @@ -196,7 +196,7 @@ account_found_with_overwrite: // The address was already in the list // stack: pred_ptr, addr_key, payload_ptr, retdest // Load the payload pointer - %increment + INCR1 // stack: payload_ptr_ptr, addr_key, payload_ptr, retdest DUP3 MSTORE_GENERAL %pop2 @@ -233,23 +233,23 @@ insert_new_account: DUP4 MSTORE_GENERAL // stack: new_ptr, next_ptr, addr_key, payload_ptr, retdest - %increment + INCR1 DUP1 DUP5 MSTORE_GENERAL // stack: new_ptr + 1, next_ptr, addr_key, payload_ptr, retdest - %increment + INCR1 DUP1 DUP5 %clone_account MSTORE_GENERAL - %increment + INCR1 DUP1 // stack: new_next_ptr, new_next_ptr, next_ptr, addr_key, payload_ptr, retdest SWAP2 MSTORE_GENERAL // stack: new_next_ptr, addr_key, payload_ptr, retdest - %increment + INCR1 %mstore_global_metadata(@GLOBAL_METADATA_ACCOUNTS_LINKED_LIST_NEXT_AVAILABLE) // stack: addr_key, payload_ptr, retdest %pop2 @@ -293,7 +293,7 @@ account_found: // The address was already in the list // stack: pred_ptr, addr_key, retdest // Load the payload pointer - %increment + INCR1 MLOAD_GENERAL // stack: orig_payload_ptr, addr_key, retdest %stack (orig_payload_ptr, addr_key, retdest) -> (retdest, orig_payload_ptr) @@ -408,7 +408,7 @@ loop_store_initial_slots: // stack: current_addr_key, current_node_ptr, cur_len', retdest SWAP1 DUP1 - %increment + INCR1 MLOAD_GENERAL // stack: current_slot_key, current_node_ptr, current_addr_key, cur_len', retdest SWAP1 @@ -422,7 +422,7 @@ loop_store_initial_slots: // stack: next_node_ptr, current_slot_key, current_addr_key, cur_len', retdest DUP1 DUP1 - %increment + INCR1 MLOAD_GENERAL // stack: next_node_slot_key, next_node_ptr, next_node_ptr, current_slot_key, current_addr_key, cur_len', retdest SWAP1 @@ -513,7 +513,7 @@ global insert_slot_with_value: %assert_eq // stack: pred_ptr, addr_key, key, value, retdest DUP1 - %increment + INCR1 MLOAD_GENERAL // stack: pred_key, pred_ptr, addr_key, key, value, retdest DUP1 DUP5 @@ -562,7 +562,7 @@ insert_new_slot_with_value: %assert_eq // stack: next_ptr, new_ptr, next_ptr_ptr, addr_key, key, value, retdest DUP1 - %increment + INCR1 MLOAD_GENERAL // stack: next_key, next_ptr, new_ptr, next_ptr_ptr, addr_key, key, value, retdest DUP1 // This is added just to have the correct stack in next_node_ok @@ -585,14 +585,14 @@ next_node_ok_with_value: MSTORE_GENERAL // stack: new_ptr, next_ptr, addr_key, key, value, retdest // Write the key in the new node - %increment + INCR1 DUP1 DUP5 MSTORE_GENERAL // stack: new_ptr + 1, next_ptr, addr_key, key, value, retdest // Write the value in the linked list. - %increment - DUP1 %increment + INCR1 + DUP1 INCR1 // stack: new_ptr+3, new_value_ptr, next_ptr, addr_key, key, value, retdest %stack (new_cloned_value_ptr, new_value_ptr, next_ptr, addr_key, key, value, retdest) -> (value, new_cloned_value_ptr, value, new_value_ptr, new_cloned_value_ptr, next_ptr, retdest) @@ -600,13 +600,13 @@ next_node_ok_with_value: MSTORE_GENERAL // Store value. // stack: new_ptr + 3, next_ptr, retdest - %increment + INCR1 DUP1 // stack: new_next_ptr_ptr, new_next_ptr_ptr, next_ptr, retdest SWAP2 MSTORE_GENERAL // stack: new_next_ptr_ptr, retdest - %increment + INCR1 %mstore_global_metadata(@GLOBAL_METADATA_STORAGE_LINKED_LIST_NEXT_AVAILABLE) // stack: retdest JUMP @@ -666,7 +666,7 @@ global insert_slot: %assert_eq // stack: pred_ptr, addr_key, key, value, retdest DUP1 - %increment + INCR1 MLOAD_GENERAL // stack: pred_key, pred_ptr, addr_key, key, value, retdest DUP1 DUP5 @@ -729,7 +729,7 @@ insert_new_slot: %assert_eq // stack: next_ptr, new_ptr, next_ptr_ptr, addr_key, key, value, retdest DUP1 - %increment + INCR1 MLOAD_GENERAL // stack: next_key, next_ptr, new_ptr, next_ptr_ptr, addr_key, key, value, retdest DUP1 // This is added just to have the correct stack in next_node_ok @@ -751,32 +751,32 @@ next_node_ok: MSTORE_GENERAL // stack: new_ptr, next_ptr, addr_key, key, value, retdest // Write the key in the new node - %increment + INCR1 DUP1 DUP5 MSTORE_GENERAL // stack: new_ptr + 1, next_ptr, addr_key, key, value, retdest // Store value - %increment + INCR1 DUP1 DUP6 MSTORE_GENERAL // stack: new_ptr + 2, next_ptr, addr_key, key, value, retdest // Store the copy of value - %increment + INCR1 DUP1 DUP6 %clone_slot MSTORE_GENERAL // stack: new_ptr + 3, next_ptr, addr_key, key, value, retdest - %increment + INCR1 DUP1 // stack: new_next_ptr, new_next_ptr, next_ptr, addr_key, key, value, retdest SWAP2 MSTORE_GENERAL // stack: new_next_ptr, addr_key, key, value, retdest - %increment + INCR1 %mstore_global_metadata(@GLOBAL_METADATA_STORAGE_LINKED_LIST_NEXT_AVAILABLE) // stack: addr_key, key, value, retdest %stack (addr_key, key, value, retdest) -> (retdest, value) @@ -809,7 +809,7 @@ global search_slot: %assert_eq // stack: pred_ptr, addr_key, key, value, retdest DUP1 - %increment + INCR1 MLOAD_GENERAL // stack: pred_key, pred_ptr, addr_key, key, value, retdest DUP1 DUP5 @@ -879,7 +879,7 @@ global remove_slot: %assert_eq // stack: next_ptr, next_ptr_ptr, addr_key, key, retdest DUP1 - %increment + INCR1 MLOAD_GENERAL // stack: next_key, next_ptr, next_ptr_ptr, addr_key, key, retdest DUP5 diff --git a/evm_arithmetization/src/cpu/kernel/asm/mpt/read.asm b/evm_arithmetization/src/cpu/kernel/asm/mpt/read.asm index 86f8ae190..c486f9586 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/mpt/read.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/mpt/read.asm @@ -32,7 +32,7 @@ global mpt_read: %mload_trie_data // stack: node_type, node_ptr, num_nibbles, key, retdest // Increment node_ptr, so it points to the node payload instead of its type. - SWAP1 %increment SWAP1 + INCR2 // stack: node_type, node_payload_ptr, num_nibbles, key, retdest DUP1 %eq_const(@MPT_NODE_EMPTY) %jumpi(mpt_read_empty) @@ -98,7 +98,7 @@ global mpt_read_extension: %mul_const(4) SHR // key_part = key >> (future_nibbles * 4) DUP1 // stack: key_part, key_part, future_nibbles, key, node_payload_ptr, retdest - DUP5 %increment %mload_trie_data + DUP5 INCR1 %mload_trie_data // stack: node_key, key_part, key_part, future_nibbles, key, node_payload_ptr, retdest EQ // does the first part of our key match the node's key? %jumpi(mpt_read_extension_found) @@ -127,7 +127,7 @@ global mpt_read_leaf: // stack: node_payload_ptr, num_nibbles, key, retdest DUP1 %mload_trie_data // stack: node_num_nibbles, node_payload_ptr, num_nibbles, key, retdest - DUP2 %increment %mload_trie_data + DUP2 INCR1 %mload_trie_data // stack: node_key, node_num_nibbles, node_payload_ptr, num_nibbles, key, retdest SWAP3 // stack: num_nibbles, node_num_nibbles, node_payload_ptr, node_key, key, retdest diff --git a/evm_arithmetization/src/cpu/kernel/asm/mpt/util.asm b/evm_arithmetization/src/cpu/kernel/asm/mpt/util.asm index 64ed2599b..9c27ef4a8 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/mpt/util.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/mpt/util.asm @@ -34,7 +34,7 @@ %get_trie_data_size // stack: trie_data_size, value DUP1 - %increment + INCR1 // stack: trie_data_size', trie_data_size, value %set_trie_data_size // stack: trie_data_size, value @@ -151,7 +151,7 @@ DUP2 DUP2 SUB %jumpi(%%return_with_first_nibs) // len_common += 1 - SWAP2 %increment SWAP2 + INCR3 // key_common = key_common * 16 + first_nib_1 SWAP3 diff --git a/evm_arithmetization/src/cpu/kernel/asm/rlp/decode.asm b/evm_arithmetization/src/cpu/kernel/asm/rlp/decode.asm index 43c6627d6..d260b3a2b 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/rlp/decode.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/rlp/decode.asm @@ -35,10 +35,9 @@ decode_rlp_string_len_medium: // stack: first_byte, rlp_addr, retdest %sub_const(0x80) // stack: len, rlp_addr, retdest - SWAP1 - %increment - // stack: rlp_addr', len, retdest - %stack (rlp_addr, len, retdest) -> (retdest, rlp_addr, len) + INCR2 + // stack: len, rlp_addr', retdest + SWAP2 JUMP decode_rlp_string_len_large: @@ -46,8 +45,8 @@ decode_rlp_string_len_large: // stack: first_byte, rlp_addr, retdest %sub_const(0xb7) // stack: len_of_len, rlp_addr, retdest + INCR2 SWAP1 - %increment // stack: rlp_addr', len_of_len, retdest %jump(decode_int_given_len) @@ -91,9 +90,7 @@ global decode_rlp_list_len: DUP1 MLOAD_GENERAL // stack: first_byte, rlp_addr, retdest - SWAP1 - %increment // increment rlp_addr - SWAP1 + INCR2 // increment rlp_addr // stack: first_byte, rlp_addr', retdest // If first_byte is >= 0xf8, it's a > 55 byte list, and // first_byte - 0xf7 is the length of the length. diff --git a/evm_arithmetization/src/cpu/kernel/asm/rlp/encode.asm b/evm_arithmetization/src/cpu/kernel/asm/rlp/encode.asm index 9f6813ab1..a9c8e7b8f 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/rlp/encode.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/rlp/encode.asm @@ -27,10 +27,9 @@ global encode_rlp_fixed: // stack: first_byte, rlp_addr, len, rlp_addr, string, retdest MSTORE_GENERAL // stack: len, rlp_addr, string, retdest - SWAP1 - %increment // increment rlp_addr - // stack: rlp_addr, len, string, retdest - %stack (rlp_addr, len, string) -> (rlp_addr, string, len, encode_rlp_fixed_finish) + INCR2 // increment rlp_addr + // stack: len, rlp_addr', string, retdest + %stack (len, rlp_addr, string) -> (rlp_addr, string, len, encode_rlp_fixed_finish) // stack: rlp_addr, string, len, encode_rlp_fixed_finish, retdest %jump(mstore_unpacking) encode_rlp_fixed_finish: @@ -48,17 +47,16 @@ global doubly_encode_rlp_fixed: // stack: first_byte, rlp_addr, len, rlp_addr, string, retdest MSTORE_GENERAL // stack: len, rlp_addr, string, retdest - DUP2 %increment + DUP2 INCR1 DUP2 %add_const(0x80) // stack: second_byte, rlp_addr', len, original_rlp_addr, string, retdest MSTORE_GENERAL // stack: len, rlp_addr, string, retdest - SWAP1 - %add_const(2) // advance past the two prefix bytes - // stack: rlp_addr'', len, string, retdest - %stack (rlp_addr, len, string) -> (rlp_addr, string, len, encode_rlp_fixed_finish) - // stack: context, segment, rlp_addr'', string, len, encode_rlp_fixed_finish, retdest + INCR2 INCR2 // advance past the two prefix bytes + // stack: len, rlp_addr'', string, retdest + %stack (len, rlp_addr, string) -> (rlp_addr, string, len, encode_rlp_fixed_finish) + // stack: rlp_addr'', string, len, encode_rlp_fixed_finish, retdest %jump(mstore_unpacking) // Writes the RLP prefix for a string of the given length. This does not handle @@ -83,7 +81,7 @@ global encode_rlp_multi_byte_string_prefix: // stack: prefix, rlp_addr, rlp_addr, retdest MSTORE_GENERAL // stack: rlp_addr, retdest - %increment + INCR1 // stack: rlp_addr', retdest SWAP1 JUMP @@ -100,7 +98,7 @@ encode_rlp_multi_byte_string_prefix_large: // stack: first_byte, rlp_addr, rlp_addr, len_of_len, str_len, retdest MSTORE_GENERAL // stack: rlp_addr, len_of_len, str_len, retdest - %increment + INCR1 // stack: rlp_addr', len_of_len, str_len, retdest %stack (rlp_addr, len_of_len, str_len) -> (rlp_addr, str_len, len_of_len) %jump(mstore_unpacking) @@ -127,7 +125,7 @@ global encode_rlp_list_prefix: // stack: prefix, rlp_addr, rlp_addr, retdest MSTORE_GENERAL // stack: rlp_addr, retdest - %increment + INCR1 SWAP1 JUMP encode_rlp_list_prefix_large: @@ -140,7 +138,7 @@ encode_rlp_list_prefix_large: // stack: first_byte, rlp_addr, len_of_len, rlp_addr, payload_len, retdest MSTORE_GENERAL // stack: len_of_len, rlp_addr, payload_len, retdest - SWAP1 %increment + INCR2 SWAP1 // stack: rlp_addr', len_of_len, payload_len, retdest %stack (rlp_addr, len_of_len, payload_len) -> (rlp_addr, payload_len, len_of_len, @@ -177,7 +175,7 @@ global prepend_rlp_list_prefix: // stack: prefix_byte, start_rlp_addr-1, payload_len, end_rlp_addr, start_rlp_addr, retdest MSTORE_GENERAL // stack: payload_len, end_rlp_addr, start_rlp_addr, retdest - %increment + INCR1 // stack: rlp_len, end_rlp_addr, start_rlp_addr, retdest SWAP2 %decrement // stack: prefix_start_rlp_addr, end_rlp_addr, rlp_len, retdest @@ -198,7 +196,7 @@ prepend_rlp_list_prefix_big: DUP1 DUP3 %add_const(0xf7) MSTORE_GENERAL // rlp[prefix_start_rlp_addr] = 0xf7 + len_of_len // stack: prefix_start_rlp_addr, len_of_len, payload_len, end_rlp_addr, start_rlp_addr, retdest - DUP1 %increment // start_len_rlp_addr = prefix_start_rlp_addr + 1 + DUP1 INCR1 // start_len_rlp_addr = prefix_start_rlp_addr + 1 %stack (start_len_rlp_addr, prefix_start_rlp_addr, len_of_len, payload_len, end_rlp_addr, start_rlp_addr, retdest) -> (start_len_rlp_addr, payload_len, len_of_len, prepend_rlp_list_prefix_big_done_writing_len, @@ -237,7 +235,7 @@ prepend_rlp_list_prefix_big_done_writing_len: // stack: scalar %num_bytes // stack: scalar_bytes - %increment // Account for the length prefix. + INCR1 // Account for the length prefix. // stack: rlp_len %%finish: %endmacro @@ -250,7 +248,7 @@ prepend_rlp_list_prefix_big_done_writing_len: // stack: is_large, payload_len %jumpi(%%large) // Small case; prefix is a single byte. - %increment + INCR1 // stack: 1 + payload_len %jump(%%finish) %%large: @@ -258,7 +256,7 @@ prepend_rlp_list_prefix_big_done_writing_len: // stack: payload_len DUP1 %num_bytes // stack: len_of_len, payload_len - %increment + INCR1 // stack: prefix_len, payload_len ADD %%finish: diff --git a/evm_arithmetization/src/cpu/kernel/asm/rlp/encode_rlp_scalar.asm b/evm_arithmetization/src/cpu/kernel/asm/rlp/encode_rlp_scalar.asm index d311a57eb..1cda0c16c 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/rlp/encode_rlp_scalar.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/rlp/encode_rlp_scalar.asm @@ -16,7 +16,7 @@ global encode_rlp_scalar: %stack (rlp_addr, scalar) -> (0x80, rlp_addr, rlp_addr) MSTORE_GENERAL // stack: rlp_addr, retdest - %increment + INCR1 // stack: rlp_addr', retdest SWAP1 JUMP @@ -50,11 +50,11 @@ global doubly_encode_rlp_scalar: %stack (rlp_addr, scalar) -> (0x81, rlp_addr, rlp_addr) MSTORE_GENERAL // stack: rlp_addr, retdest - %increment + INCR1 DUP1 PUSH 0x80 MSTORE_GENERAL // stack: rlp_addr, retdest - %increment + INCR1 // stack: rlp_addr, retdest SWAP1 JUMP @@ -80,7 +80,7 @@ encode_rlp_scalar_small: // stack: scalar, rlp_addr, rlp_addr, retdest MSTORE_GENERAL // stack: rlp_addr, retdest - %increment + INCR1 // stack: rlp_addr', retdest SWAP1 JUMP diff --git a/evm_arithmetization/src/cpu/kernel/asm/rlp/encode_rlp_string.asm b/evm_arithmetization/src/cpu/kernel/asm/rlp/encode_rlp_string.asm index 60174a943..66fe129ad 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/rlp/encode_rlp_string.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/rlp/encode_rlp_string.asm @@ -26,7 +26,7 @@ global encode_rlp_string_small: // stack: first_byte, rlp_addr, rlp_addr, ADDR, len, retdest MSTORE_GENERAL // stack: rlp_addr, ADDR, len, retdest - %increment + INCR1 // stack: rlp_addr', ADDR, len, retdest DUP3 DUP2 ADD // rlp_addr'' = rlp_addr' + len // stack: rlp_addr'', rlp_addr', ADDR, len, retdest @@ -42,7 +42,7 @@ global encode_rlp_string_small_single_byte: DUP2 SWAP1 MSTORE_GENERAL // stack: rlp_addr, retdest - %increment + INCR1 SWAP1 // stack: retdest, rlp_addr' JUMP @@ -59,7 +59,7 @@ global encode_rlp_string_large: // stack: first_byte, rlp_addr, rlp_addr, len_of_len, ADDR, len, retdest MSTORE_GENERAL // stack: rlp_addr, len_of_len, ADDR, len, retdest - %increment + INCR1 // stack: rlp_addr', len_of_len, ADDR, len, retdest %stack (rlp_addr, len_of_len, ADDR, len) -> (rlp_addr, len, len_of_len, encode_rlp_string_large_after_writing_len, ADDR, len) diff --git a/evm_arithmetization/src/cpu/kernel/asm/rlp/increment_bounded_rlp.asm b/evm_arithmetization/src/cpu/kernel/asm/rlp/increment_bounded_rlp.asm index 2f5f07500..12dc633e6 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/rlp/increment_bounded_rlp.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/rlp/increment_bounded_rlp.asm @@ -14,7 +14,7 @@ global increment_bounded_rlp: %jumpi(case_0x81ff) // If rlp_index != 0x80 and rlp_index != 0x7f and rlp_index != 0x81ff // we only need to add one and keep the number of nibbles - %increment + INCR1 %stack (next_rlp_index, next_num_nibbles, retdest) -> (retdest, next_rlp_index, next_num_nibbles) JUMP diff --git a/evm_arithmetization/src/cpu/kernel/asm/shift.asm b/evm_arithmetization/src/cpu/kernel/asm/shift.asm index ee9ccbfae..228054621 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/shift.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/shift.asm @@ -7,7 +7,7 @@ %rep 255 // stack: 2^i, addr_i dup2 - %increment + INCR1 // stack: addr_(i+1), 2^i, addr_i dup2 dup1 diff --git a/evm_arithmetization/src/cpu/kernel/asm/signed.asm b/evm_arithmetization/src/cpu/kernel/asm/signed.asm index a9e9e3648..d08ca2c56 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/signed.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/signed.asm @@ -100,7 +100,7 @@ global _sys_signextend: PUSH 31 %min // Stack: min(31, N), value, return_info - %increment + INCR1 %mul_const(8) // Stack: 8*(N + 1), value, return_info PUSH 256 diff --git a/evm_arithmetization/src/cpu/kernel/asm/transactions/common_decoding.asm b/evm_arithmetization/src/cpu/kernel/asm/transactions/common_decoding.asm index 6ee92ca2b..01d616ab2 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/transactions/common_decoding.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/transactions/common_decoding.asm @@ -300,7 +300,8 @@ sload_with_addr: // stack: hash, store_addr, store_addr, end_rlp_addr, rlp_addr MSTORE_GENERAL // stack: store_addr, end_rlp_addr, rlp_addr - %increment SWAP2 + SWAP2 + INCR3 // stack: rlp_addr, end_rlp_addr, store_addr' %jump(decode_and_store_blob_versioned_hashes_loop) decode_and_store_blob_versioned_hashes_finish: diff --git a/evm_arithmetization/src/cpu/kernel/asm/transactions/router.asm b/evm_arithmetization/src/cpu/kernel/asm/transactions/router.asm index eaef7efd7..8b4e58471 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/transactions/router.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/transactions/router.asm @@ -57,7 +57,7 @@ global update_txn_trie: // First we write txn rlp length DUP1 %append_to_trie_data // stack: txn_rlp_len, value_ptr, txn_counter, num_nibbles, ret_dest - DUP2 %increment + DUP2 INCR1 // stack: rlp_start=value_ptr+1, txn_rlp_len, value_ptr, txn_counter, num_nibbles, retdest // and now copy txn_rlp to the new block diff --git a/evm_arithmetization/src/cpu/kernel/asm/transactions/type_1.asm b/evm_arithmetization/src/cpu/kernel/asm/transactions/type_1.asm index 4000221f4..90006e99b 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/transactions/type_1.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/transactions/type_1.asm @@ -14,7 +14,7 @@ global process_type_1_txn: // stack: rlp_addr, retdest // Initial rlp address offset of 1 (skipping over the 0x01 byte) - %add_const(1) + INCR1 // stack: rlp_addr, retdest %decode_rlp_list_len // We don't actually need the length. @@ -62,7 +62,7 @@ type_1_compute_signed_data: // stack: rlp_addr, rlp_len, retdest // Hash the RLP + the leading `1` - SWAP1 %increment SWAP1 + INCR2 // stack: ADDR, len, retdest KECCAK_GENERAL // stack: hash, retdest diff --git a/evm_arithmetization/src/cpu/kernel/asm/transactions/type_2.asm b/evm_arithmetization/src/cpu/kernel/asm/transactions/type_2.asm index ba35b1402..a8818baf7 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/transactions/type_2.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/transactions/type_2.asm @@ -15,7 +15,7 @@ global process_type_2_txn: // stack: rlp_addr, retdest // Initial rlp address offset of 1 (skipping over the 0x02 byte) - %add_const(1) + INCR1 // stack: rlp_addr, retdest %decode_rlp_list_len // We don't actually need the length. @@ -65,7 +65,7 @@ type_2_compute_signed_data: // stack: rlp_addr, rlp_len, retdest // Hash the RLP + the leading `2` - SWAP1 %increment SWAP1 + INCR2 // stack: ADDR, len, retdest KECCAK_GENERAL // stack: hash, retdest diff --git a/evm_arithmetization/src/cpu/kernel/asm/transactions/type_3.asm b/evm_arithmetization/src/cpu/kernel/asm/transactions/type_3.asm index f84f95c7d..613839210 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/transactions/type_3.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/transactions/type_3.asm @@ -14,7 +14,7 @@ global process_type_3_txn: // stack: rlp_addr, retdest // Initial rlp address offset of 1 (skipping over the 0x03 byte) - %add_const(1) + INCR1 // stack: rlp_addr, retdest %decode_rlp_list_len // We don't actually need the length. @@ -65,7 +65,7 @@ type_3_compute_signed_data: // stack: rlp_addr, rlp_len, retdest // Hash the RLP + the leading `3` - SWAP1 %increment SWAP1 + INCR2 // stack: ADDR, len, retdest KECCAK_GENERAL // stack: hash, retdest diff --git a/evm_arithmetization/src/cpu/kernel/asm/util/basic_macros.asm b/evm_arithmetization/src/cpu/kernel/asm/util/basic_macros.asm index 657ee9760..2bff83dc6 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/util/basic_macros.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/util/basic_macros.asm @@ -347,10 +347,6 @@ %as_u32 %endmacro -%macro increment - %add_const(1) -%endmacro - %macro decrement %sub_const(1) %endmacro diff --git a/evm_arithmetization/src/cpu/kernel/asm/util/math.asm b/evm_arithmetization/src/cpu/kernel/asm/util/math.asm index 4bdf69023..8d7c723f1 100644 --- a/evm_arithmetization/src/cpu/kernel/asm/util/math.asm +++ b/evm_arithmetization/src/cpu/kernel/asm/util/math.asm @@ -7,9 +7,7 @@ log2_floor_helper: // stack: val, counter, retdest %div2 // stack: val/2, counter, retdest - SWAP1 - %increment - SWAP1 + INCR2 // stack: val/2, counter + 1, retdest %jump(log2_floor_helper) end: diff --git a/evm_arithmetization/src/cpu/kernel/opcodes.rs b/evm_arithmetization/src/cpu/kernel/opcodes.rs index 6491003f1..93802cb54 100644 --- a/evm_arithmetization/src/cpu/kernel/opcodes.rs +++ b/evm_arithmetization/src/cpu/kernel/opcodes.rs @@ -149,6 +149,10 @@ pub fn get_opcode(mnemonic: &str) -> u8 { "MSTORE_32BYTES_30" => 0xdd, "MSTORE_32BYTES_31" => 0xde, "MSTORE_32BYTES_32" => 0xdf, + "INCR1" => 0xe0, + "INCR2" => 0xe1, + "INCR3" => 0xe2, + "INCR4" => 0xe3, "PROVER_INPUT" => 0xee, "CREATE" => 0xf0, "CALL" => 0xf1, diff --git a/evm_arithmetization/src/cpu/mod.rs b/evm_arithmetization/src/cpu/mod.rs index 3d5124ba2..cd4c236c8 100644 --- a/evm_arithmetization/src/cpu/mod.rs +++ b/evm_arithmetization/src/cpu/mod.rs @@ -8,6 +8,7 @@ pub(crate) mod decode; mod dup_swap; mod gas; mod halt; +mod incr; mod jumps; pub mod kernel; pub(crate) mod membus; diff --git a/evm_arithmetization/src/cpu/stack.rs b/evm_arithmetization/src/cpu/stack.rs index e5b1682ad..d5851c841 100644 --- a/evm_arithmetization/src/cpu/stack.rs +++ b/evm_arithmetization/src/cpu/stack.rs @@ -39,6 +39,7 @@ pub(crate) const MIGHT_OVERFLOW: OpsColumnsView = OpsColumnsView { m_op_32bytes: false, exit_kernel: true, // Doesn't directly push, but the syscall it's returning from might. m_op_general: false, + incr: false, syscall: false, exception: false, }; @@ -164,6 +165,7 @@ pub(crate) const STACK_BEHAVIORS: OpsColumnsView> = OpsCol disable_other_channels: true, }), m_op_general: None, + incr: None, syscall: Some(StackBehavior { num_pops: 0, pushes: true, diff --git a/evm_arithmetization/src/generation/mod.rs b/evm_arithmetization/src/generation/mod.rs index 6ec02ea73..aee2c8111 100644 --- a/evm_arithmetization/src/generation/mod.rs +++ b/evm_arithmetization/src/generation/mod.rs @@ -46,10 +46,10 @@ use crate::witness::util::mem_write_log; /// Number of cycles to go after having reached the halting state. It is /// equal to the number of cycles in `exc_stop` + 1. -pub const NUM_EXTRA_CYCLES_AFTER: usize = 82; +pub const NUM_EXTRA_CYCLES_AFTER: usize = 81; /// Number of cycles to go before starting the execution: it is the number of /// cycles in `init`. -pub const NUM_EXTRA_CYCLES_BEFORE: usize = 64; +pub const NUM_EXTRA_CYCLES_BEFORE: usize = 63; /// Memory values used to initialize `MemBefore`. pub type MemBeforeValues = Vec<(MemoryAddress, U256)>; diff --git a/evm_arithmetization/src/generation/state.rs b/evm_arithmetization/src/generation/state.rs index abe4b4f1a..96fa0bc90 100644 --- a/evm_arithmetization/src/generation/state.rs +++ b/evm_arithmetization/src/generation/state.rs @@ -232,7 +232,12 @@ pub(crate) trait State { } } else { if !running { - debug_assert!(self.get_clock() - final_clock == NUM_EXTRA_CYCLES_AFTER - 1); + debug_assert!( + self.get_clock() - final_clock == NUM_EXTRA_CYCLES_AFTER - 1, + "Got {:?}, expected {:?}", + self.get_clock() - final_clock, + NUM_EXTRA_CYCLES_AFTER - 1 + ); } let final_mem = self.get_active_memory(); #[cfg(not(test))] diff --git a/evm_arithmetization/src/witness/gas.rs b/evm_arithmetization/src/witness/gas.rs index 3a184d3d0..dcf9a67c3 100644 --- a/evm_arithmetization/src/witness/gas.rs +++ b/evm_arithmetization/src/witness/gas.rs @@ -53,6 +53,7 @@ pub(crate) const fn gas_to_charge(op: Operation) -> u64 { SetContext => KERNEL_ONLY_INSTR, Mload32Bytes => KERNEL_ONLY_INSTR, Mstore32Bytes(_) => KERNEL_ONLY_INSTR, + Incr(_) => KERNEL_ONLY_INSTR, ExitKernel => KERNEL_ONLY_INSTR, MloadGeneral => KERNEL_ONLY_INSTR, MstoreGeneral => KERNEL_ONLY_INSTR, diff --git a/evm_arithmetization/src/witness/operation.rs b/evm_arithmetization/src/witness/operation.rs index c8e2a5376..7561a22c7 100644 --- a/evm_arithmetization/src/witness/operation.rs +++ b/evm_arithmetization/src/witness/operation.rs @@ -58,6 +58,7 @@ pub(crate) enum Operation { SetContext, Mload32Bytes, Mstore32Bytes(u8), + Incr(u8), ExitKernel, MloadGeneral, MstoreGeneral, @@ -561,6 +562,7 @@ pub(crate) fn generate_dup>( } else { mem_read_gp_with_log_and_fill(2, other_addr, generation_state, &mut row) }; + push_no_write(generation_state, val); state.push_memory(log_push); state.push_memory(log_read); @@ -597,6 +599,39 @@ pub(crate) fn generate_swap>( Ok(()) } +pub(crate) fn generate_incr>( + n: u8, + state: &mut T, + mut row: CpuColumnsView, +) -> Result<(), ProgramError> { + let generation_state = state.get_mut_generation_state(); + let offset = generation_state + .registers + .stack_len + .checked_sub(1 + (n as usize)) + .ok_or(ProgramError::StackUnderflow)?; + let addr = MemoryAddress::new(generation_state.registers.context, Segment::Stack, offset); + + let (val, log_in0) = mem_read_gp_with_log_and_fill(1, addr, generation_state, &mut row); + let new_val = val.overflowing_add(1.into()).0; + + // Write the read value, incremented by 1. + let log_out0 = mem_write_gp_log_and_fill(2, addr, generation_state, &mut row, new_val); + + // Manually increment the top of the stack if calling INCR1. + if n == 0 { + generation_state.registers.stack_top += U256::one(); + } + state.push_memory(log_in0); + state.push_memory(log_out0); + + let operation = arithmetic::Operation::binary(BinaryOperator::Add, val, U256::one()); + state.push_arithmetic(operation); + state.push_cpu(row); + + Ok(()) +} + pub(crate) fn generate_not>( state: &mut T, mut row: CpuColumnsView, diff --git a/evm_arithmetization/src/witness/transition.rs b/evm_arithmetization/src/witness/transition.rs index fdcf9af65..c2c6600c5 100644 --- a/evm_arithmetization/src/witness/transition.rs +++ b/evm_arithmetization/src/witness/transition.rs @@ -156,6 +156,7 @@ pub(crate) fn decode(registers: RegistersState, opcode: u8) -> Result Ok(Operation::Mstore32Bytes(opcode - 0xc0 + 1)), + (0xe0..=0xe3, true) => Ok(Operation::Incr(opcode & 0x3)), (0xee, true) => Ok(Operation::ProverInput), (0xf0, _) => Ok(Operation::Syscall(opcode, 3, false)), // CREATE (0xf1, _) => Ok(Operation::Syscall(opcode, 7, false)), // CALL @@ -202,6 +203,7 @@ pub(crate) fn fill_op_flag(op: Operation, row: &mut CpuColumnsView) Operation::Pc | Operation::Push(0) => &mut flags.pc_push0, Operation::GetContext | Operation::SetContext => &mut flags.context_op, Operation::Mload32Bytes | Operation::Mstore32Bytes(_) => &mut flags.m_op_32bytes, + Operation::Incr(_) => &mut flags.incr, Operation::ExitKernel => &mut flags.exit_kernel, Operation::MloadGeneral | Operation::MstoreGeneral => &mut flags.m_op_general, } = F::ONE; @@ -235,6 +237,7 @@ pub(crate) const fn get_op_special_length(op: Operation) -> Option { Operation::Jumpi => JUMPI_OP, Operation::GetContext | Operation::SetContext => None, Operation::Mload32Bytes | Operation::Mstore32Bytes(_) => STACK_BEHAVIORS.m_op_32bytes, + Operation::Incr(_) => STACK_BEHAVIORS.incr, Operation::ExitKernel => STACK_BEHAVIORS.exit_kernel, Operation::MloadGeneral | Operation::MstoreGeneral => STACK_BEHAVIORS.m_op_general, }; @@ -276,6 +279,7 @@ pub(crate) const fn might_overflow_op(op: Operation) -> bool { Operation::Pc | Operation::Push(0) => MIGHT_OVERFLOW.pc_push0, Operation::GetContext | Operation::SetContext => MIGHT_OVERFLOW.context_op, Operation::Mload32Bytes | Operation::Mstore32Bytes(_) => MIGHT_OVERFLOW.m_op_32bytes, + Operation::Incr(_) => MIGHT_OVERFLOW.incr, Operation::ExitKernel => MIGHT_OVERFLOW.exit_kernel, Operation::MloadGeneral | Operation::MstoreGeneral => MIGHT_OVERFLOW.m_op_general, } @@ -571,6 +575,7 @@ where Operation::SetContext => generate_set_context(self, row), Operation::Mload32Bytes => generate_mload_32bytes(self, row), Operation::Mstore32Bytes(n) => generate_mstore_32bytes(n, self, row), + Operation::Incr(n) => generate_incr(n, self, row), Operation::ExitKernel => generate_exit_kernel(self, row), Operation::MloadGeneral => generate_mload_general(self, row), Operation::MstoreGeneral => generate_mstore_general(self, row), diff --git a/scripts/prove_rpc.sh b/scripts/prove_rpc.sh index 49848fdfe..4ec17a9e0 100755 --- a/scripts/prove_rpc.sh +++ b/scripts/prove_rpc.sh @@ -20,19 +20,6 @@ export RUSTFLAGS='-C target-cpu=native -Zlinker-features=-lld' BLOCK_BATCH_SIZE="${BLOCK_BATCH_SIZE:-8}" echo "Block batch size: $BLOCK_BATCH_SIZE" -# Circuit sizes only matter in non test_only mode. -if ! [[ $8 == "test_only" ]]; then - export ARITHMETIC_CIRCUIT_SIZE="16..21" - export BYTE_PACKING_CIRCUIT_SIZE="8..21" - export CPU_CIRCUIT_SIZE="8..21" - export KECCAK_CIRCUIT_SIZE="4..20" - export KECCAK_SPONGE_CIRCUIT_SIZE="8..17" - export LOGIC_CIRCUIT_SIZE="4..21" - export MEMORY_CIRCUIT_SIZE="17..24" - export MEMORY_BEFORE_CIRCUIT_SIZE="16..23" - export MEMORY_AFTER_CIRCUIT_SIZE="7..23" -fi - REPO_ROOT=$(git rev-parse --show-toplevel) PROOF_OUTPUT_DIR="${REPO_ROOT}/proofs" diff --git a/scripts/prove_stdio.sh b/scripts/prove_stdio.sh index c3c794086..c38b5138e 100755 --- a/scripts/prove_stdio.sh +++ b/scripts/prove_stdio.sh @@ -72,7 +72,7 @@ if ! [[ $TEST_ONLY == "test_only" ]]; then export KECCAK_CIRCUIT_SIZE="4..13" export KECCAK_SPONGE_CIRCUIT_SIZE="8..9" export LOGIC_CIRCUIT_SIZE="4..14" - export MEMORY_CIRCUIT_SIZE="17..22" + export MEMORY_CIRCUIT_SIZE="16..22" export MEMORY_BEFORE_CIRCUIT_SIZE="16..18" export MEMORY_AFTER_CIRCUIT_SIZE="7..8" export POSEIDON_CIRCUIT_SIZE="4..8" @@ -102,8 +102,8 @@ if [[ $TEST_ONLY == "test_only" ]]; then exit else # Some error occurred, display the logs and exit. - cat $OUT_LOG_PATH - echo "Failed to create proof witnesses. See $OUT_LOG_PATH for more details." + cat $TEST_OUT_PATH + echo "Failed to create proof witnesses. See $TEST_OUT_PATH for more details." exit 1 fi fi