Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize component_trace() #701

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 32 additions & 28 deletions crates/prover/src/core/air/air_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,35 +90,39 @@ pub trait AirExt: Air {
&'a self,
trees: &'a [CommitmentTreeProver<B>],
) -> Vec<ComponentTrace<'_, B>> {
let poly_iter = &mut trees[0].polynomials.iter();
let eval_iter = &mut trees[0].evaluations.iter();
let mut component_traces = vec![];
self.components().iter().for_each(|component| {
let n_columns = component.trace_log_degree_bounds()[0].len();
let polys = poly_iter.take(n_columns).collect_vec();
let evals = eval_iter.take(n_columns).collect_vec();

component_traces.push(ComponentTrace {
polys: TreeVec::new(vec![polys]),
evals: TreeVec::new(vec![evals]),
});
});
let mut poly_iters = trees
.iter()
.map(|tree| tree.polynomials.iter())
.collect_vec();
let mut eval_iters = trees
.iter()
.map(|tree| tree.evaluations.iter())
.collect_vec();

if trees.len() > 1 {
let poly_iter = &mut trees[1].polynomials.iter();
let eval_iter = &mut trees[1].evaluations.iter();
self.components()
.iter()
.zip_eq(&mut component_traces)
.for_each(|(component, component_trace)| {
let n_columns = component.trace_log_degree_bounds()[1].len();
let polys = poly_iter.take(n_columns).collect_vec();
let evals = eval_iter.take(n_columns).collect_vec();
component_trace.polys.push(polys);
component_trace.evals.push(evals);
});
}
component_traces
self.components()
.iter()
.map(|component| {
let col_sizes_per_tree = component
.trace_log_degree_bounds()
.iter()
.map(|col_sizes| col_sizes.len())
.collect_vec();
let polys = col_sizes_per_tree
.iter()
.zip(poly_iters.iter_mut())
.map(|(n_columns, iter)| iter.take(*n_columns).collect_vec())
.collect_vec();
let evals = col_sizes_per_tree
.iter()
.zip(eval_iters.iter_mut())
.map(|(n_columns, iter)| iter.take(*n_columns).collect_vec())
.collect_vec();
ComponentTrace {
polys: TreeVec::new(polys),
evals: TreeVec::new(evals),
}
})
.collect_vec()
}
}

Expand Down
Loading