Skip to content

Commit

Permalink
Merge branch 'autogenerated_split' into autogenerated_split_missing_l…
Browse files Browse the repository at this point in the history
…ayouts
  • Loading branch information
Okm165 committed Sep 13, 2024
2 parents 2d68ee0 + 7eaf85b commit 1d8b83e
Show file tree
Hide file tree
Showing 34 changed files with 767 additions and 349 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/proof_verification_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ jobs:
matrix:
cairo_version: ["cairo0", "cairo1"]
layout: ["recursive", "recursive_with_poseidon", "small", "dex", "starknet", "starknet_with_keccak"]
hasher: ["keccak_160_lsb"]
prover: ["stone5"]
hash_function: ["keccak"]
hasher_bit_length: ["lsb160"]
stone_version: ["stone5"]
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -28,7 +29,7 @@ jobs:
uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Build project
run: scarb build --no-default-features --features monolith,${{ matrix.layout }},${{ matrix.hasher }},${{ matrix.prover }}
run: scarb build --no-default-features --features monolith,${{ matrix.layout }},${{ matrix.hash_function }}

- name: Run verification
run: cargo run --release --bin runner -- -p target/dev/cairo_verifier.sierra.json -c ${{ matrix.cairo_version }} < examples/proofs/${{ matrix.layout }}/${{ matrix.cairo_version }}_example_proof.json
run: cargo run --release --bin runner -- --program target/dev/cairo_verifier.sierra.json --cairo-version ${{ matrix.cairo_version }} --stone-version ${{ matrix.stone_version }} --hasher-bit-length ${{ matrix.hasher_bit_length }} < examples/proofs/${{ matrix.layout }}/${{ matrix.cairo_version }}_example_proof.json
11 changes: 3 additions & 8 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,10 @@ small = []
starknet = []
starknet_with_keccak = []

keccak_160_lsb = []
keccak_248_lsb = []
blake2s_160_lsb = []
blake2s_248_lsb = []

stone5 = []
stone6 = []
keccak = []
blake2s = []

monolith = []
split = []

default = ["recursive", "keccak_160_lsb", "stone5", "monolith"]
default = ["recursive", "keccak", "monolith"]
30 changes: 30 additions & 0 deletions runner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,33 @@ impl From<CairoVersion> for Felt252 {
}
}
}

#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
pub enum StoneVersion {
Stone5 = 0,
Stone6 = 1,
}

impl From<StoneVersion> for Felt252 {
fn from(value: StoneVersion) -> Self {
match value {
StoneVersion::Stone5 => Felt252::from(0),
StoneVersion::Stone6 => Felt252::from(1),
}
}
}

#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
pub enum HasherBitLength {
Lsb160 = 0,
Lsb248 = 1,
}

impl From<HasherBitLength> for Felt252 {
fn from(value: HasherBitLength) -> Self {
match value {
HasherBitLength::Lsb160 => Felt252::from(0),
HasherBitLength::Lsb248 => Felt252::from(1),
}
}
}
10 changes: 9 additions & 1 deletion runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use cairo_lang_sierra::program::VersionedProgram;
use cairo_lang_utils::ordered_hash_map::OrderedHashMap;
use clap::Parser;
use itertools::{chain, Itertools};
use runner::CairoVersion;
use runner::{CairoVersion, HasherBitLength, StoneVersion};
use std::{
fs,
io::{stdin, Read},
Expand All @@ -26,6 +26,12 @@ struct Cli {
/// Cairo version - public memory pattern
#[clap(value_enum, short, long, default_value_t=CairoVersion::Cairo0)]
cairo_version: CairoVersion,
/// Stone version
#[clap(value_enum, short, long, default_value_t=StoneVersion::Stone5)]
stone_version: StoneVersion,
/// Hasher bit length
#[clap(value_enum, short, long, default_value_t=HasherBitLength::Lsb160)]
hasher_bit_length: HasherBitLength,
}

fn main() -> anyhow::Result<()> {
Expand Down Expand Up @@ -66,6 +72,8 @@ fn main() -> anyhow::Result<()> {
let args = &[
Arg::Array(proof.into_iter().map(Arg::Value).collect_vec()),
Arg::Value(cli.cairo_version.into()),
Arg::Value(cli.hasher_bit_length.into()),
Arg::Value(cli.stone_version.into()),
];
let result = runner
.run_function_with_starknet_context(func, args, Some(u32::MAX as usize), Default::default())
Expand Down
9 changes: 6 additions & 3 deletions src/air/layouts/dex/traces.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use cairo_verifier::{
TableCommitmentConfig
},
vector_commitment::vector_commitment::VectorCommitmentConfigTrait,
common::asserts::assert_in_range
common::asserts::assert_in_range, settings::VerifierSettings,
};

// A protocol component (see stark.cairo for details about protocol components) for the traces
Expand Down Expand Up @@ -120,7 +120,10 @@ fn traces_decommit(
commitment: TracesCommitment,
decommitment: TracesDecommitment,
witness: TracesWitness,
settings: VerifierSettings,
) {
table_decommit(commitment.original, queries, decommitment.original, witness.original);
table_decommit(commitment.interaction, queries, decommitment.interaction, witness.interaction)
table_decommit(commitment.original, queries, decommitment.original, witness.original, settings);
table_decommit(
commitment.interaction, queries, decommitment.interaction, witness.interaction, settings
)
}
9 changes: 6 additions & 3 deletions src/air/layouts/recursive/traces.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use cairo_verifier::{
TableCommitmentConfig
},
vector_commitment::vector_commitment::VectorCommitmentConfigTrait,
common::asserts::assert_in_range
common::asserts::assert_in_range, settings::VerifierSettings,
};

// A protocol component (see stark.cairo for details about protocol components) for the traces
Expand Down Expand Up @@ -123,7 +123,10 @@ fn traces_decommit(
commitment: TracesCommitment,
decommitment: TracesDecommitment,
witness: TracesWitness,
settings: VerifierSettings,
) {
table_decommit(commitment.original, queries, decommitment.original, witness.original);
table_decommit(commitment.interaction, queries, decommitment.interaction, witness.interaction)
table_decommit(commitment.original, queries, decommitment.original, witness.original, settings);
table_decommit(
commitment.interaction, queries, decommitment.interaction, witness.interaction, settings
)
}
9 changes: 6 additions & 3 deletions src/air/layouts/recursive_with_poseidon/traces.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use cairo_verifier::{
TableCommitmentConfig
},
vector_commitment::vector_commitment::VectorCommitmentConfigTrait,
common::asserts::assert_in_range
common::asserts::assert_in_range, settings::VerifierSettings,
};

// A protocol component (see stark.cairo for details about protocol components) for the traces
Expand Down Expand Up @@ -123,7 +123,10 @@ fn traces_decommit(
commitment: TracesCommitment,
decommitment: TracesDecommitment,
witness: TracesWitness,
settings: VerifierSettings,
) {
table_decommit(commitment.original, queries, decommitment.original, witness.original);
table_decommit(commitment.interaction, queries, decommitment.interaction, witness.interaction)
table_decommit(commitment.original, queries, decommitment.original, witness.original, settings);
table_decommit(
commitment.interaction, queries, decommitment.interaction, witness.interaction, settings
)
}
9 changes: 6 additions & 3 deletions src/air/layouts/small/traces.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use cairo_verifier::{
TableCommitmentConfig
},
vector_commitment::vector_commitment::VectorCommitmentConfigTrait,
common::asserts::assert_in_range
common::asserts::assert_in_range, settings::VerifierSettings,
};

// A protocol component (see stark.cairo for details about protocol components) for the traces
Expand Down Expand Up @@ -120,7 +120,10 @@ fn traces_decommit(
commitment: TracesCommitment,
decommitment: TracesDecommitment,
witness: TracesWitness,
settings: VerifierSettings,
) {
table_decommit(commitment.original, queries, decommitment.original, witness.original);
table_decommit(commitment.interaction, queries, decommitment.interaction, witness.interaction)
table_decommit(commitment.original, queries, decommitment.original, witness.original, settings);
table_decommit(
commitment.interaction, queries, decommitment.interaction, witness.interaction, settings
)
}
10 changes: 10 additions & 0 deletions src/air/layouts/starknet.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,23 @@ mod constants;
mod global_values;
mod public_input;
mod traces;
<<<<<<< HEAD
#[cfg(feature: 'split')]
=======
>>>>>>> autogenerated_split
mod contract;

use cairo_verifier::{
air::{
constants::{SHIFT_POINT_X, SHIFT_POINT_Y, StarkCurve},
layouts::starknet::{
<<<<<<< HEAD
=======
contract::{
IStarknetLayoutContract1Dispatcher, IStarknetLayoutContract1DispatcherTrait,
IStarknetLayoutContract2Dispatcher, IStarknetLayoutContract2DispatcherTrait,
},
>>>>>>> autogenerated_split
global_values::{
GlobalValues, InteractionElements, EcPoint, EcdsaSigConfig, CurveConfig
},
Expand Down
16 changes: 16 additions & 0 deletions src/air/layouts/starknet/contract.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,27 @@ trait ILayoutOodsContract<ContractState> {

#[starknet::contract]
mod LayoutCompositionContract {
<<<<<<< HEAD
use super::{
ILayoutCompositionContract, ILayoutCompositionContractDispatcher,
ILayoutCompositionContractDispatcherTrait
};
=======
use super::ILayoutCompositionContract;
>>>>>>> autogenerated_split
use cairo_verifier::air::layouts::starknet::{
global_values::GlobalValues, autogenerated::eval_composition_polynomial_inner_part_1,
};
use starknet::ContractAddress;

#[storage]
struct Storage {
<<<<<<< HEAD
continuation_contract1: ContractAddress,
continuation_contract2: ContractAddress,
=======
continuation_contracts: Array<ContractAddress>,
>>>>>>> autogenerated_split
}

#[abi(embed_v0)]
Expand All @@ -53,7 +61,11 @@ mod LayoutCompositionContract {
global_values: GlobalValues
) -> felt252 {
let mut total_sum = ILayoutCompositionContractDispatcher {
<<<<<<< HEAD
contract_address: self.continuation_contract1.read()
=======
contract_address: continuation_contracts[0]
>>>>>>> autogenerated_split
}
.eval_composition_polynomial_inner(
mask_values,
Expand All @@ -64,9 +76,13 @@ mod LayoutCompositionContract {
);

total_sum +=
<<<<<<< HEAD
ILayoutCompositionContractDispatcher {
contract_address: self.continuation_contract2.read()
}
=======
ILayoutCompositionContractDispatcher { contract_address: continuation_contracts[1] }
>>>>>>> autogenerated_split
.eval_composition_polynomial_inner(
mask_values,
constraint_coefficients.slice(99, 99),
Expand Down
9 changes: 6 additions & 3 deletions src/air/layouts/starknet/traces.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use cairo_verifier::{
TableCommitmentConfig
},
vector_commitment::vector_commitment::VectorCommitmentConfigTrait,
common::asserts::assert_in_range
common::asserts::assert_in_range, settings::VerifierSettings,
};

// A protocol component (see stark.cairo for details about protocol components) for the traces
Expand Down Expand Up @@ -123,7 +123,10 @@ fn traces_decommit(
commitment: TracesCommitment,
decommitment: TracesDecommitment,
witness: TracesWitness,
settings: VerifierSettings,
) {
table_decommit(commitment.original, queries, decommitment.original, witness.original);
table_decommit(commitment.interaction, queries, decommitment.interaction, witness.interaction)
table_decommit(commitment.original, queries, decommitment.original, witness.original, settings);
table_decommit(
commitment.interaction, queries, decommitment.interaction, witness.interaction, settings
)
}
20 changes: 20 additions & 0 deletions src/air/layouts/starknet_with_keccak.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,25 @@ mod constants;
mod global_values;
mod public_input;
mod traces;
<<<<<<< HEAD
#[cfg(feature: 'split')]
=======
>>>>>>> autogenerated_split
mod contract;

use cairo_verifier::{
air::{
constants::{SHIFT_POINT_X, SHIFT_POINT_Y, StarkCurve},
layouts::starknet_with_keccak::{
<<<<<<< HEAD
=======
contract::{
IStarknetWithKeccakLayoutContract1Dispatcher,
IStarknetWithKeccakLayoutContract1DispatcherTrait,
IStarknetWithKeccakLayoutContract2Dispatcher,
IStarknetWithKeccakLayoutContract2DispatcherTrait,
},
>>>>>>> autogenerated_split
global_values::{
GlobalValues, InteractionElements, EcPoint, EcdsaSigConfig, CurveConfig
},
Expand All @@ -36,7 +48,11 @@ use cairo_verifier::{
use starknet::ContractAddress;

#[cfg(feature: 'monolith')]
<<<<<<< HEAD
use cairo_verifier::air::layouts::starknet_with_keccak::autogenerated::{
=======
use cairo_verifier::air::layouts::starknet::autogenerated::{
>>>>>>> autogenerated_split
eval_composition_polynomial_inner as eval_composition_polynomial_inner_,
eval_oods_polynomial_inner as eval_oods_polynomial_inner_,
};
Expand Down Expand Up @@ -71,7 +87,11 @@ fn eval_oods_polynomial_inner(
}

#[cfg(feature: 'split')]
<<<<<<< HEAD
use cairo_verifier::air::layouts::starknet_with_keccak::contract::{
=======
use cairo_verifier::air::layouts::starknet::contract::{
>>>>>>> autogenerated_split
ILayoutCompositionContractDispatcher, ILayoutCompositionContractDispatcherTrait,
ILayoutOodsContractDispatcher, ILayoutOodsContractDispatcherTrait,
};
Expand Down
Loading

0 comments on commit 1d8b83e

Please sign in to comment.