@@ -58,6 +58,7 @@ type jsonLogger struct {
5858 encoder * json.Encoder
5959 cfg * Config
6060 env * tracing.VMContext
61+ hooks * tracing.Hooks
6162}
6263
6364// NewJSONLogger creates a new EVM tracer that prints execution steps as JSON objects
@@ -67,12 +68,14 @@ func NewJSONLogger(cfg *Config, writer io.Writer) *tracing.Hooks {
6768 if l .cfg == nil {
6869 l .cfg = & Config {}
6970 }
70- return & tracing.Hooks {
71- OnTxStart : l .OnTxStart ,
72- OnExit : l .OnExit ,
73- OnOpcode : l .OnOpcode ,
74- OnFault : l .OnFault ,
71+ l .hooks = & tracing.Hooks {
72+ OnTxStart : l .OnTxStart ,
73+ OnSystemCallStart : l .onSystemCallStart ,
74+ OnExit : l .OnEnd ,
75+ OnOpcode : l .OnOpcode ,
76+ OnFault : l .OnFault ,
7577 }
78+ return l .hooks
7679}
7780
7881// NewJSONLoggerWithCallFrames creates a new EVM tracer that prints execution steps as JSON objects
@@ -82,13 +85,15 @@ func NewJSONLoggerWithCallFrames(cfg *Config, writer io.Writer) *tracing.Hooks {
8285 if l .cfg == nil {
8386 l .cfg = & Config {}
8487 }
85- return & tracing.Hooks {
86- OnTxStart : l .OnTxStart ,
87- OnEnter : l .OnEnter ,
88- OnExit : l .OnExit ,
89- OnOpcode : l .OnOpcode ,
90- OnFault : l .OnFault ,
88+ l .hooks = & tracing.Hooks {
89+ OnTxStart : l .OnTxStart ,
90+ OnSystemCallStart : l .onSystemCallStart ,
91+ OnEnter : l .OnEnter ,
92+ OnExit : l .OnExit ,
93+ OnOpcode : l .OnOpcode ,
94+ OnFault : l .OnFault ,
9195 }
96+ return l .hooks
9297}
9398
9499func (l * jsonLogger ) OnFault (pc uint64 , op byte , gas uint64 , cost uint64 , scope tracing.OpContext , depth int , err error ) {
@@ -122,6 +127,16 @@ func (l *jsonLogger) OnOpcode(pc uint64, op byte, gas, cost uint64, scope tracin
122127 l .encoder .Encode (log )
123128}
124129
130+ func (l * jsonLogger ) onSystemCallStart () {
131+ // Process no events while in system call.
132+ hooks := * l .hooks
133+ * l .hooks = tracing.Hooks {
134+ OnSystemCallEnd : func () {
135+ * l .hooks = hooks
136+ },
137+ }
138+ }
139+
125140// OnEnter is not enabled by default.
126141func (l * jsonLogger ) OnEnter (depth int , typ byte , from common.Address , to common.Address , input []byte , gas uint64 , value * big.Int ) {
127142 frame := callFrame {
0 commit comments