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

Parsing of Individual section of random values #129

Merged
merged 2 commits into from
Feb 2, 2023

Conversation

Fumuran
Copy link
Contributor

@Fumuran Fumuran commented Jan 30, 2023

Partly addressing #86.
Implementing parsing of random values, declared in individual section.

Copy link
Contributor

@grjte grjte left a 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

air-script/tests/aux_trace/aux_trace.air Outdated Show resolved Hide resolved
air-script/tests/aux_trace/aux_trace.rs Outdated Show resolved Hide resolved
air-script/tests/variables/variables.air Outdated Show resolved Hide resolved
air-script/tests/variables/variables.rs Outdated Show resolved Hide resolved
parser/src/lexer/tests/random_values.rs Outdated Show resolved Hide resolved
parser/src/parser/grammar.lalrpop Outdated Show resolved Hide resolved
parser/src/parser/grammar.lalrpop Outdated Show resolved Hide resolved
Comment on lines 64 to 70
/// 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,
}
Copy link
Contributor

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

Copy link
Contributor

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)

parser/src/parser/tests/random_values.rs Outdated Show resolved Hide resolved
parser/src/parser/tests/random_values.rs Outdated Show resolved Hide resolved
@Fumuran Fumuran requested a review from grjte January 30, 2023 20:13
Copy link
Contributor

@tohrnii tohrnii left a 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.

parser/src/ast/random_values.rs Outdated Show resolved Hide resolved
parser/src/ast/random_values.rs Outdated Show resolved Hide resolved
Comment on lines +65 to +85
#[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
}
}
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor

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/error.rs Outdated Show resolved Hide resolved
parser/src/parser/grammar.lalrpop Outdated Show resolved Hide resolved
parser/src/parser/grammar.lalrpop Outdated Show resolved Hide resolved
@Fumuran Fumuran force-pushed the andrew-parse-random-values branch from 6d2eafb to 545b997 Compare January 30, 2023 22:36
@tohrnii tohrnii mentioned this pull request Jan 31, 2023
14 tasks
@Fumuran Fumuran force-pushed the andrew-parse-random-values branch 2 times, most recently from a471852 to 2a439dd Compare January 31, 2023 22:30
@Fumuran Fumuran requested a review from tohrnii January 31, 2023 22:33
Copy link
Contributor

@tohrnii tohrnii left a 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.

parser/src/ast/random_values.rs Outdated Show resolved Hide resolved
parser/src/ast/random_values.rs Outdated Show resolved Hide resolved
parser/src/error.rs Outdated Show resolved Hide resolved
@Fumuran Fumuran force-pushed the andrew-parse-random-values branch from 2a439dd to 1c86ca1 Compare February 1, 2023 11:09
@grjte grjte removed the request for review from bobbinth February 1, 2023 12:17
Copy link
Contributor

@grjte grjte left a 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

parser/src/parser/grammar.lalrpop Outdated Show resolved Hide resolved
parser/src/parser/tests/random_values.rs Outdated Show resolved Hide resolved
parser/src/parser/tests/random_values.rs Outdated Show resolved Hide resolved
Comment on lines +65 to +85
#[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
}
}
Copy link
Contributor

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

Comment on lines 64 to 70
/// 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,
}
Copy link
Contributor

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)

@Fumuran Fumuran force-pushed the andrew-parse-random-values branch from 1c86ca1 to da01d36 Compare February 1, 2023 14:25
@Fumuran Fumuran requested a review from grjte February 1, 2023 14:29
@@ -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
Copy link
Collaborator

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

Copy link
Collaborator

@Al-Kindi-0 Al-Kindi-0 left a 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 !

Copy link
Contributor

@grjte grjte left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

@Fumuran Fumuran force-pushed the andrew-parse-random-values branch from da01d36 to 6075ea5 Compare February 1, 2023 14:48
@grjte grjte merged commit 6446fd2 into next Feb 2, 2023
@grjte grjte deleted the andrew-parse-random-values branch February 2, 2023 08:23
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.

4 participants