Skip to content

fix: addresses issue with state diff recording idx #1074

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

Merged
merged 4 commits into from
Jun 18, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions crates/strategy/zksync/src/cheatcode/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ impl ZksyncCheatcodeInspectorStrategyRunner {
// If we have a pending stack, it will be appended to the end of primary stack, else at
// the beginning, once the record is finalized.
let stack_insert_index = if recorded_account_diffs_stack.len() > 1 {
recorded_account_diffs_stack.first().map_or(0, Vec::len)
recorded_account_diffs_stack
.get(recorded_account_diffs_stack.len() - 2)
.map_or(0, Vec::len)
} else {
0
};
Expand Down Expand Up @@ -932,10 +934,14 @@ impl CheatcodeInspectorStrategyExt for ZksyncCheatcodeInspectorStrategyRunner {
if let Some(index) = ctx.remove_recorded_access_at.take() {
if let Some(recorded_account_diffs_stack) = state.recorded_account_diffs_stack.as_mut()
{
if let Some(last) = recorded_account_diffs_stack.first_mut() {
if let Some(last) = recorded_account_diffs_stack.last_mut() {
// This entry has been inserted during CREATE/CALL operations in revm's
// cheatcode inspector and must be removed.
let _ = last.remove(index);
if index < last.len() {
let _ = last.remove(index);
} else {
warn!(target: "zksync", index, len = last.len(), "skipping duplicate access removal: out of bounds");
}
}
}
}
Expand Down