-
Notifications
You must be signed in to change notification settings - Fork 57
fix: use correct rollback tails for empty frames without history #158
Changes from 6 commits
19eaada
6335e86
0f7c16d
790515d
7546534
f02d24d
4831b68
1ecbc6c
26a3b79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.text | ||
.file "Test_26" | ||
.rodata.cst32 | ||
.p2align 5 | ||
.text | ||
.globl __entry | ||
__entry: | ||
.main: | ||
add 1000, r0, r3 | ||
near_call r3, @test_invalid, @expected_panic | ||
revert("Near call not panicked") | ||
|
||
test_invalid: | ||
ret.panic r0 | ||
|
||
expected_panic: | ||
; check that we can access storage after panic | ||
log.swrite r0, r0, r0 | ||
ret.ok r0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -552,8 +552,35 @@ pub fn create_artifacts_from_tracer< | |
// wherever we have this marker we should look at the tail of the item right before it | ||
let pos = log_position_mapping[&rollback_tail_marker]; | ||
let tail = if pos == -1 { | ||
// empty | ||
global_end_of_storage_log | ||
if frame_index > 1 { | ||
// empty frame | ||
let pos_forward_head = | ||
log_position_mapping[&ExtendedLogQuery::FrameForwardHeadMarker(frame_index)]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need similar code in zksync-era's oracle? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm not sure that I understand your question: zksync-era calls this code via |
||
let pos_forward_tail = | ||
log_position_mapping[&ExtendedLogQuery::FrameForwardTailMarker(frame_index)]; | ||
let pos_rollback_head = | ||
log_position_mapping[&ExtendedLogQuery::FrameRollbackHeadMarker(frame_index)]; | ||
|
||
if pos_forward_head == -1 && pos_forward_tail == -1 && pos_rollback_head == -1 { | ||
// absolutely empty frame, most likely leaf one, | ||
// but we can not just use global end, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why we cannot use global end? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we can have some state changes after this rollback. But our rollback tail should be equal to the last state change tail before the rollback. Global end was used under assumption that situation without rollback marker can happen only in trivial cases (like entry bytecode without any state changes) |
||
// instead we should use previous frame's data | ||
let pos_previous_frame_forward_tail = log_position_mapping | ||
[&ExtendedLogQuery::FrameForwardTailMarker(frame_index - 1)]; | ||
if pos_previous_frame_forward_tail != -1 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add more explanations, as I couldn't fully understand the code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Idea: since we do not have rollback tail marker, we should try to use forward tail of the parent of this frame. Incorrect assumption: if parent is empty too, than it is "root" frame. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed the code and added more comments |
||
let pointer = pos_previous_frame_forward_tail as usize; | ||
let element = chain_of_states[pointer].2 .0; | ||
0xVolosnikov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
element | ||
} else { | ||
global_end_of_storage_log | ||
} | ||
} else { | ||
global_end_of_storage_log | ||
} | ||
} else { | ||
global_end_of_storage_log | ||
} | ||
} else { | ||
let pointer = pos as usize; | ||
let element = chain_of_states[pointer].2 .1; | ||
|
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.
FYI - this is more than 'adding tests' - please update the PR description
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.
@mm-zk you are right. Even more, proposed changes do not fix corresponding issue. I will rewrite this part of logic