Skip to content

Commit

Permalink
monolit/split for dex,small,recursive_with_poseidon
Browse files Browse the repository at this point in the history
  • Loading branch information
fmkra committed Sep 10, 2024
1 parent 854603a commit 135edf4
Show file tree
Hide file tree
Showing 4 changed files with 247 additions and 50 deletions.
90 changes: 78 additions & 12 deletions src/air/layouts/dex.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +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, StarkCurve},
layouts::dex::{
contract::{
IDexLayoutContract1Dispatcher, IDexLayoutContract1DispatcherTrait,
IDexLayoutContract2Dispatcher, IDexLayoutContract2DispatcherTrait,
},
global_values::{GlobalValues, InteractionElements, EcPoint, EcdsaSigConfig},
public_input::DexPublicInputImpl,
constants::{
Expand All @@ -27,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::dex::contract::{
IDexLayoutContract1Dispatcher,
IDexLayoutContract1DispatcherTrait,
IDexLayoutContract2Dispatcher,
IDexLayoutContract2DispatcherTrait,
};

#[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 {
IDexLayoutContract1Dispatcher {
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 {
IDexLayoutContract2Dispatcher {
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::dex::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 DexAIRCompositionImpl of AIRComposition<InteractionElements, PublicInput> {
fn eval_composition_polynomial(
Expand Down Expand Up @@ -95,10 +165,8 @@ impl DexAIRCompositionImpl of AIRComposition<InteractionElements, PublicInput> {
range_check16_perm_public_memory_prod: 1,
};

IDexLayoutContract1Dispatcher {
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 @@ -113,10 +181,8 @@ impl DexAIROodsImpl of AIROods {
trace_generator: felt252,
contract_address_2: ContractAddress,
) -> felt252 {
IDexLayoutContract2Dispatcher {
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,
)
}
}
92 changes: 78 additions & 14 deletions src/air/layouts/recursive_with_poseidon.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +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_with_poseidon::{
contract::{
IRecursiveWithPoseidonLayoutContract1Dispatcher,
IRecursiveWithPoseidonLayoutContract1DispatcherTrait,
IRecursiveWithPoseidonLayoutContract2Dispatcher,
IRecursiveWithPoseidonLayoutContract2DispatcherTrait,
},
global_values::{GlobalValues, InteractionElements, EcPoint},
public_input::RecursiveWithPoseidonPublicInputImpl,
constants::{
Expand All @@ -33,6 +28,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_with_poseidon::contract::{
IRecursiveWithPoseidonLayoutContract1Dispatcher,
IRecursiveWithPoseidonLayoutContract1DispatcherTrait,
IRecursiveWithPoseidonLayoutContract2Dispatcher,
IRecursiveWithPoseidonLayoutContract2DispatcherTrait,
};

#[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 {
IRecursiveWithPoseidonLayoutContract1Dispatcher {
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 {
IRecursiveWithPoseidonLayoutContract2Dispatcher {
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_with_poseidon::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 RecursiveWithPoseidonAIRCompositionImpl of AIRComposition<InteractionElements, PublicInput> {
fn eval_composition_polynomial(
Expand Down Expand Up @@ -127,10 +195,8 @@ impl RecursiveWithPoseidonAIRCompositionImpl of AIRComposition<InteractionElemen
diluted_check_final_cum_val: diluted_prod
};

IRecursiveWithPoseidonLayoutContract1Dispatcher {
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 @@ -145,10 +211,8 @@ impl RecursiveWithPoseidonAIROodsImpl of AIROods {
trace_generator: felt252,
contract_address_2: ContractAddress,
) -> felt252 {
IRecursiveWithPoseidonLayoutContract2Dispatcher {
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,
)
}
}
90 changes: 78 additions & 12 deletions src/air/layouts/small.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +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, StarkCurve},
layouts::small::{
contract::{
ISmallLayoutContract1Dispatcher, ISmallLayoutContract1DispatcherTrait,
ISmallLayoutContract2Dispatcher, ISmallLayoutContract2DispatcherTrait,
},
global_values::{GlobalValues, InteractionElements, EcPoint, EcdsaSigConfig},
public_input::SmallPublicInputImpl,
constants::{
Expand All @@ -27,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::small::contract::{
ISmallLayoutContract1Dispatcher,
ISmallLayoutContract1DispatcherTrait,
ISmallLayoutContract2Dispatcher,
ISmallLayoutContract2DispatcherTrait,
};

#[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 {
ISmallLayoutContract1Dispatcher {
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 {
ISmallLayoutContract2Dispatcher {
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::small::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 SmallAIRCompositionImpl of AIRComposition<InteractionElements, PublicInput> {
fn eval_composition_polynomial(
Expand Down Expand Up @@ -95,10 +165,8 @@ impl SmallAIRCompositionImpl of AIRComposition<InteractionElements, PublicInput>
range_check16_perm_public_memory_prod: 1,
};

ISmallLayoutContract1Dispatcher {
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 @@ -113,10 +181,8 @@ impl SmallAIROodsImpl of AIROods {
trace_generator: felt252,
contract_address_2: ContractAddress,
) -> felt252 {
ISmallLayoutContract2Dispatcher {
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,
)
}
}
Loading

0 comments on commit 135edf4

Please sign in to comment.