Skip to content

Commit

Permalink
Undo adding link
Browse files Browse the repository at this point in the history
  • Loading branch information
georgwiese committed Jan 10, 2025
1 parent 8c3ee28 commit d793c30
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 42 deletions.
6 changes: 2 additions & 4 deletions executor/src/witgen/block_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<'a, 'c, T: FieldElement, Q: QueryCallback<T>> BlockProcessor<'a, 'c, T, Q>
while let Some(SequenceStep { row_delta, action }) = sequence_iterator.next() {
let row_index = (1 + row_delta) as usize;
let progress = match action {
Action::PolynomialIdentity(identity_index) => {
Action::InternalIdentity(identity_index) => {
if is_identity_complete[row_index][identity_index] {
// The identity has been completed already, there is no point in processing it again.
false
Expand All @@ -92,8 +92,6 @@ impl<'a, 'c, T: FieldElement, Q: QueryCallback<T>> BlockProcessor<'a, 'c, T, Q>
res.progress
}
}
// TODO(link)
Action::Link(_) => todo!(),
Action::OuterQuery => {
let (progress, new_outer_assignments) =
self.processor.process_outer_query(row_index)?;
Expand Down Expand Up @@ -218,7 +216,7 @@ mod tests {
unused_query_callback(),
|mut processor, poly_ids, degree, num_identities| {
let mut sequence_iterator = ProcessingSequenceIterator::Default(
DefaultSequenceIterator::new(degree as usize - 2, num_identities, 0, None),
DefaultSequenceIterator::new(degree as usize - 2, num_identities, None),
);
let outer_updates = processor.solve(&mut sequence_iterator).unwrap();
assert!(outer_updates.is_complete());
Expand Down
5 changes: 1 addition & 4 deletions executor/src/witgen/machines/block_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ impl<'a, T: FieldElement> BlockMachine<'a, T> {
block_size,
latch_row,
parts.identities.len(),
// TODO(link)
0,
),
function_cache: FunctionCache::new(
fixed_data,
Expand Down Expand Up @@ -266,8 +264,7 @@ impl<'a, T: FieldElement> Machine<'a, T> for BlockMachine<'a, T> {
// Run BlockProcessor (to potentially propagate selector values)
let mut processor = BlockProcessor::from_processor(processor, &self.parts.identities);
let mut sequence_iterator = ProcessingSequenceIterator::Default(
// TODO(link)
DefaultSequenceIterator::new(self.block_size, self.parts.identities.len(), 0, None),
DefaultSequenceIterator::new(self.block_size, self.parts.identities.len(), None),
);
processor.solve(&mut sequence_iterator).unwrap();
let mut dummy_block = processor.finish().block;
Expand Down
2 changes: 1 addition & 1 deletion executor/src/witgen/machines/dynamic_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl<'a, T: FieldElement> DynamicMachine<'a, T> {
self.degree,
);
let mut sequence_iterator = ProcessingSequenceIterator::Default(
DefaultSequenceIterator::new(0, next_parts.identities.len(), 0, None),
DefaultSequenceIterator::new(0, next_parts.identities.len(), None),
);
processor.solve(&mut sequence_iterator).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion executor/src/witgen/machines/second_stage_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl<'a, T: FieldElement> SecondStageMachine<'a, T> {
self.degree,
);
let mut sequence_iterator = ProcessingSequenceIterator::Default(
DefaultSequenceIterator::new(0, next_parts.identities.len(), 0, None),
DefaultSequenceIterator::new(0, next_parts.identities.len(), None),
);
processor.solve(&mut sequence_iterator).unwrap();

Expand Down
43 changes: 11 additions & 32 deletions executor/src/witgen/sequence_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub struct SequenceStep {
/// In each row, iterates over all identities until no further progress is made.
pub struct DefaultSequenceIterator {
identities_count: usize,
link_count: usize,
row_deltas: Vec<i64>,
outer_query_row: Option<i64>,

Expand All @@ -33,16 +32,10 @@ pub struct DefaultSequenceIterator {
}

impl DefaultSequenceIterator {
pub fn new(
block_size: usize,
identities_count: usize,
link_count: usize,
outer_query_row: Option<i64>,
) -> Self {
pub fn new(block_size: usize, identities_count: usize, outer_query_row: Option<i64>) -> Self {
let max_row = block_size as i64 - 1;
DefaultSequenceIterator {
identities_count,
link_count,
row_deltas: (-1..=max_row)
.chain((-1..max_row).rev())
.chain(0..=max_row)
Expand Down Expand Up @@ -77,10 +70,10 @@ impl DefaultSequenceIterator {

let last_action_index = if is_on_row_with_outer_query {
// In the last row, we want to do one more action, processing the outer query.
(self.identities_count + self.link_count) as i32 + 1
self.identities_count as i32 + 1
} else {
// Otherwise, we want to process all identities + 1 action processing the prover queries
(self.identities_count + self.link_count) as i32
self.identities_count as i32
};

self.cur_action_index < last_action_index
Expand Down Expand Up @@ -124,9 +117,7 @@ impl DefaultSequenceIterator {
let row_delta = self.row_deltas[self.cur_row_delta_index];
let is_on_row_with_outer_query = self.outer_query_row == Some(row_delta);

let cur_action_index = if is_on_row_with_outer_query
|| self.cur_action_index < self.identities_count as i32 + 1
{
let cur_action_index = if is_on_row_with_outer_query {
self.cur_action_index as usize
} else {
// Skip the outer query action
Expand All @@ -135,26 +126,22 @@ impl DefaultSequenceIterator {

SequenceStep {
row_delta: self.row_deltas[self.cur_row_delta_index],
action: if cur_action_index < self.identities_count {
Action::PolynomialIdentity(cur_action_index)
} else if cur_action_index == self.identities_count {
Action::ProverQueries
} else if cur_action_index == self.identities_count + 1 {
action: if cur_action_index == 0 {
Action::OuterQuery
} else if cur_action_index == 1 {
Action::ProverQueries
} else {
Action::Link(cur_action_index - self.identities_count - 2)
Action::InternalIdentity(cur_action_index - 2)
},
}
}
}

#[allow(dead_code)]
#[derive(Clone, Copy, Debug)]
pub enum Action {
PolynomialIdentity(usize),
ProverQueries,
OuterQuery,
Link(usize),
ProverQueries,
InternalIdentity(usize),
}

#[derive(PartialOrd, Ord, PartialEq, Eq, Debug)]
Expand Down Expand Up @@ -251,22 +238,15 @@ pub struct ProcessingSequenceCache {
block_size: usize,
outer_query_row: usize,
identities_count: usize,
link_count: usize,
cache: BTreeMap<SequenceCacheKey, CacheEntry>,
}

impl ProcessingSequenceCache {
pub fn new(
block_size: usize,
outer_query_row: usize,
identities_count: usize,
link_count: usize,
) -> Self {
pub fn new(block_size: usize, outer_query_row: usize, identities_count: usize) -> Self {
ProcessingSequenceCache {
block_size,
outer_query_row,
identities_count,
link_count,
cache: Default::default(),
}
}
Expand Down Expand Up @@ -304,7 +284,6 @@ impl ProcessingSequenceCache {
DefaultSequenceIterator::new(
self.block_size,
self.identities_count,
self.link_count,
Some(self.outer_query_row as i64),
)
}
Expand Down

0 comments on commit d793c30

Please sign in to comment.