From 854603a483ee9ed057730be0ff62de5af8e79e0b Mon Sep 17 00:00:00 2001 From: Filip Krawczyk Date: Mon, 9 Sep 2024 16:27:22 +0200 Subject: [PATCH] Add monolit/split features for recursive --- Scarb.toml | 3 ++ src/air/layouts/recursive.cairo | 93 +++++++++++++++++++++++++++------ 2 files changed, 81 insertions(+), 15 deletions(-) diff --git a/Scarb.toml b/Scarb.toml index f5555c1d0..e9163feae 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -25,4 +25,7 @@ starknet_with_keccak = [] keccak = [] blake2s = [] +monolit = [] +split = [] + default = ["recursive", "keccak"] diff --git a/src/air/layouts/recursive.cairo b/src/air/layouts/recursive.cairo index 2c03034b4..5f7552f8a 100644 --- a/src/air/layouts/recursive.cairo +++ b/src/air/layouts/recursive.cairo @@ -3,19 +3,13 @@ mod constants; mod global_values; mod public_input; mod traces; +#[cfg(feature: 'split')] mod contract; use cairo_verifier::{ air::{ constants::{SHIFT_POINT_X, SHIFT_POINT_Y}, layouts::recursive::{ - autogenerated::{eval_composition_polynomial_inner, eval_oods_polynomial_inner}, - contract::{ - IRecursiveLayoutContract1Dispatcher, - IRecursiveLayoutContract1DispatcherTrait, - IRecursiveLayoutContract2Dispatcher, - IRecursiveLayoutContract2DispatcherTrait, - }, global_values::{GlobalValues, InteractionElements, EcPoint}, public_input::RecursivePublicInputImpl, constants::{ @@ -30,6 +24,79 @@ use cairo_verifier::{ common::{math::{Felt252Div, Felt252PartialOrd, pow}, asserts::assert_range_u128} }; use starknet::ContractAddress; +#[cfg(feature: 'split')] +use cairo_verifier::air::layouts::recursive::contract::{ + IRecursiveLayoutContract1Dispatcher, + IRecursiveLayoutContract1DispatcherTrait, + IRecursiveLayoutContract2Dispatcher, + IRecursiveLayoutContract2DispatcherTrait, +}; + +#[cfg(feature: 'split')] +fn eval_composition_polynomial_inner( + mask_values: Span, + constraint_coefficients: Span, + point: felt252, + trace_generator: felt252, + global_values: GlobalValues, + contract_address_1: ContractAddress, +) -> felt252 { + IRecursiveLayoutContract1Dispatcher { + contract_address: contract_address_1 + }.eval_composition_polynomial_inner( + mask_values, constraint_coefficients, point, trace_generator, global_values + ) +} + +#[cfg(feature: 'split')] +fn eval_oods_polynomial_inner( + column_values: Span, + oods_values: Span, + constraint_coefficients: Span, + point: felt252, + oods_point: felt252, + trace_generator: felt252, + contract_address_2: ContractAddress, +) -> felt252 { + IRecursiveLayoutContract2Dispatcher { + contract_address: contract_address_2 + }.eval_oods_polynomial_inner( + column_values, oods_values, constraint_coefficients, point, oods_point, trace_generator, + ) +} + +#[cfg(feature: 'monolit')] +use cairo_verifier::air::layouts::recursive::autogenerated::{ + eval_composition_polynomial_inner as eval_composition_polynomial_inner_, + eval_oods_polynomial_inner as eval_oods_polynomial_inner_, +}; + +#[cfg(feature: 'monolit')] +fn eval_composition_polynomial_inner( + mask_values: Span, + constraint_coefficients: Span, + point: felt252, + trace_generator: felt252, + global_values: GlobalValues, + contract_address_1: ContractAddress, +) -> felt252 { + eval_composition_polynomial_inner_(mask_values, constraint_coefficients, point, trace_generator, global_values) +} + +#[cfg(feature: 'monolit')] +fn eval_oods_polynomial_inner( + column_values: Span, + oods_values: Span, + constraint_coefficients: Span, + point: felt252, + oods_point: felt252, + trace_generator: felt252, + contract_address_2: ContractAddress, +) -> felt252 { + eval_oods_polynomial_inner_( + column_values, oods_values, constraint_coefficients, point, oods_point, trace_generator, + ) +} impl RecursiveAIRCompositionImpl of AIRComposition { fn eval_composition_polynomial( @@ -99,10 +166,8 @@ impl RecursiveAIRCompositionImpl of AIRComposition felt252 { - IRecursiveLayoutContract2Dispatcher { - contract_address: contract_address_2 - }.eval_oods_polynomial_inner( - column_values, oods_values, constraint_coefficients, point, oods_point, trace_generator, + eval_oods_polynomial_inner( + column_values, oods_values, constraint_coefficients, point, oods_point, trace_generator, contract_address_2, ) } }