Skip to content

Commit

Permalink
Add monolit/split features for recursive
Browse files Browse the repository at this point in the history
  • Loading branch information
fmkra committed Sep 9, 2024
1 parent e0293ee commit 854603a
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 15 deletions.
3 changes: 3 additions & 0 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ starknet_with_keccak = []
keccak = []
blake2s = []

monolit = []
split = []

default = ["recursive", "keccak"]
93 changes: 78 additions & 15 deletions src/air/layouts/recursive.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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<felt252>,
constraint_coefficients: Span<felt252>,
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<felt252>,
oods_values: Span<felt252>,
constraint_coefficients: Span<felt252>,
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<felt252>,
constraint_coefficients: Span<felt252>,
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<felt252>,
oods_values: Span<felt252>,
constraint_coefficients: Span<felt252>,
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<InteractionElements, PublicInput> {
fn eval_composition_polynomial(
Expand Down Expand Up @@ -99,10 +166,8 @@ impl RecursiveAIRCompositionImpl of AIRComposition<InteractionElements, PublicIn
diluted_check_final_cum_val: diluted_prod
};

IRecursiveLayoutContract1Dispatcher {
contract_address: contract_address_1
}.eval_composition_polynomial_inner(
mask_values, constraint_coefficients, point, trace_generator, global_values
eval_composition_polynomial_inner(
mask_values, constraint_coefficients, point, trace_generator, global_values, contract_address_1,
)
}
}
Expand All @@ -117,10 +182,8 @@ impl RecursiveAIROodsImpl of AIROods {
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,
eval_oods_polynomial_inner(
column_values, oods_values, constraint_coefficients, point, oods_point, trace_generator, contract_address_2,
)
}
}

0 comments on commit 854603a

Please sign in to comment.