From b65cb18f3f0a258f665b187848e846eadd40822c Mon Sep 17 00:00:00 2001 From: Ohad Agadi Date: Tue, 17 Dec 2024 13:18:41 +0200 Subject: [PATCH] derive lookup_data --- .../crates/air_structs_derive/src/lib.rs | 73 ++++++++++++------- .../prover.rs | 14 +--- .../prover.rs | 14 +--- .../prover.rs | 14 +--- .../add_opcode_is_small_f_is_imm_f/prover.rs | 22 +----- .../add_opcode_is_small_f_is_imm_t/prover.rs | 22 +----- .../add_opcode_is_small_t_is_imm_f/prover.rs | 22 +----- .../add_opcode_is_small_t_is_imm_t/prover.rs | 22 +----- .../prover.rs | 13 +--- .../prover.rs | 13 +--- .../prover.rs | 18 +---- .../prover.rs | 22 +----- .../prover.rs | 22 +----- .../prover.rs | 22 +----- .../src/components/generic_opcode/prover.rs | 10 +-- .../prover.rs | 14 +--- .../prover.rs | 14 +--- .../prover.rs | 14 +--- .../prover.rs | 14 +--- .../prover.rs | 14 +--- .../prover.rs | 14 +--- .../prover.rs | 14 +--- .../prover.rs | 14 +--- .../mul_opcode_is_small_f_is_imm_f/prover.rs | 52 +------------ .../mul_opcode_is_small_f_is_imm_t/prover.rs | 52 +------------ .../src/components/ret_opcode/prover.rs | 14 +--- 26 files changed, 98 insertions(+), 455 deletions(-) diff --git a/stwo_cairo_prover/crates/air_structs_derive/src/lib.rs b/stwo_cairo_prover/crates/air_structs_derive/src/lib.rs index 94f1e092..ac2a5791 100644 --- a/stwo_cairo_prover/crates/air_structs_derive/src/lib.rs +++ b/stwo_cairo_prover/crates/air_structs_derive/src/lib.rs @@ -1,13 +1,15 @@ use itertools::Itertools; use proc_macro2::TokenStream; use quote::quote; -use syn::{parse_macro_input, Data, DeriveInput, Fields, Path, Type}; +use syn::{parse_macro_input, Data, DataStruct, DeriveInput, Fields, Path, Type}; + +// TODO(Ohad): consider moving this crate to 'Stwo'. #[proc_macro_derive(SubComponentInputs)] pub fn derive_sub_component_inputs(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let input = parse_macro_input!(input as DeriveInput); - assert_is_struct(&input); let name = &input.ident; + let input = expect_struct(&input); let vec_array_fields = extract_vec_array_fields(&input); // TODO(Ohad): deprecate with_capacity. @@ -26,40 +28,61 @@ pub fn derive_sub_component_inputs(input: proc_macro::TokenStream) -> proc_macro proc_macro::TokenStream::from(expanded) } +#[proc_macro_derive(LookupData)] +pub fn derive_lookup_data(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + let input = parse_macro_input!(input as DeriveInput); + let name = &input.ident; + let input = expect_struct(&input); + let vec_array_fields = extract_vec_array_fields(&input); + + // TODO(Ohad): deprecate with_capacity. + let with_capacity_method = generate_with_capacity_method(&vec_array_fields); + let uninitialized_method = generate_uninitialized_method(&vec_array_fields); + + let expanded = quote! { + impl #name { + #with_capacity_method + #uninitialized_method + } + }; + + proc_macro::TokenStream::from(expanded) +} + #[derive(Clone)] struct VecArrayField { name: syn::Ident, array_length: usize, } -fn assert_is_struct(input: &DeriveInput) { - if !matches!(input.data, Data::Struct(_)) { - panic!("Derive(SubComponentInputs) can only be applied to structs."); +fn expect_struct(input: &DeriveInput) -> DataStruct { + if let Data::Struct(data_struct) = &input.data { + data_struct.clone() + } else { + panic!("Expected a struct"); } } -fn extract_vec_array_fields(input: &DeriveInput) -> Vec { +fn extract_vec_array_fields(data_struct: &DataStruct) -> Vec { let mut vec_array_fields = Vec::new(); - if let Data::Struct(data_struct) = &input.data { - if let Fields::Named(fields) = &data_struct.fields { - for field in &fields.named { - // Field is an array of Vecs. - if let Type::Array(type_array) = &field.ty { - if let Type::Path(element_type) = &*type_array.elem { - // Element is a Vec. - if is_vec_type(&element_type.path) { - // Get the array length - if let syn::Expr::Lit(syn::ExprLit { - lit: syn::Lit::Int(length_lit), - .. - }) = type_array.len.clone() - { - vec_array_fields.push(VecArrayField { - name: field.ident.clone().unwrap(), - array_length: length_lit.base10_parse().unwrap(), - }); - } + if let Fields::Named(fields) = &data_struct.fields { + for field in &fields.named { + // Field is an array of Vecs. + if let Type::Array(type_array) = &field.ty { + if let Type::Path(element_type) = &*type_array.elem { + // Element is a Vec. + if is_vec_type(&element_type.path) { + // Get the array length + if let syn::Expr::Lit(syn::ExprLit { + lit: syn::Lit::Int(length_lit), + .. + }) = type_array.len.clone() + { + vec_array_fields.push(VecArrayField { + name: field.ident.clone().unwrap(), + array_length: length_lit.base10_parse().unwrap(), + }); } } } diff --git a/stwo_cairo_prover/crates/prover/src/components/add_ap_opcode_is_imm_f_op1_base_fp_f/prover.rs b/stwo_cairo_prover/crates/prover/src/components/add_ap_opcode_is_imm_f_op1_base_fp_f/prover.rs index b714e4b8..6383d8b4 100644 --- a/stwo_cairo_prover/crates/prover/src/components/add_ap_opcode_is_imm_f_op1_base_fp_f/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/add_ap_opcode_is_imm_f_op1_base_fp_f/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -301,23 +301,13 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 1], pub memoryidtobig: [Vec<[PackedM31; 29]>; 1], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [Vec::with_capacity(capacity)], - memoryidtobig: [Vec::with_capacity(capacity)], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/add_ap_opcode_is_imm_f_op1_base_fp_t/prover.rs b/stwo_cairo_prover/crates/prover/src/components/add_ap_opcode_is_imm_f_op1_base_fp_t/prover.rs index e3f1091a..22298add 100644 --- a/stwo_cairo_prover/crates/prover/src/components/add_ap_opcode_is_imm_f_op1_base_fp_t/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/add_ap_opcode_is_imm_f_op1_base_fp_t/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -301,23 +301,13 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 1], pub memoryidtobig: [Vec<[PackedM31; 29]>; 1], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [Vec::with_capacity(capacity)], - memoryidtobig: [Vec::with_capacity(capacity)], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/add_ap_opcode_is_imm_t_op1_base_fp_f/prover.rs b/stwo_cairo_prover/crates/prover/src/components/add_ap_opcode_is_imm_t_op1_base_fp_f/prover.rs index 07fe7688..62cd92b0 100644 --- a/stwo_cairo_prover/crates/prover/src/components/add_ap_opcode_is_imm_t_op1_base_fp_f/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/add_ap_opcode_is_imm_t_op1_base_fp_f/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -285,23 +285,13 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 1], pub memoryidtobig: [Vec<[PackedM31; 29]>; 1], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [Vec::with_capacity(capacity)], - memoryidtobig: [Vec::with_capacity(capacity)], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/add_opcode_is_small_f_is_imm_f/prover.rs b/stwo_cairo_prover/crates/prover/src/components/add_opcode_is_small_f_is_imm_f/prover.rs index 67ea0f28..ea330021 100644 --- a/stwo_cairo_prover/crates/prover/src/components/add_opcode_is_small_f_is_imm_f/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/add_opcode_is_small_f_is_imm_f/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -658,31 +658,13 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 3], pub memoryidtobig: [Vec<[PackedM31; 29]>; 3], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - memoryidtobig: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/add_opcode_is_small_f_is_imm_t/prover.rs b/stwo_cairo_prover/crates/prover/src/components/add_opcode_is_small_f_is_imm_t/prover.rs index 50d6c46b..ceabcc74 100644 --- a/stwo_cairo_prover/crates/prover/src/components/add_opcode_is_small_f_is_imm_t/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/add_opcode_is_small_f_is_imm_t/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -620,31 +620,13 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 3], pub memoryidtobig: [Vec<[PackedM31; 29]>; 3], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - memoryidtobig: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/add_opcode_is_small_t_is_imm_f/prover.rs b/stwo_cairo_prover/crates/prover/src/components/add_opcode_is_small_t_is_imm_f/prover.rs index 3ca30b9e..f0d74c67 100644 --- a/stwo_cairo_prover/crates/prover/src/components/add_opcode_is_small_t_is_imm_f/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/add_opcode_is_small_t_is_imm_f/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -532,31 +532,13 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 3], pub memoryidtobig: [Vec<[PackedM31; 29]>; 3], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - memoryidtobig: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/add_opcode_is_small_t_is_imm_t/prover.rs b/stwo_cairo_prover/crates/prover/src/components/add_opcode_is_small_t_is_imm_t/prover.rs index 6f7ab016..48410834 100644 --- a/stwo_cairo_prover/crates/prover/src/components/add_opcode_is_small_t_is_imm_t/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/add_opcode_is_small_t_is_imm_t/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -494,31 +494,13 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 3], pub memoryidtobig: [Vec<[PackedM31; 29]>; 3], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - memoryidtobig: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/assert_eq_opcode_is_double_deref_f_is_imm_f/prover.rs b/stwo_cairo_prover/crates/prover/src/components/assert_eq_opcode_is_double_deref_f_is_imm_f/prover.rs index 0a36e02a..84c8bb7f 100644 --- a/stwo_cairo_prover/crates/prover/src/components/assert_eq_opcode_is_double_deref_f_is_imm_f/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/assert_eq_opcode_is_double_deref_f_is_imm_f/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -316,21 +316,12 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 2], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/assert_eq_opcode_is_double_deref_f_is_imm_t/prover.rs b/stwo_cairo_prover/crates/prover/src/components/assert_eq_opcode_is_double_deref_f_is_imm_t/prover.rs index 3685c2cd..eb2cc818 100644 --- a/stwo_cairo_prover/crates/prover/src/components/assert_eq_opcode_is_double_deref_f_is_imm_t/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/assert_eq_opcode_is_double_deref_f_is_imm_t/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -279,21 +279,12 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 2], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/assert_eq_opcode_is_double_deref_t_is_imm_f/prover.rs b/stwo_cairo_prover/crates/prover/src/components/assert_eq_opcode_is_double_deref_t_is_imm_f/prover.rs index 8f9b5763..7e282495 100644 --- a/stwo_cairo_prover/crates/prover/src/components/assert_eq_opcode_is_double_deref_t_is_imm_f/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/assert_eq_opcode_is_double_deref_t_is_imm_f/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -393,27 +393,13 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 3], pub memoryidtobig: [Vec<[PackedM31; 29]>; 1], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - memoryidtobig: [Vec::with_capacity(capacity)], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/call_opcode_is_rel_f_op1_base_fp_f/prover.rs b/stwo_cairo_prover/crates/prover/src/components/call_opcode_is_rel_f_op1_base_fp_f/prover.rs index 3686e203..94f23db1 100644 --- a/stwo_cairo_prover/crates/prover/src/components/call_opcode_is_rel_f_op1_base_fp_f/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/call_opcode_is_rel_f_op1_base_fp_f/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -389,31 +389,13 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 3], pub memoryidtobig: [Vec<[PackedM31; 29]>; 3], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - memoryidtobig: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/call_opcode_is_rel_f_op1_base_fp_t/prover.rs b/stwo_cairo_prover/crates/prover/src/components/call_opcode_is_rel_f_op1_base_fp_t/prover.rs index a94d10f0..32ad0d8b 100644 --- a/stwo_cairo_prover/crates/prover/src/components/call_opcode_is_rel_f_op1_base_fp_t/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/call_opcode_is_rel_f_op1_base_fp_t/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -389,31 +389,13 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 3], pub memoryidtobig: [Vec<[PackedM31; 29]>; 3], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - memoryidtobig: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/call_opcode_is_rel_t_op1_base_fp_f/prover.rs b/stwo_cairo_prover/crates/prover/src/components/call_opcode_is_rel_t_op1_base_fp_f/prover.rs index 8baf1fa0..38637630 100644 --- a/stwo_cairo_prover/crates/prover/src/components/call_opcode_is_rel_t_op1_base_fp_f/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/call_opcode_is_rel_t_op1_base_fp_f/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -392,31 +392,13 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 3], pub memoryidtobig: [Vec<[PackedM31; 29]>; 3], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - memoryidtobig: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/generic_opcode/prover.rs b/stwo_cairo_prover/crates/prover/src/components/generic_opcode/prover.rs index e617d491..a0238d2d 100644 --- a/stwo_cairo_prover/crates/prover/src/components/generic_opcode/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/generic_opcode/prover.rs @@ -1,6 +1,6 @@ #![cfg_attr(rustfmt, rustfmt_skip)]#![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{SubComponentInputs, LookupData}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -1256,15 +1256,9 @@ lookup_data.opcodes[1].push([((((((((pc_update_regular_tmp_5745_23) * (((input_p (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData {pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 3],pub memoryidtobig: [Vec<[PackedM31; 29]>; 3],pub opcodes: [Vec<[PackedM31; 3]>; 2],pub rangecheck_19: [Vec<[PackedM31; 1]>; 28],pub rangecheck_9_9: [Vec<[PackedM31; 2]>; 28],pub verifyinstruction: [Vec<[PackedM31; 19]>; 1],} -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self {memoryaddresstoid: [Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),],memoryidtobig: [Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),],opcodes: [Vec::with_capacity(capacity),Vec::with_capacity(capacity),],rangecheck_19: [Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),],rangecheck_9_9: [Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),Vec::with_capacity(capacity),],verifyinstruction: [Vec::with_capacity(capacity),],} - - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/jnz_opcode_is_taken_f_dst_base_fp_f/prover.rs b/stwo_cairo_prover/crates/prover/src/components/jnz_opcode_is_taken_f_dst_base_fp_f/prover.rs index 90bd9761..f131489b 100644 --- a/stwo_cairo_prover/crates/prover/src/components/jnz_opcode_is_taken_f_dst_base_fp_f/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/jnz_opcode_is_taken_f_dst_base_fp_f/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -354,23 +354,13 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 1], pub memoryidtobig: [Vec<[PackedM31; 29]>; 1], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [Vec::with_capacity(capacity)], - memoryidtobig: [Vec::with_capacity(capacity)], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/jnz_opcode_is_taken_f_dst_base_fp_t/prover.rs b/stwo_cairo_prover/crates/prover/src/components/jnz_opcode_is_taken_f_dst_base_fp_t/prover.rs index 125a74fb..98f0b913 100644 --- a/stwo_cairo_prover/crates/prover/src/components/jnz_opcode_is_taken_f_dst_base_fp_t/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/jnz_opcode_is_taken_f_dst_base_fp_t/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -354,23 +354,13 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 1], pub memoryidtobig: [Vec<[PackedM31; 29]>; 1], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [Vec::with_capacity(capacity)], - memoryidtobig: [Vec::with_capacity(capacity)], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/jnz_opcode_is_taken_t_dst_base_fp_f/prover.rs b/stwo_cairo_prover/crates/prover/src/components/jnz_opcode_is_taken_t_dst_base_fp_f/prover.rs index ef67e91f..8c387e3b 100644 --- a/stwo_cairo_prover/crates/prover/src/components/jnz_opcode_is_taken_t_dst_base_fp_f/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/jnz_opcode_is_taken_t_dst_base_fp_f/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -493,23 +493,13 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 2], pub memoryidtobig: [Vec<[PackedM31; 29]>; 2], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - memoryidtobig: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/jnz_opcode_is_taken_t_dst_base_fp_t/prover.rs b/stwo_cairo_prover/crates/prover/src/components/jnz_opcode_is_taken_t_dst_base_fp_t/prover.rs index f3bea673..f755d4ac 100644 --- a/stwo_cairo_prover/crates/prover/src/components/jnz_opcode_is_taken_t_dst_base_fp_t/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/jnz_opcode_is_taken_t_dst_base_fp_t/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -493,23 +493,13 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 2], pub memoryidtobig: [Vec<[PackedM31; 29]>; 2], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - memoryidtobig: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_f/prover.rs b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_f/prover.rs index a6c3cfb5..88bb555e 100644 --- a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_f/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_f/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -334,23 +334,13 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 1], pub memoryidtobig: [Vec<[PackedM31; 29]>; 1], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [Vec::with_capacity(capacity)], - memoryidtobig: [Vec::with_capacity(capacity)], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_t/prover.rs b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_t/prover.rs index b2446713..9525f549 100644 --- a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_t/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_f_is_imm_f_is_double_deref_t/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -404,23 +404,13 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 2], pub memoryidtobig: [Vec<[PackedM31; 29]>; 2], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - memoryidtobig: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_f_is_double_deref_f/prover.rs b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_f_is_double_deref_f/prover.rs index 2127a5c2..ec9107a8 100644 --- a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_f_is_double_deref_f/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_f_is_double_deref_f/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -351,23 +351,13 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 1], pub memoryidtobig: [Vec<[PackedM31; 29]>; 1], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [Vec::with_capacity(capacity)], - memoryidtobig: [Vec::with_capacity(capacity)], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_t_is_double_deref_f/prover.rs b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_t_is_double_deref_f/prover.rs index de77998e..3a1cf6b3 100644 --- a/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_t_is_double_deref_f/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/jump_opcode_is_rel_t_is_imm_t_is_double_deref_f/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -310,23 +310,13 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 1], pub memoryidtobig: [Vec<[PackedM31; 29]>; 1], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [Vec::with_capacity(capacity)], - memoryidtobig: [Vec::with_capacity(capacity)], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/mul_opcode_is_small_f_is_imm_f/prover.rs b/stwo_cairo_prover/crates/prover/src/components/mul_opcode_is_small_f_is_imm_f/prover.rs index 73f735c4..b20fdbad 100644 --- a/stwo_cairo_prover/crates/prover/src/components/mul_opcode_is_small_f_is_imm_f/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/mul_opcode_is_small_f_is_imm_f/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -1839,6 +1839,7 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 3], pub memoryidtobig: [Vec<[PackedM31; 29]>; 3], @@ -1846,55 +1847,6 @@ pub struct LookupData { pub rangecheck_19: [Vec<[PackedM31; 1]>; 28], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - memoryidtobig: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - rangecheck_19: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/mul_opcode_is_small_f_is_imm_t/prover.rs b/stwo_cairo_prover/crates/prover/src/components/mul_opcode_is_small_f_is_imm_t/prover.rs index 70cf2292..8fe617a6 100644 --- a/stwo_cairo_prover/crates/prover/src/components/mul_opcode_is_small_f_is_imm_t/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/mul_opcode_is_small_f_is_imm_t/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -1800,6 +1800,7 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 3], pub memoryidtobig: [Vec<[PackedM31; 29]>; 3], @@ -1807,55 +1808,6 @@ pub struct LookupData { pub rangecheck_19: [Vec<[PackedM31; 1]>; 28], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - memoryidtobig: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - rangecheck_19: [ - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - Vec::with_capacity(capacity), - ], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize, diff --git a/stwo_cairo_prover/crates/prover/src/components/ret_opcode/prover.rs b/stwo_cairo_prover/crates/prover/src/components/ret_opcode/prover.rs index d73788ab..e8a819a8 100644 --- a/stwo_cairo_prover/crates/prover/src/components/ret_opcode/prover.rs +++ b/stwo_cairo_prover/crates/prover/src/components/ret_opcode/prover.rs @@ -1,6 +1,6 @@ #![allow(unused_parens)] #![allow(unused_imports)] -use air_structs_derive::SubComponentInputs; +use air_structs_derive::{LookupData, SubComponentInputs}; use itertools::{chain, zip_eq, Itertools}; use num_traits::{One, Zero}; use prover_types::cpu::*; @@ -322,23 +322,13 @@ pub fn write_trace_simd( (trace, sub_components_inputs, lookup_data) } +#[derive(LookupData)] pub struct LookupData { pub memoryaddresstoid: [Vec<[PackedM31; 2]>; 2], pub memoryidtobig: [Vec<[PackedM31; 29]>; 2], pub opcodes: [Vec<[PackedM31; 3]>; 2], pub verifyinstruction: [Vec<[PackedM31; 19]>; 1], } -impl LookupData { - #[allow(unused_variables)] - fn with_capacity(capacity: usize) -> Self { - Self { - memoryaddresstoid: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - memoryidtobig: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - opcodes: [Vec::with_capacity(capacity), Vec::with_capacity(capacity)], - verifyinstruction: [Vec::with_capacity(capacity)], - } - } -} pub struct InteractionClaimGenerator { pub n_calls: usize,