File tree Expand file tree Collapse file tree 4 files changed +42
-11
lines changed Expand file tree Collapse file tree 4 files changed +42
-11
lines changed Original file line number Diff line number Diff line change 1
1
use crate :: { Evm , EvmEnv } ;
2
2
use alloy_primitives:: { Address , Bytes } ;
3
- use revm:: context:: { either, BlockEnv } ;
3
+ use revm:: context:: { either, result :: ResultAndState , BlockEnv } ;
4
4
5
5
impl < L , R > Evm for either:: Either < L , R >
6
6
where
45
45
either:: for_both!( self , evm => evm. transact( tx) )
46
46
}
47
47
48
+ fn inspect_system_call (
49
+ & mut self ,
50
+ caller : Address ,
51
+ contract : Address ,
52
+ data : Bytes ,
53
+ ) -> Result < ResultAndState < Self :: HaltReason > , Self :: Error > {
54
+ either:: for_both!( self , evm => evm. inspect_system_call( caller, contract, data) )
55
+ }
56
+
48
57
fn transact_system_call (
49
58
& mut self ,
50
59
caller : Address ,
Original file line number Diff line number Diff line change @@ -137,17 +137,22 @@ where
137
137
}
138
138
}
139
139
140
+ fn inspect_system_call (
141
+ & mut self ,
142
+ caller : Address ,
143
+ contract : Address ,
144
+ data : Bytes ,
145
+ ) -> Result < ResultAndState < Self :: HaltReason > , Self :: Error > {
146
+ self . inner . inspect_system_call_with_caller ( caller, contract, data)
147
+ }
148
+
140
149
fn transact_system_call (
141
150
& mut self ,
142
151
caller : Address ,
143
152
contract : Address ,
144
153
data : Bytes ,
145
154
) -> Result < ResultAndState < Self :: HaltReason > , Self :: Error > {
146
- if self . inspect {
147
- self . inner . inspect_system_call_with_caller ( caller, contract, data)
148
- } else {
149
- self . inner . system_call_with_caller ( caller, contract, data)
150
- }
155
+ self . inner . system_call_with_caller ( caller, contract, data)
151
156
}
152
157
153
158
fn finish ( self ) -> ( Self :: DB , EvmEnv < Self :: Spec > ) {
Original file line number Diff line number Diff line change @@ -88,6 +88,18 @@ pub trait Evm {
88
88
self . transact_raw ( tx. into_tx_env ( ) )
89
89
}
90
90
91
+ /// Inspects a system call without committing state changes.
92
+ ///
93
+ /// This method executes a system call with inspection enabled, allowing observation of the
94
+ /// execution without modifying the underlying state. Similar to [`Evm::transact_system_call`]
95
+ /// but returns the result with state changes that can be examined or discarded.
96
+ fn inspect_system_call (
97
+ & mut self ,
98
+ caller : Address ,
99
+ contract : Address ,
100
+ data : Bytes ,
101
+ ) -> Result < ResultAndState < Self :: HaltReason > , Self :: Error > ;
102
+
91
103
/// Executes a system call.
92
104
///
93
105
/// Note: this will only keep the target `contract` in the state. This is done because revm is
Original file line number Diff line number Diff line change @@ -116,17 +116,22 @@ where
116
116
}
117
117
}
118
118
119
+ fn inspect_system_call (
120
+ & mut self ,
121
+ caller : Address ,
122
+ contract : Address ,
123
+ data : Bytes ,
124
+ ) -> Result < ResultAndState < Self :: HaltReason > , Self :: Error > {
125
+ self . inner . inspect_system_call_with_caller ( caller, contract, data)
126
+ }
127
+
119
128
fn transact_system_call (
120
129
& mut self ,
121
130
caller : Address ,
122
131
contract : Address ,
123
132
data : Bytes ,
124
133
) -> Result < ResultAndState < Self :: HaltReason > , Self :: Error > {
125
- if self . inspect {
126
- self . inner . inspect_system_call_with_caller ( caller, contract, data)
127
- } else {
128
- self . inner . system_call_with_caller ( caller, contract, data)
129
- }
134
+ self . inner . system_call_with_caller ( caller, contract, data)
130
135
}
131
136
132
137
fn finish ( self ) -> ( Self :: DB , EvmEnv < Self :: Spec > ) {
You can’t perform that action at this time.
0 commit comments