@@ -274,11 +274,10 @@ impl Executor {
274
274
// and also the chainid, which can be set manually
275
275
self . env . cfg . chain_id = res. env . cfg . chain_id ;
276
276
277
- if let Some ( changeset) = & res. state_changeset {
278
- let success = self . is_raw_call_success ( to, Cow :: Borrowed ( changeset) , & res, false ) ;
279
- if !success {
280
- return Err ( res. into_execution_error ( "execution error" . to_string ( ) ) . into ( ) ) ;
281
- }
277
+ let success =
278
+ self . is_raw_call_success ( to, Cow :: Borrowed ( & res. state_changeset ) , & res, false ) ;
279
+ if !success {
280
+ return Err ( res. into_execution_error ( "execution error" . to_string ( ) ) . into ( ) ) ;
282
281
}
283
282
284
283
Ok ( res)
@@ -380,9 +379,7 @@ impl Executor {
380
379
/// This should not be exposed to the user, as it should be called only by `transact*`.
381
380
fn commit ( & mut self , result : & mut RawCallResult ) {
382
381
// Persist changes to db.
383
- if let Some ( changes) = & result. state_changeset {
384
- self . backend . commit ( changes. clone ( ) ) ;
385
- }
382
+ self . backend . commit ( result. state_changeset . clone ( ) ) ;
386
383
387
384
// Persist cheatcode state.
388
385
self . inspector . cheatcodes = result. cheatcodes . take ( ) ;
@@ -411,7 +408,7 @@ impl Executor {
411
408
) -> bool {
412
409
self . is_raw_call_success (
413
410
address,
414
- Cow :: Owned ( call_result . state_changeset . take ( ) . unwrap_or_default ( ) ) ,
411
+ Cow :: Owned ( std :: mem :: take ( & mut call_result . state_changeset ) ) ,
415
412
call_result,
416
413
should_fail,
417
414
)
@@ -667,7 +664,7 @@ pub struct RawCallResult {
667
664
/// Scripted transactions generated from this call
668
665
pub transactions : Option < BroadcastableTransactions > ,
669
666
/// The changeset of the state.
670
- pub state_changeset : Option < StateChangeset > ,
667
+ pub state_changeset : StateChangeset ,
671
668
/// The `revm::Env` after the call
672
669
pub env : EnvWithHandlerCfg ,
673
670
/// The cheatcode states after execution
@@ -694,7 +691,7 @@ impl Default for RawCallResult {
694
691
coverage : None ,
695
692
debug : None ,
696
693
transactions : None ,
697
- state_changeset : None ,
694
+ state_changeset : HashMap :: default ( ) ,
698
695
env : EnvWithHandlerCfg :: new_with_spec_id ( Box :: default ( ) , SpecId :: LATEST ) ,
699
696
cheatcodes : Default :: default ( ) ,
700
697
out : None ,
@@ -778,19 +775,20 @@ impl std::ops::DerefMut for CallResult {
778
775
fn convert_executed_result (
779
776
env : EnvWithHandlerCfg ,
780
777
inspector : InspectorStack ,
781
- result : ResultAndState ,
778
+ ResultAndState { result, state : state_changeset } : ResultAndState ,
782
779
has_snapshot_failure : bool ,
783
780
) -> eyre:: Result < RawCallResult > {
784
- let ResultAndState { result : exec_result, state : state_changeset } = result;
785
- let ( exit_reason, gas_refunded, gas_used, out) = match exec_result {
786
- ExecutionResult :: Success { reason, gas_used, gas_refunded, output, .. } => {
787
- ( reason. into ( ) , gas_refunded, gas_used, Some ( output) )
781
+ let ( exit_reason, gas_refunded, gas_used, out, exec_logs) = match result {
782
+ ExecutionResult :: Success { reason, gas_used, gas_refunded, output, logs, .. } => {
783
+ ( reason. into ( ) , gas_refunded, gas_used, Some ( output) , logs)
788
784
}
789
785
ExecutionResult :: Revert { gas_used, output } => {
790
786
// Need to fetch the unused gas
791
- ( InstructionResult :: Revert , 0_u64 , gas_used, Some ( Output :: Call ( output) ) )
787
+ ( InstructionResult :: Revert , 0_u64 , gas_used, Some ( Output :: Call ( output) ) , vec ! [ ] )
788
+ }
789
+ ExecutionResult :: Halt { reason, gas_used } => {
790
+ ( reason. into ( ) , 0_u64 , gas_used, None , vec ! [ ] )
792
791
}
793
- ExecutionResult :: Halt { reason, gas_used } => ( reason. into ( ) , 0_u64 , gas_used, None ) ,
794
792
} ;
795
793
let stipend = revm:: interpreter:: gas:: validate_initial_tx_gas (
796
794
env. spec_id ( ) ,
@@ -804,15 +802,17 @@ fn convert_executed_result(
804
802
_ => Bytes :: new ( ) ,
805
803
} ;
806
804
807
- let InspectorData { logs, labels, traces, coverage, debug, cheatcodes, chisel_state } =
805
+ let InspectorData { mut logs, labels, traces, coverage, debug, cheatcodes, chisel_state } =
808
806
inspector. collect ( ) ;
809
807
810
- let transactions = match cheatcodes. as_ref ( ) {
811
- Some ( cheats) if !cheats. broadcastable_transactions . is_empty ( ) => {
812
- Some ( cheats. broadcastable_transactions . clone ( ) )
813
- }
814
- _ => None ,
815
- } ;
808
+ if logs. is_empty ( ) {
809
+ logs = exec_logs;
810
+ }
811
+
812
+ let transactions = cheatcodes
813
+ . as_ref ( )
814
+ . map ( |c| c. broadcastable_transactions . clone ( ) )
815
+ . filter ( |txs| !txs. is_empty ( ) ) ;
816
816
817
817
Ok ( RawCallResult {
818
818
exit_reason,
@@ -828,7 +828,7 @@ fn convert_executed_result(
828
828
coverage,
829
829
debug,
830
830
transactions,
831
- state_changeset : Some ( state_changeset ) ,
831
+ state_changeset,
832
832
env,
833
833
cheatcodes,
834
834
out,
0 commit comments