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

Update usize serialization and deserialization #1266

Merged
merged 1 commit into from
Mar 9, 2024

Conversation

Fumuran
Copy link
Contributor

@Fumuran Fumuran commented Mar 1, 2024

This PR changes the serialization and deserialization method of usize values to write_usize() and read_usize() respectively.

@Fumuran Fumuran linked an issue Mar 1, 2024 that may be closed by this pull request
assembly/src/ast/module.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@bobbinth bobbinth 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! Looks good. I left a few comments inline.

Also, I think we can roll back the AST-related changes as these will not be needed after the assembler refactoring that @bitwalker is working on.

core/src/program/mod.rs Show resolved Hide resolved
core/src/stack/inputs.rs Outdated Show resolved Hide resolved
core/src/stack/inputs.rs Show resolved Hide resolved
core/src/stack/outputs.rs Outdated Show resolved Hide resolved
core/src/stack/outputs.rs Outdated Show resolved Hide resolved
core/src/stack/outputs.rs Outdated Show resolved Hide resolved
@Fumuran Fumuran force-pushed the andrew-update-usize-serialization branch from 7d27b42 to da18d4d Compare March 3, 2024 22:15
core/src/stack/inputs.rs Outdated Show resolved Hide resolved
core/src/stack/outputs.rs Outdated Show resolved Hide resolved
@Fumuran Fumuran requested a review from bobbinth March 4, 2024 10:29
@Fumuran Fumuran force-pushed the andrew-update-usize-serialization branch from 852d1ee to 82e71b8 Compare March 4, 2024 21:49
Copy link
Contributor

@bobbinth bobbinth 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! Looks good. I left a few more comments inline.

core/src/stack/inputs.rs Outdated Show resolved Hide resolved
core/src/stack/inputs.rs Outdated Show resolved Hide resolved
core/src/stack/inputs.rs Outdated Show resolved Hide resolved
core/src/stack/outputs.rs Outdated Show resolved Hide resolved
core/src/stack/outputs.rs Outdated Show resolved Hide resolved
@Fumuran Fumuran force-pushed the andrew-update-usize-serialization branch 2 times, most recently from 68a993f to 024c631 Compare March 6, 2024 15:40
@Fumuran Fumuran requested a review from bobbinth March 6, 2024 16:20
Copy link
Contributor

@bobbinth bobbinth left a 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 few minor nits related to naming inline. Once these are addressed, we can merge.

// CONSTANTS
// --------------------------------------------------------------------------------------------

pub const MAX_STACK_INPUTS_SIZE: usize = u16::MAX as usize;
Copy link
Contributor

Choose a reason for hiding this comment

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

The naming is a bit redundant here - e.g., StackInputs::MAX_STACK_INPUTS_SIZE. I would probably change this to something like MAX_LEN and then it would be StackInputs::MAX_LEN.

// CONSTANTS
// --------------------------------------------------------------------------------------------

pub const MAX_STACK_OUTPUTS_SIZE: usize = u16::MAX as usize;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above - probably MAX_LEN would be sufficient here.

/// # Errors
/// Returns an error if:
/// - The values do not represent a valid field element.
/// - Number of values in the iterator exceeds the allowed maximum number of input values.
pub fn try_from_values<I>(iter: I) -> Result<Self, InputError>
Copy link
Contributor

Choose a reason for hiding this comment

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

I just noticed that StackOutputs has try_from_ints() method. So, we should either name this one try_from_ints() or rename the other one into try_from_values(). I think the first option is probably a bit better.

@Fumuran Fumuran force-pushed the andrew-update-usize-serialization branch from 024c631 to bc11f61 Compare March 9, 2024 20:56
@Fumuran Fumuran force-pushed the andrew-update-usize-serialization branch from bc11f61 to b0df9b8 Compare March 9, 2024 21:02
@Fumuran Fumuran merged commit 322a70b into next Mar 9, 2024
15 checks passed
@Fumuran Fumuran deleted the andrew-update-usize-serialization branch March 9, 2024 21:50
Al-Kindi-0 added a commit that referenced this pull request Mar 28, 2024
refactor: serialize usize with write_usize (#1266)
Al-Kindi-0 added a commit that referenced this pull request May 22, 2024
refactor: serialize usize with write_usize (#1266)
Al-Kindi-0 added a commit that referenced this pull request May 24, 2024
refactor: serialize usize with write_usize (#1266)
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.

Update usize serialization and deserialization
2 participants