Skip to content

Commit

Permalink
Fix for possible panic. (#4627)
Browse files Browse the repository at this point in the history
  • Loading branch information
Frozen authored Feb 13, 2024
1 parent 313daea commit d5956ce
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,17 @@ func ApplyTransaction(bc ChainContext, author *common.Address, gp *GasPool, stat
// Apply the transaction to the current state (included in the env)
result, err := ApplyMessage(vmenv, msg, gp)
if err != nil {
return nil, nil, nil, 0, errors.Wrapf(err, "apply failed from='%s' to='%s' balance='%s'", msg.From().Hex(), msg.To().Hex(), statedb.GetBalance(msg.From()).String())
if err != nil {
to := ""
if m := msg.To(); m != nil {
to = m.Hex()
}
balance := ""
if a := statedb.GetBalance(msg.From()); a != nil {
balance = a.String()
}
return nil, nil, nil, 0, errors.Wrapf(err, "apply failed from='%s' to='%s' balance='%s'", msg.From().Hex(), to, balance)
}
}
// Update the state with pending changes
var root []byte
Expand Down

0 comments on commit d5956ce

Please sign in to comment.