-
Notifications
You must be signed in to change notification settings - Fork 16
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
Parsing of Individual section of random values #129
Conversation
52c0aa1
to
9bbf0b9
Compare
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.
Thanks @Overcastan, this looks good! I left a few thoughts inline
parser/src/ast/random_values.rs
Outdated
/// Declaration of a random value used in [RandomValues]. It is represented by a named identifier and its size. | ||
#[derive(Debug, Eq, PartialEq)] | ||
pub struct RandBinding { | ||
name: Identifier, | ||
size: usize, | ||
} |
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.
Although binding is a good word choice, this feels inconsistent with the other ways we've implemented and named things. I wonder if we should either change this to NamedRandomValues
or plan to use the word binding more consistently in other places.
Curious what others think
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.
We can revisit this in a future PR, alongside @tohrnii's comment #129 (comment)
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.
Thank you @Overcastan, overall looks good to me. I just left some small things inline.
#[derive(Debug, Eq, PartialEq, Clone)] | ||
pub struct RandBinding { | ||
name: Identifier, | ||
size: u64, | ||
} | ||
|
||
impl RandBinding { | ||
pub(crate) fn new(name: Identifier, size: u64) -> Self { | ||
Self { name, size } | ||
} | ||
|
||
pub fn name(&self) -> &str { | ||
let Identifier(name) = &self.name; | ||
name | ||
} | ||
|
||
pub fn size(&self) -> u64 { | ||
self.size | ||
} | ||
} |
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'm wondering if we can create a structure with more generic name that we can use for other similar structs (like TraceCols and PublicInput), and then define aliases for those instead. This will make things a little less redundant. cc: @grjte
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've thought about it too, but I haven't figured out how to do it well. It will be great if we can implement this
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 agree that this would be ideal. Let me take a look and see if I think of anything. Otherwise, we can make a separate issue to revisit this in a future PR. It would be great to do it now, though.
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.
Can we call this just Array
or ArrayDecl
?
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.
Let's revisit this in a future PR
6d2eafb
to
545b997
Compare
a471852
to
2a439dd
Compare
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.
Thank you @Overcastan, looks good to me. I just left a few very minor nits.
2a439dd
to
1c86ca1
Compare
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.
Thanks @Overcastan, looks good! Just a couple very small final things
#[derive(Debug, Eq, PartialEq, Clone)] | ||
pub struct RandBinding { | ||
name: Identifier, | ||
size: u64, | ||
} | ||
|
||
impl RandBinding { | ||
pub(crate) fn new(name: Identifier, size: u64) -> Self { | ||
Self { name, size } | ||
} | ||
|
||
pub fn name(&self) -> &str { | ||
let Identifier(name) = &self.name; | ||
name | ||
} | ||
|
||
pub fn size(&self) -> u64 { | ||
self.size | ||
} | ||
} |
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.
Let's revisit this in a future PR
parser/src/ast/random_values.rs
Outdated
/// Declaration of a random value used in [RandomValues]. It is represented by a named identifier and its size. | ||
#[derive(Debug, Eq, PartialEq)] | ||
pub struct RandBinding { | ||
name: Identifier, | ||
size: usize, | ||
} |
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.
We can revisit this in a future PR, alongside @tohrnii's comment #129 (comment)
1c86ca1
to
da01d36
Compare
parser/src/ast/mod.rs
Outdated
@@ -32,6 +35,7 @@ pub struct Source(pub Vec<SourceSection>); | |||
/// - PeriodicColumns: Periodic columns are each represented by a fixed-size array with all of its | |||
/// elements specified. The array length is expected to be a power of 2, but this is not checked | |||
/// during parsing. | |||
/// - RandomValues: Random Values represent the randomness sent by the Verifier |
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: a dot at the end is missing
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 @Overcastan !
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.
LGTM! Thank you!
da01d36
to
6075ea5
Compare
Partly addressing #86.
Implementing parsing of random values, declared in individual section.