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

feat: add MemoryTable struct #35

Merged
merged 4 commits into from
Nov 8, 2024
Merged

feat: add MemoryTable struct #35

merged 4 commits into from
Nov 8, 2024

Conversation

zmalatrax
Copy link
Collaborator

Closes #32

The field d representing the flag for dummy rows is private: d must either be 0 or 1 (as a BaseField), which is enforced by the methods new and new_dummy.

This field d appears useless atm, but it'll make more sense once #33 and #34 are done.


impl MemoryTableRow {
pub fn new(clk: BaseField, mp: BaseField, mv: BaseField) -> Self {
Self { clk, mp, mv, d: BaseField::zero() }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Self { clk, mp, mv, d: BaseField::zero() }
Self { clk, mp, mv, ..Default::default() }

/// # Returns
/// A new instance of [`MemoryTable`] with an empty table.
pub const fn new() -> Self {
Self { table: Vec::new() }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Self { table: Vec::new() }
Self::default()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, didn't catch it indeed
We've got the same in instruction/table.rs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, it requires not having the new method as const (or implement Default as const ?)

Comment on lines 24 to 30
pub fn new(clk: BaseField, mp: BaseField, mv: BaseField) -> Self {
Self { clk, mp, mv, d: BaseField::zero() }
}

pub fn new_dummy(clk: BaseField, mp: BaseField, mv: BaseField) -> Self {
Self { clk, mp, mv, d: BaseField::one() }
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here really pedantic but I think that we miss 2 small unit tests:

  • To validate that the fields clk, mp, mv, d are properly set up for a row with the new function
  • To validate that the fields clk, mp, mv, d are properly set up for a row with the new_dummy function

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I'll add them

@tcoratger tcoratger merged commit ce96fd8 into main Nov 8, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: add a struct for the Memory component trace
2 participants