-
Notifications
You must be signed in to change notification settings - Fork 25
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(blockifier): add NativeSyscallHandler
#1240
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1240 +/- ##
==========================================
- Coverage 74.18% 69.30% -4.89%
==========================================
Files 359 88 -271
Lines 36240 11803 -24437
Branches 36240 11803 -24437
==========================================
- Hits 26886 8180 -18706
+ Misses 7220 3256 -3964
+ Partials 2134 367 -1767
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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 4 files at r1.
Reviewable status: 2 of 5 files reviewed, all discussions resolved
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 1 of 4 files at r1, 1 of 1 files at r2, 1 of 1 files at r6, all commit messages.
Reviewable status: 4 of 5 files reviewed, 2 unresolved discussions (waiting on @meship-starkware and @rodrigo-pino)
crates/blockifier/src/execution/native/utils.rs
line 22 at r7 (raw file):
encoding[i] = Felt::from_bytes_be(&chunk); } encoding
The chunks
are of size 31 (as well as data_chunk
.
chunk
is of size 32.
We write at indices 1-31 the value of data_chunk
as the MSB no?
It's different than what we do in the constants messages, right?
Suggestion:
let data = msg.as_bytes().chunks(CHUNK_SIZE - 1);
let mut encoding = vec![];
for data_chunk in data.iter() {
let mut chunk = [0_u8; CHUNK_SIZE];
chunk[1..data_chunk.len() + 1].copy_from_slice(data_chunk);
encoding.push(Felt::from_bytes_be(&chunk));
}
encoding
crates/blockifier/src/execution/native/utils.rs
line 27 at r7 (raw file):
// Todo(rodrigo): This is an opinionated way of interpretting error messages. It's ok for now but I // think it can be improved; (for example) trying to make the output similar to a Cairo VM panic pub fn decode_felts_as_str(encoding: &[Felt]) -> String {
When will it be used?
Code quote:
pub fn decode_felts_as_str(encoding: &[Felt]) -> 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.
Reviewed 1 of 1 files at r6.
Reviewable status: 4 of 5 files reviewed, 2 unresolved discussions (waiting on @rodrigo-pino)
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: 4 of 5 files reviewed, 2 unresolved discussions (waiting on @meship-starkware and @noaov1)
crates/blockifier/src/execution/native/utils.rs
line 22 at r7 (raw file):
We write at indices 1-31 the value of
data_chunk
as the MSB no?
It's different than what we do in the constants messages, right?
I'd have to dive a bit deep in the code to answer a 100% sure but I think is not. Both messages are encoded in the same fashion as your error messages. When they get decoded during execution we don't see any word being reversed 🤔
crates/blockifier/src/execution/native/utils.rs
line 27 at r7 (raw file):
Previously, noaov1 (Noa Oved) wrote…
When will it be used?
When outputting the final error message, after Cairo Native returned control if there was a failure, the message is contained in a Vec<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.
Reviewable status: 4 of 5 files reviewed, 3 unresolved discussions (waiting on @meship-starkware and @rodrigo-pino)
crates/blockifier/src/execution/native/utils.rs
line 22 at r7 (raw file):
Previously, rodrigo-pino (Rodrigo) wrote…
We write at indices 1-31 the value of
data_chunk
as the MSB no?
It's different than what we do in the constants messages, right?I'd have to dive a bit deep in the code to answer a 100% sure but I think is not. Both messages are encoded in the same fashion as your error messages. When they get decoded during execution we don't see any word being reversed 🤔
I tried to decode it and it seems to result with the same "Out of gas" message. I guess it's because you remove the 0's (in prefix and suffix). Makes sense?
crates/blockifier/src/execution/native/utils.rs
line 34 at r7 (raw file):
// If the string is utf8 make sure it is not prefixed by no null chars. Null chars in // between can still happen Ok(s) => s.trim_matches('\0').to_owned(),
Can it be problematic? Consider the error message: "Not supporting Cairo 0". It's hex is "4E 6F 74 20 73 75 70 70 6F 72 74 69 6E 67 20 43 61 69 72 6F 20 30", so trimming the last zero can be problematic.
Code quote:
Ok(s) => s.trim_matches('\0').to_owned(),
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 1 of 1 files at r2.
Reviewable status: 4 of 5 files reviewed, 3 unresolved discussions (waiting on @rodrigo-pino)
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: 4 of 5 files reviewed, 3 unresolved discussions (waiting on @meship-starkware, @noaov1, and @rodrigo-pino)
crates/blockifier/src/execution/native/utils.rs
line 27 at r7 (raw file):
Previously, rodrigo-pino (Rodrigo) wrote…
When outputting the final error message, after Cairo Native returned control if there was a failure, the message is contained in a
Vec<Felt>
It's used in the syscall_handler.rs execute_inner_call
to translate the CallEntryPoint.
crates/blockifier/src/execution/native/utils.rs
line 34 at r7 (raw file):
Previously, noaov1 (Noa Oved) wrote…
Can it be problematic? Consider the error message: "Not supporting Cairo 0". It's hex is "4E 6F 74 20 73 75 70 70 6F 72 74 69 6E 67 20 43 61 69 72 6F 20 30", so trimming the last zero can be problematic.
I don't think this will match unicode 0s. I can't reproduce an error with the test string "Not supporting Cairo 0" in "test_encode_decode_str".
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 1 of 4 files at r1.
Reviewable status: 4 of 5 files reviewed, 1 unresolved discussion (waiting on @meship-starkware, @PearsonWhite, and @rodrigo-pino)
crates/blockifier/src/execution/native/utils.rs
line 34 at r7 (raw file):
Previously, PearsonWhite wrote…
I don't think this will match unicode 0s. I can't reproduce an error with the test string "Not supporting Cairo 0" in "test_encode_decode_str".
You are right :)
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 all commit messages.
Reviewable status: 4 of 5 files reviewed, 1 unresolved discussion (waiting on @PearsonWhite and @rodrigo-pino)
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: 4 of 5 files reviewed, 1 unresolved discussion (waiting on @PearsonWhite and @rodrigo-pino)
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 1 of 1 files at r5.
Reviewable status: 4 of 5 files reviewed, all discussions resolved (waiting on @PearsonWhite)
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 1 of 1 files at r7.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @PearsonWhite)
Recration of #1157 targeting Main
This change is