From 5cc40e667180ff05baf09016955589ce5aa0bd0f Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 25 Aug 2023 14:28:16 +0200 Subject: [PATCH 1/3] Fix single broadcast --- .../src/executor/inspector/cheatcodes/mod.rs | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/crates/evm/src/executor/inspector/cheatcodes/mod.rs b/crates/evm/src/executor/inspector/cheatcodes/mod.rs index cd2c84808b5c..1324c0e74f77 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mod.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mod.rs @@ -758,9 +758,10 @@ impl Inspector 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); + + if prank.single_call { + std::mem::take(&mut self.prank); + } } } @@ -768,10 +769,10 @@ impl Inspector for Cheatcodes { 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); + if broadcast.single_call { + std::mem::take(&mut self.broadcast); + } } } @@ -1043,9 +1044,10 @@ impl Inspector 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); + + if prank.single_call { + std::mem::take(&mut self.prank); + } } } @@ -1053,10 +1055,10 @@ impl Inspector for Cheatcodes { 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); + if broadcast.single_call { + std::mem::take(&mut self.broadcast); + } } } From 08ba89462f73e28d0f5c9094a1dc86064f3fd05a Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 25 Aug 2023 20:50:43 +0200 Subject: [PATCH 2/3] Add comments --- crates/evm/src/executor/inspector/cheatcodes/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/evm/src/executor/inspector/cheatcodes/mod.rs b/crates/evm/src/executor/inspector/cheatcodes/mod.rs index 1324c0e74f77..5787d46f2645 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mod.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mod.rs @@ -758,7 +758,8 @@ impl Inspector 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); - + + // Clean single-call prank once we have returned to the original depth if prank.single_call { std::mem::take(&mut self.prank); } @@ -770,6 +771,7 @@ impl Inspector for Cheatcodes { if data.journaled_state.depth() == broadcast.depth { data.env.tx.caller = h160_to_b160(broadcast.original_origin); + // Clean single-call broadcast once we have returned to the original depth if broadcast.single_call { std::mem::take(&mut self.broadcast); } @@ -1045,6 +1047,7 @@ impl Inspector for Cheatcodes { if data.journaled_state.depth() == prank.depth { data.env.tx.caller = h160_to_b160(prank.prank_origin); + // Clean single-call prank once we have returned to the original depth if prank.single_call { std::mem::take(&mut self.prank); } @@ -1055,7 +1058,8 @@ impl Inspector for Cheatcodes { if let Some(broadcast) = &self.broadcast { if data.journaled_state.depth() == broadcast.depth { data.env.tx.caller = h160_to_b160(broadcast.original_origin); - + + // Clean single-call broadcast once we have returned to the original depth if broadcast.single_call { std::mem::take(&mut self.broadcast); } From 02b35b1c01efae8e7d9439bb33932242dccfe648 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 25 Aug 2023 21:01:40 +0200 Subject: [PATCH 3/3] rustfmt --- crates/evm/src/executor/inspector/cheatcodes/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/evm/src/executor/inspector/cheatcodes/mod.rs b/crates/evm/src/executor/inspector/cheatcodes/mod.rs index 5787d46f2645..ebd4d9c0b310 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/mod.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/mod.rs @@ -758,7 +758,7 @@ impl Inspector 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); - + // Clean single-call prank once we have returned to the original depth if prank.single_call { std::mem::take(&mut self.prank); @@ -1058,7 +1058,7 @@ impl Inspector for Cheatcodes { if let Some(broadcast) = &self.broadcast { if data.journaled_state.depth() == broadcast.depth { data.env.tx.caller = h160_to_b160(broadcast.original_origin); - + // Clean single-call broadcast once we have returned to the original depth if broadcast.single_call { std::mem::take(&mut self.broadcast);