Skip to content

Commit

Permalink
Trigger OnLog tracer hooks upon successful call & tx results
Browse files Browse the repository at this point in the history
  • Loading branch information
m-Peter committed Jan 9, 2025
1 parent 47f24e9 commit ae7f1c7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions fvm/evm/emulator/emulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ func (bl *BlockView) DirectCall(call *types.DirectCall) (res *types.Result, err
err == nil && res != nil {
proc.evm.Config.Tracer.OnTxEnd(res.Receipt(), res.ValidationError)
}

// call OnLog tracer hook, upon successful call result
if proc.evm.Config.Tracer.OnLog != nil &&
err == nil && res != nil {
for _, log := range res.Logs {
proc.evm.Config.Tracer.OnLog(log)
}
}
}()
}

Expand Down Expand Up @@ -191,6 +199,15 @@ func (bl *BlockView) RunTransaction(
proc.evm.Config.Tracer.OnTxEnd(res.Receipt(), res.ValidationError)
}

// call OnLog tracer hook, upon successful tx result
if proc.evm.Config.Tracer != nil &&
proc.evm.Config.Tracer.OnLog != nil &&
res != nil {
for _, log := range res.Logs {
proc.evm.Config.Tracer.OnLog(log)
}
}

return res, nil
}

Expand Down Expand Up @@ -243,6 +260,15 @@ func (bl *BlockView) BatchRunTransactions(txs []*gethTypes.Transaction) ([]*type
res != nil {
proc.evm.Config.Tracer.OnTxEnd(res.Receipt(), res.ValidationError)
}

// call OnLog tracer hook, upon successful tx result
if proc.evm.Config.Tracer != nil &&
proc.evm.Config.Tracer.OnLog != nil &&
res != nil {
for _, log := range res.Logs {
proc.evm.Config.Tracer.OnLog(log)
}
}
}

// finalize after all the batch transactions are executed to save resources
Expand Down

0 comments on commit ae7f1c7

Please sign in to comment.