-
Notifications
You must be signed in to change notification settings - Fork 160
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 #1557
Open
plafer
wants to merge
1
commit into
next
Choose a base branch
from
plafer-fix-block-stack-table
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+33
−16
Open
Fix block stack table #1557
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,10 +21,8 @@ impl<E: FieldElement<BaseField = Felt>> AuxColumnBuilder<E> for BlockStackColumn | |
let op_code = op_code_felt.as_int() as u8; | ||
|
||
match op_code { | ||
OPCODE_RESPAN => { | ||
get_block_stack_table_removal_multiplicand(main_trace, i, true, alphas) | ||
}, | ||
OPCODE_END => get_block_stack_table_removal_multiplicand(main_trace, i, false, alphas), | ||
OPCODE_RESPAN => get_block_stack_table_respan_multiplicand(main_trace, i, alphas), | ||
OPCODE_END => get_block_stack_table_end_multiplicand(main_trace, i, alphas), | ||
_ => E::ONE, | ||
} | ||
} | ||
|
@@ -48,18 +46,33 @@ impl<E: FieldElement<BaseField = Felt>> AuxColumnBuilder<E> for BlockStackColumn | |
// ================================================================================================ | ||
|
||
/// Computes the multiplicand representing the removal of a row from the block stack table. | ||
fn get_block_stack_table_removal_multiplicand<E: FieldElement<BaseField = Felt>>( | ||
fn get_block_stack_table_respan_multiplicand<E: FieldElement<BaseField = Felt>>( | ||
main_trace: &MainTrace, | ||
i: RowIndex, | ||
is_respan: bool, | ||
alphas: &[E], | ||
) -> E { | ||
let block_id = main_trace.addr(i); | ||
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.is_loop_flag(i)) | ||
}; | ||
let parent_id = main_trace.decoder_hasher_state_element(1, i + 1); | ||
let is_loop = ZERO; | ||
|
||
// Note: the last 8 elements are set to ZERO, so we omit them here. | ||
let elements = [ONE, block_id, parent_id, is_loop]; | ||
|
||
let mut table_row = E::ZERO; | ||
for (&alpha, &element) in alphas.iter().zip(elements.iter()) { | ||
table_row += alpha.mul_base(element); | ||
} | ||
table_row | ||
} | ||
|
||
fn get_block_stack_table_end_multiplicand<E: FieldElement<BaseField = Felt>>( | ||
Comment on lines
+67
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be good to add a brief comment here. |
||
main_trace: &MainTrace, | ||
i: RowIndex, | ||
alphas: &[E], | ||
) -> E { | ||
let block_id = main_trace.addr(i); | ||
let parent_id = main_trace.addr(i + 1); | ||
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); | ||
|
@@ -91,12 +104,11 @@ fn get_block_stack_table_removal_multiplicand<E: FieldElement<BaseField = Felt>> | |
result | ||
}; | ||
|
||
let mut value = E::ZERO; | ||
|
||
let mut table_row = E::ZERO; | ||
for (&alpha, &element) in alphas.iter().zip(elements.iter()) { | ||
value += alpha.mul_base(element); | ||
table_row += alpha.mul_base(element); | ||
} | ||
value | ||
table_row | ||
} | ||
|
||
/// Computes the multiplicand representing the inclusion of a new row to the block stack table. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the comment here needs to be updated.