Skip to content

Commit

Permalink
Fix fri instances
Browse files Browse the repository at this point in the history
  • Loading branch information
hratoanina committed Jul 19, 2024
1 parent c9ed24c commit a3c23aa
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 6 deletions.
62 changes: 57 additions & 5 deletions evm_arithmetization/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use plonky2::field::polynomial::{PolynomialCoeffs, PolynomialValues};
use plonky2::field::types::Field;
use plonky2::fri::oracle::PolynomialBatch;
use plonky2::fri::reduction_strategies::FriReductionStrategy;
use plonky2::fri::structure::{FriInstanceInfo, FriOpeningBatch};
use plonky2::fri::structure::{FriInstanceInfo, FriOpeningBatch, FriOracleInfo};
use plonky2::fri::FriConfig;
use plonky2::hash::hash_types::RichField;
use plonky2::hash::merkle_tree::MerkleCap;
Expand Down Expand Up @@ -87,7 +87,7 @@ impl GenerationSegmentData {
}
}

pub(crate) fn zkevm_fast_config() -> StarkConfig {
pub fn zkevm_fast_config() -> StarkConfig {
StarkConfig {
security_bits: 100,
num_challenges: 2,
Expand Down Expand Up @@ -515,8 +515,10 @@ where
&quotient_commitment,
];

let mut degree_bits_squashed = Table::all_degree_logs().to_vec();
degree_bits_squashed.dedup();
let opening_proof = BatchFriOracle::prove_openings(
&Table::all_degree_logs(),
&degree_bits_squashed,
&all_fri_instances,
&initial_merkle_trees,
&mut challenger,
Expand Down Expand Up @@ -1147,10 +1149,60 @@ where
config,
));

Table::all_sorted()
let res_sorted: Vec<_> = Table::all_sorted()
.iter()
.map(|&table| res[*table].clone())
.collect()
.collect();

let mut squashed_res = Vec::new();
let mut i = 0;
let mut current_instance = FriInstanceInfo {
oracles: vec![
FriOracleInfo {
num_polys: 0,
blinding: false,
},
FriOracleInfo {
num_polys: 0,
blinding: false,
},
FriOracleInfo {
num_polys: 0,
blinding: false,
},
],
batches: vec![],
};

while i < NUM_TABLES {
let instance = &res_sorted[i];
for (k, oracle) in instance.oracles.iter().enumerate() {
current_instance.oracles[k].num_polys += oracle.num_polys;
}
current_instance.batches.extend(instance.batches.clone());

if i == NUM_TABLES - 1 || Table::all_degree_logs()[i + 1] < Table::all_degree_logs()[i] {
squashed_res.push(current_instance.clone());
current_instance.oracles = vec![
FriOracleInfo {
num_polys: 0,
blinding: false,
},
FriOracleInfo {
num_polys: 0,
blinding: false,
},
FriOracleInfo {
num_polys: 0,
blinding: false,
},
];
current_instance.batches = vec![];
}
i += 1;
}

squashed_res
}

fn all_openings_single_stark<F, C, S, const D: usize>(
Expand Down
3 changes: 2 additions & 1 deletion evm_arithmetization/tests/simple_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use evm_arithmetization::generation::mpt::{AccountRlp, LegacyReceiptRlp};
use evm_arithmetization::generation::{GenerationInputs, TrieInputs};
use evm_arithmetization::proof::{BlockHashes, BlockMetadata, TrieRoots};
use evm_arithmetization::prover::testing::{prove_all_segments, prove_all_segments_batch};
use evm_arithmetization::prover::zkevm_fast_config;
use evm_arithmetization::verifier::testing::verify_all_proofs;
use evm_arithmetization::{AllStark, Node, StarkConfig};
use hex_literal::hex;
Expand All @@ -31,7 +32,7 @@ fn test_simple_transfer() -> anyhow::Result<()> {
init_logger();

let all_stark = AllStark::<F, D>::default();
let config = StarkConfig::standard_fast_config();
let config = zkevm_fast_config();

let beneficiary = hex!("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef");
let sender = hex!("2c7536e3605d9c16a7a3d7b1898e529396a65c23");
Expand Down

0 comments on commit a3c23aa

Please sign in to comment.