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(levm): improve precompiles code clarity #1579

Merged
merged 9 commits into from
Jan 6, 2025

Conversation

maximopalopoli
Copy link
Contributor

@maximopalopoli maximopalopoli commented Dec 30, 2024

Motivation

The motivation is to improve the clarity of the code.

Description

Added some comments, made a constant and some separate functions to make the code more understandable.

@maximopalopoli maximopalopoli added the levm Lambda EVM implementation label Dec 30, 2024
@maximopalopoli maximopalopoli self-assigned this Dec 30, 2024
@maximopalopoli maximopalopoli changed the title feat(levm): improve code clarity feat(levm): improve precompiles code clarity Dec 30, 2024
@maximopalopoli maximopalopoli marked this pull request as ready for review December 30, 2024 16:27
@maximopalopoli maximopalopoli requested a review from a team as a code owner December 30, 2024 16:27
Copy link
Contributor

@JereSalo JereSalo left a comment

Choose a reason for hiding this comment

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

It's good, I just left some suggestions to improve redaction, you can either take them or maybe replace them for something else that sounds good

Comment on lines 343 to 344
/// This function returns the slice defined by the limits converted to a vec. If the size to expand the
/// slice are not covered by the calldata size, then the missing space needed is filled with zeros.
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
/// This function returns the slice defined by the limits converted to a vec. If the size to expand the
/// slice are not covered by the calldata size, then the missing space needed is filled with zeros.
/// This function returns the slice between the lower and upper limit of the calldata (as a vector), padding with zeros at the end if necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -366,6 +374,7 @@ fn mod_exp(base: BigUint, exponent: BigUint, modulus: BigUint) -> BigUint {
}
}

/// If the result size is lower than the needed, then pads the result to right filling with zeros at left.
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
/// If the result size is lower than the needed, then pads the result to right filling with zeros at left.
/// If the result size is less than needed, pads left with zeros.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -805,7 +862,7 @@ fn blake2f_compress_f(
Ok(output)
}

// Reads a part of the calldata and returns what is read as u64 or an error
/// Reads a part of the calldata and returns what is read as u64 or an error
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
/// Reads a part of the calldata and returns what is read as u64 or an error
/// Reads part of the calldata and returns what is read as u64 or an error

Maybe it would be good if we clarify in which scenario it returns an error. "or an error if out of bounds" for example

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@damiramirez damiramirez left a comment

Choose a reason for hiding this comment

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

LGTM!

@ilitteri ilitteri added this pull request to the merge queue Jan 6, 2025
Merged via the queue into main with commit 7bc5d4a Jan 6, 2025
4 checks passed
@ilitteri ilitteri deleted the levm/add-comments-precompiles branch January 6, 2025 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
levm Lambda EVM implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants