@@ -9,42 +9,29 @@ use tracing::debug;
99
1010use crate :: { core:: analyze:: AnalyzerState , interfaces:: AnalyzedFunction , Error } ;
1111
12- use lazy_static:: lazy_static;
13-
14- lazy_static ! {
15- /// A list of opcodes that are considered non-pure (state accessing)
16- pub static ref NON_PURE_OPCODES : Vec <u8 > = vec![
17- 0x31 , 0x32 , 0x33 , 0x3a , 0x3b , 0x3c , 0x40 , 0x41 , 0x42 ,
18- 0x43 , 0x44 , 0x45 , 0x46 , 0x47 , 0x48 , 0x54 , 0x55 , 0xf0 ,
19- 0xf1 , 0xf2 , 0xf4 , 0xf5 , 0xfa , 0xff
20- ] ;
21- /// A list of opcodes that are considered non-view (state modifying)
22- pub static ref NON_VIEW_OPCODES : Vec <u8 > = vec![
23- 0x55 , 0xf0 , 0xf1 , 0xf2 , 0xf4 , 0xf5 , 0xfa , 0xff
24- ] ;
25- }
26-
2712pub fn modifier_heuristic (
2813 function : & mut AnalyzedFunction ,
2914 state : & State ,
3015 _: & mut AnalyzerState ,
3116) -> Result < ( ) , Error > {
32- let opcode_name = OpCodeInfo :: from ( state. last_instruction . opcode ) . name ( ) ;
17+ let opcode_info = OpCodeInfo :: from ( state. last_instruction . opcode ) ;
3318
3419 // if any instruction is non-pure, the function is non-pure
35- if function. pure && NON_PURE_OPCODES . contains ( & state . last_instruction . opcode ) {
20+ if function. pure && !opcode_info . is_pure ( ) {
3621 debug ! (
3722 "instruction {} ({}) indicates a non-pure function" ,
38- state. last_instruction. instruction, opcode_name
23+ state. last_instruction. instruction,
24+ opcode_info. name( )
3925 ) ;
4026 function. pure = false ;
4127 }
4228
4329 // if any instruction is non-view, the function is non-view
44- if function. view && NON_VIEW_OPCODES . contains ( & state . last_instruction . opcode ) {
30+ if function. view && !opcode_info . is_view ( ) {
4531 debug ! (
4632 "instruction {} ({}) indicates a non-view function" ,
47- state. last_instruction. instruction, opcode_name
33+ state. last_instruction. instruction,
34+ opcode_info. name( )
4835 ) ;
4936 function. view = false ;
5037 }
0 commit comments