Skip to content
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

Fix single broadcast/prank nonce setting #5727

Merged
merged 4 commits into from
Aug 29, 2023
Merged
Changes from all commits
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
30 changes: 18 additions & 12 deletions crates/evm/src/executor/inspector/cheatcodes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,20 +758,23 @@ impl<DB: DatabaseExt> Inspector<DB> for Cheatcodes {
if let Some(prank) = &self.prank {
if data.journaled_state.depth() == prank.depth {
data.env.tx.caller = h160_to_b160(prank.prank_origin);
}
if prank.single_call {
std::mem::take(&mut self.prank);

// Clean single-call prank once we have returned to the original depth
if prank.single_call {
std::mem::take(&mut self.prank);
}
}
}

// Clean up broadcast
if let Some(broadcast) = &self.broadcast {
if data.journaled_state.depth() == broadcast.depth {
data.env.tx.caller = h160_to_b160(broadcast.original_origin);
}

if broadcast.single_call {
std::mem::take(&mut self.broadcast);
// Clean single-call broadcast once we have returned to the original depth
if broadcast.single_call {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto here and the others

std::mem::take(&mut self.broadcast);
}
}
}

Expand Down Expand Up @@ -1043,20 +1046,23 @@ impl<DB: DatabaseExt> Inspector<DB> for Cheatcodes {
if let Some(prank) = &self.prank {
if data.journaled_state.depth() == prank.depth {
data.env.tx.caller = h160_to_b160(prank.prank_origin);
}
if prank.single_call {
std::mem::take(&mut self.prank);

// Clean single-call prank once we have returned to the original depth
if prank.single_call {
std::mem::take(&mut self.prank);
}
}
}

// Clean up broadcasts
if let Some(broadcast) = &self.broadcast {
if data.journaled_state.depth() == broadcast.depth {
data.env.tx.caller = h160_to_b160(broadcast.original_origin);
}

if broadcast.single_call {
std::mem::take(&mut self.broadcast);
// Clean single-call broadcast once we have returned to the original depth
if broadcast.single_call {
std::mem::take(&mut self.broadcast);
}
}
}

Expand Down