-
Notifications
You must be signed in to change notification settings - Fork 144
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
Plafer cleanup block hash table #1333
Conversation
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.
Looks great, thank you!
Just a couple of minor nits from my side
/// - current_block_id: contains the ID of the current block. Note: the current block's ID is the | ||
/// parent block's ID from the perspective of the block being added to the table. |
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.
nit: should we just use parent_id
as in the docs? It was a bit easier for me to understand the logic of this virtual table using this name.
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.
Agreed, switched back to parent_block_id
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.
Looks great! Thank you!
One thing I am wondering is whether we should create a struct for the block hash table row. It could look something like this:
struct BlockHashTableRow {
parent_block_id: Felt,
child_block_hash: Word,
is_first_child: bool,
is_loop_body: bool,
}
Then, we could add various constructor methods to it:
impl BlockHashTableRow {
pub fn from_end(trace: &MainTrace, row: usize) -> Self {
todo!()
}
pub fn from_join(trace: &MainTrace, row: usize, is_first_child: bool) -> Self {
todo!()
}
...
}
And then we could add a to_value()
method to reduce a row to a single value. It could look like this:
impl BlockHashTableRow {
pub fn to_value<E: FieldElement<BaseField = Felt>>(&self, alphas: &[E]) -> E {
todo!()
}
}
Then, when using these, we could do something like:
SPLIT => BlockHashTableRow::from_split(main_trace, i).to_value(alphas),
I think this structure would make it a bit easier to follow - though, I think the improvement would not be all that big over what you already have. So, if you'd rather keep it as is, that's fine too.
I agree that a The only place where it breaks a little bit is with |
I think it could still works if the constructor has the following signature: pub fn from_join(trace: &MainTrace, row: usize, is_first_child: bool) -> Self {
todo!()
} Then, this function can be called twice to generate two rows (once with |
@bobbinth implementation now uses |
Note: clippy failures are due to a new version of nightly rust, and there are many errors, so I think we should do it in another PR instead |
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.
Looks good! Thank you! I left a couple of small comments inline. Once these are addressed, we can merge.
Makes the block hash table aux column builder more readable. Also adds more documentation.