-
Notifications
You must be signed in to change notification settings - Fork 596
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
Add encode/decode functionality to hints. #3289
Conversation
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.
Reviewed 2 of 6 files at r1.
Reviewable status: 2 of 6 files reviewed, 3 unresolved discussions (waiting on @dan-starkware and @yair-starkware)
Cargo.toml
line 71 at r1 (raw file):
num-traits = "0.2" once_cell = "1.17.1" parity-scale-codec = "3.5.0"
Depending on scale is one thing, but are we sure we want to depend on partiy
code? Can you explain what exactly this crate has that we need? Regular SCALE doesn't have derive?
Code quote:
parity-scale-codec
crates/cairo-lang-casm/src/operand.rs
line 63 at r1 (raw file):
} } // Can't derive the trait because BigIntAsHex doesn't implement Encode.
Why not implement it for BigIntAsHex insteaD?
crates/cairo-lang-casm/src/hints/mod.rs
line 14 at r1 (raw file):
// Represents a cairo hint. // Note: some projects store the encoding of hints. Be mindful about making changes as they are hard // to detect and may require storage migration.
.
Suggestion:
// Note: Hint encoding should be backwards-compatible. This is an API guarantee.
// For example, new variants should haev new `index`.
2514f68
to
936a049
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.
Reviewable status: 2 of 9 files reviewed, 3 unresolved discussions (waiting on @dan-starkware and @spapinistarkware)
Cargo.toml
line 71 at r1 (raw file):
Previously, spapinistarkware (Shahar Papini) wrote…
Depending on scale is one thing, but are we sure we want to depend on
partiy
code? Can you explain what exactly this crate has that we need? Regular SCALE doesn't have derive?
WDYM by regular scale?
There are multiple scale related crates, all depending on parity-scale-codec in their basis, if I understand correctly.
crates/cairo-lang-casm/src/operand.rs
line 63 at r1 (raw file):
Previously, spapinistarkware (Shahar Papini) wrote…
Why not implement it for BigIntAsHex insteaD?
Done, thanks.
crates/cairo-lang-casm/src/hints/mod.rs
line 14 at r1 (raw file):
Previously, spapinistarkware (Shahar Papini) wrote…
.
Done.
936a049
to
36109a6
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.
Reviewed 6 of 7 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @dan-starkware)
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.
Reviewed 3 of 3 files at r4, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @dan-starkware and @orizi)
Issues I found:
It is dangerous since we won’t be able to detect things like changing fields order, removing + adding fields, etc.
3. Adding option fields breaks the decoding, so we can't rely on it for adding data without migration:
This change is