diff --git a/avm-transpiler/src/opcodes.rs b/avm-transpiler/src/opcodes.rs index 9e60aee398f..3584d63b643 100644 --- a/avm-transpiler/src/opcodes.rs +++ b/avm-transpiler/src/opcodes.rs @@ -37,6 +37,8 @@ pub enum AvmOpcode { // Execution environment GETENVVAR_16, CALLDATACOPY, + RETURNDATASIZE, + RETURNDATACOPY, // Control flow JUMP_16, JUMPI_16, @@ -123,6 +125,8 @@ impl AvmOpcode { AvmOpcode::GETENVVAR_16 => "GETENVVAR_16", // Execution Environment - Calldata AvmOpcode::CALLDATACOPY => "CALLDATACOPY", + AvmOpcode::RETURNDATASIZE => "RETURNDATASIZE", + AvmOpcode::RETURNDATACOPY => "RETURNDATACOPY", // Machine State // Machine State - Internal Control Flow diff --git a/avm-transpiler/src/transpile.rs b/avm-transpiler/src/transpile.rs index bb020717208..59311033991 100644 --- a/avm-transpiler/src/transpile.rs +++ b/avm-transpiler/src/transpile.rs @@ -396,6 +396,8 @@ fn handle_foreign_call( "avmOpcodeL1ToL2MsgExists" => handle_l1_to_l2_msg_exists(avm_instrs, destinations, inputs), "avmOpcodeSendL2ToL1Msg" => handle_send_l2_to_l1_msg(avm_instrs, destinations, inputs), "avmOpcodeCalldataCopy" => handle_calldata_copy(avm_instrs, destinations, inputs), + "avmOpcodeReturndataSize" => handle_returndata_size(avm_instrs, destinations, inputs), + "avmOpcodeReturndataCopy" => handle_returndata_copy(avm_instrs, destinations, inputs), "avmOpcodeReturn" => handle_return(avm_instrs, destinations, inputs), "avmOpcodeRevert" => handle_revert(avm_instrs, destinations, inputs), "avmOpcodeStorageRead" => handle_storage_read(avm_instrs, destinations, inputs), @@ -1217,6 +1219,87 @@ fn handle_calldata_copy( }); } +// #[oracle(avmOpcodeReturndataSize)] +// unconstrained fn returndata_size_opcode() -> u32 {} +fn handle_returndata_size( + avm_instrs: &mut Vec, + destinations: &Vec, + inputs: &Vec, +) { + assert!(inputs.len() == 0); + assert!(destinations.len() == 1); + + let dest_offset = match destinations[0] { + ValueOrArray::MemoryAddress(address) => address, + _ => panic!("ReturndataSize destination should be a memory location"), + }; + + avm_instrs.push(AvmInstruction { + opcode: AvmOpcode::RETURNDATASIZE, + indirect: Some(AddressingModeBuilder::default().direct_operand(&dest_offset).build()), + operands: vec![AvmOperand::U16 { value: dest_offset.to_usize() as u16 }], + ..Default::default() + }); +} + +// #[oracle(avmOpcodeReturndataCopy)] +// unconstrained fn returndata_copy_opcode(rdoffset: u32, copy_size: u32) -> [Field] {} +fn handle_returndata_copy( + avm_instrs: &mut Vec, + destinations: &Vec, + inputs: &Vec, +) { + assert!(inputs.len() == 2); + assert!(destinations.len() == 2); + + let cd_offset = match inputs[0] { + ValueOrArray::MemoryAddress(address) => address, + _ => panic!("ReturndataCopy offset should be a memory address"), + }; + + let copy_size_offset = match inputs[1] { + ValueOrArray::MemoryAddress(address) => address, + _ => panic!("ReturndataCopy size should be a memory address"), + }; + + // We skip the first destination, which is the size of the slice. + let (dest_offset, write_size_here_offset) = match destinations[1] { + ValueOrArray::HeapVector(HeapVector { pointer, size }) => (pointer, size), + _ => panic!("ReturndataCopy destination should be a vector (slice)"), + }; + + avm_instrs.extend([ + // First we write the return data. + AvmInstruction { + opcode: AvmOpcode::RETURNDATACOPY, + indirect: Some( + AddressingModeBuilder::default() + .direct_operand(&cd_offset) + .direct_operand(©_size_offset) + .indirect_operand(&dest_offset) + .build(), + ), + operands: vec![ + AvmOperand::U16 { value: cd_offset.to_usize() as u16 }, + AvmOperand::U16 { value: copy_size_offset.to_usize() as u16 }, + AvmOperand::U16 { value: dest_offset.to_usize() as u16 }, + ], + ..Default::default() + }, + // Then we set the size of the slice, using the input size. + generate_mov_instruction( + Some( + AddressingModeBuilder::default() + .direct_operand(©_size_offset) + .direct_operand(&write_size_here_offset) + .build(), + ), + copy_size_offset.to_usize() as u32, + write_size_here_offset.to_usize() as u32, + ), + ]); +} + // #[oracle(avmOpcodeReturn)] // unconstrained fn return_opcode(returndata: [Field; N]) {} fn handle_return( @@ -1309,6 +1392,7 @@ fn handle_get_contract_instance( destinations: &Vec, inputs: &Vec, ) { + #[allow(non_camel_case_types)] enum ContractInstanceMember { DEPLOYER, CLASS_ID, @@ -1444,7 +1528,7 @@ pub fn patch_assert_message_pcs( /// This must be done before transpiling to properly transpile jump destinations. /// This is necessary for two reasons: /// 1. The transpiler injects `initial_offset` instructions at the beginning of the program. -/// 2. Some brillig instructions (_e.g._ Stop, or certain ForeignCalls) map to multiple AVM instructions +/// 2. Some brillig instructions map to multiple AVM instructions /// args: /// initial_offset: how many AVM instructions were inserted at the start of the program /// brillig: the Brillig program @@ -1456,6 +1540,11 @@ pub fn map_brillig_pcs_to_avm_pcs(brillig_bytecode: &[BrilligOpcode + { + 2 + } _ => 1, }; // next Brillig pc will map to an AVM pc offset by the diff --git a/barretenberg/cpp/pil/avm/main.pil b/barretenberg/cpp/pil/avm/main.pil index 6011fdda2f6..dc2d5f88507 100644 --- a/barretenberg/cpp/pil/avm/main.pil +++ b/barretenberg/cpp/pil/avm/main.pil @@ -95,6 +95,8 @@ namespace main(256); //===== Memory Slice Gadget Selectors ========================================= pol commit sel_op_calldata_copy; + pol commit sel_op_returndata_size; + pol commit sel_op_returndata_copy; pol commit sel_op_external_return; pol commit sel_op_external_revert; @@ -275,6 +277,8 @@ namespace main(256); sel_op_static_call * (1 - sel_op_static_call) = 0; sel_op_calldata_copy * (1 - sel_op_calldata_copy) = 0; + sel_op_returndata_size * (1 - sel_op_returndata_size) = 0; + sel_op_returndata_copy * (1 - sel_op_returndata_copy) = 0; sel_op_external_return * (1 - sel_op_external_return) = 0; sel_op_external_revert * (1 - sel_op_external_revert) = 0; @@ -409,7 +413,8 @@ namespace main(256); //===== CONTROL_FLOW_CONSISTENCY ============================================ pol SEL_ALL_CTRL_FLOW = sel_op_jump + sel_op_jumpi + sel_op_internal_call - + sel_op_internal_return + sel_op_external_call + sel_op_static_call + sel_op_external_return; + + sel_op_internal_return + sel_op_external_call + sel_op_static_call + + sel_op_external_return + sel_op_external_revert; pol SEL_ALU_R_TAG = sel_op_add + sel_op_sub + sel_op_mul + sel_op_div + sel_op_not + sel_op_eq + sel_op_lt + sel_op_lte + sel_op_shr + sel_op_shl; pol SEL_ALU_W_TAG = sel_op_cast; @@ -420,6 +425,7 @@ namespace main(256); + sel_op_ecadd + sel_op_msm; pol SEL_ALL_MEMORY = sel_op_mov + sel_op_set; pol OPCODE_SELECTORS = sel_op_fdiv + sel_op_calldata_copy + sel_op_get_contract_instance + + sel_op_returndata_size + sel_op_returndata_copy + SEL_ALL_ALU + SEL_ALL_BINARY + SEL_ALL_MEMORY + SEL_ALL_GADGET + KERNEL_INPUT_SELECTORS + KERNEL_OUTPUT_SELECTORS + SEL_ALL_LEFTGAS + SEL_ALL_CTRL_FLOW; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.cpp index 331b844159f..2b3453dce43 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/circuit_builder.cpp @@ -357,6 +357,8 @@ AvmCircuitBuilder::ProverPolynomials AvmCircuitBuilder::compute_polynomials() co polys.main_sel_op_or.set_if_valid_index(i, rows[i].main_sel_op_or); polys.main_sel_op_poseidon2.set_if_valid_index(i, rows[i].main_sel_op_poseidon2); polys.main_sel_op_radix_be.set_if_valid_index(i, rows[i].main_sel_op_radix_be); + polys.main_sel_op_returndata_copy.set_if_valid_index(i, rows[i].main_sel_op_returndata_copy); + polys.main_sel_op_returndata_size.set_if_valid_index(i, rows[i].main_sel_op_returndata_size); polys.main_sel_op_sender.set_if_valid_index(i, rows[i].main_sel_op_sender); polys.main_sel_op_set.set_if_valid_index(i, rows[i].main_sel_op_set); polys.main_sel_op_sha256.set_if_valid_index(i, rows[i].main_sel_op_sha256); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp index 3551642c096..aa153f0dc57 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.cpp @@ -255,581 +255,583 @@ AvmFlavor::AllConstRefValues::AllConstRefValues( , main_sel_op_or(il[247]) , main_sel_op_poseidon2(il[248]) , main_sel_op_radix_be(il[249]) - , main_sel_op_sender(il[250]) - , main_sel_op_set(il[251]) - , main_sel_op_sha256(il[252]) - , main_sel_op_shl(il[253]) - , main_sel_op_shr(il[254]) - , main_sel_op_sload(il[255]) - , main_sel_op_sstore(il[256]) - , main_sel_op_static_call(il[257]) - , main_sel_op_sub(il[258]) - , main_sel_op_timestamp(il[259]) - , main_sel_op_transaction_fee(il[260]) - , main_sel_op_version(il[261]) - , main_sel_op_xor(il[262]) - , main_sel_q_kernel_lookup(il[263]) - , main_sel_q_kernel_output_lookup(il[264]) - , main_sel_resolve_ind_addr_a(il[265]) - , main_sel_resolve_ind_addr_b(il[266]) - , main_sel_resolve_ind_addr_c(il[267]) - , main_sel_resolve_ind_addr_d(il[268]) - , main_sel_returndata(il[269]) - , main_sel_rng_16(il[270]) - , main_sel_rng_8(il[271]) - , main_sel_slice_gadget(il[272]) - , main_side_effect_counter(il[273]) - , main_sload_write_offset(il[274]) - , main_space_id(il[275]) - , main_sstore_write_offset(il[276]) - , main_tag_err(il[277]) - , main_w_in_tag(il[278]) - , mem_addr(il[279]) - , mem_clk(il[280]) - , mem_diff(il[281]) - , mem_glob_addr(il[282]) - , mem_last(il[283]) - , mem_lastAccess(il[284]) - , mem_one_min_inv(il[285]) - , mem_r_in_tag(il[286]) - , mem_rw(il[287]) - , mem_sel_mem(il[288]) - , mem_sel_mov_ia_to_ic(il[289]) - , mem_sel_mov_ib_to_ic(il[290]) - , mem_sel_op_a(il[291]) - , mem_sel_op_b(il[292]) - , mem_sel_op_c(il[293]) - , mem_sel_op_d(il[294]) - , mem_sel_op_poseidon_read_a(il[295]) - , mem_sel_op_poseidon_read_b(il[296]) - , mem_sel_op_poseidon_read_c(il[297]) - , mem_sel_op_poseidon_read_d(il[298]) - , mem_sel_op_poseidon_write_a(il[299]) - , mem_sel_op_poseidon_write_b(il[300]) - , mem_sel_op_poseidon_write_c(il[301]) - , mem_sel_op_poseidon_write_d(il[302]) - , mem_sel_op_slice(il[303]) - , mem_sel_resolve_ind_addr_a(il[304]) - , mem_sel_resolve_ind_addr_b(il[305]) - , mem_sel_resolve_ind_addr_c(il[306]) - , mem_sel_resolve_ind_addr_d(il[307]) - , mem_sel_rng_chk(il[308]) - , mem_skip_check_tag(il[309]) - , mem_space_id(il[310]) - , mem_tag(il[311]) - , mem_tag_err(il[312]) - , mem_tsp(il[313]) - , mem_val(il[314]) - , mem_w_in_tag(il[315]) - , merkle_tree_clk(il[316]) - , merkle_tree_expected_tree_root(il[317]) - , merkle_tree_latch(il[318]) - , merkle_tree_leaf_index(il[319]) - , merkle_tree_leaf_index_is_even(il[320]) - , merkle_tree_leaf_value(il[321]) - , merkle_tree_left_hash(il[322]) - , merkle_tree_output_hash(il[323]) - , merkle_tree_path_len(il[324]) - , merkle_tree_path_len_inv(il[325]) - , merkle_tree_right_hash(il[326]) - , merkle_tree_sel_merkle_tree(il[327]) - , merkle_tree_sibling_value(il[328]) - , poseidon2_B_10_0(il[329]) - , poseidon2_B_10_1(il[330]) - , poseidon2_B_10_2(il[331]) - , poseidon2_B_10_3(il[332]) - , poseidon2_B_11_0(il[333]) - , poseidon2_B_11_1(il[334]) - , poseidon2_B_11_2(il[335]) - , poseidon2_B_11_3(il[336]) - , poseidon2_B_12_0(il[337]) - , poseidon2_B_12_1(il[338]) - , poseidon2_B_12_2(il[339]) - , poseidon2_B_12_3(il[340]) - , poseidon2_B_13_0(il[341]) - , poseidon2_B_13_1(il[342]) - , poseidon2_B_13_2(il[343]) - , poseidon2_B_13_3(il[344]) - , poseidon2_B_14_0(il[345]) - , poseidon2_B_14_1(il[346]) - , poseidon2_B_14_2(il[347]) - , poseidon2_B_14_3(il[348]) - , poseidon2_B_15_0(il[349]) - , poseidon2_B_15_1(il[350]) - , poseidon2_B_15_2(il[351]) - , poseidon2_B_15_3(il[352]) - , poseidon2_B_16_0(il[353]) - , poseidon2_B_16_1(il[354]) - , poseidon2_B_16_2(il[355]) - , poseidon2_B_16_3(il[356]) - , poseidon2_B_17_0(il[357]) - , poseidon2_B_17_1(il[358]) - , poseidon2_B_17_2(il[359]) - , poseidon2_B_17_3(il[360]) - , poseidon2_B_18_0(il[361]) - , poseidon2_B_18_1(il[362]) - , poseidon2_B_18_2(il[363]) - , poseidon2_B_18_3(il[364]) - , poseidon2_B_19_0(il[365]) - , poseidon2_B_19_1(il[366]) - , poseidon2_B_19_2(il[367]) - , poseidon2_B_19_3(il[368]) - , poseidon2_B_20_0(il[369]) - , poseidon2_B_20_1(il[370]) - , poseidon2_B_20_2(il[371]) - , poseidon2_B_20_3(il[372]) - , poseidon2_B_21_0(il[373]) - , poseidon2_B_21_1(il[374]) - , poseidon2_B_21_2(il[375]) - , poseidon2_B_21_3(il[376]) - , poseidon2_B_22_0(il[377]) - , poseidon2_B_22_1(il[378]) - , poseidon2_B_22_2(il[379]) - , poseidon2_B_22_3(il[380]) - , poseidon2_B_23_0(il[381]) - , poseidon2_B_23_1(il[382]) - , poseidon2_B_23_2(il[383]) - , poseidon2_B_23_3(il[384]) - , poseidon2_B_24_0(il[385]) - , poseidon2_B_24_1(il[386]) - , poseidon2_B_24_2(il[387]) - , poseidon2_B_24_3(il[388]) - , poseidon2_B_25_0(il[389]) - , poseidon2_B_25_1(il[390]) - , poseidon2_B_25_2(il[391]) - , poseidon2_B_25_3(il[392]) - , poseidon2_B_26_0(il[393]) - , poseidon2_B_26_1(il[394]) - , poseidon2_B_26_2(il[395]) - , poseidon2_B_26_3(il[396]) - , poseidon2_B_27_0(il[397]) - , poseidon2_B_27_1(il[398]) - , poseidon2_B_27_2(il[399]) - , poseidon2_B_27_3(il[400]) - , poseidon2_B_28_0(il[401]) - , poseidon2_B_28_1(il[402]) - , poseidon2_B_28_2(il[403]) - , poseidon2_B_28_3(il[404]) - , poseidon2_B_29_0(il[405]) - , poseidon2_B_29_1(il[406]) - , poseidon2_B_29_2(il[407]) - , poseidon2_B_29_3(il[408]) - , poseidon2_B_30_0(il[409]) - , poseidon2_B_30_1(il[410]) - , poseidon2_B_30_2(il[411]) - , poseidon2_B_30_3(il[412]) - , poseidon2_B_31_0(il[413]) - , poseidon2_B_31_1(il[414]) - , poseidon2_B_31_2(il[415]) - , poseidon2_B_31_3(il[416]) - , poseidon2_B_32_0(il[417]) - , poseidon2_B_32_1(il[418]) - , poseidon2_B_32_2(il[419]) - , poseidon2_B_32_3(il[420]) - , poseidon2_B_33_0(il[421]) - , poseidon2_B_33_1(il[422]) - , poseidon2_B_33_2(il[423]) - , poseidon2_B_33_3(il[424]) - , poseidon2_B_34_0(il[425]) - , poseidon2_B_34_1(il[426]) - , poseidon2_B_34_2(il[427]) - , poseidon2_B_34_3(il[428]) - , poseidon2_B_35_0(il[429]) - , poseidon2_B_35_1(il[430]) - , poseidon2_B_35_2(il[431]) - , poseidon2_B_35_3(il[432]) - , poseidon2_B_36_0(il[433]) - , poseidon2_B_36_1(il[434]) - , poseidon2_B_36_2(il[435]) - , poseidon2_B_36_3(il[436]) - , poseidon2_B_37_0(il[437]) - , poseidon2_B_37_1(il[438]) - , poseidon2_B_37_2(il[439]) - , poseidon2_B_37_3(il[440]) - , poseidon2_B_38_0(il[441]) - , poseidon2_B_38_1(il[442]) - , poseidon2_B_38_2(il[443]) - , poseidon2_B_38_3(il[444]) - , poseidon2_B_39_0(il[445]) - , poseidon2_B_39_1(il[446]) - , poseidon2_B_39_2(il[447]) - , poseidon2_B_39_3(il[448]) - , poseidon2_B_40_0(il[449]) - , poseidon2_B_40_1(il[450]) - , poseidon2_B_40_2(il[451]) - , poseidon2_B_40_3(il[452]) - , poseidon2_B_41_0(il[453]) - , poseidon2_B_41_1(il[454]) - , poseidon2_B_41_2(il[455]) - , poseidon2_B_41_3(il[456]) - , poseidon2_B_42_0(il[457]) - , poseidon2_B_42_1(il[458]) - , poseidon2_B_42_2(il[459]) - , poseidon2_B_42_3(il[460]) - , poseidon2_B_43_0(il[461]) - , poseidon2_B_43_1(il[462]) - , poseidon2_B_43_2(il[463]) - , poseidon2_B_43_3(il[464]) - , poseidon2_B_44_0(il[465]) - , poseidon2_B_44_1(il[466]) - , poseidon2_B_44_2(il[467]) - , poseidon2_B_44_3(il[468]) - , poseidon2_B_45_0(il[469]) - , poseidon2_B_45_1(il[470]) - , poseidon2_B_45_2(il[471]) - , poseidon2_B_45_3(il[472]) - , poseidon2_B_46_0(il[473]) - , poseidon2_B_46_1(il[474]) - , poseidon2_B_46_2(il[475]) - , poseidon2_B_46_3(il[476]) - , poseidon2_B_47_0(il[477]) - , poseidon2_B_47_1(il[478]) - , poseidon2_B_47_2(il[479]) - , poseidon2_B_47_3(il[480]) - , poseidon2_B_48_0(il[481]) - , poseidon2_B_48_1(il[482]) - , poseidon2_B_48_2(il[483]) - , poseidon2_B_48_3(il[484]) - , poseidon2_B_49_0(il[485]) - , poseidon2_B_49_1(il[486]) - , poseidon2_B_49_2(il[487]) - , poseidon2_B_49_3(il[488]) - , poseidon2_B_4_0(il[489]) - , poseidon2_B_4_1(il[490]) - , poseidon2_B_4_2(il[491]) - , poseidon2_B_4_3(il[492]) - , poseidon2_B_50_0(il[493]) - , poseidon2_B_50_1(il[494]) - , poseidon2_B_50_2(il[495]) - , poseidon2_B_50_3(il[496]) - , poseidon2_B_51_0(il[497]) - , poseidon2_B_51_1(il[498]) - , poseidon2_B_51_2(il[499]) - , poseidon2_B_51_3(il[500]) - , poseidon2_B_52_0(il[501]) - , poseidon2_B_52_1(il[502]) - , poseidon2_B_52_2(il[503]) - , poseidon2_B_52_3(il[504]) - , poseidon2_B_53_0(il[505]) - , poseidon2_B_53_1(il[506]) - , poseidon2_B_53_2(il[507]) - , poseidon2_B_53_3(il[508]) - , poseidon2_B_54_0(il[509]) - , poseidon2_B_54_1(il[510]) - , poseidon2_B_54_2(il[511]) - , poseidon2_B_54_3(il[512]) - , poseidon2_B_55_0(il[513]) - , poseidon2_B_55_1(il[514]) - , poseidon2_B_55_2(il[515]) - , poseidon2_B_55_3(il[516]) - , poseidon2_B_56_0(il[517]) - , poseidon2_B_56_1(il[518]) - , poseidon2_B_56_2(il[519]) - , poseidon2_B_56_3(il[520]) - , poseidon2_B_57_0(il[521]) - , poseidon2_B_57_1(il[522]) - , poseidon2_B_57_2(il[523]) - , poseidon2_B_57_3(il[524]) - , poseidon2_B_58_0(il[525]) - , poseidon2_B_58_1(il[526]) - , poseidon2_B_58_2(il[527]) - , poseidon2_B_58_3(il[528]) - , poseidon2_B_59_0(il[529]) - , poseidon2_B_59_1(il[530]) - , poseidon2_B_59_2(il[531]) - , poseidon2_B_59_3(il[532]) - , poseidon2_B_5_0(il[533]) - , poseidon2_B_5_1(il[534]) - , poseidon2_B_5_2(il[535]) - , poseidon2_B_5_3(il[536]) - , poseidon2_B_6_0(il[537]) - , poseidon2_B_6_1(il[538]) - , poseidon2_B_6_2(il[539]) - , poseidon2_B_6_3(il[540]) - , poseidon2_B_7_0(il[541]) - , poseidon2_B_7_1(il[542]) - , poseidon2_B_7_2(il[543]) - , poseidon2_B_7_3(il[544]) - , poseidon2_B_8_0(il[545]) - , poseidon2_B_8_1(il[546]) - , poseidon2_B_8_2(il[547]) - , poseidon2_B_8_3(il[548]) - , poseidon2_B_9_0(il[549]) - , poseidon2_B_9_1(il[550]) - , poseidon2_B_9_2(il[551]) - , poseidon2_B_9_3(il[552]) - , poseidon2_EXT_LAYER_4(il[553]) - , poseidon2_EXT_LAYER_5(il[554]) - , poseidon2_EXT_LAYER_6(il[555]) - , poseidon2_EXT_LAYER_7(il[556]) - , poseidon2_T_0_4(il[557]) - , poseidon2_T_0_5(il[558]) - , poseidon2_T_0_6(il[559]) - , poseidon2_T_0_7(il[560]) - , poseidon2_T_1_4(il[561]) - , poseidon2_T_1_5(il[562]) - , poseidon2_T_1_6(il[563]) - , poseidon2_T_1_7(il[564]) - , poseidon2_T_2_4(il[565]) - , poseidon2_T_2_5(il[566]) - , poseidon2_T_2_6(il[567]) - , poseidon2_T_2_7(il[568]) - , poseidon2_T_3_4(il[569]) - , poseidon2_T_3_5(il[570]) - , poseidon2_T_3_6(il[571]) - , poseidon2_T_3_7(il[572]) - , poseidon2_T_60_4(il[573]) - , poseidon2_T_60_5(il[574]) - , poseidon2_T_60_6(il[575]) - , poseidon2_T_60_7(il[576]) - , poseidon2_T_61_4(il[577]) - , poseidon2_T_61_5(il[578]) - , poseidon2_T_61_6(il[579]) - , poseidon2_T_61_7(il[580]) - , poseidon2_T_62_4(il[581]) - , poseidon2_T_62_5(il[582]) - , poseidon2_T_62_6(il[583]) - , poseidon2_T_62_7(il[584]) - , poseidon2_T_63_4(il[585]) - , poseidon2_T_63_5(il[586]) - , poseidon2_T_63_6(il[587]) - , poseidon2_T_63_7(il[588]) - , poseidon2_a_0(il[589]) - , poseidon2_a_1(il[590]) - , poseidon2_a_2(il[591]) - , poseidon2_a_3(il[592]) - , poseidon2_b_0(il[593]) - , poseidon2_b_1(il[594]) - , poseidon2_b_2(il[595]) - , poseidon2_b_3(il[596]) - , poseidon2_clk(il[597]) - , poseidon2_full_a_0(il[598]) - , poseidon2_full_a_1(il[599]) - , poseidon2_full_a_2(il[600]) - , poseidon2_full_a_3(il[601]) - , poseidon2_full_b_0(il[602]) - , poseidon2_full_b_1(il[603]) - , poseidon2_full_b_2(il[604]) - , poseidon2_full_b_3(il[605]) - , poseidon2_full_clk(il[606]) - , poseidon2_full_end_poseidon(il[607]) - , poseidon2_full_execute_poseidon_perm(il[608]) - , poseidon2_full_input_0(il[609]) - , poseidon2_full_input_1(il[610]) - , poseidon2_full_input_2(il[611]) - , poseidon2_full_input_len(il[612]) - , poseidon2_full_num_perm_rounds_rem(il[613]) - , poseidon2_full_num_perm_rounds_rem_inv(il[614]) - , poseidon2_full_output(il[615]) - , poseidon2_full_padding(il[616]) - , poseidon2_full_sel_merkle_tree(il[617]) - , poseidon2_full_sel_poseidon(il[618]) - , poseidon2_full_start_poseidon(il[619]) - , poseidon2_input_addr(il[620]) - , poseidon2_mem_addr_read_a(il[621]) - , poseidon2_mem_addr_read_b(il[622]) - , poseidon2_mem_addr_read_c(il[623]) - , poseidon2_mem_addr_read_d(il[624]) - , poseidon2_mem_addr_write_a(il[625]) - , poseidon2_mem_addr_write_b(il[626]) - , poseidon2_mem_addr_write_c(il[627]) - , poseidon2_mem_addr_write_d(il[628]) - , poseidon2_output_addr(il[629]) - , poseidon2_sel_poseidon_perm(il[630]) - , poseidon2_sel_poseidon_perm_immediate(il[631]) - , poseidon2_sel_poseidon_perm_mem_op(il[632]) - , poseidon2_space_id(il[633]) - , range_check_alu_rng_chk(il[634]) - , range_check_clk(il[635]) - , range_check_cmp_hi_bits_rng_chk(il[636]) - , range_check_cmp_lo_bits_rng_chk(il[637]) - , range_check_dyn_diff(il[638]) - , range_check_dyn_rng_chk_bits(il[639]) - , range_check_dyn_rng_chk_pow_2(il[640]) - , range_check_gas_da_rng_chk(il[641]) - , range_check_gas_l2_rng_chk(il[642]) - , range_check_is_lte_u112(il[643]) - , range_check_is_lte_u128(il[644]) - , range_check_is_lte_u16(il[645]) - , range_check_is_lte_u32(il[646]) - , range_check_is_lte_u48(il[647]) - , range_check_is_lte_u64(il[648]) - , range_check_is_lte_u80(il[649]) - , range_check_is_lte_u96(il[650]) - , range_check_mem_rng_chk(il[651]) - , range_check_rng_chk_bits(il[652]) - , range_check_sel_lookup_0(il[653]) - , range_check_sel_lookup_1(il[654]) - , range_check_sel_lookup_2(il[655]) - , range_check_sel_lookup_3(il[656]) - , range_check_sel_lookup_4(il[657]) - , range_check_sel_lookup_5(il[658]) - , range_check_sel_lookup_6(il[659]) - , range_check_sel_rng_chk(il[660]) - , range_check_u16_r0(il[661]) - , range_check_u16_r1(il[662]) - , range_check_u16_r2(il[663]) - , range_check_u16_r3(il[664]) - , range_check_u16_r4(il[665]) - , range_check_u16_r5(il[666]) - , range_check_u16_r6(il[667]) - , range_check_u16_r7(il[668]) - , range_check_value(il[669]) - , sha256_clk(il[670]) - , sha256_input(il[671]) - , sha256_output(il[672]) - , sha256_sel_sha256_compression(il[673]) - , sha256_state(il[674]) - , slice_addr(il[675]) - , slice_clk(il[676]) - , slice_cnt(il[677]) - , slice_col_offset(il[678]) - , slice_one_min_inv(il[679]) - , slice_sel_cd_cpy(il[680]) - , slice_sel_mem_active(il[681]) - , slice_sel_return(il[682]) - , slice_sel_start(il[683]) - , slice_space_id(il[684]) - , slice_val(il[685]) - , lookup_rng_chk_pow_2_counts(il[686]) - , lookup_rng_chk_diff_counts(il[687]) - , lookup_rng_chk_0_counts(il[688]) - , lookup_rng_chk_1_counts(il[689]) - , lookup_rng_chk_2_counts(il[690]) - , lookup_rng_chk_3_counts(il[691]) - , lookup_rng_chk_4_counts(il[692]) - , lookup_rng_chk_5_counts(il[693]) - , lookup_rng_chk_6_counts(il[694]) - , lookup_rng_chk_7_counts(il[695]) - , lookup_pow_2_0_counts(il[696]) - , lookup_pow_2_1_counts(il[697]) - , lookup_byte_lengths_counts(il[698]) - , lookup_byte_operations_counts(il[699]) - , lookup_opcode_gas_counts(il[700]) - , kernel_output_lookup_counts(il[701]) - , lookup_into_kernel_counts(il[702]) - , lookup_cd_value_counts(il[703]) - , lookup_ret_value_counts(il[704]) - , incl_main_tag_err_counts(il[705]) - , incl_mem_tag_err_counts(il[706]) - , perm_rng_mem_inv(il[707]) - , perm_rng_cmp_lo_inv(il[708]) - , perm_rng_cmp_hi_inv(il[709]) - , perm_rng_alu_inv(il[710]) - , perm_cmp_alu_inv(il[711]) - , perm_rng_gas_l2_inv(il[712]) - , perm_rng_gas_da_inv(il[713]) - , perm_l2_start_gas_inv(il[714]) - , perm_da_start_gas_inv(il[715]) - , perm_l2_end_gas_inv(il[716]) - , perm_da_end_gas_inv(il[717]) - , perm_pos_mem_read_a_inv(il[718]) - , perm_pos_mem_read_b_inv(il[719]) - , perm_pos_mem_read_c_inv(il[720]) - , perm_pos_mem_read_d_inv(il[721]) - , perm_pos_mem_write_a_inv(il[722]) - , perm_pos_mem_write_b_inv(il[723]) - , perm_pos_mem_write_c_inv(il[724]) - , perm_pos_mem_write_d_inv(il[725]) - , perm_pos2_fixed_pos2_perm_inv(il[726]) - , perm_slice_mem_inv(il[727]) - , perm_merkle_poseidon2_inv(il[728]) - , perm_main_alu_inv(il[729]) - , perm_main_bin_inv(il[730]) - , perm_main_conv_inv(il[731]) - , perm_main_sha256_inv(il[732]) - , perm_main_pos2_perm_inv(il[733]) - , perm_main_slice_inv(il[734]) - , perm_main_mem_a_inv(il[735]) - , perm_main_mem_b_inv(il[736]) - , perm_main_mem_c_inv(il[737]) - , perm_main_mem_d_inv(il[738]) - , perm_main_mem_ind_addr_a_inv(il[739]) - , perm_main_mem_ind_addr_b_inv(il[740]) - , perm_main_mem_ind_addr_c_inv(il[741]) - , perm_main_mem_ind_addr_d_inv(il[742]) - , lookup_rng_chk_pow_2_inv(il[743]) - , lookup_rng_chk_diff_inv(il[744]) - , lookup_rng_chk_0_inv(il[745]) - , lookup_rng_chk_1_inv(il[746]) - , lookup_rng_chk_2_inv(il[747]) - , lookup_rng_chk_3_inv(il[748]) - , lookup_rng_chk_4_inv(il[749]) - , lookup_rng_chk_5_inv(il[750]) - , lookup_rng_chk_6_inv(il[751]) - , lookup_rng_chk_7_inv(il[752]) - , lookup_pow_2_0_inv(il[753]) - , lookup_pow_2_1_inv(il[754]) - , lookup_byte_lengths_inv(il[755]) - , lookup_byte_operations_inv(il[756]) - , lookup_opcode_gas_inv(il[757]) - , kernel_output_lookup_inv(il[758]) - , lookup_into_kernel_inv(il[759]) - , lookup_cd_value_inv(il[760]) - , lookup_ret_value_inv(il[761]) - , incl_main_tag_err_inv(il[762]) - , incl_mem_tag_err_inv(il[763]) - , binary_acc_ia_shift(il[764]) - , binary_acc_ib_shift(il[765]) - , binary_acc_ic_shift(il[766]) - , binary_mem_tag_ctr_shift(il[767]) - , binary_op_id_shift(il[768]) - , cmp_a_hi_shift(il[769]) - , cmp_a_lo_shift(il[770]) - , cmp_b_hi_shift(il[771]) - , cmp_b_lo_shift(il[772]) - , cmp_cmp_rng_ctr_shift(il[773]) - , cmp_op_gt_shift(il[774]) - , cmp_p_sub_a_hi_shift(il[775]) - , cmp_p_sub_a_lo_shift(il[776]) - , cmp_p_sub_b_hi_shift(il[777]) - , cmp_p_sub_b_lo_shift(il[778]) - , cmp_sel_rng_chk_shift(il[779]) - , main_da_gas_remaining_shift(il[780]) - , main_emit_l2_to_l1_msg_write_offset_shift(il[781]) - , main_emit_note_hash_write_offset_shift(il[782]) - , main_emit_nullifier_write_offset_shift(il[783]) - , main_emit_unencrypted_log_write_offset_shift(il[784]) - , main_internal_return_ptr_shift(il[785]) - , main_l1_to_l2_msg_exists_write_offset_shift(il[786]) - , main_l2_gas_remaining_shift(il[787]) - , main_note_hash_exist_write_offset_shift(il[788]) - , main_nullifier_exists_write_offset_shift(il[789]) - , main_nullifier_non_exists_write_offset_shift(il[790]) - , main_pc_shift(il[791]) - , main_sel_execution_end_shift(il[792]) - , main_sel_execution_row_shift(il[793]) - , main_sload_write_offset_shift(il[794]) - , main_sstore_write_offset_shift(il[795]) - , mem_glob_addr_shift(il[796]) - , mem_rw_shift(il[797]) - , mem_sel_mem_shift(il[798]) - , mem_tag_shift(il[799]) - , mem_tsp_shift(il[800]) - , mem_val_shift(il[801]) - , merkle_tree_leaf_index_shift(il[802]) - , merkle_tree_leaf_value_shift(il[803]) - , merkle_tree_path_len_shift(il[804]) - , poseidon2_full_a_0_shift(il[805]) - , poseidon2_full_a_1_shift(il[806]) - , poseidon2_full_a_2_shift(il[807]) - , poseidon2_full_a_3_shift(il[808]) - , poseidon2_full_execute_poseidon_perm_shift(il[809]) - , poseidon2_full_input_0_shift(il[810]) - , poseidon2_full_input_1_shift(il[811]) - , poseidon2_full_input_2_shift(il[812]) - , poseidon2_full_num_perm_rounds_rem_shift(il[813]) - , poseidon2_full_sel_poseidon_shift(il[814]) - , poseidon2_full_start_poseidon_shift(il[815]) - , slice_addr_shift(il[816]) - , slice_clk_shift(il[817]) - , slice_cnt_shift(il[818]) - , slice_col_offset_shift(il[819]) - , slice_sel_cd_cpy_shift(il[820]) - , slice_sel_mem_active_shift(il[821]) - , slice_sel_return_shift(il[822]) - , slice_sel_start_shift(il[823]) - , slice_space_id_shift(il[824]) + , main_sel_op_returndata_copy(il[250]) + , main_sel_op_returndata_size(il[251]) + , main_sel_op_sender(il[252]) + , main_sel_op_set(il[253]) + , main_sel_op_sha256(il[254]) + , main_sel_op_shl(il[255]) + , main_sel_op_shr(il[256]) + , main_sel_op_sload(il[257]) + , main_sel_op_sstore(il[258]) + , main_sel_op_static_call(il[259]) + , main_sel_op_sub(il[260]) + , main_sel_op_timestamp(il[261]) + , main_sel_op_transaction_fee(il[262]) + , main_sel_op_version(il[263]) + , main_sel_op_xor(il[264]) + , main_sel_q_kernel_lookup(il[265]) + , main_sel_q_kernel_output_lookup(il[266]) + , main_sel_resolve_ind_addr_a(il[267]) + , main_sel_resolve_ind_addr_b(il[268]) + , main_sel_resolve_ind_addr_c(il[269]) + , main_sel_resolve_ind_addr_d(il[270]) + , main_sel_returndata(il[271]) + , main_sel_rng_16(il[272]) + , main_sel_rng_8(il[273]) + , main_sel_slice_gadget(il[274]) + , main_side_effect_counter(il[275]) + , main_sload_write_offset(il[276]) + , main_space_id(il[277]) + , main_sstore_write_offset(il[278]) + , main_tag_err(il[279]) + , main_w_in_tag(il[280]) + , mem_addr(il[281]) + , mem_clk(il[282]) + , mem_diff(il[283]) + , mem_glob_addr(il[284]) + , mem_last(il[285]) + , mem_lastAccess(il[286]) + , mem_one_min_inv(il[287]) + , mem_r_in_tag(il[288]) + , mem_rw(il[289]) + , mem_sel_mem(il[290]) + , mem_sel_mov_ia_to_ic(il[291]) + , mem_sel_mov_ib_to_ic(il[292]) + , mem_sel_op_a(il[293]) + , mem_sel_op_b(il[294]) + , mem_sel_op_c(il[295]) + , mem_sel_op_d(il[296]) + , mem_sel_op_poseidon_read_a(il[297]) + , mem_sel_op_poseidon_read_b(il[298]) + , mem_sel_op_poseidon_read_c(il[299]) + , mem_sel_op_poseidon_read_d(il[300]) + , mem_sel_op_poseidon_write_a(il[301]) + , mem_sel_op_poseidon_write_b(il[302]) + , mem_sel_op_poseidon_write_c(il[303]) + , mem_sel_op_poseidon_write_d(il[304]) + , mem_sel_op_slice(il[305]) + , mem_sel_resolve_ind_addr_a(il[306]) + , mem_sel_resolve_ind_addr_b(il[307]) + , mem_sel_resolve_ind_addr_c(il[308]) + , mem_sel_resolve_ind_addr_d(il[309]) + , mem_sel_rng_chk(il[310]) + , mem_skip_check_tag(il[311]) + , mem_space_id(il[312]) + , mem_tag(il[313]) + , mem_tag_err(il[314]) + , mem_tsp(il[315]) + , mem_val(il[316]) + , mem_w_in_tag(il[317]) + , merkle_tree_clk(il[318]) + , merkle_tree_expected_tree_root(il[319]) + , merkle_tree_latch(il[320]) + , merkle_tree_leaf_index(il[321]) + , merkle_tree_leaf_index_is_even(il[322]) + , merkle_tree_leaf_value(il[323]) + , merkle_tree_left_hash(il[324]) + , merkle_tree_output_hash(il[325]) + , merkle_tree_path_len(il[326]) + , merkle_tree_path_len_inv(il[327]) + , merkle_tree_right_hash(il[328]) + , merkle_tree_sel_merkle_tree(il[329]) + , merkle_tree_sibling_value(il[330]) + , poseidon2_B_10_0(il[331]) + , poseidon2_B_10_1(il[332]) + , poseidon2_B_10_2(il[333]) + , poseidon2_B_10_3(il[334]) + , poseidon2_B_11_0(il[335]) + , poseidon2_B_11_1(il[336]) + , poseidon2_B_11_2(il[337]) + , poseidon2_B_11_3(il[338]) + , poseidon2_B_12_0(il[339]) + , poseidon2_B_12_1(il[340]) + , poseidon2_B_12_2(il[341]) + , poseidon2_B_12_3(il[342]) + , poseidon2_B_13_0(il[343]) + , poseidon2_B_13_1(il[344]) + , poseidon2_B_13_2(il[345]) + , poseidon2_B_13_3(il[346]) + , poseidon2_B_14_0(il[347]) + , poseidon2_B_14_1(il[348]) + , poseidon2_B_14_2(il[349]) + , poseidon2_B_14_3(il[350]) + , poseidon2_B_15_0(il[351]) + , poseidon2_B_15_1(il[352]) + , poseidon2_B_15_2(il[353]) + , poseidon2_B_15_3(il[354]) + , poseidon2_B_16_0(il[355]) + , poseidon2_B_16_1(il[356]) + , poseidon2_B_16_2(il[357]) + , poseidon2_B_16_3(il[358]) + , poseidon2_B_17_0(il[359]) + , poseidon2_B_17_1(il[360]) + , poseidon2_B_17_2(il[361]) + , poseidon2_B_17_3(il[362]) + , poseidon2_B_18_0(il[363]) + , poseidon2_B_18_1(il[364]) + , poseidon2_B_18_2(il[365]) + , poseidon2_B_18_3(il[366]) + , poseidon2_B_19_0(il[367]) + , poseidon2_B_19_1(il[368]) + , poseidon2_B_19_2(il[369]) + , poseidon2_B_19_3(il[370]) + , poseidon2_B_20_0(il[371]) + , poseidon2_B_20_1(il[372]) + , poseidon2_B_20_2(il[373]) + , poseidon2_B_20_3(il[374]) + , poseidon2_B_21_0(il[375]) + , poseidon2_B_21_1(il[376]) + , poseidon2_B_21_2(il[377]) + , poseidon2_B_21_3(il[378]) + , poseidon2_B_22_0(il[379]) + , poseidon2_B_22_1(il[380]) + , poseidon2_B_22_2(il[381]) + , poseidon2_B_22_3(il[382]) + , poseidon2_B_23_0(il[383]) + , poseidon2_B_23_1(il[384]) + , poseidon2_B_23_2(il[385]) + , poseidon2_B_23_3(il[386]) + , poseidon2_B_24_0(il[387]) + , poseidon2_B_24_1(il[388]) + , poseidon2_B_24_2(il[389]) + , poseidon2_B_24_3(il[390]) + , poseidon2_B_25_0(il[391]) + , poseidon2_B_25_1(il[392]) + , poseidon2_B_25_2(il[393]) + , poseidon2_B_25_3(il[394]) + , poseidon2_B_26_0(il[395]) + , poseidon2_B_26_1(il[396]) + , poseidon2_B_26_2(il[397]) + , poseidon2_B_26_3(il[398]) + , poseidon2_B_27_0(il[399]) + , poseidon2_B_27_1(il[400]) + , poseidon2_B_27_2(il[401]) + , poseidon2_B_27_3(il[402]) + , poseidon2_B_28_0(il[403]) + , poseidon2_B_28_1(il[404]) + , poseidon2_B_28_2(il[405]) + , poseidon2_B_28_3(il[406]) + , poseidon2_B_29_0(il[407]) + , poseidon2_B_29_1(il[408]) + , poseidon2_B_29_2(il[409]) + , poseidon2_B_29_3(il[410]) + , poseidon2_B_30_0(il[411]) + , poseidon2_B_30_1(il[412]) + , poseidon2_B_30_2(il[413]) + , poseidon2_B_30_3(il[414]) + , poseidon2_B_31_0(il[415]) + , poseidon2_B_31_1(il[416]) + , poseidon2_B_31_2(il[417]) + , poseidon2_B_31_3(il[418]) + , poseidon2_B_32_0(il[419]) + , poseidon2_B_32_1(il[420]) + , poseidon2_B_32_2(il[421]) + , poseidon2_B_32_3(il[422]) + , poseidon2_B_33_0(il[423]) + , poseidon2_B_33_1(il[424]) + , poseidon2_B_33_2(il[425]) + , poseidon2_B_33_3(il[426]) + , poseidon2_B_34_0(il[427]) + , poseidon2_B_34_1(il[428]) + , poseidon2_B_34_2(il[429]) + , poseidon2_B_34_3(il[430]) + , poseidon2_B_35_0(il[431]) + , poseidon2_B_35_1(il[432]) + , poseidon2_B_35_2(il[433]) + , poseidon2_B_35_3(il[434]) + , poseidon2_B_36_0(il[435]) + , poseidon2_B_36_1(il[436]) + , poseidon2_B_36_2(il[437]) + , poseidon2_B_36_3(il[438]) + , poseidon2_B_37_0(il[439]) + , poseidon2_B_37_1(il[440]) + , poseidon2_B_37_2(il[441]) + , poseidon2_B_37_3(il[442]) + , poseidon2_B_38_0(il[443]) + , poseidon2_B_38_1(il[444]) + , poseidon2_B_38_2(il[445]) + , poseidon2_B_38_3(il[446]) + , poseidon2_B_39_0(il[447]) + , poseidon2_B_39_1(il[448]) + , poseidon2_B_39_2(il[449]) + , poseidon2_B_39_3(il[450]) + , poseidon2_B_40_0(il[451]) + , poseidon2_B_40_1(il[452]) + , poseidon2_B_40_2(il[453]) + , poseidon2_B_40_3(il[454]) + , poseidon2_B_41_0(il[455]) + , poseidon2_B_41_1(il[456]) + , poseidon2_B_41_2(il[457]) + , poseidon2_B_41_3(il[458]) + , poseidon2_B_42_0(il[459]) + , poseidon2_B_42_1(il[460]) + , poseidon2_B_42_2(il[461]) + , poseidon2_B_42_3(il[462]) + , poseidon2_B_43_0(il[463]) + , poseidon2_B_43_1(il[464]) + , poseidon2_B_43_2(il[465]) + , poseidon2_B_43_3(il[466]) + , poseidon2_B_44_0(il[467]) + , poseidon2_B_44_1(il[468]) + , poseidon2_B_44_2(il[469]) + , poseidon2_B_44_3(il[470]) + , poseidon2_B_45_0(il[471]) + , poseidon2_B_45_1(il[472]) + , poseidon2_B_45_2(il[473]) + , poseidon2_B_45_3(il[474]) + , poseidon2_B_46_0(il[475]) + , poseidon2_B_46_1(il[476]) + , poseidon2_B_46_2(il[477]) + , poseidon2_B_46_3(il[478]) + , poseidon2_B_47_0(il[479]) + , poseidon2_B_47_1(il[480]) + , poseidon2_B_47_2(il[481]) + , poseidon2_B_47_3(il[482]) + , poseidon2_B_48_0(il[483]) + , poseidon2_B_48_1(il[484]) + , poseidon2_B_48_2(il[485]) + , poseidon2_B_48_3(il[486]) + , poseidon2_B_49_0(il[487]) + , poseidon2_B_49_1(il[488]) + , poseidon2_B_49_2(il[489]) + , poseidon2_B_49_3(il[490]) + , poseidon2_B_4_0(il[491]) + , poseidon2_B_4_1(il[492]) + , poseidon2_B_4_2(il[493]) + , poseidon2_B_4_3(il[494]) + , poseidon2_B_50_0(il[495]) + , poseidon2_B_50_1(il[496]) + , poseidon2_B_50_2(il[497]) + , poseidon2_B_50_3(il[498]) + , poseidon2_B_51_0(il[499]) + , poseidon2_B_51_1(il[500]) + , poseidon2_B_51_2(il[501]) + , poseidon2_B_51_3(il[502]) + , poseidon2_B_52_0(il[503]) + , poseidon2_B_52_1(il[504]) + , poseidon2_B_52_2(il[505]) + , poseidon2_B_52_3(il[506]) + , poseidon2_B_53_0(il[507]) + , poseidon2_B_53_1(il[508]) + , poseidon2_B_53_2(il[509]) + , poseidon2_B_53_3(il[510]) + , poseidon2_B_54_0(il[511]) + , poseidon2_B_54_1(il[512]) + , poseidon2_B_54_2(il[513]) + , poseidon2_B_54_3(il[514]) + , poseidon2_B_55_0(il[515]) + , poseidon2_B_55_1(il[516]) + , poseidon2_B_55_2(il[517]) + , poseidon2_B_55_3(il[518]) + , poseidon2_B_56_0(il[519]) + , poseidon2_B_56_1(il[520]) + , poseidon2_B_56_2(il[521]) + , poseidon2_B_56_3(il[522]) + , poseidon2_B_57_0(il[523]) + , poseidon2_B_57_1(il[524]) + , poseidon2_B_57_2(il[525]) + , poseidon2_B_57_3(il[526]) + , poseidon2_B_58_0(il[527]) + , poseidon2_B_58_1(il[528]) + , poseidon2_B_58_2(il[529]) + , poseidon2_B_58_3(il[530]) + , poseidon2_B_59_0(il[531]) + , poseidon2_B_59_1(il[532]) + , poseidon2_B_59_2(il[533]) + , poseidon2_B_59_3(il[534]) + , poseidon2_B_5_0(il[535]) + , poseidon2_B_5_1(il[536]) + , poseidon2_B_5_2(il[537]) + , poseidon2_B_5_3(il[538]) + , poseidon2_B_6_0(il[539]) + , poseidon2_B_6_1(il[540]) + , poseidon2_B_6_2(il[541]) + , poseidon2_B_6_3(il[542]) + , poseidon2_B_7_0(il[543]) + , poseidon2_B_7_1(il[544]) + , poseidon2_B_7_2(il[545]) + , poseidon2_B_7_3(il[546]) + , poseidon2_B_8_0(il[547]) + , poseidon2_B_8_1(il[548]) + , poseidon2_B_8_2(il[549]) + , poseidon2_B_8_3(il[550]) + , poseidon2_B_9_0(il[551]) + , poseidon2_B_9_1(il[552]) + , poseidon2_B_9_2(il[553]) + , poseidon2_B_9_3(il[554]) + , poseidon2_EXT_LAYER_4(il[555]) + , poseidon2_EXT_LAYER_5(il[556]) + , poseidon2_EXT_LAYER_6(il[557]) + , poseidon2_EXT_LAYER_7(il[558]) + , poseidon2_T_0_4(il[559]) + , poseidon2_T_0_5(il[560]) + , poseidon2_T_0_6(il[561]) + , poseidon2_T_0_7(il[562]) + , poseidon2_T_1_4(il[563]) + , poseidon2_T_1_5(il[564]) + , poseidon2_T_1_6(il[565]) + , poseidon2_T_1_7(il[566]) + , poseidon2_T_2_4(il[567]) + , poseidon2_T_2_5(il[568]) + , poseidon2_T_2_6(il[569]) + , poseidon2_T_2_7(il[570]) + , poseidon2_T_3_4(il[571]) + , poseidon2_T_3_5(il[572]) + , poseidon2_T_3_6(il[573]) + , poseidon2_T_3_7(il[574]) + , poseidon2_T_60_4(il[575]) + , poseidon2_T_60_5(il[576]) + , poseidon2_T_60_6(il[577]) + , poseidon2_T_60_7(il[578]) + , poseidon2_T_61_4(il[579]) + , poseidon2_T_61_5(il[580]) + , poseidon2_T_61_6(il[581]) + , poseidon2_T_61_7(il[582]) + , poseidon2_T_62_4(il[583]) + , poseidon2_T_62_5(il[584]) + , poseidon2_T_62_6(il[585]) + , poseidon2_T_62_7(il[586]) + , poseidon2_T_63_4(il[587]) + , poseidon2_T_63_5(il[588]) + , poseidon2_T_63_6(il[589]) + , poseidon2_T_63_7(il[590]) + , poseidon2_a_0(il[591]) + , poseidon2_a_1(il[592]) + , poseidon2_a_2(il[593]) + , poseidon2_a_3(il[594]) + , poseidon2_b_0(il[595]) + , poseidon2_b_1(il[596]) + , poseidon2_b_2(il[597]) + , poseidon2_b_3(il[598]) + , poseidon2_clk(il[599]) + , poseidon2_full_a_0(il[600]) + , poseidon2_full_a_1(il[601]) + , poseidon2_full_a_2(il[602]) + , poseidon2_full_a_3(il[603]) + , poseidon2_full_b_0(il[604]) + , poseidon2_full_b_1(il[605]) + , poseidon2_full_b_2(il[606]) + , poseidon2_full_b_3(il[607]) + , poseidon2_full_clk(il[608]) + , poseidon2_full_end_poseidon(il[609]) + , poseidon2_full_execute_poseidon_perm(il[610]) + , poseidon2_full_input_0(il[611]) + , poseidon2_full_input_1(il[612]) + , poseidon2_full_input_2(il[613]) + , poseidon2_full_input_len(il[614]) + , poseidon2_full_num_perm_rounds_rem(il[615]) + , poseidon2_full_num_perm_rounds_rem_inv(il[616]) + , poseidon2_full_output(il[617]) + , poseidon2_full_padding(il[618]) + , poseidon2_full_sel_merkle_tree(il[619]) + , poseidon2_full_sel_poseidon(il[620]) + , poseidon2_full_start_poseidon(il[621]) + , poseidon2_input_addr(il[622]) + , poseidon2_mem_addr_read_a(il[623]) + , poseidon2_mem_addr_read_b(il[624]) + , poseidon2_mem_addr_read_c(il[625]) + , poseidon2_mem_addr_read_d(il[626]) + , poseidon2_mem_addr_write_a(il[627]) + , poseidon2_mem_addr_write_b(il[628]) + , poseidon2_mem_addr_write_c(il[629]) + , poseidon2_mem_addr_write_d(il[630]) + , poseidon2_output_addr(il[631]) + , poseidon2_sel_poseidon_perm(il[632]) + , poseidon2_sel_poseidon_perm_immediate(il[633]) + , poseidon2_sel_poseidon_perm_mem_op(il[634]) + , poseidon2_space_id(il[635]) + , range_check_alu_rng_chk(il[636]) + , range_check_clk(il[637]) + , range_check_cmp_hi_bits_rng_chk(il[638]) + , range_check_cmp_lo_bits_rng_chk(il[639]) + , range_check_dyn_diff(il[640]) + , range_check_dyn_rng_chk_bits(il[641]) + , range_check_dyn_rng_chk_pow_2(il[642]) + , range_check_gas_da_rng_chk(il[643]) + , range_check_gas_l2_rng_chk(il[644]) + , range_check_is_lte_u112(il[645]) + , range_check_is_lte_u128(il[646]) + , range_check_is_lte_u16(il[647]) + , range_check_is_lte_u32(il[648]) + , range_check_is_lte_u48(il[649]) + , range_check_is_lte_u64(il[650]) + , range_check_is_lte_u80(il[651]) + , range_check_is_lte_u96(il[652]) + , range_check_mem_rng_chk(il[653]) + , range_check_rng_chk_bits(il[654]) + , range_check_sel_lookup_0(il[655]) + , range_check_sel_lookup_1(il[656]) + , range_check_sel_lookup_2(il[657]) + , range_check_sel_lookup_3(il[658]) + , range_check_sel_lookup_4(il[659]) + , range_check_sel_lookup_5(il[660]) + , range_check_sel_lookup_6(il[661]) + , range_check_sel_rng_chk(il[662]) + , range_check_u16_r0(il[663]) + , range_check_u16_r1(il[664]) + , range_check_u16_r2(il[665]) + , range_check_u16_r3(il[666]) + , range_check_u16_r4(il[667]) + , range_check_u16_r5(il[668]) + , range_check_u16_r6(il[669]) + , range_check_u16_r7(il[670]) + , range_check_value(il[671]) + , sha256_clk(il[672]) + , sha256_input(il[673]) + , sha256_output(il[674]) + , sha256_sel_sha256_compression(il[675]) + , sha256_state(il[676]) + , slice_addr(il[677]) + , slice_clk(il[678]) + , slice_cnt(il[679]) + , slice_col_offset(il[680]) + , slice_one_min_inv(il[681]) + , slice_sel_cd_cpy(il[682]) + , slice_sel_mem_active(il[683]) + , slice_sel_return(il[684]) + , slice_sel_start(il[685]) + , slice_space_id(il[686]) + , slice_val(il[687]) + , lookup_rng_chk_pow_2_counts(il[688]) + , lookup_rng_chk_diff_counts(il[689]) + , lookup_rng_chk_0_counts(il[690]) + , lookup_rng_chk_1_counts(il[691]) + , lookup_rng_chk_2_counts(il[692]) + , lookup_rng_chk_3_counts(il[693]) + , lookup_rng_chk_4_counts(il[694]) + , lookup_rng_chk_5_counts(il[695]) + , lookup_rng_chk_6_counts(il[696]) + , lookup_rng_chk_7_counts(il[697]) + , lookup_pow_2_0_counts(il[698]) + , lookup_pow_2_1_counts(il[699]) + , lookup_byte_lengths_counts(il[700]) + , lookup_byte_operations_counts(il[701]) + , lookup_opcode_gas_counts(il[702]) + , kernel_output_lookup_counts(il[703]) + , lookup_into_kernel_counts(il[704]) + , lookup_cd_value_counts(il[705]) + , lookup_ret_value_counts(il[706]) + , incl_main_tag_err_counts(il[707]) + , incl_mem_tag_err_counts(il[708]) + , perm_rng_mem_inv(il[709]) + , perm_rng_cmp_lo_inv(il[710]) + , perm_rng_cmp_hi_inv(il[711]) + , perm_rng_alu_inv(il[712]) + , perm_cmp_alu_inv(il[713]) + , perm_rng_gas_l2_inv(il[714]) + , perm_rng_gas_da_inv(il[715]) + , perm_l2_start_gas_inv(il[716]) + , perm_da_start_gas_inv(il[717]) + , perm_l2_end_gas_inv(il[718]) + , perm_da_end_gas_inv(il[719]) + , perm_pos_mem_read_a_inv(il[720]) + , perm_pos_mem_read_b_inv(il[721]) + , perm_pos_mem_read_c_inv(il[722]) + , perm_pos_mem_read_d_inv(il[723]) + , perm_pos_mem_write_a_inv(il[724]) + , perm_pos_mem_write_b_inv(il[725]) + , perm_pos_mem_write_c_inv(il[726]) + , perm_pos_mem_write_d_inv(il[727]) + , perm_pos2_fixed_pos2_perm_inv(il[728]) + , perm_slice_mem_inv(il[729]) + , perm_merkle_poseidon2_inv(il[730]) + , perm_main_alu_inv(il[731]) + , perm_main_bin_inv(il[732]) + , perm_main_conv_inv(il[733]) + , perm_main_sha256_inv(il[734]) + , perm_main_pos2_perm_inv(il[735]) + , perm_main_slice_inv(il[736]) + , perm_main_mem_a_inv(il[737]) + , perm_main_mem_b_inv(il[738]) + , perm_main_mem_c_inv(il[739]) + , perm_main_mem_d_inv(il[740]) + , perm_main_mem_ind_addr_a_inv(il[741]) + , perm_main_mem_ind_addr_b_inv(il[742]) + , perm_main_mem_ind_addr_c_inv(il[743]) + , perm_main_mem_ind_addr_d_inv(il[744]) + , lookup_rng_chk_pow_2_inv(il[745]) + , lookup_rng_chk_diff_inv(il[746]) + , lookup_rng_chk_0_inv(il[747]) + , lookup_rng_chk_1_inv(il[748]) + , lookup_rng_chk_2_inv(il[749]) + , lookup_rng_chk_3_inv(il[750]) + , lookup_rng_chk_4_inv(il[751]) + , lookup_rng_chk_5_inv(il[752]) + , lookup_rng_chk_6_inv(il[753]) + , lookup_rng_chk_7_inv(il[754]) + , lookup_pow_2_0_inv(il[755]) + , lookup_pow_2_1_inv(il[756]) + , lookup_byte_lengths_inv(il[757]) + , lookup_byte_operations_inv(il[758]) + , lookup_opcode_gas_inv(il[759]) + , kernel_output_lookup_inv(il[760]) + , lookup_into_kernel_inv(il[761]) + , lookup_cd_value_inv(il[762]) + , lookup_ret_value_inv(il[763]) + , incl_main_tag_err_inv(il[764]) + , incl_mem_tag_err_inv(il[765]) + , binary_acc_ia_shift(il[766]) + , binary_acc_ib_shift(il[767]) + , binary_acc_ic_shift(il[768]) + , binary_mem_tag_ctr_shift(il[769]) + , binary_op_id_shift(il[770]) + , cmp_a_hi_shift(il[771]) + , cmp_a_lo_shift(il[772]) + , cmp_b_hi_shift(il[773]) + , cmp_b_lo_shift(il[774]) + , cmp_cmp_rng_ctr_shift(il[775]) + , cmp_op_gt_shift(il[776]) + , cmp_p_sub_a_hi_shift(il[777]) + , cmp_p_sub_a_lo_shift(il[778]) + , cmp_p_sub_b_hi_shift(il[779]) + , cmp_p_sub_b_lo_shift(il[780]) + , cmp_sel_rng_chk_shift(il[781]) + , main_da_gas_remaining_shift(il[782]) + , main_emit_l2_to_l1_msg_write_offset_shift(il[783]) + , main_emit_note_hash_write_offset_shift(il[784]) + , main_emit_nullifier_write_offset_shift(il[785]) + , main_emit_unencrypted_log_write_offset_shift(il[786]) + , main_internal_return_ptr_shift(il[787]) + , main_l1_to_l2_msg_exists_write_offset_shift(il[788]) + , main_l2_gas_remaining_shift(il[789]) + , main_note_hash_exist_write_offset_shift(il[790]) + , main_nullifier_exists_write_offset_shift(il[791]) + , main_nullifier_non_exists_write_offset_shift(il[792]) + , main_pc_shift(il[793]) + , main_sel_execution_end_shift(il[794]) + , main_sel_execution_row_shift(il[795]) + , main_sload_write_offset_shift(il[796]) + , main_sstore_write_offset_shift(il[797]) + , mem_glob_addr_shift(il[798]) + , mem_rw_shift(il[799]) + , mem_sel_mem_shift(il[800]) + , mem_tag_shift(il[801]) + , mem_tsp_shift(il[802]) + , mem_val_shift(il[803]) + , merkle_tree_leaf_index_shift(il[804]) + , merkle_tree_leaf_value_shift(il[805]) + , merkle_tree_path_len_shift(il[806]) + , poseidon2_full_a_0_shift(il[807]) + , poseidon2_full_a_1_shift(il[808]) + , poseidon2_full_a_2_shift(il[809]) + , poseidon2_full_a_3_shift(il[810]) + , poseidon2_full_execute_poseidon_perm_shift(il[811]) + , poseidon2_full_input_0_shift(il[812]) + , poseidon2_full_input_1_shift(il[813]) + , poseidon2_full_input_2_shift(il[814]) + , poseidon2_full_num_perm_rounds_rem_shift(il[815]) + , poseidon2_full_sel_poseidon_shift(il[816]) + , poseidon2_full_start_poseidon_shift(il[817]) + , slice_addr_shift(il[818]) + , slice_clk_shift(il[819]) + , slice_cnt_shift(il[820]) + , slice_col_offset_shift(il[821]) + , slice_sel_cd_cpy_shift(il[822]) + , slice_sel_mem_active_shift(il[823]) + , slice_sel_return_shift(il[824]) + , slice_sel_start_shift(il[825]) + , slice_space_id_shift(il[826]) {} AvmFlavor::ProverPolynomials::ProverPolynomials(ProvingKey& proving_key) @@ -1096,6 +1098,8 @@ AvmFlavor::AllConstRefValues AvmFlavor::ProverPolynomials::get_row(size_t row_id main_sel_op_or[row_idx], main_sel_op_poseidon2[row_idx], main_sel_op_radix_be[row_idx], + main_sel_op_returndata_copy[row_idx], + main_sel_op_returndata_size[row_idx], main_sel_op_sender[row_idx], main_sel_op_set[row_idx], main_sel_op_sha256[row_idx], @@ -1925,6 +1929,8 @@ AvmFlavor::CommitmentLabels::CommitmentLabels() Base::main_sel_op_or = "MAIN_SEL_OP_OR"; Base::main_sel_op_poseidon2 = "MAIN_SEL_OP_POSEIDON2"; Base::main_sel_op_radix_be = "MAIN_SEL_OP_RADIX_BE"; + Base::main_sel_op_returndata_copy = "MAIN_SEL_OP_RETURNDATA_COPY"; + Base::main_sel_op_returndata_size = "MAIN_SEL_OP_RETURNDATA_SIZE"; Base::main_sel_op_sender = "MAIN_SEL_OP_SENDER"; Base::main_sel_op_set = "MAIN_SEL_OP_SET"; Base::main_sel_op_sha256 = "MAIN_SEL_OP_SHA256"; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp index e83b4604038..1d74ca93b78 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp @@ -98,7 +98,7 @@ template using tuple_cat_t = decltype(std::tuple_cat(std:: // The entities that will be used in the flavor. // clang-format off #define PRECOMPUTED_ENTITIES byte_lookup_sel_bin, byte_lookup_table_byte_lengths, byte_lookup_table_in_tags, byte_lookup_table_input_a, byte_lookup_table_input_b, byte_lookup_table_op_id, byte_lookup_table_output, gas_base_da_gas_fixed_table, gas_base_l2_gas_fixed_table, gas_dyn_da_gas_fixed_table, gas_dyn_l2_gas_fixed_table, gas_sel_gas_cost, main_clk, main_sel_da_end_gas_kernel_input, main_sel_da_start_gas_kernel_input, main_sel_first, main_sel_l2_end_gas_kernel_input, main_sel_l2_start_gas_kernel_input, main_sel_start_exec, main_zeroes, powers_power_of_2 -#define WIRE_ENTITIES main_kernel_inputs, main_kernel_value_out, main_kernel_side_effect_out, main_kernel_metadata_out, main_calldata, main_returndata, alu_a_hi, alu_a_lo, alu_b_hi, alu_b_lo, alu_b_pow, alu_c_hi, alu_c_lo, alu_cf, alu_clk, alu_cmp_gadget_gt, alu_cmp_gadget_input_a, alu_cmp_gadget_input_b, alu_cmp_gadget_result, alu_cmp_gadget_sel, alu_ff_tag, alu_ia, alu_ib, alu_ic, alu_in_tag, alu_max_bits_sub_b_bits, alu_max_bits_sub_b_pow, alu_op_add, alu_op_cast, alu_op_div, alu_op_eq, alu_op_lt, alu_op_lte, alu_op_mul, alu_op_not, alu_op_shl, alu_op_shr, alu_op_sub, alu_partial_prod_hi, alu_partial_prod_lo, alu_range_check_input_value, alu_range_check_num_bits, alu_range_check_sel, alu_remainder, alu_sel_alu, alu_sel_cmp, alu_sel_shift_which, alu_u128_tag, alu_u16_tag, alu_u1_tag, alu_u32_tag, alu_u64_tag, alu_u8_tag, alu_zero_shift, binary_acc_ia, binary_acc_ib, binary_acc_ic, binary_clk, binary_ia_bytes, binary_ib_bytes, binary_ic_bytes, binary_in_tag, binary_mem_tag_ctr, binary_mem_tag_ctr_inv, binary_op_id, binary_sel_bin, binary_start, bytecode_arifact_hash, bytecode_as_fields, bytecode_bytes, bytecode_bytes_pc, bytecode_class_id, bytecode_contract_address, bytecode_decomposed, bytecode_deployer_addr, bytecode_end_latch, bytecode_incoming_viewing_key_x, bytecode_incoming_viewing_key_y, bytecode_initialization_hash, bytecode_length_remaining, bytecode_nullifier_key_x, bytecode_nullifier_key_y, bytecode_outgoing_viewing_key_x, bytecode_outgoing_viewing_key_y, bytecode_private_fn_root, bytecode_public_key_hash, bytecode_running_hash, bytecode_salt, bytecode_tagging_key_x, bytecode_tagging_key_y, cmp_a_hi, cmp_a_lo, cmp_b_hi, cmp_b_lo, cmp_borrow, cmp_clk, cmp_cmp_rng_ctr, cmp_input_a, cmp_input_b, cmp_op_eq, cmp_op_eq_diff_inv, cmp_op_gt, cmp_p_a_borrow, cmp_p_b_borrow, cmp_p_sub_a_hi, cmp_p_sub_a_lo, cmp_p_sub_b_hi, cmp_p_sub_b_lo, cmp_range_chk_clk, cmp_res_hi, cmp_res_lo, cmp_result, cmp_sel_cmp, cmp_sel_rng_chk, cmp_shift_sel, conversion_clk, conversion_input, conversion_num_limbs, conversion_output_bits, conversion_radix, conversion_sel_to_radix_be, keccakf1600_clk, keccakf1600_input, keccakf1600_output, keccakf1600_sel_keccakf1600, main_abs_da_rem_gas, main_abs_l2_rem_gas, main_alu_in_tag, main_base_da_gas_op_cost, main_base_l2_gas_op_cost, main_bin_op_id, main_call_ptr, main_da_gas_remaining, main_da_out_of_gas, main_dyn_da_gas_op_cost, main_dyn_gas_multiplier, main_dyn_l2_gas_op_cost, main_emit_l2_to_l1_msg_write_offset, main_emit_note_hash_write_offset, main_emit_nullifier_write_offset, main_emit_unencrypted_log_write_offset, main_ia, main_ib, main_ic, main_id, main_id_zero, main_ind_addr_a, main_ind_addr_b, main_ind_addr_c, main_ind_addr_d, main_internal_return_ptr, main_inv, main_is_fake_row, main_is_gas_accounted, main_kernel_in_offset, main_kernel_out_offset, main_l1_to_l2_msg_exists_write_offset, main_l2_gas_remaining, main_l2_out_of_gas, main_mem_addr_a, main_mem_addr_b, main_mem_addr_c, main_mem_addr_d, main_note_hash_exist_write_offset, main_nullifier_exists_write_offset, main_nullifier_non_exists_write_offset, main_op_err, main_opcode_val, main_pc, main_r_in_tag, main_rwa, main_rwb, main_rwc, main_rwd, main_sel_alu, main_sel_bin, main_sel_calldata, main_sel_execution_end, main_sel_execution_row, main_sel_kernel_inputs, main_sel_kernel_out, main_sel_mem_op_a, main_sel_mem_op_b, main_sel_mem_op_c, main_sel_mem_op_d, main_sel_mov_ia_to_ic, main_sel_mov_ib_to_ic, main_sel_op_add, main_sel_op_address, main_sel_op_and, main_sel_op_block_number, main_sel_op_calldata_copy, main_sel_op_cast, main_sel_op_chain_id, main_sel_op_dagasleft, main_sel_op_div, main_sel_op_ecadd, main_sel_op_emit_l2_to_l1_msg, main_sel_op_emit_note_hash, main_sel_op_emit_nullifier, main_sel_op_emit_unencrypted_log, main_sel_op_eq, main_sel_op_external_call, main_sel_op_external_return, main_sel_op_external_revert, main_sel_op_fdiv, main_sel_op_fee_per_da_gas, main_sel_op_fee_per_l2_gas, main_sel_op_function_selector, main_sel_op_get_contract_instance, main_sel_op_internal_call, main_sel_op_internal_return, main_sel_op_is_static_call, main_sel_op_jump, main_sel_op_jumpi, main_sel_op_keccak, main_sel_op_l1_to_l2_msg_exists, main_sel_op_l2gasleft, main_sel_op_lt, main_sel_op_lte, main_sel_op_mov, main_sel_op_msm, main_sel_op_mul, main_sel_op_not, main_sel_op_note_hash_exists, main_sel_op_nullifier_exists, main_sel_op_or, main_sel_op_poseidon2, main_sel_op_radix_be, main_sel_op_sender, main_sel_op_set, main_sel_op_sha256, main_sel_op_shl, main_sel_op_shr, main_sel_op_sload, main_sel_op_sstore, main_sel_op_static_call, main_sel_op_sub, main_sel_op_timestamp, main_sel_op_transaction_fee, main_sel_op_version, main_sel_op_xor, main_sel_q_kernel_lookup, main_sel_q_kernel_output_lookup, main_sel_resolve_ind_addr_a, main_sel_resolve_ind_addr_b, main_sel_resolve_ind_addr_c, main_sel_resolve_ind_addr_d, main_sel_returndata, main_sel_rng_16, main_sel_rng_8, main_sel_slice_gadget, main_side_effect_counter, main_sload_write_offset, main_space_id, main_sstore_write_offset, main_tag_err, main_w_in_tag, mem_addr, mem_clk, mem_diff, mem_glob_addr, mem_last, mem_lastAccess, mem_one_min_inv, mem_r_in_tag, mem_rw, mem_sel_mem, mem_sel_mov_ia_to_ic, mem_sel_mov_ib_to_ic, mem_sel_op_a, mem_sel_op_b, mem_sel_op_c, mem_sel_op_d, mem_sel_op_poseidon_read_a, mem_sel_op_poseidon_read_b, mem_sel_op_poseidon_read_c, mem_sel_op_poseidon_read_d, mem_sel_op_poseidon_write_a, mem_sel_op_poseidon_write_b, mem_sel_op_poseidon_write_c, mem_sel_op_poseidon_write_d, mem_sel_op_slice, mem_sel_resolve_ind_addr_a, mem_sel_resolve_ind_addr_b, mem_sel_resolve_ind_addr_c, mem_sel_resolve_ind_addr_d, mem_sel_rng_chk, mem_skip_check_tag, mem_space_id, mem_tag, mem_tag_err, mem_tsp, mem_val, mem_w_in_tag, merkle_tree_clk, merkle_tree_expected_tree_root, merkle_tree_latch, merkle_tree_leaf_index, merkle_tree_leaf_index_is_even, merkle_tree_leaf_value, merkle_tree_left_hash, merkle_tree_output_hash, merkle_tree_path_len, merkle_tree_path_len_inv, merkle_tree_right_hash, merkle_tree_sel_merkle_tree, merkle_tree_sibling_value, poseidon2_B_10_0, poseidon2_B_10_1, poseidon2_B_10_2, poseidon2_B_10_3, poseidon2_B_11_0, poseidon2_B_11_1, poseidon2_B_11_2, poseidon2_B_11_3, poseidon2_B_12_0, poseidon2_B_12_1, poseidon2_B_12_2, poseidon2_B_12_3, poseidon2_B_13_0, poseidon2_B_13_1, poseidon2_B_13_2, poseidon2_B_13_3, poseidon2_B_14_0, poseidon2_B_14_1, poseidon2_B_14_2, poseidon2_B_14_3, poseidon2_B_15_0, poseidon2_B_15_1, poseidon2_B_15_2, poseidon2_B_15_3, poseidon2_B_16_0, poseidon2_B_16_1, poseidon2_B_16_2, poseidon2_B_16_3, poseidon2_B_17_0, poseidon2_B_17_1, poseidon2_B_17_2, poseidon2_B_17_3, poseidon2_B_18_0, poseidon2_B_18_1, poseidon2_B_18_2, poseidon2_B_18_3, poseidon2_B_19_0, poseidon2_B_19_1, poseidon2_B_19_2, poseidon2_B_19_3, poseidon2_B_20_0, poseidon2_B_20_1, poseidon2_B_20_2, poseidon2_B_20_3, poseidon2_B_21_0, poseidon2_B_21_1, poseidon2_B_21_2, poseidon2_B_21_3, poseidon2_B_22_0, poseidon2_B_22_1, poseidon2_B_22_2, poseidon2_B_22_3, poseidon2_B_23_0, poseidon2_B_23_1, poseidon2_B_23_2, poseidon2_B_23_3, poseidon2_B_24_0, poseidon2_B_24_1, poseidon2_B_24_2, poseidon2_B_24_3, poseidon2_B_25_0, poseidon2_B_25_1, poseidon2_B_25_2, poseidon2_B_25_3, poseidon2_B_26_0, poseidon2_B_26_1, poseidon2_B_26_2, poseidon2_B_26_3, poseidon2_B_27_0, poseidon2_B_27_1, poseidon2_B_27_2, poseidon2_B_27_3, poseidon2_B_28_0, poseidon2_B_28_1, poseidon2_B_28_2, poseidon2_B_28_3, poseidon2_B_29_0, poseidon2_B_29_1, poseidon2_B_29_2, poseidon2_B_29_3, poseidon2_B_30_0, poseidon2_B_30_1, poseidon2_B_30_2, poseidon2_B_30_3, poseidon2_B_31_0, poseidon2_B_31_1, poseidon2_B_31_2, poseidon2_B_31_3, poseidon2_B_32_0, poseidon2_B_32_1, poseidon2_B_32_2, poseidon2_B_32_3, poseidon2_B_33_0, poseidon2_B_33_1, poseidon2_B_33_2, poseidon2_B_33_3, poseidon2_B_34_0, poseidon2_B_34_1, poseidon2_B_34_2, poseidon2_B_34_3, poseidon2_B_35_0, poseidon2_B_35_1, poseidon2_B_35_2, poseidon2_B_35_3, poseidon2_B_36_0, poseidon2_B_36_1, poseidon2_B_36_2, poseidon2_B_36_3, poseidon2_B_37_0, poseidon2_B_37_1, poseidon2_B_37_2, poseidon2_B_37_3, poseidon2_B_38_0, poseidon2_B_38_1, poseidon2_B_38_2, poseidon2_B_38_3, poseidon2_B_39_0, poseidon2_B_39_1, poseidon2_B_39_2, poseidon2_B_39_3, poseidon2_B_40_0, poseidon2_B_40_1, poseidon2_B_40_2, poseidon2_B_40_3, poseidon2_B_41_0, poseidon2_B_41_1, poseidon2_B_41_2, poseidon2_B_41_3, poseidon2_B_42_0, poseidon2_B_42_1, poseidon2_B_42_2, poseidon2_B_42_3, poseidon2_B_43_0, poseidon2_B_43_1, poseidon2_B_43_2, poseidon2_B_43_3, poseidon2_B_44_0, poseidon2_B_44_1, poseidon2_B_44_2, poseidon2_B_44_3, poseidon2_B_45_0, poseidon2_B_45_1, poseidon2_B_45_2, poseidon2_B_45_3, poseidon2_B_46_0, poseidon2_B_46_1, poseidon2_B_46_2, poseidon2_B_46_3, poseidon2_B_47_0, poseidon2_B_47_1, poseidon2_B_47_2, poseidon2_B_47_3, poseidon2_B_48_0, poseidon2_B_48_1, poseidon2_B_48_2, poseidon2_B_48_3, poseidon2_B_49_0, poseidon2_B_49_1, poseidon2_B_49_2, poseidon2_B_49_3, poseidon2_B_4_0, poseidon2_B_4_1, poseidon2_B_4_2, poseidon2_B_4_3, poseidon2_B_50_0, poseidon2_B_50_1, poseidon2_B_50_2, poseidon2_B_50_3, poseidon2_B_51_0, poseidon2_B_51_1, poseidon2_B_51_2, poseidon2_B_51_3, poseidon2_B_52_0, poseidon2_B_52_1, poseidon2_B_52_2, poseidon2_B_52_3, poseidon2_B_53_0, poseidon2_B_53_1, poseidon2_B_53_2, poseidon2_B_53_3, poseidon2_B_54_0, poseidon2_B_54_1, poseidon2_B_54_2, poseidon2_B_54_3, poseidon2_B_55_0, poseidon2_B_55_1, poseidon2_B_55_2, poseidon2_B_55_3, poseidon2_B_56_0, poseidon2_B_56_1, poseidon2_B_56_2, poseidon2_B_56_3, poseidon2_B_57_0, poseidon2_B_57_1, poseidon2_B_57_2, poseidon2_B_57_3, poseidon2_B_58_0, poseidon2_B_58_1, poseidon2_B_58_2, poseidon2_B_58_3, poseidon2_B_59_0, poseidon2_B_59_1, poseidon2_B_59_2, poseidon2_B_59_3, poseidon2_B_5_0, poseidon2_B_5_1, poseidon2_B_5_2, poseidon2_B_5_3, poseidon2_B_6_0, poseidon2_B_6_1, poseidon2_B_6_2, poseidon2_B_6_3, poseidon2_B_7_0, poseidon2_B_7_1, poseidon2_B_7_2, poseidon2_B_7_3, poseidon2_B_8_0, poseidon2_B_8_1, poseidon2_B_8_2, poseidon2_B_8_3, poseidon2_B_9_0, poseidon2_B_9_1, poseidon2_B_9_2, poseidon2_B_9_3, poseidon2_EXT_LAYER_4, poseidon2_EXT_LAYER_5, poseidon2_EXT_LAYER_6, poseidon2_EXT_LAYER_7, poseidon2_T_0_4, poseidon2_T_0_5, poseidon2_T_0_6, poseidon2_T_0_7, poseidon2_T_1_4, poseidon2_T_1_5, poseidon2_T_1_6, poseidon2_T_1_7, poseidon2_T_2_4, poseidon2_T_2_5, poseidon2_T_2_6, poseidon2_T_2_7, poseidon2_T_3_4, poseidon2_T_3_5, poseidon2_T_3_6, poseidon2_T_3_7, poseidon2_T_60_4, poseidon2_T_60_5, poseidon2_T_60_6, poseidon2_T_60_7, poseidon2_T_61_4, poseidon2_T_61_5, poseidon2_T_61_6, poseidon2_T_61_7, poseidon2_T_62_4, poseidon2_T_62_5, poseidon2_T_62_6, poseidon2_T_62_7, poseidon2_T_63_4, poseidon2_T_63_5, poseidon2_T_63_6, poseidon2_T_63_7, poseidon2_a_0, poseidon2_a_1, poseidon2_a_2, poseidon2_a_3, poseidon2_b_0, poseidon2_b_1, poseidon2_b_2, poseidon2_b_3, poseidon2_clk, poseidon2_full_a_0, poseidon2_full_a_1, poseidon2_full_a_2, poseidon2_full_a_3, poseidon2_full_b_0, poseidon2_full_b_1, poseidon2_full_b_2, poseidon2_full_b_3, poseidon2_full_clk, poseidon2_full_end_poseidon, poseidon2_full_execute_poseidon_perm, poseidon2_full_input_0, poseidon2_full_input_1, poseidon2_full_input_2, poseidon2_full_input_len, poseidon2_full_num_perm_rounds_rem, poseidon2_full_num_perm_rounds_rem_inv, poseidon2_full_output, poseidon2_full_padding, poseidon2_full_sel_merkle_tree, poseidon2_full_sel_poseidon, poseidon2_full_start_poseidon, poseidon2_input_addr, poseidon2_mem_addr_read_a, poseidon2_mem_addr_read_b, poseidon2_mem_addr_read_c, poseidon2_mem_addr_read_d, poseidon2_mem_addr_write_a, poseidon2_mem_addr_write_b, poseidon2_mem_addr_write_c, poseidon2_mem_addr_write_d, poseidon2_output_addr, poseidon2_sel_poseidon_perm, poseidon2_sel_poseidon_perm_immediate, poseidon2_sel_poseidon_perm_mem_op, poseidon2_space_id, range_check_alu_rng_chk, range_check_clk, range_check_cmp_hi_bits_rng_chk, range_check_cmp_lo_bits_rng_chk, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_gas_da_rng_chk, range_check_gas_l2_rng_chk, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_mem_rng_chk, range_check_rng_chk_bits, range_check_sel_lookup_0, range_check_sel_lookup_1, range_check_sel_lookup_2, range_check_sel_lookup_3, range_check_sel_lookup_4, range_check_sel_lookup_5, range_check_sel_lookup_6, range_check_sel_rng_chk, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, sha256_clk, sha256_input, sha256_output, sha256_sel_sha256_compression, sha256_state, slice_addr, slice_clk, slice_cnt, slice_col_offset, slice_one_min_inv, slice_sel_cd_cpy, slice_sel_mem_active, slice_sel_return, slice_sel_start, slice_space_id, slice_val, lookup_rng_chk_pow_2_counts, lookup_rng_chk_diff_counts, lookup_rng_chk_0_counts, lookup_rng_chk_1_counts, lookup_rng_chk_2_counts, lookup_rng_chk_3_counts, lookup_rng_chk_4_counts, lookup_rng_chk_5_counts, lookup_rng_chk_6_counts, lookup_rng_chk_7_counts, lookup_pow_2_0_counts, lookup_pow_2_1_counts, lookup_byte_lengths_counts, lookup_byte_operations_counts, lookup_opcode_gas_counts, kernel_output_lookup_counts, lookup_into_kernel_counts, lookup_cd_value_counts, lookup_ret_value_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts +#define WIRE_ENTITIES main_kernel_inputs, main_kernel_value_out, main_kernel_side_effect_out, main_kernel_metadata_out, main_calldata, main_returndata, alu_a_hi, alu_a_lo, alu_b_hi, alu_b_lo, alu_b_pow, alu_c_hi, alu_c_lo, alu_cf, alu_clk, alu_cmp_gadget_gt, alu_cmp_gadget_input_a, alu_cmp_gadget_input_b, alu_cmp_gadget_result, alu_cmp_gadget_sel, alu_ff_tag, alu_ia, alu_ib, alu_ic, alu_in_tag, alu_max_bits_sub_b_bits, alu_max_bits_sub_b_pow, alu_op_add, alu_op_cast, alu_op_div, alu_op_eq, alu_op_lt, alu_op_lte, alu_op_mul, alu_op_not, alu_op_shl, alu_op_shr, alu_op_sub, alu_partial_prod_hi, alu_partial_prod_lo, alu_range_check_input_value, alu_range_check_num_bits, alu_range_check_sel, alu_remainder, alu_sel_alu, alu_sel_cmp, alu_sel_shift_which, alu_u128_tag, alu_u16_tag, alu_u1_tag, alu_u32_tag, alu_u64_tag, alu_u8_tag, alu_zero_shift, binary_acc_ia, binary_acc_ib, binary_acc_ic, binary_clk, binary_ia_bytes, binary_ib_bytes, binary_ic_bytes, binary_in_tag, binary_mem_tag_ctr, binary_mem_tag_ctr_inv, binary_op_id, binary_sel_bin, binary_start, bytecode_arifact_hash, bytecode_as_fields, bytecode_bytes, bytecode_bytes_pc, bytecode_class_id, bytecode_contract_address, bytecode_decomposed, bytecode_deployer_addr, bytecode_end_latch, bytecode_incoming_viewing_key_x, bytecode_incoming_viewing_key_y, bytecode_initialization_hash, bytecode_length_remaining, bytecode_nullifier_key_x, bytecode_nullifier_key_y, bytecode_outgoing_viewing_key_x, bytecode_outgoing_viewing_key_y, bytecode_private_fn_root, bytecode_public_key_hash, bytecode_running_hash, bytecode_salt, bytecode_tagging_key_x, bytecode_tagging_key_y, cmp_a_hi, cmp_a_lo, cmp_b_hi, cmp_b_lo, cmp_borrow, cmp_clk, cmp_cmp_rng_ctr, cmp_input_a, cmp_input_b, cmp_op_eq, cmp_op_eq_diff_inv, cmp_op_gt, cmp_p_a_borrow, cmp_p_b_borrow, cmp_p_sub_a_hi, cmp_p_sub_a_lo, cmp_p_sub_b_hi, cmp_p_sub_b_lo, cmp_range_chk_clk, cmp_res_hi, cmp_res_lo, cmp_result, cmp_sel_cmp, cmp_sel_rng_chk, cmp_shift_sel, conversion_clk, conversion_input, conversion_num_limbs, conversion_output_bits, conversion_radix, conversion_sel_to_radix_be, keccakf1600_clk, keccakf1600_input, keccakf1600_output, keccakf1600_sel_keccakf1600, main_abs_da_rem_gas, main_abs_l2_rem_gas, main_alu_in_tag, main_base_da_gas_op_cost, main_base_l2_gas_op_cost, main_bin_op_id, main_call_ptr, main_da_gas_remaining, main_da_out_of_gas, main_dyn_da_gas_op_cost, main_dyn_gas_multiplier, main_dyn_l2_gas_op_cost, main_emit_l2_to_l1_msg_write_offset, main_emit_note_hash_write_offset, main_emit_nullifier_write_offset, main_emit_unencrypted_log_write_offset, main_ia, main_ib, main_ic, main_id, main_id_zero, main_ind_addr_a, main_ind_addr_b, main_ind_addr_c, main_ind_addr_d, main_internal_return_ptr, main_inv, main_is_fake_row, main_is_gas_accounted, main_kernel_in_offset, main_kernel_out_offset, main_l1_to_l2_msg_exists_write_offset, main_l2_gas_remaining, main_l2_out_of_gas, main_mem_addr_a, main_mem_addr_b, main_mem_addr_c, main_mem_addr_d, main_note_hash_exist_write_offset, main_nullifier_exists_write_offset, main_nullifier_non_exists_write_offset, main_op_err, main_opcode_val, main_pc, main_r_in_tag, main_rwa, main_rwb, main_rwc, main_rwd, main_sel_alu, main_sel_bin, main_sel_calldata, main_sel_execution_end, main_sel_execution_row, main_sel_kernel_inputs, main_sel_kernel_out, main_sel_mem_op_a, main_sel_mem_op_b, main_sel_mem_op_c, main_sel_mem_op_d, main_sel_mov_ia_to_ic, main_sel_mov_ib_to_ic, main_sel_op_add, main_sel_op_address, main_sel_op_and, main_sel_op_block_number, main_sel_op_calldata_copy, main_sel_op_cast, main_sel_op_chain_id, main_sel_op_dagasleft, main_sel_op_div, main_sel_op_ecadd, main_sel_op_emit_l2_to_l1_msg, main_sel_op_emit_note_hash, main_sel_op_emit_nullifier, main_sel_op_emit_unencrypted_log, main_sel_op_eq, main_sel_op_external_call, main_sel_op_external_return, main_sel_op_external_revert, main_sel_op_fdiv, main_sel_op_fee_per_da_gas, main_sel_op_fee_per_l2_gas, main_sel_op_function_selector, main_sel_op_get_contract_instance, main_sel_op_internal_call, main_sel_op_internal_return, main_sel_op_is_static_call, main_sel_op_jump, main_sel_op_jumpi, main_sel_op_keccak, main_sel_op_l1_to_l2_msg_exists, main_sel_op_l2gasleft, main_sel_op_lt, main_sel_op_lte, main_sel_op_mov, main_sel_op_msm, main_sel_op_mul, main_sel_op_not, main_sel_op_note_hash_exists, main_sel_op_nullifier_exists, main_sel_op_or, main_sel_op_poseidon2, main_sel_op_radix_be, main_sel_op_returndata_copy, main_sel_op_returndata_size, main_sel_op_sender, main_sel_op_set, main_sel_op_sha256, main_sel_op_shl, main_sel_op_shr, main_sel_op_sload, main_sel_op_sstore, main_sel_op_static_call, main_sel_op_sub, main_sel_op_timestamp, main_sel_op_transaction_fee, main_sel_op_version, main_sel_op_xor, main_sel_q_kernel_lookup, main_sel_q_kernel_output_lookup, main_sel_resolve_ind_addr_a, main_sel_resolve_ind_addr_b, main_sel_resolve_ind_addr_c, main_sel_resolve_ind_addr_d, main_sel_returndata, main_sel_rng_16, main_sel_rng_8, main_sel_slice_gadget, main_side_effect_counter, main_sload_write_offset, main_space_id, main_sstore_write_offset, main_tag_err, main_w_in_tag, mem_addr, mem_clk, mem_diff, mem_glob_addr, mem_last, mem_lastAccess, mem_one_min_inv, mem_r_in_tag, mem_rw, mem_sel_mem, mem_sel_mov_ia_to_ic, mem_sel_mov_ib_to_ic, mem_sel_op_a, mem_sel_op_b, mem_sel_op_c, mem_sel_op_d, mem_sel_op_poseidon_read_a, mem_sel_op_poseidon_read_b, mem_sel_op_poseidon_read_c, mem_sel_op_poseidon_read_d, mem_sel_op_poseidon_write_a, mem_sel_op_poseidon_write_b, mem_sel_op_poseidon_write_c, mem_sel_op_poseidon_write_d, mem_sel_op_slice, mem_sel_resolve_ind_addr_a, mem_sel_resolve_ind_addr_b, mem_sel_resolve_ind_addr_c, mem_sel_resolve_ind_addr_d, mem_sel_rng_chk, mem_skip_check_tag, mem_space_id, mem_tag, mem_tag_err, mem_tsp, mem_val, mem_w_in_tag, merkle_tree_clk, merkle_tree_expected_tree_root, merkle_tree_latch, merkle_tree_leaf_index, merkle_tree_leaf_index_is_even, merkle_tree_leaf_value, merkle_tree_left_hash, merkle_tree_output_hash, merkle_tree_path_len, merkle_tree_path_len_inv, merkle_tree_right_hash, merkle_tree_sel_merkle_tree, merkle_tree_sibling_value, poseidon2_B_10_0, poseidon2_B_10_1, poseidon2_B_10_2, poseidon2_B_10_3, poseidon2_B_11_0, poseidon2_B_11_1, poseidon2_B_11_2, poseidon2_B_11_3, poseidon2_B_12_0, poseidon2_B_12_1, poseidon2_B_12_2, poseidon2_B_12_3, poseidon2_B_13_0, poseidon2_B_13_1, poseidon2_B_13_2, poseidon2_B_13_3, poseidon2_B_14_0, poseidon2_B_14_1, poseidon2_B_14_2, poseidon2_B_14_3, poseidon2_B_15_0, poseidon2_B_15_1, poseidon2_B_15_2, poseidon2_B_15_3, poseidon2_B_16_0, poseidon2_B_16_1, poseidon2_B_16_2, poseidon2_B_16_3, poseidon2_B_17_0, poseidon2_B_17_1, poseidon2_B_17_2, poseidon2_B_17_3, poseidon2_B_18_0, poseidon2_B_18_1, poseidon2_B_18_2, poseidon2_B_18_3, poseidon2_B_19_0, poseidon2_B_19_1, poseidon2_B_19_2, poseidon2_B_19_3, poseidon2_B_20_0, poseidon2_B_20_1, poseidon2_B_20_2, poseidon2_B_20_3, poseidon2_B_21_0, poseidon2_B_21_1, poseidon2_B_21_2, poseidon2_B_21_3, poseidon2_B_22_0, poseidon2_B_22_1, poseidon2_B_22_2, poseidon2_B_22_3, poseidon2_B_23_0, poseidon2_B_23_1, poseidon2_B_23_2, poseidon2_B_23_3, poseidon2_B_24_0, poseidon2_B_24_1, poseidon2_B_24_2, poseidon2_B_24_3, poseidon2_B_25_0, poseidon2_B_25_1, poseidon2_B_25_2, poseidon2_B_25_3, poseidon2_B_26_0, poseidon2_B_26_1, poseidon2_B_26_2, poseidon2_B_26_3, poseidon2_B_27_0, poseidon2_B_27_1, poseidon2_B_27_2, poseidon2_B_27_3, poseidon2_B_28_0, poseidon2_B_28_1, poseidon2_B_28_2, poseidon2_B_28_3, poseidon2_B_29_0, poseidon2_B_29_1, poseidon2_B_29_2, poseidon2_B_29_3, poseidon2_B_30_0, poseidon2_B_30_1, poseidon2_B_30_2, poseidon2_B_30_3, poseidon2_B_31_0, poseidon2_B_31_1, poseidon2_B_31_2, poseidon2_B_31_3, poseidon2_B_32_0, poseidon2_B_32_1, poseidon2_B_32_2, poseidon2_B_32_3, poseidon2_B_33_0, poseidon2_B_33_1, poseidon2_B_33_2, poseidon2_B_33_3, poseidon2_B_34_0, poseidon2_B_34_1, poseidon2_B_34_2, poseidon2_B_34_3, poseidon2_B_35_0, poseidon2_B_35_1, poseidon2_B_35_2, poseidon2_B_35_3, poseidon2_B_36_0, poseidon2_B_36_1, poseidon2_B_36_2, poseidon2_B_36_3, poseidon2_B_37_0, poseidon2_B_37_1, poseidon2_B_37_2, poseidon2_B_37_3, poseidon2_B_38_0, poseidon2_B_38_1, poseidon2_B_38_2, poseidon2_B_38_3, poseidon2_B_39_0, poseidon2_B_39_1, poseidon2_B_39_2, poseidon2_B_39_3, poseidon2_B_40_0, poseidon2_B_40_1, poseidon2_B_40_2, poseidon2_B_40_3, poseidon2_B_41_0, poseidon2_B_41_1, poseidon2_B_41_2, poseidon2_B_41_3, poseidon2_B_42_0, poseidon2_B_42_1, poseidon2_B_42_2, poseidon2_B_42_3, poseidon2_B_43_0, poseidon2_B_43_1, poseidon2_B_43_2, poseidon2_B_43_3, poseidon2_B_44_0, poseidon2_B_44_1, poseidon2_B_44_2, poseidon2_B_44_3, poseidon2_B_45_0, poseidon2_B_45_1, poseidon2_B_45_2, poseidon2_B_45_3, poseidon2_B_46_0, poseidon2_B_46_1, poseidon2_B_46_2, poseidon2_B_46_3, poseidon2_B_47_0, poseidon2_B_47_1, poseidon2_B_47_2, poseidon2_B_47_3, poseidon2_B_48_0, poseidon2_B_48_1, poseidon2_B_48_2, poseidon2_B_48_3, poseidon2_B_49_0, poseidon2_B_49_1, poseidon2_B_49_2, poseidon2_B_49_3, poseidon2_B_4_0, poseidon2_B_4_1, poseidon2_B_4_2, poseidon2_B_4_3, poseidon2_B_50_0, poseidon2_B_50_1, poseidon2_B_50_2, poseidon2_B_50_3, poseidon2_B_51_0, poseidon2_B_51_1, poseidon2_B_51_2, poseidon2_B_51_3, poseidon2_B_52_0, poseidon2_B_52_1, poseidon2_B_52_2, poseidon2_B_52_3, poseidon2_B_53_0, poseidon2_B_53_1, poseidon2_B_53_2, poseidon2_B_53_3, poseidon2_B_54_0, poseidon2_B_54_1, poseidon2_B_54_2, poseidon2_B_54_3, poseidon2_B_55_0, poseidon2_B_55_1, poseidon2_B_55_2, poseidon2_B_55_3, poseidon2_B_56_0, poseidon2_B_56_1, poseidon2_B_56_2, poseidon2_B_56_3, poseidon2_B_57_0, poseidon2_B_57_1, poseidon2_B_57_2, poseidon2_B_57_3, poseidon2_B_58_0, poseidon2_B_58_1, poseidon2_B_58_2, poseidon2_B_58_3, poseidon2_B_59_0, poseidon2_B_59_1, poseidon2_B_59_2, poseidon2_B_59_3, poseidon2_B_5_0, poseidon2_B_5_1, poseidon2_B_5_2, poseidon2_B_5_3, poseidon2_B_6_0, poseidon2_B_6_1, poseidon2_B_6_2, poseidon2_B_6_3, poseidon2_B_7_0, poseidon2_B_7_1, poseidon2_B_7_2, poseidon2_B_7_3, poseidon2_B_8_0, poseidon2_B_8_1, poseidon2_B_8_2, poseidon2_B_8_3, poseidon2_B_9_0, poseidon2_B_9_1, poseidon2_B_9_2, poseidon2_B_9_3, poseidon2_EXT_LAYER_4, poseidon2_EXT_LAYER_5, poseidon2_EXT_LAYER_6, poseidon2_EXT_LAYER_7, poseidon2_T_0_4, poseidon2_T_0_5, poseidon2_T_0_6, poseidon2_T_0_7, poseidon2_T_1_4, poseidon2_T_1_5, poseidon2_T_1_6, poseidon2_T_1_7, poseidon2_T_2_4, poseidon2_T_2_5, poseidon2_T_2_6, poseidon2_T_2_7, poseidon2_T_3_4, poseidon2_T_3_5, poseidon2_T_3_6, poseidon2_T_3_7, poseidon2_T_60_4, poseidon2_T_60_5, poseidon2_T_60_6, poseidon2_T_60_7, poseidon2_T_61_4, poseidon2_T_61_5, poseidon2_T_61_6, poseidon2_T_61_7, poseidon2_T_62_4, poseidon2_T_62_5, poseidon2_T_62_6, poseidon2_T_62_7, poseidon2_T_63_4, poseidon2_T_63_5, poseidon2_T_63_6, poseidon2_T_63_7, poseidon2_a_0, poseidon2_a_1, poseidon2_a_2, poseidon2_a_3, poseidon2_b_0, poseidon2_b_1, poseidon2_b_2, poseidon2_b_3, poseidon2_clk, poseidon2_full_a_0, poseidon2_full_a_1, poseidon2_full_a_2, poseidon2_full_a_3, poseidon2_full_b_0, poseidon2_full_b_1, poseidon2_full_b_2, poseidon2_full_b_3, poseidon2_full_clk, poseidon2_full_end_poseidon, poseidon2_full_execute_poseidon_perm, poseidon2_full_input_0, poseidon2_full_input_1, poseidon2_full_input_2, poseidon2_full_input_len, poseidon2_full_num_perm_rounds_rem, poseidon2_full_num_perm_rounds_rem_inv, poseidon2_full_output, poseidon2_full_padding, poseidon2_full_sel_merkle_tree, poseidon2_full_sel_poseidon, poseidon2_full_start_poseidon, poseidon2_input_addr, poseidon2_mem_addr_read_a, poseidon2_mem_addr_read_b, poseidon2_mem_addr_read_c, poseidon2_mem_addr_read_d, poseidon2_mem_addr_write_a, poseidon2_mem_addr_write_b, poseidon2_mem_addr_write_c, poseidon2_mem_addr_write_d, poseidon2_output_addr, poseidon2_sel_poseidon_perm, poseidon2_sel_poseidon_perm_immediate, poseidon2_sel_poseidon_perm_mem_op, poseidon2_space_id, range_check_alu_rng_chk, range_check_clk, range_check_cmp_hi_bits_rng_chk, range_check_cmp_lo_bits_rng_chk, range_check_dyn_diff, range_check_dyn_rng_chk_bits, range_check_dyn_rng_chk_pow_2, range_check_gas_da_rng_chk, range_check_gas_l2_rng_chk, range_check_is_lte_u112, range_check_is_lte_u128, range_check_is_lte_u16, range_check_is_lte_u32, range_check_is_lte_u48, range_check_is_lte_u64, range_check_is_lte_u80, range_check_is_lte_u96, range_check_mem_rng_chk, range_check_rng_chk_bits, range_check_sel_lookup_0, range_check_sel_lookup_1, range_check_sel_lookup_2, range_check_sel_lookup_3, range_check_sel_lookup_4, range_check_sel_lookup_5, range_check_sel_lookup_6, range_check_sel_rng_chk, range_check_u16_r0, range_check_u16_r1, range_check_u16_r2, range_check_u16_r3, range_check_u16_r4, range_check_u16_r5, range_check_u16_r6, range_check_u16_r7, range_check_value, sha256_clk, sha256_input, sha256_output, sha256_sel_sha256_compression, sha256_state, slice_addr, slice_clk, slice_cnt, slice_col_offset, slice_one_min_inv, slice_sel_cd_cpy, slice_sel_mem_active, slice_sel_return, slice_sel_start, slice_space_id, slice_val, lookup_rng_chk_pow_2_counts, lookup_rng_chk_diff_counts, lookup_rng_chk_0_counts, lookup_rng_chk_1_counts, lookup_rng_chk_2_counts, lookup_rng_chk_3_counts, lookup_rng_chk_4_counts, lookup_rng_chk_5_counts, lookup_rng_chk_6_counts, lookup_rng_chk_7_counts, lookup_pow_2_0_counts, lookup_pow_2_1_counts, lookup_byte_lengths_counts, lookup_byte_operations_counts, lookup_opcode_gas_counts, kernel_output_lookup_counts, lookup_into_kernel_counts, lookup_cd_value_counts, lookup_ret_value_counts, incl_main_tag_err_counts, incl_mem_tag_err_counts #define DERIVED_WITNESS_ENTITIES perm_rng_mem_inv, perm_rng_cmp_lo_inv, perm_rng_cmp_hi_inv, perm_rng_alu_inv, perm_cmp_alu_inv, perm_rng_gas_l2_inv, perm_rng_gas_da_inv, perm_l2_start_gas_inv, perm_da_start_gas_inv, perm_l2_end_gas_inv, perm_da_end_gas_inv, perm_pos_mem_read_a_inv, perm_pos_mem_read_b_inv, perm_pos_mem_read_c_inv, perm_pos_mem_read_d_inv, perm_pos_mem_write_a_inv, perm_pos_mem_write_b_inv, perm_pos_mem_write_c_inv, perm_pos_mem_write_d_inv, perm_pos2_fixed_pos2_perm_inv, perm_slice_mem_inv, perm_merkle_poseidon2_inv, perm_main_alu_inv, perm_main_bin_inv, perm_main_conv_inv, perm_main_sha256_inv, perm_main_pos2_perm_inv, perm_main_slice_inv, perm_main_mem_a_inv, perm_main_mem_b_inv, perm_main_mem_c_inv, perm_main_mem_d_inv, perm_main_mem_ind_addr_a_inv, perm_main_mem_ind_addr_b_inv, perm_main_mem_ind_addr_c_inv, perm_main_mem_ind_addr_d_inv, lookup_rng_chk_pow_2_inv, lookup_rng_chk_diff_inv, lookup_rng_chk_0_inv, lookup_rng_chk_1_inv, lookup_rng_chk_2_inv, lookup_rng_chk_3_inv, lookup_rng_chk_4_inv, lookup_rng_chk_5_inv, lookup_rng_chk_6_inv, lookup_rng_chk_7_inv, lookup_pow_2_0_inv, lookup_pow_2_1_inv, lookup_byte_lengths_inv, lookup_byte_operations_inv, lookup_opcode_gas_inv, kernel_output_lookup_inv, lookup_into_kernel_inv, lookup_cd_value_inv, lookup_ret_value_inv, incl_main_tag_err_inv, incl_mem_tag_err_inv #define SHIFTED_ENTITIES binary_acc_ia_shift, binary_acc_ib_shift, binary_acc_ic_shift, binary_mem_tag_ctr_shift, binary_op_id_shift, cmp_a_hi_shift, cmp_a_lo_shift, cmp_b_hi_shift, cmp_b_lo_shift, cmp_cmp_rng_ctr_shift, cmp_op_gt_shift, cmp_p_sub_a_hi_shift, cmp_p_sub_a_lo_shift, cmp_p_sub_b_hi_shift, cmp_p_sub_b_lo_shift, cmp_sel_rng_chk_shift, main_da_gas_remaining_shift, main_emit_l2_to_l1_msg_write_offset_shift, main_emit_note_hash_write_offset_shift, main_emit_nullifier_write_offset_shift, main_emit_unencrypted_log_write_offset_shift, main_internal_return_ptr_shift, main_l1_to_l2_msg_exists_write_offset_shift, main_l2_gas_remaining_shift, main_note_hash_exist_write_offset_shift, main_nullifier_exists_write_offset_shift, main_nullifier_non_exists_write_offset_shift, main_pc_shift, main_sel_execution_end_shift, main_sel_execution_row_shift, main_sload_write_offset_shift, main_sstore_write_offset_shift, mem_glob_addr_shift, mem_rw_shift, mem_sel_mem_shift, mem_tag_shift, mem_tsp_shift, mem_val_shift, merkle_tree_leaf_index_shift, merkle_tree_leaf_value_shift, merkle_tree_path_len_shift, poseidon2_full_a_0_shift, poseidon2_full_a_1_shift, poseidon2_full_a_2_shift, poseidon2_full_a_3_shift, poseidon2_full_execute_poseidon_perm_shift, poseidon2_full_input_0_shift, poseidon2_full_input_1_shift, poseidon2_full_input_2_shift, poseidon2_full_num_perm_rounds_rem_shift, poseidon2_full_sel_poseidon_shift, poseidon2_full_start_poseidon_shift, slice_addr_shift, slice_clk_shift, slice_cnt_shift, slice_col_offset_shift, slice_sel_cd_cpy_shift, slice_sel_mem_active_shift, slice_sel_return_shift, slice_sel_start_shift, slice_space_id_shift #define TO_BE_SHIFTED(e) e.binary_acc_ia, e.binary_acc_ib, e.binary_acc_ic, e.binary_mem_tag_ctr, e.binary_op_id, e.cmp_a_hi, e.cmp_a_lo, e.cmp_b_hi, e.cmp_b_lo, e.cmp_cmp_rng_ctr, e.cmp_op_gt, e.cmp_p_sub_a_hi, e.cmp_p_sub_a_lo, e.cmp_p_sub_b_hi, e.cmp_p_sub_b_lo, e.cmp_sel_rng_chk, e.main_da_gas_remaining, e.main_emit_l2_to_l1_msg_write_offset, e.main_emit_note_hash_write_offset, e.main_emit_nullifier_write_offset, e.main_emit_unencrypted_log_write_offset, e.main_internal_return_ptr, e.main_l1_to_l2_msg_exists_write_offset, e.main_l2_gas_remaining, e.main_note_hash_exist_write_offset, e.main_nullifier_exists_write_offset, e.main_nullifier_non_exists_write_offset, e.main_pc, e.main_sel_execution_end, e.main_sel_execution_row, e.main_sload_write_offset, e.main_sstore_write_offset, e.mem_glob_addr, e.mem_rw, e.mem_sel_mem, e.mem_tag, e.mem_tsp, e.mem_val, e.merkle_tree_leaf_index, e.merkle_tree_leaf_value, e.merkle_tree_path_len, e.poseidon2_full_a_0, e.poseidon2_full_a_1, e.poseidon2_full_a_2, e.poseidon2_full_a_3, e.poseidon2_full_execute_poseidon_perm, e.poseidon2_full_input_0, e.poseidon2_full_input_1, e.poseidon2_full_input_2, e.poseidon2_full_num_perm_rounds_rem, e.poseidon2_full_sel_poseidon, e.poseidon2_full_start_poseidon, e.slice_addr, e.slice_clk, e.slice_cnt, e.slice_col_offset, e.slice_sel_cd_cpy, e.slice_sel_mem_active, e.slice_sel_return, e.slice_sel_start, e.slice_space_id @@ -127,12 +127,12 @@ class AvmFlavor { static constexpr bool HasZK = false; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 21; - static constexpr size_t NUM_WITNESS_ENTITIES = 743; + static constexpr size_t NUM_WITNESS_ENTITIES = 745; static constexpr size_t NUM_SHIFTED_ENTITIES = 61; static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; // We have two copies of the witness entities, so we subtract the number of fixed ones (they have no shift), one for // the unshifted and one for the shifted - static constexpr size_t NUM_ALL_ENTITIES = 825; + static constexpr size_t NUM_ALL_ENTITIES = 827; // The total number of witnesses including shifts and derived entities. static constexpr size_t NUM_ALL_WITNESS_ENTITIES = NUM_WITNESS_ENTITIES + NUM_SHIFTED_ENTITIES; diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.cpp index 084579138ed..e59b17b05ca 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.cpp @@ -269,6 +269,8 @@ template std::vector AvmFullRow::names() "main_sel_op_or", "main_sel_op_poseidon2", "main_sel_op_radix_be", + "main_sel_op_returndata_copy", + "main_sel_op_returndata_size", "main_sel_op_sender", "main_sel_op_set", "main_sel_op_sha256", @@ -1038,6 +1040,8 @@ template RefVector AvmFullRow::as_vector() const main_sel_op_or, main_sel_op_poseidon2, main_sel_op_radix_be, + main_sel_op_returndata_copy, + main_sel_op_returndata_size, main_sel_op_sender, main_sel_op_set, main_sel_op_sha256, diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.hpp index b2cb3b0782f..853dcfb0b82 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/full_row.hpp @@ -260,6 +260,8 @@ template struct AvmFullRow { FF main_sel_op_or{}; FF main_sel_op_poseidon2{}; FF main_sel_op_radix_be{}; + FF main_sel_op_returndata_copy{}; + FF main_sel_op_returndata_size{}; FF main_sel_op_sender{}; FF main_sel_op_set{}; FF main_sel_op_sha256{}; @@ -778,7 +780,7 @@ template struct AvmFullRow { RefVector as_vector() const; static std::vector names(); - static constexpr size_t SIZE = 764; + static constexpr size_t SIZE = 766; }; template std::ostream& operator<<(std::ostream& os, AvmFullRow const& row); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/main.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/main.hpp index 108623ff265..95eb0206a11 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/main.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/generated/relations/main.hpp @@ -10,10 +10,11 @@ template class mainImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { - 2, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 5, 4, 4, 3, 3, 3, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 3, 3, 4, 4, 3, 3, 3, 3, 4, 3, 3, 3, 3, 4, 2, 2 + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS = { + 2, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 4, 4, 3, 3, 3, 3, 4, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 3, 3, 4, 4, 3, 3, 3, 3, 4, 3, 3, 3, 3, 4, 2, 2 }; template @@ -45,11 +46,12 @@ template class mainImpl { new_term.main_sel_op_sload) + new_term.main_sel_op_sstore); const auto main_SEL_ALL_CTRL_FLOW = - ((((((new_term.main_sel_op_jump + new_term.main_sel_op_jumpi) + new_term.main_sel_op_internal_call) + - new_term.main_sel_op_internal_return) + - new_term.main_sel_op_external_call) + - new_term.main_sel_op_static_call) + - new_term.main_sel_op_external_return); + (((((((new_term.main_sel_op_jump + new_term.main_sel_op_jumpi) + new_term.main_sel_op_internal_call) + + new_term.main_sel_op_internal_return) + + new_term.main_sel_op_external_call) + + new_term.main_sel_op_static_call) + + new_term.main_sel_op_external_return) + + new_term.main_sel_op_external_revert); const auto main_SEL_ALU_R_TAG = (((((((((new_term.main_sel_op_add + new_term.main_sel_op_sub) + new_term.main_sel_op_mul) + new_term.main_sel_op_div) + @@ -70,8 +72,10 @@ template class mainImpl { new_term.main_sel_op_ecadd) + new_term.main_sel_op_msm); const auto main_SEL_ALL_MEMORY = (new_term.main_sel_op_mov + new_term.main_sel_op_set); - const auto main_OPCODE_SELECTORS = ((((((((((new_term.main_sel_op_fdiv + new_term.main_sel_op_calldata_copy) + - new_term.main_sel_op_get_contract_instance) + + const auto main_OPCODE_SELECTORS = ((((((((((((new_term.main_sel_op_fdiv + new_term.main_sel_op_calldata_copy) + + new_term.main_sel_op_get_contract_instance) + + new_term.main_sel_op_returndata_size) + + new_term.main_sel_op_returndata_copy) + main_SEL_ALL_ALU) + main_SEL_ALL_BINARY) + main_SEL_ALL_MEMORY) + @@ -413,366 +417,378 @@ template class mainImpl { } { using Accumulator = typename std::tuple_element_t<54, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_external_return * (FF(1) - new_term.main_sel_op_external_return)); + auto tmp = (new_term.main_sel_op_returndata_size * (FF(1) - new_term.main_sel_op_returndata_size)); tmp *= scaling_factor; std::get<54>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<55, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_external_revert * (FF(1) - new_term.main_sel_op_external_revert)); + auto tmp = (new_term.main_sel_op_returndata_copy * (FF(1) - new_term.main_sel_op_returndata_copy)); tmp *= scaling_factor; std::get<55>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<56, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_set * (FF(1) - new_term.main_sel_op_set)); + auto tmp = (new_term.main_sel_op_external_return * (FF(1) - new_term.main_sel_op_external_return)); tmp *= scaling_factor; std::get<56>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<57, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_mov * (FF(1) - new_term.main_sel_op_mov)); + auto tmp = (new_term.main_sel_op_external_revert * (FF(1) - new_term.main_sel_op_external_revert)); tmp *= scaling_factor; std::get<57>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<58, ContainerOverSubrelations>; - auto tmp = (new_term.main_op_err * (FF(1) - new_term.main_op_err)); + auto tmp = (new_term.main_sel_op_set * (FF(1) - new_term.main_sel_op_set)); tmp *= scaling_factor; std::get<58>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<59, ContainerOverSubrelations>; - auto tmp = (new_term.main_tag_err * (FF(1) - new_term.main_tag_err)); + auto tmp = (new_term.main_sel_op_mov * (FF(1) - new_term.main_sel_op_mov)); tmp *= scaling_factor; std::get<59>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<60, ContainerOverSubrelations>; - auto tmp = (new_term.main_id_zero * (FF(1) - new_term.main_id_zero)); + auto tmp = (new_term.main_op_err * (FF(1) - new_term.main_op_err)); tmp *= scaling_factor; std::get<60>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<61, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_mem_op_a * (FF(1) - new_term.main_sel_mem_op_a)); + auto tmp = (new_term.main_tag_err * (FF(1) - new_term.main_tag_err)); tmp *= scaling_factor; std::get<61>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<62, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_mem_op_b * (FF(1) - new_term.main_sel_mem_op_b)); + auto tmp = (new_term.main_id_zero * (FF(1) - new_term.main_id_zero)); tmp *= scaling_factor; std::get<62>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<63, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_mem_op_c * (FF(1) - new_term.main_sel_mem_op_c)); + auto tmp = (new_term.main_sel_mem_op_a * (FF(1) - new_term.main_sel_mem_op_a)); tmp *= scaling_factor; std::get<63>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<64, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_mem_op_d * (FF(1) - new_term.main_sel_mem_op_d)); + auto tmp = (new_term.main_sel_mem_op_b * (FF(1) - new_term.main_sel_mem_op_b)); tmp *= scaling_factor; std::get<64>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<65, ContainerOverSubrelations>; - auto tmp = (new_term.main_rwa * (FF(1) - new_term.main_rwa)); + auto tmp = (new_term.main_sel_mem_op_c * (FF(1) - new_term.main_sel_mem_op_c)); tmp *= scaling_factor; std::get<65>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<66, ContainerOverSubrelations>; - auto tmp = (new_term.main_rwb * (FF(1) - new_term.main_rwb)); + auto tmp = (new_term.main_sel_mem_op_d * (FF(1) - new_term.main_sel_mem_op_d)); tmp *= scaling_factor; std::get<66>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<67, ContainerOverSubrelations>; - auto tmp = (new_term.main_rwc * (FF(1) - new_term.main_rwc)); + auto tmp = (new_term.main_rwa * (FF(1) - new_term.main_rwa)); tmp *= scaling_factor; std::get<67>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<68, ContainerOverSubrelations>; - auto tmp = (new_term.main_rwd * (FF(1) - new_term.main_rwd)); + auto tmp = (new_term.main_rwb * (FF(1) - new_term.main_rwb)); tmp *= scaling_factor; std::get<68>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<69, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_resolve_ind_addr_a * (FF(1) - new_term.main_sel_resolve_ind_addr_a)); + auto tmp = (new_term.main_rwc * (FF(1) - new_term.main_rwc)); tmp *= scaling_factor; std::get<69>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<70, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_resolve_ind_addr_b * (FF(1) - new_term.main_sel_resolve_ind_addr_b)); + auto tmp = (new_term.main_rwd * (FF(1) - new_term.main_rwd)); tmp *= scaling_factor; std::get<70>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<71, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_resolve_ind_addr_c * (FF(1) - new_term.main_sel_resolve_ind_addr_c)); + auto tmp = (new_term.main_sel_resolve_ind_addr_a * (FF(1) - new_term.main_sel_resolve_ind_addr_a)); tmp *= scaling_factor; std::get<71>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<72, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_resolve_ind_addr_d * (FF(1) - new_term.main_sel_resolve_ind_addr_d)); + auto tmp = (new_term.main_sel_resolve_ind_addr_b * (FF(1) - new_term.main_sel_resolve_ind_addr_b)); tmp *= scaling_factor; std::get<72>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<73, ContainerOverSubrelations>; - auto tmp = (((new_term.main_sel_op_eq + new_term.main_sel_op_lte) + new_term.main_sel_op_lt) * - (new_term.main_w_in_tag - constants_MEM_TAG_U1)); + auto tmp = (new_term.main_sel_resolve_ind_addr_c * (FF(1) - new_term.main_sel_resolve_ind_addr_c)); tmp *= scaling_factor; std::get<73>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<74, ContainerOverSubrelations>; - auto tmp = ((new_term.main_sel_op_fdiv * (FF(1) - new_term.main_op_err)) * - ((new_term.main_ic * new_term.main_ib) - new_term.main_ia)); + auto tmp = (new_term.main_sel_resolve_ind_addr_d * (FF(1) - new_term.main_sel_resolve_ind_addr_d)); tmp *= scaling_factor; std::get<74>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<75, ContainerOverSubrelations>; - auto tmp = ((new_term.main_sel_op_fdiv + new_term.main_sel_op_div) * - (((new_term.main_ib * new_term.main_inv) - FF(1)) + new_term.main_op_err)); + auto tmp = (((new_term.main_sel_op_eq + new_term.main_sel_op_lte) + new_term.main_sel_op_lt) * + (new_term.main_w_in_tag - constants_MEM_TAG_U1)); tmp *= scaling_factor; std::get<75>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<76, ContainerOverSubrelations>; - auto tmp = (((new_term.main_sel_op_fdiv + new_term.main_sel_op_div) * new_term.main_op_err) * - (FF(1) - new_term.main_inv)); + auto tmp = ((new_term.main_sel_op_fdiv * (FF(1) - new_term.main_op_err)) * + ((new_term.main_ic * new_term.main_ib) - new_term.main_ia)); tmp *= scaling_factor; std::get<76>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<77, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_fdiv * (new_term.main_r_in_tag - constants_MEM_TAG_FF)); + auto tmp = ((new_term.main_sel_op_fdiv + new_term.main_sel_op_div) * + (((new_term.main_ib * new_term.main_inv) - FF(1)) + new_term.main_op_err)); tmp *= scaling_factor; std::get<77>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<78, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_fdiv * (new_term.main_w_in_tag - constants_MEM_TAG_FF)); + auto tmp = (((new_term.main_sel_op_fdiv + new_term.main_sel_op_div) * new_term.main_op_err) * + (FF(1) - new_term.main_inv)); tmp *= scaling_factor; std::get<78>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<79, ContainerOverSubrelations>; - auto tmp = (new_term.main_op_err * (((new_term.main_sel_op_fdiv + new_term.main_sel_op_div) + - new_term.main_sel_op_get_contract_instance) - - FF(1))); + auto tmp = (new_term.main_sel_op_fdiv * (new_term.main_r_in_tag - constants_MEM_TAG_FF)); tmp *= scaling_factor; std::get<79>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<80, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_jump * (new_term.main_pc_shift - new_term.main_ia)); + auto tmp = (new_term.main_sel_op_fdiv * (new_term.main_w_in_tag - constants_MEM_TAG_FF)); tmp *= scaling_factor; std::get<80>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<81, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_jumpi * - (((FF(1) - new_term.main_id_zero) * (new_term.main_pc_shift - new_term.main_ia)) + - (new_term.main_id_zero * ((new_term.main_pc_shift - new_term.main_pc) - FF(1))))); + auto tmp = (new_term.main_op_err * (((new_term.main_sel_op_fdiv + new_term.main_sel_op_div) + + new_term.main_sel_op_get_contract_instance) - + FF(1))); tmp *= scaling_factor; std::get<81>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<82, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_call * - (new_term.main_internal_return_ptr_shift - (new_term.main_internal_return_ptr + FF(1)))); + auto tmp = (new_term.main_sel_op_jump * (new_term.main_pc_shift - new_term.main_ia)); tmp *= scaling_factor; std::get<82>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<83, ContainerOverSubrelations>; - auto tmp = - (new_term.main_sel_op_internal_call * (new_term.main_internal_return_ptr - new_term.main_mem_addr_b)); + auto tmp = (new_term.main_sel_op_jumpi * + (((FF(1) - new_term.main_id_zero) * (new_term.main_pc_shift - new_term.main_ia)) + + (new_term.main_id_zero * ((new_term.main_pc_shift - new_term.main_pc) - FF(1))))); tmp *= scaling_factor; std::get<83>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<84, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_call * (new_term.main_pc_shift - new_term.main_ia)); + auto tmp = (new_term.main_sel_op_internal_call * + (new_term.main_internal_return_ptr_shift - (new_term.main_internal_return_ptr + FF(1)))); tmp *= scaling_factor; std::get<84>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<85, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_call * ((new_term.main_pc + FF(1)) - new_term.main_ib)); + auto tmp = + (new_term.main_sel_op_internal_call * (new_term.main_internal_return_ptr - new_term.main_mem_addr_b)); tmp *= scaling_factor; std::get<85>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<86, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_call * (new_term.main_rwb - FF(1))); + auto tmp = (new_term.main_sel_op_internal_call * (new_term.main_pc_shift - new_term.main_ia)); tmp *= scaling_factor; std::get<86>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<87, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_call * (new_term.main_sel_mem_op_b - FF(1))); + auto tmp = (new_term.main_sel_op_internal_call * ((new_term.main_pc + FF(1)) - new_term.main_ib)); tmp *= scaling_factor; std::get<87>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<88, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_return * - (new_term.main_internal_return_ptr_shift - (new_term.main_internal_return_ptr - FF(1)))); + auto tmp = (new_term.main_sel_op_internal_call * (new_term.main_rwb - FF(1))); tmp *= scaling_factor; std::get<88>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<89, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_return * - ((new_term.main_internal_return_ptr - FF(1)) - new_term.main_mem_addr_a)); + auto tmp = (new_term.main_sel_op_internal_call * (new_term.main_sel_mem_op_b - FF(1))); tmp *= scaling_factor; std::get<89>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<90, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_return * (new_term.main_pc_shift - new_term.main_ia)); + auto tmp = (new_term.main_sel_op_internal_return * + (new_term.main_internal_return_ptr_shift - (new_term.main_internal_return_ptr - FF(1)))); tmp *= scaling_factor; std::get<90>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<91, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_return * new_term.main_rwa); + auto tmp = (new_term.main_sel_op_internal_return * + ((new_term.main_internal_return_ptr - FF(1)) - new_term.main_mem_addr_a)); tmp *= scaling_factor; std::get<91>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<92, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_internal_return * (new_term.main_sel_mem_op_a - FF(1))); + auto tmp = (new_term.main_sel_op_internal_return * (new_term.main_pc_shift - new_term.main_ia)); tmp *= scaling_factor; std::get<92>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<93, ContainerOverSubrelations>; - auto tmp = ((main_CUR_AND_NEXT_ARE_MAIN * (FF(1) - main_SEL_ALL_CTRL_FLOW)) * - (new_term.main_pc_shift - (new_term.main_pc + FF(1)))); + auto tmp = (new_term.main_sel_op_internal_return * new_term.main_rwa); tmp *= scaling_factor; std::get<93>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<94, ContainerOverSubrelations>; - auto tmp = ((main_CUR_AND_NEXT_ARE_MAIN * (FF(1) - main_SEL_ALL_CTRL_FLOW)) * - (new_term.main_internal_return_ptr_shift - new_term.main_internal_return_ptr)); + auto tmp = (new_term.main_sel_op_internal_return * (new_term.main_sel_mem_op_a - FF(1))); tmp *= scaling_factor; std::get<94>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<95, ContainerOverSubrelations>; - auto tmp = ((new_term.main_sel_op_internal_call + new_term.main_sel_op_internal_return) * - (new_term.main_space_id - constants_misc_INTERNAL_CALL_SPACE_ID)); + auto tmp = ((main_CUR_AND_NEXT_ARE_MAIN * (FF(1) - main_SEL_ALL_CTRL_FLOW)) * + (new_term.main_pc_shift - (new_term.main_pc + FF(1)))); tmp *= scaling_factor; std::get<95>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<96, ContainerOverSubrelations>; - auto tmp = (((FF(1) - new_term.main_sel_op_internal_call) - new_term.main_sel_op_internal_return) * - (new_term.main_call_ptr - new_term.main_space_id)); + auto tmp = ((main_CUR_AND_NEXT_ARE_MAIN * (FF(1) - main_SEL_ALL_CTRL_FLOW)) * + (new_term.main_internal_return_ptr_shift - new_term.main_internal_return_ptr)); tmp *= scaling_factor; std::get<96>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<97, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_jumpi * - (((new_term.main_id * new_term.main_inv) - FF(1)) + new_term.main_id_zero)); + auto tmp = ((new_term.main_sel_op_internal_call + new_term.main_sel_op_internal_return) * + (new_term.main_space_id - constants_misc_INTERNAL_CALL_SPACE_ID)); tmp *= scaling_factor; std::get<97>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<98, ContainerOverSubrelations>; - auto tmp = ((new_term.main_sel_op_jumpi * new_term.main_id_zero) * (FF(1) - new_term.main_inv)); + auto tmp = (((FF(1) - new_term.main_sel_op_internal_call) - new_term.main_sel_op_internal_return) * + (new_term.main_call_ptr - new_term.main_space_id)); tmp *= scaling_factor; std::get<98>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<99, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_mov_ia_to_ic - (new_term.main_sel_op_mov * (FF(1) - new_term.main_id_zero))); + auto tmp = (new_term.main_sel_op_jumpi * + (((new_term.main_id * new_term.main_inv) - FF(1)) + new_term.main_id_zero)); tmp *= scaling_factor; std::get<99>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<100, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_mov_ia_to_ic * (new_term.main_ia - new_term.main_ic)); + auto tmp = ((new_term.main_sel_op_jumpi * new_term.main_id_zero) * (FF(1) - new_term.main_inv)); tmp *= scaling_factor; std::get<100>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<101, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_mov_ib_to_ic * (new_term.main_ib - new_term.main_ic)); + auto tmp = (new_term.main_sel_mov_ia_to_ic - (new_term.main_sel_op_mov * (FF(1) - new_term.main_id_zero))); tmp *= scaling_factor; std::get<101>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<102, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_mov * (new_term.main_r_in_tag - new_term.main_w_in_tag)); + auto tmp = (new_term.main_sel_mov_ia_to_ic * (new_term.main_ia - new_term.main_ic)); tmp *= scaling_factor; std::get<102>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<103, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_alu - - ((main_SEL_ALL_ALU * (FF(1) - new_term.main_tag_err)) * (FF(1) - new_term.main_op_err))); + auto tmp = (new_term.main_sel_mov_ib_to_ic * (new_term.main_ib - new_term.main_ic)); tmp *= scaling_factor; std::get<103>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<104, ContainerOverSubrelations>; - auto tmp = (main_SEL_ALU_R_TAG * (new_term.main_alu_in_tag - new_term.main_r_in_tag)); + auto tmp = (new_term.main_sel_op_mov * (new_term.main_r_in_tag - new_term.main_w_in_tag)); tmp *= scaling_factor; std::get<104>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<105, ContainerOverSubrelations>; - auto tmp = (main_SEL_ALU_W_TAG * (new_term.main_alu_in_tag - new_term.main_w_in_tag)); + auto tmp = (new_term.main_sel_alu - + ((main_SEL_ALL_ALU * (FF(1) - new_term.main_tag_err)) * (FF(1) - new_term.main_op_err))); tmp *= scaling_factor; std::get<105>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<106, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_l2gasleft * (new_term.main_ia - new_term.main_l2_gas_remaining_shift)); + auto tmp = (main_SEL_ALU_R_TAG * (new_term.main_alu_in_tag - new_term.main_r_in_tag)); tmp *= scaling_factor; std::get<106>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<107, ContainerOverSubrelations>; - auto tmp = (new_term.main_sel_op_dagasleft * (new_term.main_ia - new_term.main_da_gas_remaining_shift)); + auto tmp = (main_SEL_ALU_W_TAG * (new_term.main_alu_in_tag - new_term.main_w_in_tag)); tmp *= scaling_factor; std::get<107>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<108, ContainerOverSubrelations>; - auto tmp = ((new_term.main_ib * (FF(1) - new_term.main_tag_err)) * - ((new_term.main_sel_op_calldata_copy + new_term.main_sel_op_external_return) - - new_term.main_sel_slice_gadget)); + auto tmp = (new_term.main_sel_op_l2gasleft * (new_term.main_ia - new_term.main_l2_gas_remaining_shift)); tmp *= scaling_factor; std::get<108>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<109, ContainerOverSubrelations>; - auto tmp = (new_term.main_bin_op_id - (new_term.main_sel_op_or + (FF(2) * new_term.main_sel_op_xor))); + auto tmp = (new_term.main_sel_op_dagasleft * (new_term.main_ia - new_term.main_da_gas_remaining_shift)); tmp *= scaling_factor; std::get<109>(evals) += typename Accumulator::View(tmp); } { using Accumulator = typename std::tuple_element_t<110, ContainerOverSubrelations>; + auto tmp = ((new_term.main_ib * (FF(1) - new_term.main_tag_err)) * + ((new_term.main_sel_op_calldata_copy + new_term.main_sel_op_external_return) - + new_term.main_sel_slice_gadget)); + tmp *= scaling_factor; + std::get<110>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<111, ContainerOverSubrelations>; + auto tmp = (new_term.main_bin_op_id - (new_term.main_sel_op_or + (FF(2) * new_term.main_sel_op_xor))); + tmp *= scaling_factor; + std::get<111>(evals) += typename Accumulator::View(tmp); + } + { + using Accumulator = typename std::tuple_element_t<112, ContainerOverSubrelations>; auto tmp = (new_term.main_sel_bin - ((new_term.main_sel_op_and + new_term.main_sel_op_or) + new_term.main_sel_op_xor)); tmp *= scaling_factor; - std::get<110>(evals) += typename Accumulator::View(tmp); + std::get<112>(evals) += typename Accumulator::View(tmp); } } }; @@ -786,53 +802,53 @@ template class main : public Relation> { switch (index) { case 0: return "OPCODE_SELECTORS"; - case 73: + case 75: return "OUTPUT_U1"; - case 74: + case 76: return "SUBOP_FDIV"; - case 75: + case 77: return "SUBOP_FDIV_ZERO_ERR1"; - case 76: + case 78: return "SUBOP_FDIV_ZERO_ERR2"; - case 77: + case 79: return "SUBOP_FDIV_R_IN_TAG_FF"; - case 78: + case 80: return "SUBOP_FDIV_W_IN_TAG_FF"; - case 79: + case 81: return "SUBOP_ERROR_RELEVANT_OP"; - case 80: + case 82: return "PC_JUMP"; - case 81: + case 83: return "PC_JUMPI"; - case 82: + case 84: return "RETURN_POINTER_INCREMENT"; - case 88: + case 90: return "RETURN_POINTER_DECREMENT"; - case 93: + case 95: return "PC_INCREMENT"; - case 94: + case 96: return "INTERNAL_RETURN_POINTER_CONSISTENCY"; - case 95: + case 97: return "SPACE_ID_INTERNAL"; - case 96: + case 98: return "SPACE_ID_STANDARD_OPCODES"; - case 97: + case 99: return "JMP_CONDITION_RES_1"; - case 98: - return "JMP_CONDITION_RES_2"; case 100: + return "JMP_CONDITION_RES_2"; + case 102: return "MOV_SAME_VALUE_A"; - case 101: + case 103: return "MOV_SAME_VALUE_B"; - case 102: + case 104: return "MOV_MAIN_SAME_TAG"; - case 106: + case 108: return "L2GASLEFT"; - case 107: - return "DAGASLEFT"; case 109: + return "DAGASLEFT"; + case 111: return "BIN_SEL_1"; - case 110: + case 112: return "BIN_SEL_2"; } return std::to_string(index); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/tests/execution.test.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/tests/execution.test.cpp index ccf0646e049..4837b592ea4 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/tests/execution.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/tests/execution.test.cpp @@ -1733,7 +1733,7 @@ TEST_F(AvmExecutionTests, kernelOutputEmitOpcodes) auto emit_log_row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.main_sel_op_emit_unencrypted_log == 1; }); // Trust me bro for now, this is the truncated sha output - FF expected_hash = FF(std::string("0x00c826495d6e1248a170accc2790424505d5d20204053143bda20812e360299e")); + FF expected_hash = FF(std::string("0x00b5c135991581f3049df936e35ef23af34bb04a4775426481d944d35a618e9d")); EXPECT_EQ(emit_log_row->main_ia, expected_hash); EXPECT_EQ(emit_log_row->main_side_effect_counter, 2); // Value is 40 = 32 * log_length + 40 (and log_length is 0 in this case). diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/deserialization.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/deserialization.cpp index ca6ab5e3dc4..c692d13611a 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/deserialization.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/deserialization.cpp @@ -88,6 +88,9 @@ const std::unordered_map> OPCODE_WIRE_FORMAT = // Execution Environment - Calldata { OpCode::CALLDATACOPY, { OperandType::INDIRECT8, OperandType::UINT16, OperandType::UINT16, OperandType::UINT16 } }, + { OpCode::RETURNDATASIZE, { OperandType::INDIRECT8, OperandType::UINT16 } }, + { OpCode::RETURNDATACOPY, + { OperandType::INDIRECT8, OperandType::UINT16, OperandType::UINT16, OperandType::UINT16 } }, // Machine State - Internal Control Flow { OpCode::JUMP_16, { OperandType::UINT16 } }, diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution.cpp index 77e159673f2..799f75c6b52 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/execution.cpp @@ -495,6 +495,18 @@ std::vector Execution::gen_trace(std::vector const& calldata, std::get(inst.operands.at(3))); break; + case OpCode::RETURNDATASIZE: + trace_builder.op_returndata_size(std::get(inst.operands.at(0)), + std::get(inst.operands.at(1))); + break; + + case OpCode::RETURNDATACOPY: + trace_builder.op_returndata_copy(std::get(inst.operands.at(0)), + std::get(inst.operands.at(1)), + std::get(inst.operands.at(2)), + std::get(inst.operands.at(3))); + break; + // Machine State - Internal Control Flow case OpCode::JUMP_16: trace_builder.op_jump(std::get(inst.operands.at(0))); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/fixed_gas.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/fixed_gas.cpp index edb550f2b15..8fa808e4ad3 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/fixed_gas.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/fixed_gas.cpp @@ -50,6 +50,8 @@ const std::unordered_map GAS_COST_TABLE = { { OpCode::CAST_16, make_cost(AVM_CAST_BASE_L2_GAS, 0, 0, 0) }, { OpCode::GETENVVAR_16, make_cost(AVM_GETENVVAR_BASE_L2_GAS, 0, 0, 0) }, { OpCode::CALLDATACOPY, make_cost(AVM_CALLDATACOPY_BASE_L2_GAS, 0, AVM_CALLDATACOPY_DYN_L2_GAS, 0) }, + { OpCode::RETURNDATASIZE, make_cost(AVM_RETURNDATASIZE_BASE_L2_GAS, 0, 0, 0) }, + { OpCode::RETURNDATACOPY, make_cost(AVM_RETURNDATACOPY_BASE_L2_GAS, 0, AVM_RETURNDATACOPY_DYN_L2_GAS, 0) }, { OpCode::JUMP_16, make_cost(AVM_JUMP_BASE_L2_GAS, 0, 0, 0) }, { OpCode::JUMPI_16, make_cost(AVM_JUMPI_BASE_L2_GAS, 0, 0, 0) }, { OpCode::INTERNALCALL, make_cost(AVM_INTERNALCALL_BASE_L2_GAS, 0, 0, 0) }, diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/opcode.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/opcode.hpp index 917e2c16c4a..cc5318be696 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/opcode.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/opcode.hpp @@ -56,6 +56,8 @@ enum class OpCode : uint8_t { GETENVVAR_16, // Execution Environment - Calldata CALLDATACOPY, + RETURNDATASIZE, + RETURNDATACOPY, // Machine State // Machine State - Internal Control Flow diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.cpp index 404ca05c20a..4faac1365fc 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.cpp @@ -1556,6 +1556,69 @@ void AvmTraceBuilder::op_calldata_copy(uint8_t indirect, }); } +void AvmTraceBuilder::op_returndata_size(uint8_t indirect, uint32_t dst_offset) +{ + auto const clk = static_cast(main_trace.size()) + 1; + // This boolean will not be a trivial constant anymore once we constrain address resolution. + bool tag_match = true; + + auto [resolved_dst_offset] = Addressing<1>::fromWire(indirect, call_ptr).resolve({ dst_offset }, mem_trace_builder); + + FF returndata_size = tag_match ? FF(nested_returndata.size()) : FF(0); + // TODO: constrain + write_to_memory(resolved_dst_offset, returndata_size, AvmMemoryTag::U32); + + // Constrain gas cost + gas_trace_builder.constrain_gas(clk, OpCode::RETURNDATASIZE); + + main_trace.push_back(Row{ + .main_clk = clk, + .main_call_ptr = call_ptr, + .main_internal_return_ptr = FF(internal_return_ptr), + .main_pc = FF(pc++), + .main_sel_op_returndata_size = FF(1), + .main_tag_err = FF(static_cast(!tag_match)), + .main_w_in_tag = FF(static_cast(AvmMemoryTag::U32)), + }); +} + +void AvmTraceBuilder::op_returndata_copy(uint8_t indirect, + uint32_t rd_offset_address, + uint32_t copy_size_offset, + uint32_t dst_offset) +{ + auto clk = static_cast(main_trace.size()) + 1; + + auto [rd_offset_resolved, copy_size_offset_resolved, dst_offset_resolved] = + Addressing<3>::fromWire(indirect, call_ptr) + .resolve({ rd_offset_address, copy_size_offset, dst_offset }, mem_trace_builder); + + // This boolean will not be a trivial constant anymore once we constrain address resolution. + bool tag_match = true; + + // TODO: constrain these. + const uint32_t rd_offset = static_cast(unconstrained_read_from_memory(rd_offset_resolved)); + const uint32_t copy_size = static_cast(unconstrained_read_from_memory(copy_size_offset_resolved)); + + gas_trace_builder.constrain_gas(clk, + OpCode::RETURNDATACOPY, + /*dyn_gas_multiplier=*/copy_size); + + main_trace.push_back(Row{ + .main_clk = clk, + .main_internal_return_ptr = FF(internal_return_ptr), + .main_pc = FF(pc++), + .main_sel_op_returndata_copy = FF(1), + .main_tag_err = FF(static_cast(!tag_match)), + }); + + // Write the return data to memory + // TODO: validate bounds + auto returndata_slice = + std::vector(nested_returndata.begin() + rd_offset, nested_returndata.begin() + rd_offset + copy_size); + write_slice_to_memory(dst_offset_resolved, AvmMemoryTag::FF, returndata_slice); +} + /************************************************************************************************** * MACHINE STATE - GAS **************************************************************************************************/ @@ -2665,14 +2728,21 @@ void AvmTraceBuilder::constrain_external_call(OpCode opcode, .main_tag_err = FF(static_cast(!tag_match)), }); - // The return data hint is used for now, we check it has the same length as the ret_size - ASSERT(hint.return_data.size() == ret_size); + // The hint contains the FULL return data. + // TODO: Don't fail if we ask for too much data. + ASSERT(ret_size <= hint.return_data.size()); + // Write the return data to memory - write_slice_to_memory(resolved_ret_offset, AvmMemoryTag::FF, hint.return_data); + write_slice_to_memory(resolved_ret_offset, + AvmMemoryTag::FF, + std::vector(hint.return_data.begin(), hint.return_data.begin() + ret_size)); // Write the success flag to memory write_slice_to_memory(resolved_success_offset, AvmMemoryTag::U8, std::vector{ hint.success }); external_call_counter++; + // Save return data for later. + nested_returndata = hint.return_data; + // Adjust the side_effect_counter to the value at the end of the external call but not static call. if (opcode == OpCode::CALL) { side_effect_counter = static_cast(hint.end_side_effect_counter); @@ -2835,7 +2905,7 @@ std::vector AvmTraceBuilder::op_revert(uint8_t indirect, uint32_t ret_offset Addressing<2>::fromWire(indirect, call_ptr).resolve({ ret_offset, ret_size_offset }, mem_trace_builder); const auto ret_size = static_cast(unconstrained_read_from_memory(resolved_ret_size_offset)); - gas_trace_builder.constrain_gas(clk, OpCode::RETURN, ret_size); + gas_trace_builder.constrain_gas(clk, OpCode::REVERT_8, ret_size); // TODO: fix and set sel_op_revert if (ret_size == 0) { diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.hpp index eda154a4c5f..66d373502b4 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/trace/trace.hpp @@ -80,6 +80,11 @@ class AvmTraceBuilder { // Execution Environment - Calldata void op_calldata_copy(uint8_t indirect, uint32_t cd_offset_address, uint32_t copy_size_offset, uint32_t dst_offset); + void op_returndata_size(uint8_t indirect, uint32_t dst_offset); + void op_returndata_copy(uint8_t indirect, + uint32_t rd_offset_address, + uint32_t copy_size_offset, + uint32_t dst_offset); // Machine State - Gas void op_l2gasleft(uint8_t indirect, uint32_t dst_offset); @@ -201,6 +206,10 @@ class AvmTraceBuilder { std::vector calldata; std::vector returndata; + + // Return/revert data of the last nested call. + std::vector nested_returndata; + // Side effect counter will increment when any state writing values are encountered. uint32_t side_effect_counter = 0; uint32_t external_call_counter = 0; // Incremented both by OpCode::CALL and OpCode::STATICCALL diff --git a/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp b/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp index 72f7b269c01..7cee92f4f3a 100644 --- a/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/aztec_constants.hpp @@ -36,7 +36,7 @@ #define PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH 866 #define PUBLIC_CONTEXT_INPUTS_LENGTH 41 #define AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS 86 -#define AVM_PROOF_LENGTH_IN_FIELDS 4166 +#define AVM_PROOF_LENGTH_IN_FIELDS 4176 #define AVM_PUBLIC_COLUMN_MAX_SIZE 1024 #define AVM_PUBLIC_INPUTS_FLATTENED_SIZE 2914 #define MEM_TAG_FF 0 @@ -88,6 +88,8 @@ #define AVM_CAST_BASE_L2_GAS 30 #define AVM_GETENVVAR_BASE_L2_GAS 20 #define AVM_CALLDATACOPY_BASE_L2_GAS 29 +#define AVM_RETURNDATASIZE_BASE_L2_GAS 20 +#define AVM_RETURNDATACOPY_BASE_L2_GAS 29 #define AVM_JUMP_BASE_L2_GAS 12 #define AVM_JUMPI_BASE_L2_GAS 18 #define AVM_INTERNALCALL_BASE_L2_GAS 18 @@ -116,6 +118,7 @@ #define AVM_MSM_BASE_L2_GAS 1000 #define AVM_TORADIXBE_BASE_L2_GAS 46 #define AVM_CALLDATACOPY_DYN_L2_GAS 6 +#define AVM_RETURNDATACOPY_DYN_L2_GAS 6 #define AVM_EMITUNENCRYPTEDLOG_DYN_L2_GAS 146 #define AVM_CALL_DYN_L2_GAS 4 #define AVM_STATICCALL_DYN_L2_GAS 4 diff --git a/noir-projects/aztec-nr/authwit/src/auth.nr b/noir-projects/aztec-nr/authwit/src/auth.nr index a3f15076f98..3809f76566a 100644 --- a/noir-projects/aztec-nr/authwit/src/auth.nr +++ b/noir-projects/aztec-nr/authwit/src/auth.nr @@ -252,7 +252,7 @@ pub fn assert_inner_hash_valid_authwit( * @param on_behalf_of The address that have authorized the current call */ // docs:start:assert_current_call_valid_authwit_public -pub fn assert_current_call_valid_authwit_public( +pub unconstrained fn assert_current_call_valid_authwit_public( context: &mut PublicContext, on_behalf_of: AztecAddress, ) { @@ -276,20 +276,19 @@ pub fn assert_current_call_valid_authwit_public( * * @param on_behalf_of The address that have authorized the `inner_hash` */ -pub fn assert_inner_hash_valid_authwit_public( +pub unconstrained fn assert_inner_hash_valid_authwit_public( context: &mut PublicContext, on_behalf_of: AztecAddress, inner_hash: Field, ) { - let result: Field = context - .call_public_function( - CANONICAL_AUTH_REGISTRY_ADDRESS, - comptime { FunctionSelector::from_signature("consume((Field),Field)") }, - [on_behalf_of.to_field(), inner_hash].as_slice(), - GasOpts::default(), - ) - .deserialize_into(); - assert(result == IS_VALID_SELECTOR, "Message not authorized by account"); + let results: [Field] = context.call_public_function( + CANONICAL_AUTH_REGISTRY_ADDRESS, + comptime { FunctionSelector::from_signature("consume((Field),Field)") }, + [on_behalf_of.to_field(), inner_hash].as_slice(), + GasOpts::default(), + ); + assert(results.len() == 1, "Invalid response from registry"); + assert(results[0] == IS_VALID_SELECTOR, "Message not authorized by account"); } /** @@ -377,15 +376,18 @@ pub fn compute_authwit_message_hash( * @param message_hash The hash of the message to authorize * @param authorize True if the message should be authorized, false if it should be revoked */ -pub fn set_authorized(context: &mut PublicContext, message_hash: Field, authorize: bool) { - context - .call_public_function( - CANONICAL_AUTH_REGISTRY_ADDRESS, - comptime { FunctionSelector::from_signature("set_authorized(Field,bool)") }, - [message_hash, authorize as Field].as_slice(), - GasOpts::default(), - ) - .assert_empty(); +pub unconstrained fn set_authorized( + context: &mut PublicContext, + message_hash: Field, + authorize: bool, +) { + let res = context.call_public_function( + CANONICAL_AUTH_REGISTRY_ADDRESS, + comptime { FunctionSelector::from_signature("set_authorized(Field,bool)") }, + [message_hash, authorize as Field].as_slice(), + GasOpts::default(), + ); + assert(res.len() == 0); } /** @@ -395,13 +397,12 @@ pub fn set_authorized(context: &mut PublicContext, message_hash: Field, authoriz * * @param reject True if all authwits should be rejected, false otherwise */ -pub fn set_reject_all(context: &mut PublicContext, reject: bool) { - context - .call_public_function( - CANONICAL_AUTH_REGISTRY_ADDRESS, - comptime { FunctionSelector::from_signature("set_reject_all(bool)") }, - [context.this_address().to_field(), reject as Field].as_slice(), - GasOpts::default(), - ) - .assert_empty(); +pub unconstrained fn set_reject_all(context: &mut PublicContext, reject: bool) { + let res = context.call_public_function( + CANONICAL_AUTH_REGISTRY_ADDRESS, + comptime { FunctionSelector::from_signature("set_reject_all(bool)") }, + [context.this_address().to_field(), reject as Field].as_slice(), + GasOpts::default(), + ); + assert(res.len() == 0); } diff --git a/noir-projects/aztec-nr/authwit/src/cheatcodes.nr b/noir-projects/aztec-nr/authwit/src/cheatcodes.nr index 8e1b3909044..21347c52316 100644 --- a/noir-projects/aztec-nr/authwit/src/cheatcodes.nr +++ b/noir-projects/aztec-nr/authwit/src/cheatcodes.nr @@ -28,7 +28,7 @@ where cheatcodes::add_authwit(on_behalf_of, message_hash); } -pub fn add_public_authwit_from_call_interface( +pub unconstrained fn add_public_authwit_from_call_interface( on_behalf_of: AztecAddress, caller: AztecAddress, call_interface: C, diff --git a/noir-projects/aztec-nr/aztec/src/context/call_interfaces.nr b/noir-projects/aztec-nr/aztec/src/context/call_interfaces.nr index b4e55f61288..b799f51fabf 100644 --- a/noir-projects/aztec-nr/aztec/src/context/call_interfaces.nr +++ b/noir-projects/aztec-nr/aztec/src/context/call_interfaces.nr @@ -183,7 +183,7 @@ impl PublicCallInterface { self } - pub fn call(self, context: &mut PublicContext) -> T + pub unconstrained fn call(self, context: &mut PublicContext) -> T where T: Deserialize, { @@ -193,10 +193,10 @@ impl PublicCallInterface { self.args, self.gas_opts, ); - returns.deserialize_into() + Deserialize::deserialize(returns.as_array::()) } - pub fn view(self, context: &mut PublicContext) -> T + pub unconstrained fn view(self, context: &mut PublicContext) -> T where T: Deserialize, { @@ -206,7 +206,7 @@ impl PublicCallInterface { self.args, self.gas_opts, ); - returns.deserialize_into() + Deserialize::deserialize(returns.as_array::()) } pub fn enqueue(self, context: &mut PrivateContext) { @@ -252,24 +252,24 @@ impl PublicVoidCallInterface { self } - pub fn call(self, context: &mut PublicContext) { + pub unconstrained fn call(self, context: &mut PublicContext) { let returns = context.call_public_function( self.target_contract, self.selector, self.args, self.gas_opts, ); - returns.assert_empty() + assert(returns.len() == 0); } - pub fn view(self, context: &mut PublicContext) { + pub unconstrained fn view(self, context: &mut PublicContext) { let returns = context.static_call_public_function( self.target_contract, self.selector, self.args, self.gas_opts, ); - returns.assert_empty() + assert(returns.len() == 0); } pub fn enqueue(self, context: &mut PrivateContext) { @@ -315,7 +315,7 @@ impl PublicStaticCallInterface { self } - pub fn view(self, context: &mut PublicContext) -> T + pub unconstrained fn view(self, context: &mut PublicContext) -> T where T: Deserialize, { @@ -325,8 +325,7 @@ impl PublicStaticCallInterface { self.args, self.gas_opts, ); - let unpacked: T = returns.deserialize_into(); - unpacked + Deserialize::deserialize(returns.as_array::()) } pub fn enqueue_view(self, context: &mut PrivateContext) { @@ -360,14 +359,14 @@ impl PublicStaticVoidCallInterface { self } - pub fn view(self, context: &mut PublicContext) { + pub unconstrained fn view(self, context: &mut PublicContext) { let returns = context.static_call_public_function( self.target_contract, self.selector, self.args, self.gas_opts, ); - returns.assert_empty() + assert(returns.len() == 0); } pub fn enqueue_view(self, context: &mut PrivateContext) { diff --git a/noir-projects/aztec-nr/aztec/src/context/mod.nr b/noir-projects/aztec-nr/aztec/src/context/mod.nr index 62347debff9..e51a7677ee7 100644 --- a/noir-projects/aztec-nr/aztec/src/context/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/context/mod.nr @@ -16,6 +16,5 @@ pub use call_interfaces::{ }; pub use packed_returns::PackedReturns; pub use private_context::PrivateContext; -pub use public_context::FunctionReturns; pub use public_context::PublicContext; pub use unconstrained_context::UnconstrainedContext; diff --git a/noir-projects/aztec-nr/aztec/src/context/public_context.nr b/noir-projects/aztec-nr/aztec/src/context/public_context.nr index bd1bcb4d8dc..83f7a37f067 100644 --- a/noir-projects/aztec-nr/aztec/src/context/public_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/public_context.nr @@ -69,44 +69,52 @@ impl PublicContext { send_l2_to_l1_msg(recipient, content); } - fn call_public_function( + pub unconstrained fn call_public_function( _self: &mut Self, contract_address: AztecAddress, function_selector: FunctionSelector, args: [Field], gas_opts: GasOpts, - ) -> FunctionReturns { - let args = &[function_selector.to_field()].append(args); - let results = call( + ) -> [Field] { + let args = args.push_front(function_selector.to_field()); + // TODO(https://github.com/AztecProtocol/aztec-packages/issues/9061): modify call opcode and remove <0>. + let (_, success) = call::<0>( gas_for_call(gas_opts), contract_address, args, PUBLIC_DISPATCH_SELECTOR, ); - let data_to_return: [Field; RETURNS_COUNT] = results.0; - let success: u8 = results.1; - assert(success == 1, "Nested call failed!"); - FunctionReturns::new(data_to_return) + let result_data = returndata_copy(0, returndata_size()); + if success == 0 { + // Rethrow the revert data. + avm_revert(result_data); + } + result_data } - fn static_call_public_function( + pub unconstrained fn static_call_public_function( _self: &mut Self, contract_address: AztecAddress, function_selector: FunctionSelector, args: [Field], gas_opts: GasOpts, - ) -> FunctionReturns { - let args = &[function_selector.to_field()].append(args); - let (data_to_return, success): ([Field; RETURNS_COUNT], u8) = call_static( + ) -> [Field] { + let args = args.push_front(function_selector.to_field()); + // TODO(https://github.com/AztecProtocol/aztec-packages/issues/9061): modify call_static opcode and remove <0>. + let (_, success) = call_static::<0>( gas_for_call(gas_opts), contract_address, args, PUBLIC_DISPATCH_SELECTOR, ); - assert(success == 1, "Nested static call failed!"); - FunctionReturns::new(data_to_return) + let result_data = returndata_copy(0, returndata_size()); + if success == 0 { + // Rethrow the revert data. + avm_revert(result_data); + } + result_data } fn push_note_hash(_self: &mut Self, note_hash: Field) { @@ -290,6 +298,14 @@ pub unconstrained fn calldata_copy(cdoffset: u32, copy_size: u32) -> calldata_copy_opcode(cdoffset, copy_size) } +unconstrained fn returndata_size() -> u32 { + returndata_size_opcode() +} + +unconstrained fn returndata_copy(rdoffset: u32, copy_size: u32) -> [Field] { + returndata_copy_opcode(rdoffset, copy_size) +} + unconstrained fn avm_return(returndata: [Field; N]) { return_opcode(returndata) } @@ -384,6 +400,12 @@ unconstrained fn send_l2_to_l1_msg_opcode(recipient: EthAddress, content: Field) #[oracle(avmOpcodeCalldataCopy)] unconstrained fn calldata_copy_opcode(cdoffset: u32, copy_size: u32) -> [Field; N] {} +#[oracle(avmOpcodeReturndataSize)] +unconstrained fn returndata_size_opcode() -> u32 {} + +#[oracle(avmOpcodeReturndataCopy)] +unconstrained fn returndata_copy_opcode(rdoffset: u32, copy_size: u32) -> [Field] {} + #[oracle(avmOpcodeReturn)] unconstrained fn return_opcode(returndata: [Field; N]) {} @@ -419,30 +441,3 @@ unconstrained fn storage_read_opcode(storage_slot: Field) -> Field {} #[oracle(avmOpcodeStorageWrite)] unconstrained fn storage_write_opcode(storage_slot: Field, value: Field) {} - -pub struct FunctionReturns { - values: [Field; N], -} - -impl FunctionReturns { - pub fn new(values: [Field; N]) -> FunctionReturns { - FunctionReturns { values } - } - - pub fn raw(self) -> [Field; N] { - self.values - } - - pub fn deserialize_into(self) -> T - where - T: Deserialize, - { - Deserialize::deserialize(self.raw()) - } -} - -impl FunctionReturns<0> { - pub fn assert_empty(self) { - assert(self.values.len() == 0); - } -} diff --git a/noir-projects/aztec-nr/aztec/src/prelude.nr b/noir-projects/aztec-nr/aztec/src/prelude.nr index 04dee82bf14..d1b5b34475a 100644 --- a/noir-projects/aztec-nr/aztec/src/prelude.nr +++ b/noir-projects/aztec-nr/aztec/src/prelude.nr @@ -1,6 +1,6 @@ // docs:start:prelude pub use crate::{ - context::{FunctionReturns, PackedReturns, PrivateContext, PublicContext}, + context::{PackedReturns, PrivateContext, PublicContext}, note::{ note_getter_options::NoteGetterOptions, note_header::NoteHeader, diff --git a/noir-projects/aztec-nr/aztec/src/test/helpers/utils.nr b/noir-projects/aztec-nr/aztec/src/test/helpers/utils.nr index 5b28a1a1253..643d8e82e26 100644 --- a/noir-projects/aztec-nr/aztec/src/test/helpers/utils.nr +++ b/noir-projects/aztec-nr/aztec/src/test/helpers/utils.nr @@ -74,14 +74,13 @@ impl Deployer { let mut public_context = PublicContext::new(|| panic(f"Provide args hash manually")); - public_context - .call_public_function( - instance.to_address(), - call_interface.get_selector(), - call_interface.get_args(), - GasOpts::default(), - ) - .assert_empty(); + let results = public_context.call_public_function( + instance.to_address(), + call_interface.get_selector(), + call_interface.get_args(), + GasOpts::default(), + ); + assert(results.len() == 0); instance } @@ -105,14 +104,12 @@ impl Deployer { let mut public_context = PublicContext::new(|| panic(f"Provide args hash manually")); - let _: T = public_context - .call_public_function( - instance.to_address(), - call_interface.get_selector(), - call_interface.get_args(), - GasOpts::default(), - ) - .deserialize_into(); + let _ = public_context.call_public_function( + instance.to_address(), + call_interface.get_selector(), + call_interface.get_args(), + GasOpts::default(), + ); instance } diff --git a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr index d564c046037..586ad030846 100644 --- a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr @@ -250,6 +250,14 @@ contract AvmTest { assert(cd == args, "Calldata copy failed"); } + #[public] + fn returndata_copy_oracle() { + AvmTest::at(context.this_address()).return_oracle().call(&mut context); + let returndatasize = dep::aztec::context::public_context::returndata_size(); + let returndata = dep::aztec::context::public_context::returndata_copy(0, returndatasize); + assert(returndata == &[1, 2, 3], "Returndata copy failed"); + } + #[public] fn return_oracle() -> [Field; 3] { dep::aztec::context::public_context::avm_return([1, 2, 3]); diff --git a/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr b/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr index b586f73b956..1f7757239d7 100644 --- a/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr @@ -18,14 +18,12 @@ contract Parent { target_selector: FunctionSelector, init_value: Field, ) -> Field { - context - .call_public_function( - target_contract, - target_selector, - [init_value].as_slice(), - GasOpts::default(), - ) - .deserialize_into() + context.call_public_function( + target_contract, + target_selector, + [init_value].as_slice(), + GasOpts::default(), + )[0] } // Same as pub_entry_point, but calls the target contract twice, using the return value from the first invocation as the argument for the second. #[public] @@ -34,22 +32,18 @@ contract Parent { target_selector: FunctionSelector, init_value: Field, ) -> Field { - let return_value: Field = context - .call_public_function( - target_contract, - target_selector, - [init_value].as_slice(), - GasOpts::default(), - ) - .deserialize_into(); - context - .call_public_function( - target_contract, - target_selector, - [return_value].as_slice(), - GasOpts::default(), - ) - .deserialize_into() + let return_value: Field = context.call_public_function( + target_contract, + target_selector, + [init_value].as_slice(), + GasOpts::default(), + )[0]; + context.call_public_function( + target_contract, + target_selector, + [return_value].as_slice(), + GasOpts::default(), + )[0] } // Private function to enqueue a call to the target_contract address using the selector and argument provided #[private] @@ -191,14 +185,12 @@ contract Parent { target_selector: FunctionSelector, args: [Field; 1], ) -> Field { - context - .static_call_public_function( - target_contract, - target_selector, - args.as_slice(), - GasOpts::default(), - ) - .deserialize_into() + context.static_call_public_function( + target_contract, + target_selector, + args.as_slice(), + GasOpts::default(), + )[0] } // Public function to set a static context and verify correct propagation for nested public calls #[public] @@ -211,14 +203,12 @@ contract Parent { let pub_entry_point_selector = FunctionSelector::from_signature("pub_entry_point((Field),(u32),Field)"); let this_address = context.this_address(); - context - .static_call_public_function( - this_address, - pub_entry_point_selector, - [target_contract.to_field(), target_selector.to_field(), args[0]].as_slice(), - GasOpts::default(), - ) - .deserialize_into() + context.static_call_public_function( + this_address, + pub_entry_point_selector, + [target_contract.to_field(), target_selector.to_field(), args[0]].as_slice(), + GasOpts::default(), + )[0] } // Private function to enqueue a static call to the pub_entry_point function of another contract, passing the target arguments provided #[private] diff --git a/noir-projects/noir-contracts/contracts/static_parent_contract/src/main.nr b/noir-projects/noir-contracts/contracts/static_parent_contract/src/main.nr index f1e0487c446..ef606854b3c 100644 --- a/noir-projects/noir-contracts/contracts/static_parent_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/static_parent_contract/src/main.nr @@ -14,14 +14,12 @@ contract StaticParent { target_selector: FunctionSelector, arg: Field, ) -> Field { - context - .call_public_function( - target_contract, - target_selector, - [arg].as_slice(), - GasOpts::default(), - ) - .deserialize_into() + context.call_public_function( + target_contract, + target_selector, + [arg].as_slice(), + GasOpts::default(), + )[0] } // Private function to directly call another private function to the target_contract using the selector and args provided @@ -114,14 +112,12 @@ contract StaticParent { target_selector: FunctionSelector, args: [Field; 1], ) -> Field { - context - .static_call_public_function( - target_contract, - target_selector, - args.as_slice(), - GasOpts::default(), - ) - .deserialize_into() + context.static_call_public_function( + target_contract, + target_selector, + args.as_slice(), + GasOpts::default(), + )[0] } // Same as above but using a specific function from the interface diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr index 1e61784737f..d132ebc7a8b 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr @@ -490,7 +490,7 @@ global AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS: u32 = 2 + 21 * 4; // `AVM_PROOF_LENGTH_IN_FIELDS` must be updated when AVM circuit changes. // To determine latest value, hover `COMPUTED_AVM_PROOF_LENGTH_IN_FIELDS` // in barretenberg/cpp/src/barretenberg/vm/avm/generated/flavor.hpp -global AVM_PROOF_LENGTH_IN_FIELDS: u32 = 4166; +global AVM_PROOF_LENGTH_IN_FIELDS: u32 = 4176; global AVM_PUBLIC_COLUMN_MAX_SIZE: u32 = 1024; global AVM_PUBLIC_INPUTS_FLATTENED_SIZE: u32 = 2 * AVM_PUBLIC_COLUMN_MAX_SIZE + PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH; @@ -638,6 +638,8 @@ global AVM_SHR_BASE_L2_GAS: u32 = 32; global AVM_CAST_BASE_L2_GAS: u32 = 30; global AVM_GETENVVAR_BASE_L2_GAS: u16 = 20; global AVM_CALLDATACOPY_BASE_L2_GAS: u32 = 29; +global AVM_RETURNDATASIZE_BASE_L2_GAS: u32 = 20; +global AVM_RETURNDATACOPY_BASE_L2_GAS: u32 = 29; global AVM_JUMP_BASE_L2_GAS: u32 = 12; global AVM_JUMPI_BASE_L2_GAS: u32 = 18; global AVM_INTERNALCALL_BASE_L2_GAS: u32 = 18; @@ -669,6 +671,7 @@ global AVM_TORADIXBE_BASE_L2_GAS: u32 = 46; // Dynamic L2 GAS global AVM_CALLDATACOPY_DYN_L2_GAS: u32 = 6; +global AVM_RETURNDATACOPY_DYN_L2_GAS: u32 = 6; // a single increment here corresponds to an entire additional field (hence x32 bytes per field) global AVM_EMITUNENCRYPTEDLOG_DYN_L2_GAS: u32 = 18 + (DA_BYTES_PER_FIELD * L2_GAS_PER_LOG_BYTE); global AVM_CALL_DYN_L2_GAS: u32 = 4; diff --git a/yarn-project/circuits.js/src/constants.gen.ts b/yarn-project/circuits.js/src/constants.gen.ts index 32813affa18..bc7b31cc912 100644 --- a/yarn-project/circuits.js/src/constants.gen.ts +++ b/yarn-project/circuits.js/src/constants.gen.ts @@ -223,7 +223,7 @@ export const TUBE_PROOF_LENGTH = 463; export const HONK_VERIFICATION_KEY_LENGTH_IN_FIELDS = 128; export const CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS = 143; export const AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS = 86; -export const AVM_PROOF_LENGTH_IN_FIELDS = 4166; +export const AVM_PROOF_LENGTH_IN_FIELDS = 4176; export const AVM_PUBLIC_COLUMN_MAX_SIZE = 1024; export const AVM_PUBLIC_INPUTS_FLATTENED_SIZE = 2914; export const MEM_TAG_FF = 0; @@ -275,6 +275,8 @@ export const AVM_SHR_BASE_L2_GAS = 32; export const AVM_CAST_BASE_L2_GAS = 30; export const AVM_GETENVVAR_BASE_L2_GAS = 20; export const AVM_CALLDATACOPY_BASE_L2_GAS = 29; +export const AVM_RETURNDATASIZE_BASE_L2_GAS = 20; +export const AVM_RETURNDATACOPY_BASE_L2_GAS = 29; export const AVM_JUMP_BASE_L2_GAS = 12; export const AVM_JUMPI_BASE_L2_GAS = 18; export const AVM_INTERNALCALL_BASE_L2_GAS = 18; @@ -303,6 +305,7 @@ export const AVM_ECADD_BASE_L2_GAS = 62; export const AVM_MSM_BASE_L2_GAS = 1000; export const AVM_TORADIXBE_BASE_L2_GAS = 46; export const AVM_CALLDATACOPY_DYN_L2_GAS = 6; +export const AVM_RETURNDATACOPY_DYN_L2_GAS = 6; export const AVM_EMITUNENCRYPTEDLOG_DYN_L2_GAS = 146; export const AVM_CALL_DYN_L2_GAS = 4; export const AVM_STATICCALL_DYN_L2_GAS = 4; diff --git a/yarn-project/circuits.js/src/contract/contract_class_id.ts b/yarn-project/circuits.js/src/contract/contract_class_id.ts index 935e0c5b6e3..360a498ff61 100644 --- a/yarn-project/circuits.js/src/contract/contract_class_id.ts +++ b/yarn-project/circuits.js/src/contract/contract_class_id.ts @@ -60,7 +60,7 @@ export type ContractClassIdPreimage = { }; export function computePublicBytecodeCommitment(packedBytecode: Buffer) { - // Encode the buffer into field elements (chunked into 31 bytes each) + // Encode the buffer into field elements (chunked into 32 bytes each) const encodedBytecode: Fr[] = bufferAsFields(packedBytecode, MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS); // The first element is the length of the bytecode (in bytes) const bytecodeLength = Math.ceil(encodedBytecode[0].toNumber() / (Fr.SIZE_IN_BYTES - 1)); diff --git a/yarn-project/protocol-contracts/src/protocol_contract_data.ts b/yarn-project/protocol-contracts/src/protocol_contract_data.ts index 8512d948c85..8b1c4f4c09a 100644 --- a/yarn-project/protocol-contracts/src/protocol_contract_data.ts +++ b/yarn-project/protocol-contracts/src/protocol_contract_data.ts @@ -50,14 +50,14 @@ export const ProtocolContractAddress: Record }; export const ProtocolContractLeaf = { - AuthRegistry: Fr.fromString('0x305c48d9d087f24b1618a7cc92c5081db4672f6855816af7ac89ea7e873245cd'), + AuthRegistry: Fr.fromString('0x13794ed6c957a68bc852fe4c2a161019a53011b08331d8eb0287483a7845d334'), ContractInstanceDeployer: Fr.fromString('0x04a661c9d4d295fc485a7e0f3de40c09b35366343bce8ad229106a8ef4076fe5'), ContractClassRegisterer: Fr.fromString('0x147ba3294403576dbad10f86d3ffd4eb83fb230ffbcd5c8b153dd02942d0611f'), MultiCallEntrypoint: Fr.fromString('0x154b701b41d6cf6da7204fef36b2ee9578b449d21b3792a9287bf45eba48fd26'), - FeeJuice: Fr.fromString('0x21c9ab2e339c9b3394e4e1ff3b7cf37be4e0fc0bc177a192d287d98963b9b254'), - Router: Fr.fromString('0x2b0b558e92b7a13cde0a2ecc7570c181a6fbae2bdc6f966cacfc39a784635394'), + FeeJuice: Fr.fromString('0x0191fe64a9d9efca55572a5190479698b8a3b296295f0f2d917b91fcb5486251'), + Router: Fr.fromString('0x19e9ec99aedfe3ea69ba91b862b815df7d1796fa802985a154159cd739fe4817'), }; export const protocolContractTreeRoot = Fr.fromString( - '0x0d560ad12f14dd5026070bc037ac343535db339212f0904dfc96c4aea4dcc8ab', + '0x158c0b725f29c56278203f9d49c503c14bcf22888684ee73a4826e2edf2a56a8', ); diff --git a/yarn-project/simulator/src/avm/avm_gas.ts b/yarn-project/simulator/src/avm/avm_gas.ts index 88f1b27d706..3e2a31367da 100644 --- a/yarn-project/simulator/src/avm/avm_gas.ts +++ b/yarn-project/simulator/src/avm/avm_gas.ts @@ -89,6 +89,8 @@ const BASE_GAS_COSTS: Record = { [Opcode.CAST_16]: makeCost(c.AVM_CAST_BASE_L2_GAS, 0), [Opcode.GETENVVAR_16]: makeCost(c.AVM_GETENVVAR_BASE_L2_GAS, 0), [Opcode.CALLDATACOPY]: makeCost(c.AVM_CALLDATACOPY_BASE_L2_GAS, 0), + [Opcode.RETURNDATASIZE]: makeCost(c.AVM_RETURNDATASIZE_BASE_L2_GAS, 0), + [Opcode.RETURNDATACOPY]: makeCost(c.AVM_RETURNDATACOPY_BASE_L2_GAS, 0), [Opcode.JUMP_16]: makeCost(c.AVM_JUMP_BASE_L2_GAS, 0), [Opcode.JUMPI_16]: makeCost(c.AVM_JUMPI_BASE_L2_GAS, 0), [Opcode.INTERNALCALL]: makeCost(c.AVM_INTERNALCALL_BASE_L2_GAS, 0), @@ -127,6 +129,7 @@ const BASE_GAS_COSTS: Record = { const DYNAMIC_GAS_COSTS = new Map([ [Opcode.CALLDATACOPY, makeCost(c.AVM_CALLDATACOPY_DYN_L2_GAS, 0)], + [Opcode.RETURNDATACOPY, makeCost(c.AVM_RETURNDATACOPY_DYN_L2_GAS, 0)], [Opcode.EMITUNENCRYPTEDLOG, makeCost(c.AVM_EMITUNENCRYPTEDLOG_DYN_L2_GAS, c.AVM_EMITUNENCRYPTEDLOG_DYN_DA_GAS)], [Opcode.CALL, makeCost(c.AVM_CALL_DYN_L2_GAS, 0)], [Opcode.STATICCALL, makeCost(c.AVM_STATICCALL_DYN_L2_GAS, 0)], diff --git a/yarn-project/simulator/src/avm/avm_machine_state.ts b/yarn-project/simulator/src/avm/avm_machine_state.ts index b9a46e8cb9b..a46f0028d63 100644 --- a/yarn-project/simulator/src/avm/avm_machine_state.ts +++ b/yarn-project/simulator/src/avm/avm_machine_state.ts @@ -21,6 +21,8 @@ export class AvmMachineState { public daGasLeft: number; /** program counter */ public pc: number = 0; + /** return/revertdata of the last nested call. */ + public nestedReturndata: Fr[] = []; /** * On INTERNALCALL, internal call stack is pushed to with the current pc + 1 diff --git a/yarn-project/simulator/src/avm/avm_simulator.test.ts b/yarn-project/simulator/src/avm/avm_simulator.test.ts index 613c7bf68a0..eb4beb17b6e 100644 --- a/yarn-project/simulator/src/avm/avm_simulator.test.ts +++ b/yarn-project/simulator/src/avm/avm_simulator.test.ts @@ -1015,6 +1015,27 @@ describe('AVM simulator: transpiled Noir contracts', () => { 'Values are not equal', ); }); + + it('Should handle returndatacopy oracle', async () => { + const context = createContext(); + const callBytecode = getAvmTestContractBytecode('returndata_copy_oracle'); + const nestedBytecode = getAvmTestContractBytecode('public_dispatch'); + mockGetBytecode(worldStateDB, nestedBytecode); + + const contractClass = makeContractClassPublic(0, { + bytecode: nestedBytecode, + selector: FunctionSelector.random(), + }); + mockGetContractClass(worldStateDB, contractClass); + const contractInstance = makeContractInstanceFromClassId(contractClass.id); + mockGetContractInstance(worldStateDB, contractInstance); + + mockTraceFork(trace); + + const results = await new AvmSimulator(context).executeBytecode(callBytecode); + + expect(results.reverted).toBe(false); + }); }); describe('Side effect trace errors on overflow', () => { diff --git a/yarn-project/simulator/src/avm/opcodes/external_calls.ts b/yarn-project/simulator/src/avm/opcodes/external_calls.ts index df8950e7153..fca523f965c 100644 --- a/yarn-project/simulator/src/avm/opcodes/external_calls.ts +++ b/yarn-project/simulator/src/avm/opcodes/external_calls.ts @@ -106,9 +106,12 @@ abstract class ExternalCall extends Instruction { throw new RethrownError(nestedCallResults.revertReason.message, nestedCallResults.revertReason); } + const fullReturnData = nestedCallResults.output; + context.machineState.nestedReturndata = fullReturnData; + // We only take as much data as was specified in the return size and pad with zeroes if the return data is smaller // than the specified size in order to prevent that memory to be left with garbage - const returnData = nestedCallResults.output.slice(0, this.retSize); + const returnData = fullReturnData.slice(0, this.retSize); const convertedReturnData = padArrayEnd( returnData.map(f => new Field(f)), new Field(0), diff --git a/yarn-project/simulator/src/avm/opcodes/memory.test.ts b/yarn-project/simulator/src/avm/opcodes/memory.test.ts index e466cbe46c5..5f7bf1ae6e7 100644 --- a/yarn-project/simulator/src/avm/opcodes/memory.test.ts +++ b/yarn-project/simulator/src/avm/opcodes/memory.test.ts @@ -5,7 +5,7 @@ import { Field, TypeTag, Uint8, Uint16, Uint32, Uint64, Uint128 } from '../avm_m import { initContext, initExecutionEnvironment } from '../fixtures/index.js'; import { Opcode } from '../serialization/instruction_serialization.js'; import { Addressing, AddressingMode } from './addressing_mode.js'; -import { CalldataCopy, Cast, Mov, Set } from './memory.js'; +import { CalldataCopy, Cast, Mov, ReturndataCopy, ReturndataSize, Set } from './memory.js'; describe('Memory instructions', () => { let context: AvmContext; @@ -423,4 +423,88 @@ describe('Memory instructions', () => { // TODO: check bad cases (i.e., out of bounds) }); + + describe('RETURNDATASIZE', () => { + it('Should (de)serialize correctly', () => { + const buf = Buffer.from([ + ReturndataSize.opcode, // opcode + 0x01, // indirect + ...Buffer.from('3456', 'hex'), // dstOffset + ]); + const inst = new ReturndataSize(/*indirect=*/ 0x01, /*dstOffset=*/ 0x3456); + + expect(ReturndataSize.deserialize(buf)).toEqual(inst); + expect(inst.serialize()).toEqual(buf); + }); + + it('Writes size', async () => { + context = initContext(); + context.machineState.nestedReturndata = [new Fr(1n), new Fr(2n), new Fr(3n)]; + + await new ReturndataSize(/*indirect=*/ 0, /*dstOffset=*/ 10).execute(context); + + const actual = context.machineState.memory.get(10); + expect(actual).toEqual(new Uint32(3)); + }); + }); + + describe('RETURNDATACOPY', () => { + it('Should (de)serialize correctly', () => { + const buf = Buffer.from([ + ReturndataCopy.opcode, // opcode + 0x01, // indirect + ...Buffer.from('1234', 'hex'), // rdOffsetAddress + ...Buffer.from('2345', 'hex'), // copysizeOffset + ...Buffer.from('3456', 'hex'), // dstOffset + ]); + const inst = new ReturndataCopy( + /*indirect=*/ 0x01, + /*cdOffsetAddress=*/ 0x1234, + /*copysizeOffset=*/ 0x2345, + /*dstOffset=*/ 0x3456, + ); + + expect(ReturndataCopy.deserialize(buf)).toEqual(inst); + expect(inst.serialize()).toEqual(buf); + }); + + it('Writes nothing if size is 0', async () => { + context = initContext(); + context.machineState.nestedReturndata = [new Fr(1n), new Fr(2n), new Fr(3n)]; + context.machineState.memory.set(0, new Uint32(0)); // rdoffset + context.machineState.memory.set(1, new Uint32(0)); // size + context.machineState.memory.set(3, new Uint16(12)); // not overwritten + + await new ReturndataCopy(/*indirect=*/ 0, /*rdOffset=*/ 0, /*copySize=*/ 1, /*dstOffset=*/ 0).execute(context); + + const actual = context.machineState.memory.get(3); + expect(actual).toEqual(new Uint16(12)); + }); + + it('Copies all returndata', async () => { + context = initContext(); + context.machineState.nestedReturndata = [new Fr(1n), new Fr(2n), new Fr(3n)]; + context.machineState.memory.set(0, new Uint32(0)); // rdoffset + context.machineState.memory.set(1, new Uint32(3)); // size + + await new ReturndataCopy(/*indirect=*/ 0, /*rdOffset=*/ 0, /*copySize=*/ 1, /*dstOffset=*/ 0).execute(context); + + const actual = context.machineState.memory.getSlice(/*offset=*/ 0, /*size=*/ 3); + expect(actual).toEqual([new Field(1), new Field(2), new Field(3)]); + }); + + it('Copies slice of returndata', async () => { + context = initContext(); + context.machineState.nestedReturndata = [new Fr(1n), new Fr(2n), new Fr(3n)]; + context.machineState.memory.set(0, new Uint32(1)); // rdoffset + context.machineState.memory.set(1, new Uint32(2)); // size + + await new ReturndataCopy(/*indirect=*/ 0, /*rdOffset=*/ 0, /*copySize=*/ 1, /*dstOffset=*/ 0).execute(context); + + const actual = context.machineState.memory.getSlice(/*offset=*/ 0, /*size=*/ 2); + expect(actual).toEqual([new Field(2), new Field(3)]); + }); + + // TODO: check bad cases (i.e., out of bounds) + }); }); diff --git a/yarn-project/simulator/src/avm/opcodes/memory.ts b/yarn-project/simulator/src/avm/opcodes/memory.ts index 2ba943e2210..cde6056f688 100644 --- a/yarn-project/simulator/src/avm/opcodes/memory.ts +++ b/yarn-project/simulator/src/avm/opcodes/memory.ts @@ -1,5 +1,5 @@ import type { AvmContext } from '../avm_context.js'; -import { Field, TaggedMemory } from '../avm_memory_types.js'; +import { Field, TaggedMemory, TypeTag, Uint32 } from '../avm_memory_types.js'; import { Opcode, OperandType } from '../serialization/instruction_serialization.js'; import { Addressing } from './addressing_mode.js'; import { Instruction } from './instruction.js'; @@ -179,11 +179,11 @@ export class CalldataCopy extends Instruction { public async execute(context: AvmContext): Promise { const memory = context.machineState.memory.track(this.type); - // We don't need to check tags here because: (1) the calldata is NOT in memory, and (2) we are the ones writing to destination. const operands = [this.cdStartOffset, this.copySizeOffset, this.dstOffset]; const addressing = Addressing.fromWire(this.indirect, operands.length); const [cdStartOffset, copySizeOffset, dstOffset] = addressing.resolve(operands, memory); + memory.checkTags(TypeTag.UINT32, cdStartOffset, copySizeOffset); const cdStart = memory.get(cdStartOffset).toNumber(); const copySize = memory.get(copySizeOffset).toNumber(); context.machineState.consumeGas(this.gasCost(copySize)); @@ -196,3 +196,70 @@ export class CalldataCopy extends Instruction { context.machineState.incrementPc(); } } + +export class ReturndataSize extends Instruction { + static readonly type: string = 'RETURNDATASIZE'; + static readonly opcode: Opcode = Opcode.RETURNDATASIZE; + // Informs (de)serialization. See Instruction.deserialize. + static readonly wireFormat: OperandType[] = [OperandType.UINT8, OperandType.UINT8, OperandType.UINT16]; + + constructor(private indirect: number, private dstOffset: number) { + super(); + } + + public async execute(context: AvmContext): Promise { + const memory = context.machineState.memory.track(this.type); + const operands = [this.dstOffset]; + const addressing = Addressing.fromWire(this.indirect, operands.length); + const [dstOffset] = addressing.resolve(operands, memory); + context.machineState.consumeGas(this.gasCost()); + + memory.set(dstOffset, new Uint32(context.machineState.nestedReturndata.length)); + + memory.assert({ writes: 1, addressing }); + context.machineState.incrementPc(); + } +} + +export class ReturndataCopy extends Instruction { + static readonly type: string = 'RETURNDATACOPY'; + static readonly opcode: Opcode = Opcode.RETURNDATACOPY; + // Informs (de)serialization. See Instruction.deserialize. + static readonly wireFormat: OperandType[] = [ + OperandType.UINT8, + OperandType.UINT8, + OperandType.UINT16, + OperandType.UINT16, + OperandType.UINT16, + ]; + + constructor( + private indirect: number, + private rdStartOffset: number, + private copySizeOffset: number, + private dstOffset: number, + ) { + super(); + } + + public async execute(context: AvmContext): Promise { + const memory = context.machineState.memory.track(this.type); + const operands = [this.rdStartOffset, this.copySizeOffset, this.dstOffset]; + const addressing = Addressing.fromWire(this.indirect, operands.length); + const [rdStartOffset, copySizeOffset, dstOffset] = addressing.resolve(operands, memory); + + memory.checkTags(TypeTag.UINT32, rdStartOffset, copySizeOffset); + const rdStart = memory.get(rdStartOffset).toNumber(); + const copySize = memory.get(copySizeOffset).toNumber(); + context.machineState.consumeGas(this.gasCost(copySize)); + + const transformedData = context.machineState.nestedReturndata + .slice(rdStart, rdStart + copySize) + .map(f => new Field(f)); + + memory.setSlice(dstOffset, transformedData); + + memory.assert({ reads: 2, writes: copySize, addressing }); + context.machineState.incrementPc(); + } +} diff --git a/yarn-project/simulator/src/avm/serialization/bytecode_serialization.ts b/yarn-project/simulator/src/avm/serialization/bytecode_serialization.ts index 8eabfedac2b..88f9ef16de5 100644 --- a/yarn-project/simulator/src/avm/serialization/bytecode_serialization.ts +++ b/yarn-project/simulator/src/avm/serialization/bytecode_serialization.ts @@ -31,6 +31,8 @@ import { Or, Poseidon2, Return, + ReturndataCopy, + ReturndataSize, Revert, SLoad, SStore, @@ -96,6 +98,8 @@ const INSTRUCTION_SET = () => // Execution Environment [Opcode.GETENVVAR_16, GetEnvVar.as(GetEnvVar.wireFormat16).deserialize], [CalldataCopy.opcode, Instruction.deserialize.bind(CalldataCopy)], + [Opcode.RETURNDATASIZE, Instruction.deserialize.bind(ReturndataSize)], + [Opcode.RETURNDATACOPY, Instruction.deserialize.bind(ReturndataCopy)], // Machine State - Internal Control Flow [Jump.opcode, Instruction.deserialize.bind(Jump)], diff --git a/yarn-project/simulator/src/avm/serialization/instruction_serialization.ts b/yarn-project/simulator/src/avm/serialization/instruction_serialization.ts index 10edd3794a1..048d9c481d6 100644 --- a/yarn-project/simulator/src/avm/serialization/instruction_serialization.ts +++ b/yarn-project/simulator/src/avm/serialization/instruction_serialization.ts @@ -41,6 +41,8 @@ export enum Opcode { // Execution environment GETENVVAR_16, CALLDATACOPY, + RETURNDATASIZE, + RETURNDATACOPY, // Control flow JUMP_16, JUMPI_16, diff --git a/yarn-project/txe/src/oracle/txe_oracle.ts b/yarn-project/txe/src/oracle/txe_oracle.ts index b16be91beb1..e0911adf571 100644 --- a/yarn-project/txe/src/oracle/txe_oracle.ts +++ b/yarn-project/txe/src/oracle/txe_oracle.ts @@ -82,6 +82,8 @@ export class TXE implements TypedOracle { private msgSender: AztecAddress; private functionSelector = FunctionSelector.fromField(new Fr(0)); private isStaticCall = false; + // Return/revert data of the latest nested call. + private nestedCallReturndata: Fr[] = []; private contractDataOracle: ContractDataOracle; @@ -801,6 +803,8 @@ export class TXE implements TypedOracle { ); const executionResult = await this.executePublicFunction(args, callContext, this.sideEffectsCounter); + // Save return/revert data for later. + this.nestedCallReturndata = executionResult.returnValues; // Apply side effects if (!executionResult.reverted) { @@ -822,6 +826,14 @@ export class TXE implements TypedOracle { return executionResult; } + avmOpcodeReturndataSize(): number { + return this.nestedCallReturndata.length; + } + + avmOpcodeReturndataCopy(rdOffset: number, copySize: number): Fr[] { + return this.nestedCallReturndata.slice(rdOffset, rdOffset + copySize); + } + async avmOpcodeNullifierExists(innerNullifier: Fr, targetAddress: AztecAddress): Promise { const nullifier = siloNullifier(targetAddress, innerNullifier!); const db = await this.trees.getLatest(); diff --git a/yarn-project/txe/src/txe_service/txe_service.ts b/yarn-project/txe/src/txe_service/txe_service.ts index 7731f55b23f..07c9fc8b05c 100644 --- a/yarn-project/txe/src/txe_service/txe_service.ts +++ b/yarn-project/txe/src/txe_service/txe_service.ts @@ -711,6 +711,20 @@ export class TXEService { return toForeignCallResult([toSingle(version)]); } + avmOpcodeReturndataSize() { + const size = (this.typedOracle as TXE).avmOpcodeReturndataSize(); + return toForeignCallResult([toSingle(new Fr(size))]); + } + + avmOpcodeReturndataCopy(rdOffset: ForeignCallSingle, copySize: ForeignCallSingle) { + const returndata = (this.typedOracle as TXE).avmOpcodeReturndataCopy( + fromSingle(rdOffset).toNumber(), + fromSingle(copySize).toNumber(), + ); + // This is a slice, so we need to return the length as well. + return toForeignCallResult([toSingle(new Fr(returndata.length)), toArray(returndata)]); + } + async avmOpcodeCall( _gas: ForeignCallArray, address: ForeignCallSingle,