33extern crate alloc;
44
55use codec:: { Decode , Encode } ;
6- #[ cfg( feature = "evm-tracing" ) ]
7- use evm:: Opcode ;
86pub use evm:: { ExitError , ExitReason , ExitSucceed } ;
97use sp_core:: { sp_std:: vec:: Vec , H160 , H256 , U256 } ;
108
@@ -62,7 +60,7 @@ pub enum Capture<E, T> {
6260}
6361
6462/// A type alias representing trap data. Should hold the marshalled `Opcode`.
65- pub type Trap = Vec < u8 > ;
63+ pub type Trap = evm :: Opcode ;
6664
6765/// EVM runtime event.
6866#[ derive( Debug , Clone , Encode , Decode , PartialEq , Eq ) ]
@@ -72,7 +70,7 @@ pub enum RuntimeEvent {
7270 /// Context.
7371 context : Context ,
7472 /// Opcode.
75- opcode : Vec < u8 > ,
73+ opcode : evm :: Opcode ,
7674 /// Position.
7775 position : Result < u64 , ExitReason > ,
7876 /// Stack.
@@ -121,7 +119,7 @@ impl RuntimeEvent {
121119 memory,
122120 } => Self :: Step {
123121 context : context. clone ( ) . into ( ) ,
124- opcode : opcodes_string ( opcode ) ,
122+ opcode,
125123 position : match position {
126124 Ok ( position) => Ok ( * position as u64 ) ,
127125 Err ( e) => Err ( e. clone ( ) ) ,
@@ -145,7 +143,7 @@ impl RuntimeEvent {
145143 Ok ( _) => Ok ( ( ) ) ,
146144 Err ( capture) => match capture {
147145 evm:: Capture :: Exit ( e) => Err ( Capture :: Exit ( e. clone ( ) ) ) ,
148- evm:: Capture :: Trap ( t) => Err ( Capture :: Trap ( opcodes_string ( * t ) ) ) ,
146+ evm:: Capture :: Trap ( t) => Err ( Capture :: Trap ( * t ) ) ,
149147 } ,
150148 } ,
151149 return_value : return_value. to_vec ( ) ,
@@ -171,177 +169,3 @@ impl RuntimeEvent {
171169 }
172170 }
173171}
174-
175- /// Converts an `Opcode` into its name, stored in a `Vec<u8>`.
176- #[ cfg( feature = "evm-tracing" ) ]
177- pub fn opcodes_string ( opcode : Opcode ) -> Vec < u8 > {
178- match opcode_str ( opcode) {
179- Some ( s) => s. into ( ) ,
180- None => alloc:: format!( "Unknown({})" , opcode. 0 ) . into ( ) ,
181- }
182- }
183-
184- /// Converts an `Opcode` into its name.
185- #[ cfg( feature = "evm-tracing" ) ]
186- pub fn opcode_str ( opcode : Opcode ) -> Option < & ' static str > {
187- Some ( match opcode. 0 {
188- 0 => "Stop" ,
189- 1 => "Add" ,
190- 2 => "Mul" ,
191- 3 => "Sub" ,
192- 4 => "Div" ,
193- 5 => "SDiv" ,
194- 6 => "Mod" ,
195- 7 => "SMod" ,
196- 8 => "AddMod" ,
197- 9 => "MulMod" ,
198- 10 => "Exp" ,
199- 11 => "SignExtend" ,
200- 16 => "Lt" ,
201- 17 => "Gt" ,
202- 18 => "Slt" ,
203- 19 => "Sgt" ,
204- 20 => "Eq" ,
205- 21 => "IsZero" ,
206- 22 => "And" ,
207- 23 => "Or" ,
208- 24 => "Xor" ,
209- 25 => "Not" ,
210- 26 => "Byte" ,
211- 27 => "Shl" ,
212- 28 => "Shr" ,
213- 29 => "Sar" ,
214- 32 => "Keccak256" ,
215- 48 => "Address" ,
216- 49 => "Balance" ,
217- 50 => "Origin" ,
218- 51 => "Caller" ,
219- 52 => "CallValue" ,
220- 53 => "CallDataLoad" ,
221- 54 => "CallDataSize" ,
222- 55 => "CallDataCopy" ,
223- 56 => "CodeSize" ,
224- 57 => "CodeCopy" ,
225- 58 => "GasPrice" ,
226- 59 => "ExtCodeSize" ,
227- 60 => "ExtCodeCopy" ,
228- 61 => "ReturnDataSize" ,
229- 62 => "ReturnDataCopy" ,
230- 63 => "ExtCodeHash" ,
231- 64 => "BlockHash" ,
232- 65 => "Coinbase" ,
233- 66 => "Timestamp" ,
234- 67 => "Number" ,
235- 68 => "Difficulty" ,
236- 69 => "GasLimit" ,
237- 70 => "ChainId" ,
238- 80 => "Pop" ,
239- 81 => "MLoad" ,
240- 82 => "MStore" ,
241- 83 => "MStore8" ,
242- 84 => "SLoad" ,
243- 85 => "SStore" ,
244- 86 => "Jump" ,
245- 87 => "JumpI" ,
246- 88 => "GetPc" ,
247- 89 => "MSize" ,
248- 90 => "Gas" ,
249- 91 => "JumpDest" ,
250- 92 => "TLoad" ,
251- 93 => "TStore" ,
252- 94 => "MCopy" ,
253- 96 => "Push1" ,
254- 97 => "Push2" ,
255- 98 => "Push3" ,
256- 99 => "Push4" ,
257- 100 => "Push5" ,
258- 101 => "Push6" ,
259- 102 => "Push7" ,
260- 103 => "Push8" ,
261- 104 => "Push9" ,
262- 105 => "Push10" ,
263- 106 => "Push11" ,
264- 107 => "Push12" ,
265- 108 => "Push13" ,
266- 109 => "Push14" ,
267- 110 => "Push15" ,
268- 111 => "Push16" ,
269- 112 => "Push17" ,
270- 113 => "Push18" ,
271- 114 => "Push19" ,
272- 115 => "Push20" ,
273- 116 => "Push21" ,
274- 117 => "Push22" ,
275- 118 => "Push23" ,
276- 119 => "Push24" ,
277- 120 => "Push25" ,
278- 121 => "Push26" ,
279- 122 => "Push27" ,
280- 123 => "Push28" ,
281- 124 => "Push29" ,
282- 125 => "Push30" ,
283- 126 => "Push31" ,
284- 127 => "Push32" ,
285- 128 => "Dup1" ,
286- 129 => "Dup2" ,
287- 130 => "Dup3" ,
288- 131 => "Dup4" ,
289- 132 => "Dup5" ,
290- 133 => "Dup6" ,
291- 134 => "Dup7" ,
292- 135 => "Dup8" ,
293- 136 => "Dup9" ,
294- 137 => "Dup10" ,
295- 138 => "Dup11" ,
296- 139 => "Dup12" ,
297- 140 => "Dup13" ,
298- 141 => "Dup14" ,
299- 142 => "Dup15" ,
300- 143 => "Dup16" ,
301- 144 => "Swap1" ,
302- 145 => "Swap2" ,
303- 146 => "Swap3" ,
304- 147 => "Swap4" ,
305- 148 => "Swap5" ,
306- 149 => "Swap6" ,
307- 150 => "Swap7" ,
308- 151 => "Swap8" ,
309- 152 => "Swap9" ,
310- 153 => "Swap10" ,
311- 154 => "Swap11" ,
312- 155 => "Swap12" ,
313- 156 => "Swap13" ,
314- 157 => "Swap14" ,
315- 158 => "Swap15" ,
316- 159 => "Swap16" ,
317- 160 => "Log0" ,
318- 161 => "Log1" ,
319- 162 => "Log2" ,
320- 163 => "Log3" ,
321- 164 => "Log4" ,
322- 176 => "JumpTo" ,
323- 177 => "JumpIf" ,
324- 178 => "JumpSub" ,
325- 180 => "JumpSubv" ,
326- 181 => "BeginSub" ,
327- 182 => "BeginData" ,
328- 184 => "ReturnSub" ,
329- 185 => "PutLocal" ,
330- 186 => "GetLocal" ,
331- 225 => "SLoadBytes" ,
332- 226 => "SStoreBytes" ,
333- 227 => "SSize" ,
334- 240 => "Create" ,
335- 241 => "Call" ,
336- 242 => "CallCode" ,
337- 243 => "Return" ,
338- 244 => "DelegateCall" ,
339- 245 => "Create2" ,
340- 250 => "StaticCall" ,
341- 252 => "TxExecGas" ,
342- 253 => "Revert" ,
343- 254 => "Invalid" ,
344- 255 => "SelfDestruct" ,
345- _ => return None ,
346- } )
347- }
0 commit comments