-
Notifications
You must be signed in to change notification settings - Fork 148
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
Improve error handling of ids variables #851
Conversation
FailedToComputeOperands
errorFailedToGetIds
error
…pack_from_relocatable
FailedToGetIds
error
Codecov Report
@@ Coverage Diff @@
## main #851 +/- ##
==========================================
+ Coverage 96.79% 96.82% +0.03%
==========================================
Files 69 69
Lines 28788 28835 +47
==========================================
+ Hits 27864 27920 +56
+ Misses 924 915 -9
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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 but see comments.
pub(crate) struct BigInt3<'a> { | ||
pub d0: Cow<'a, Felt>, | ||
pub d1: Cow<'a, Felt>, | ||
pub d2: Cow<'a, Felt>, | ||
} |
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.
Why Cow<_>
?
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 wanted to use references when possible instead of cloning values, and using references wasn't possible
src/vm/errors/hint_errors.rs
Outdated
#[error("Expected ids.{0} to be an Integer value")] | ||
IdentifierNotInteger(String), | ||
#[error("Expected ids.{0} to be a Relocatable value")] | ||
IdentifierNotRelocatable(String), |
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.
It may be a good idea (or not, I'm not really sure) to include the resolved address.
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.
On it!
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.
Done
Currently, when retrieving ids values from memory, all internal memory errors get replaced by the
FailedToGetIds
error, which doesnt give us much information about what went wrong.This PR aims to remove this error, and replace it with variants that state which is the identifier that couldnt be computed.
Also, methods reflecting internal computation of ids values and addresses will have their return values changed to Option<>, as their errors arent and wont be used
This pr also refactors secp hints to use concrete types for structs (
EcPoint
&BigInt3
) failing to create these types will return anUnknownIdentifier
orIdentifierHasNoMember
error instead of relying on internal memory errorsAfter this PR the following error cases will be outputed by the hint in case of undetermined ids:
UnknownIdentifier
: The identifier is unknown (aka ids.val doesnt exist)IdentifierNotInteger
/IdentifierNotRelocatable
: The identifier is of invalid type (aka ids.val exists but its not integer/reloctable)IdentifierHasNoMember
: The identifier doesnt have a member (aka ids.val.x doesnt exist or has incorrect type)