Skip to content

Commit

Permalink
Merge pull request onflow#6491 from m-Peter/dry-run-transaction-with-…
Browse files Browse the repository at this point in the history
…tracing

[Flow EVM] Run tracing hooks `OnTxStart`, `OnTxEnd` for `DryRunTransaction`
  • Loading branch information
j1010001 authored Sep 25, 2024
2 parents a573d77 + ee3c489 commit 66c06c5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions fvm/evm/emulator/emulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ func (bl *BlockView) DryRunTransaction(
// we need to skip nonce check for dry run
msg.SkipAccountChecks = true

// call tracer
if proc.evm.Config.Tracer != nil && proc.evm.Config.Tracer.OnTxStart != nil {
proc.evm.Config.Tracer.OnTxStart(proc.evm.GetVMContext(), tx, msg.From)
}

// return without committing the state
txResult, err = proc.run(msg, tx.Hash(), tx.Type())
if txResult.Successful() {
Expand All @@ -306,6 +311,13 @@ func (bl *BlockView) DryRunTransaction(
txResult.GasConsumed += txResult.GasRefund
}

// call tracer on tx end
if proc.evm.Config.Tracer != nil &&
proc.evm.Config.Tracer.OnTxEnd != nil &&
txResult != nil {
proc.evm.Config.Tracer.OnTxEnd(txResult.Receipt(), txResult.ValidationError)
}

return txResult, err
}

Expand Down

0 comments on commit 66c06c5

Please sign in to comment.