Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Flow EVM] Trigger OnLog tracer hooks upon successful call & tx results #6860

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading