@@ -28,20 +28,20 @@ var (
28
28
allowedDepth = float64 (1 )
29
29
30
30
// The gas opcode is only allowed if followed immediately by callOpcodes.
31
- // gasOpCode = "GAS"
31
+ gasOpCode = "GAS"
32
32
33
33
// Only one create2 opcode is allowed if these two conditions are met:
34
34
// 1. op.initcode.length != 0
35
35
// 2. During account simulation (i.e. before markerOpCode)
36
36
// create2OpCode = "CREATE2"
37
37
38
38
// List of opcodes related to CALL.
39
- // callOpcodes = mapset.NewSet(
40
- // "CALL",
41
- // "DELEGATECALL",
42
- // "CALLCODE",
43
- // "STATICCALL",
44
- // )
39
+ callOpcodes = mapset .NewSet (
40
+ "CALL" ,
41
+ "DELEGATECALL" ,
42
+ "CALLCODE" ,
43
+ "STATICCALL" ,
44
+ )
45
45
46
46
// List of opcodes not allowed during simulation for depth > allowedDepth (i.e. account, paymaster, or
47
47
// contracts called by them).
@@ -147,19 +147,25 @@ func TraceSimulateValidation(rpc *rpc.Client, entryPoint common.Address, op *use
147
147
return err
148
148
}
149
149
150
+ var prev structLog
150
151
simFor := "account"
151
152
for _ , sl := range res .StructLogs {
152
- if sl .Depth == allowedDepth && sl .Op == markerOpCode {
153
- simFor = "paymaster"
154
- }
155
-
156
153
if sl .Depth == allowedDepth {
154
+ if sl .Op == markerOpCode {
155
+ simFor = "paymaster"
156
+ }
157
157
continue
158
158
}
159
159
160
+ if prev .Op == gasOpCode && ! callOpcodes .Contains (sl .Op ) {
161
+ return fmt .Errorf ("%s: uses opcode %s incorrectly" , simFor , gasOpCode )
162
+ }
163
+
160
164
if baseForbiddenOpCodes .Contains (sl .Op ) {
161
165
return fmt .Errorf ("%s: uses forbidden opcode %s" , simFor , sl .Op )
162
166
}
167
+
168
+ prev = sl
163
169
}
164
170
165
171
return nil
0 commit comments