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

Fix block stack table respan #1512

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

- Fixed an issue with formatting of blocks in Miden Assembly syntax
- Fixed the construction of the block hash table (#1506)
- Fixed a bug in the block stack table (#1511)
- Fixed a bug in the block stack table (#1511) (#1512)
- Fixed the construction of the chiplets virtual table (#1514)
- Fixed the construction of the chiplets bus (#1516)

Expand Down
13 changes: 12 additions & 1 deletion miden/tests/integration/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate alloc;

use test_utils::build_test;
use test_utils::{build_op_test, build_test};

mod air;
mod cli;
Expand All @@ -21,3 +21,14 @@ fn multi_output_program() {
let test = build_test!("begin mul movup.2 drop end", &[1, 2, 3]);
test.prove_and_verify(vec![1, 2, 3], false);
}

#[test]
fn program_with_respan() {
let source = "
repeat.49
swap dup.1 add
end";
let pub_inputs = vec![];

build_op_test!(source, &pub_inputs).prove_and_verify(pub_inputs, false);
}
7 changes: 3 additions & 4 deletions processor/src/decoder/aux_trace/block_stack_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ fn get_block_stack_table_removal_multiplicand<E: FieldElement<BaseField = Felt>>
alphas: &[E],
) -> E {
let block_id = main_trace.addr(i);
let parent_id = if is_respan {
main_trace.decoder_hasher_state_element(1, i + 1)
let (parent_id, is_loop) = if is_respan {
(main_trace.decoder_hasher_state_element(1, i + 1), ZERO)
} else {
main_trace.addr(i + 1)
(main_trace.addr(i + 1), main_trace.is_loop_flag(i))
};
let is_loop = main_trace.is_loop_flag(i);

let elements = if main_trace.is_call_flag(i) == ONE || main_trace.is_syscall_flag(i) == ONE {
let parent_ctx = main_trace.ctx(i + 1);
Expand Down
17 changes: 15 additions & 2 deletions processor/src/decoder/aux_trace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,21 @@ impl AuxTraceBuilder {
let p2 = block_hash_column_builder.build_aux_column(main_trace, rand_elements);
let p3 = op_group_table_column_builder.build_aux_column(main_trace, rand_elements);

debug_assert_eq!(*p2.last().unwrap(), E::ONE);
debug_assert_eq!(*p3.last().unwrap(), E::ONE);
debug_assert_eq!(
*p1.last().unwrap(),
E::ONE,
"block stack table is not empty at the end of program execution"
);
debug_assert_eq!(
*p2.last().unwrap(),
E::ONE,
"block hash table is not empty at the end of program execution"
);
debug_assert_eq!(
*p3.last().unwrap(),
E::ONE,
"op group table is not empty at the end of program execution"
);

vec![p1, p2, p3]
}
Expand Down
Loading