From d5956cee90c7487ab909e43802f0d74737d3e301 Mon Sep 17 00:00:00 2001 From: Konstantin <355847+Frozen@users.noreply.github.com> Date: Tue, 13 Feb 2024 04:21:30 -0400 Subject: [PATCH] Fix for possible panic. (#4627) --- core/state_processor.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/state_processor.go b/core/state_processor.go index 6ea9e244a..2141fe0cf 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -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