Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed Sep 10, 2024
1 parent 23b125e commit 6414a95
Show file tree
Hide file tree
Showing 39 changed files with 418 additions and 446 deletions.
4 changes: 2 additions & 2 deletions src/air/air.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait AIRComposition<IE, PI> {
point: felt252,
trace_domain_size: felt252,
trace_generator: felt252,
contract_address_1: ContractAddress,
contract_address: ContractAddress,
) -> felt252;
}

Expand All @@ -21,6 +21,6 @@ trait AIROods {
point: felt252,
oods_point: felt252,
trace_generator: felt252,
contract_address_2: ContractAddress,
contract_address: ContractAddress,
) -> felt252;
}
74 changes: 42 additions & 32 deletions src/air/layouts/dex.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -24,78 +24,77 @@ 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: '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: 'split')]
#[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,
contract_address: ContractAddress,
) -> felt252 {
IDexLayoutContract1Dispatcher {
contract_address: contract_address_1
}.eval_composition_polynomial_inner(
eval_composition_polynomial_inner_(
mask_values, constraint_coefficients, point, trace_generator, global_values
)
}

#[cfg(feature: 'split')]
#[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,
contract_address: ContractAddress,
) -> felt252 {
IDexLayoutContract2Dispatcher {
contract_address: contract_address_2
}.eval_oods_polynomial_inner(
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: 'split')]
use cairo_verifier::air::layouts::dex::contract::{
ILayoutCompositionContractDispatcher, ILayoutCompositionContractDispatcherTrait,
ILayoutOodsContractDispatcher, ILayoutOodsContractDispatcherTrait,
};

#[cfg(feature: 'monolit')]
#[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,
contract_address: ContractAddress,
) -> felt252 {
eval_composition_polynomial_inner_(mask_values, constraint_coefficients, point, trace_generator, global_values)
ILayoutCompositionContractDispatcher { contract_address }
.eval_composition_polynomial_inner(
mask_values, constraint_coefficients, point, trace_generator, global_values
)
}

#[cfg(feature: 'monolit')]
#[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,
contract_address: ContractAddress,
) -> felt252 {
eval_oods_polynomial_inner_(
column_values, oods_values, constraint_coefficients, point, oods_point, trace_generator,
)
ILayoutOodsContractDispatcher { contract_address }
.eval_oods_polynomial_inner(
column_values, oods_values, constraint_coefficients, point, oods_point, trace_generator,
)
}

impl DexAIRCompositionImpl of AIRComposition<InteractionElements, PublicInput> {
Expand All @@ -107,7 +106,7 @@ impl DexAIRCompositionImpl of AIRComposition<InteractionElements, PublicInput> {
point: felt252,
trace_domain_size: felt252,
trace_generator: felt252,
contract_address_1: ContractAddress,
contract_address: ContractAddress,
) -> felt252 {
let memory_z = interaction_elements.memory_multi_column_perm_perm_interaction_elm;
let memory_alpha = interaction_elements.memory_multi_column_perm_hash_interaction_elm0;
Expand Down Expand Up @@ -166,7 +165,12 @@ impl DexAIRCompositionImpl of AIRComposition<InteractionElements, PublicInput> {
};

eval_composition_polynomial_inner(
mask_values, constraint_coefficients, point, trace_generator, global_values, contract_address_1,
mask_values,
constraint_coefficients,
point,
trace_generator,
global_values,
contract_address,
)
}
}
Expand All @@ -179,10 +183,16 @@ impl DexAIROodsImpl of AIROods {
point: felt252,
oods_point: felt252,
trace_generator: felt252,
contract_address_2: ContractAddress,
contract_address: ContractAddress,
) -> felt252 {
eval_oods_polynomial_inner(
column_values, oods_values, constraint_coefficients, point, oods_point, trace_generator, contract_address_2,
column_values,
oods_values,
constraint_coefficients,
point,
oods_point,
trace_generator,
contract_address,
)
}
}
30 changes: 12 additions & 18 deletions src/air/layouts/dex/contract.cairo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use cairo_verifier::air::layouts::dex::global_values::GlobalValues;

#[starknet::interface]
trait IDexLayoutContract1<ContractState> {
trait ILayoutCompositionContract<ContractState> {
fn eval_composition_polynomial_inner(
self: @ContractState,
mask_values: Span<felt252>,
Expand All @@ -13,7 +13,7 @@ trait IDexLayoutContract1<ContractState> {
}

#[starknet::interface]
trait IDexLayoutContract2<ContractState> {
trait ILayoutOodsContract<ContractState> {
fn eval_oods_polynomial_inner(
self: @ContractState,
column_values: Span<felt252>,
Expand All @@ -26,18 +26,17 @@ trait IDexLayoutContract2<ContractState> {
}

#[starknet::contract]
mod DexLayoutContract1 {
use super::IDexLayoutContract1;
mod LayoutCompositionContract {
use super::ILayoutCompositionContract;
use cairo_verifier::air::layouts::dex::{
global_values::GlobalValues,
autogenerated::eval_composition_polynomial_inner,
global_values::GlobalValues, autogenerated::eval_composition_polynomial_inner,
};

#[storage]
struct Storage {}

#[abi(embed_v0)]
impl DexLayoutContract1 of IDexLayoutContract1<ContractState> {
impl LayoutCompositionContract of ILayoutCompositionContract<ContractState> {
fn eval_composition_polynomial_inner(
self: @ContractState,
mask_values: Span<felt252>,
Expand All @@ -47,29 +46,24 @@ mod DexLayoutContract1 {
global_values: GlobalValues
) -> felt252 {
eval_composition_polynomial_inner(
mask_values,
constraint_coefficients,
point,
trace_generator,
global_values
mask_values, constraint_coefficients, point, trace_generator, global_values
)
}
}
}

#[starknet::contract]
mod DexLayoutContract2 {
use super::IDexLayoutContract2;
mod LayoutOodsContract {
use super::ILayoutOodsContract;
use cairo_verifier::air::layouts::dex::{
global_values::GlobalValues,
autogenerated::eval_oods_polynomial_inner,
global_values::GlobalValues, autogenerated::eval_oods_polynomial_inner,
};

#[storage]
struct Storage {}

#[abi(embed_v0)]
impl DexLayoutContract2 of IDexLayoutContract2<ContractState> {
impl LayoutOodsContract of ILayoutOodsContract<ContractState> {
fn eval_oods_polynomial_inner(
self: @ContractState,
column_values: Span<felt252>,
Expand All @@ -89,4 +83,4 @@ mod DexLayoutContract2 {
)
}
}
}
}
2 changes: 1 addition & 1 deletion src/air/layouts/dex/public_input.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl DexPublicInputImpl of PublicInputTrait {
ref memory_index
);

// 3. Output segment
// 3. Output segment
let output_len = output_stop - output_start;
let output = memory
.extract_range(
Expand Down
100 changes: 0 additions & 100 deletions src/air/layouts/generator.py

This file was deleted.

Loading

0 comments on commit 6414a95

Please sign in to comment.