Skip to content

Commit

Permalink
Merge pull request #6261 from onflow/ramtin/evm-patch-the-nil-reference
Browse files Browse the repository at this point in the history
[Flow EVM] fix the issue with the new Geth tracing
  • Loading branch information
ramtinms authored Jul 25, 2024
2 parents 608d9f5 + d27b2d0 commit b92e8e2
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions fvm/evm/emulator/emulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,16 @@ func (bl *BlockView) DirectCall(call *types.DirectCall) (res *types.Result, err
// Call tx tracer
if proc.evm.Config.Tracer != nil && proc.evm.Config.Tracer.OnTxStart != nil {
proc.evm.Config.Tracer.OnTxStart(proc.evm.GetVMContext(), call.Transaction(), call.From.ToCommon())
if proc.evm.Config.Tracer.OnTxEnd != nil {
defer func() {
proc.evm.Config.Tracer.OnTxEnd(res.Receipt(), err)
}()
}
defer func() {
if proc.evm.Config.Tracer.OnTxEnd != nil {
receipt := &gethTypes.Receipt{}
if res != nil {
receipt = res.Receipt()
}
proc.evm.Config.Tracer.OnTxEnd(receipt, err)
}
}()

}

// re-route based on the sub type
Expand Down Expand Up @@ -168,11 +173,16 @@ func (bl *BlockView) RunTransaction(
// 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)
if proc.evm.Config.Tracer.OnTxEnd != nil {
defer func() {
proc.evm.Config.Tracer.OnTxEnd(result.Receipt(), err)
}()
}
defer func() {
if proc.evm.Config.Tracer.OnTxEnd != nil {
receipt := &gethTypes.Receipt{}
if result != nil {
receipt = result.Receipt()
}
proc.evm.Config.Tracer.OnTxEnd(receipt, err)
}
}()

}

// run msg
Expand Down Expand Up @@ -211,14 +221,19 @@ func (bl *BlockView) BatchRunTransactions(txs []*gethTypes.Transaction) ([]*type
// 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)
if proc.evm.Config.Tracer.OnTxEnd != nil {
defer func() {
defer func() {
if proc.evm.Config.Tracer.OnTxEnd != nil {
receipt := &gethTypes.Receipt{}
if batchResults[i] != nil {
receipt = batchResults[i].Receipt()
}
proc.evm.Config.Tracer.OnTxEnd(
batchResults[i].Receipt(),
receipt,
err,
)
}()
}
}
}()

}

// run msg
Expand Down

0 comments on commit b92e8e2

Please sign in to comment.