-
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): limit characters in cairo1 revert trace #1468
feat(blockifier): limit characters in cairo1 revert trace #1468
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1468 +/- ##
===========================================
+ Coverage 40.10% 67.35% +27.24%
===========================================
Files 26 103 +77
Lines 1895 13800 +11905
Branches 1895 13800 +11905
===========================================
+ Hits 760 9295 +8535
- Misses 1100 4104 +3004
- Partials 35 401 +366 ☔ View full report in Codecov by Sentry. |
925040d
to
99eea64
Compare
c12f6ca
to
2a6741b
Compare
99eea64
to
a94d27b
Compare
2a6741b
to
c126f53
Compare
a94d27b
to
cb1ae57
Compare
c126f53
to
bfef88e
Compare
cb1ae57
to
276265c
Compare
bfef88e
to
586d8e8
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 1 of 1 files at r1, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @ilyalesokhin-starkware)
276265c
to
da3be39
Compare
586d8e8
to
b1a7928
Compare
da3be39
to
a5bacb8
Compare
b1a7928
to
d050f37
Compare
a5bacb8
to
9869960
Compare
d050f37
to
368e075
Compare
c0023dc
to
1ef3528
Compare
55a8ac2
to
63ce81a
Compare
63ce81a
to
4aa867b
Compare
Artifacts upload triggered. View details here |
Artifacts upload triggered. View details here |
Artifacts upload triggered. View details here |
Artifacts upload triggered. View details here |
Artifacts upload triggered. View details here |
4aa867b
to
054bd31
Compare
Artifacts upload triggered. View details here |
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: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @dorimedini-starkware, @ilyalesokhin-starkware, and @Yoni-Starkware)
crates/blockifier/src/execution/stack_trace.rs
line 278 at r4 (raw file):
.chars() .take(TRACE_LENGTH_CAP) .collect::<String>()
I really don't like the fact that we need this logic to support an edge-case character limitation...
a frame is 264 characters, so 56 frames fit in the cap bound, not including the innermost retdata which should be short (unless there are use cases for many felts in the failure reason?)...
@ilyalesokhin-starkware if it's worth the extra code, do you have any ideas for improvements / helpful assumptions that will simplify the logic?
Code quote:
// Total string length is limited by TRACE_LENGTH_CAP.
// Prioritize the failure reason felts over the frames.
// If the failure reason is too long to include a minimal frame trace, display only the
// failure reason (truncated if necessary).
let failure_reason = format_panic_data(&self.last_retdata.0);
if failure_reason.len() >= TRACE_LENGTH_CAP - *MIN_CAIRO1_FRAMES_STACK_LENGTH {
let output = if failure_reason.len() <= TRACE_LENGTH_CAP {
failure_reason
} else {
failure_reason
.chars()
.take(TRACE_LENGTH_CAP - Self::TRUNCATION_SEPARATOR.len())
.collect::<String>()
+ &format!("{}", Self::TRUNCATION_SEPARATOR)
};
return write!(f, "{}", output);
}
let untruncated_string = self
.stack
.iter()
.map(|frame| frame.to_string())
.chain([failure_reason.clone()])
.join("\n");
if untruncated_string.len() <= TRACE_LENGTH_CAP {
return write!(f, "{}", untruncated_string);
}
// If the number of frames is too large, drop frames above the last frame (two frames are
// not too many, as checked above with MIN_CAIRO1_FRAMES_STACK_LENGTH).
let n_frames_to_drop = (untruncated_string.len() - TRACE_LENGTH_CAP
+ Self::TRUNCATION_SEPARATOR.len())
.div_ceil(*MIN_CAIRO1_FRAME_LENGTH);
// Expect the number of frames to be at least the number of frames to drop + 2. If not,
// fall back to the failure reason.
if self.stack.len() < n_frames_to_drop + 2 {
return write!(f, "{}", failure_reason);
}
write!(
f,
"{}",
self.stack[..self.stack.len() - n_frames_to_drop - 1]
.iter()
.map(|frame| frame.to_string())
.chain([
String::from(Self::TRUNCATION_SEPARATOR),
self.stack
.last()
.expect("Stack has at least two frames at this point.")
.to_string(),
failure_reason,
])
.join("\n")
// Truncate again as a failsafe.
.chars()
.take(TRACE_LENGTH_CAP)
.collect::<String>()
054bd31
to
9f232fc
Compare
Artifacts upload triggered. View details here |
9f232fc
to
77832c9
Compare
Artifacts upload triggered. View details here |
I'd rather not use expect her. |
Previously, dorimedini-starkware wrote…
I guess I didn't think it was going to be that complicated. but if you already wrote it lets keep 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.
Reviewed 1 of 1 files at r5.
Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @dorimedini-starkware)
77832c9
to
c0953ac
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: 0 of 2 files reviewed, all discussions resolved (waiting on @dorimedini-starkware and @ilyalesokhin-starkware)
crates/blockifier/src/execution/stack_trace.rs
line 278 at r4 (raw file):
Previously, ilyalesokhin-starkware wrote…
.expect("Stack has at least two frames at this point.")
I'd rather not use expect her.
done
Artifacts upload triggered. View details here |
Is putting the actual string here bad? as it is written the length is the only thing being tested. Code quote: format!("{}", extract_trailing_cairo1_revert_trace(&next_call_info)).len()
<= TRACE_LENGTH_CAP |
c0953ac
to
44f85b6
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: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @dorimedini-starkware and @ilyalesokhin-starkware)
crates/blockifier/src/execution/stack_trace_test.rs
line 851 at r6 (raw file):
Previously, ilyalesokhin-starkware wrote…
Is putting the actual string here bad?
as it is written the length is the only thing being tested.
Done.
Artifacts upload triggered. View details here |
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 2 files at r4, 2 of 2 files at r7, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @dorimedini-starkware)
No description provided.