Commit 21b28e61 authored by hezhengjun's avatar hezhengjun

make evm error info prettier

parent b88d528a
......@@ -300,6 +300,7 @@ ForkEVMFrozen=0
ForkEVMKVHash=0
ForkEVMYoloV1=0
ForkEVMTxGroup=0
ForkEVMRevertErrFormat=0
[fork.sub.blackwhite]
Enable=0
......
......@@ -116,7 +116,20 @@ func (evm *EVMExecutor) innerExec(msg *common.Message, txHash []byte, index int,
curVer := evm.mStateDB.GetLastSnapshot()
if vmerr != nil {
log.Error("evm contract exec error", "error info", vmerr, "ret", string(ret))
vmerr = errors.New(fmt.Sprintf("%s,detail: %s", vmerr.Error(), string(ret)))
if cfg.IsDappFork(evm.GetHeight(), "evm", evmtypes.ForkEVMRevertErrFormat) {
var visiableOut []byte
for i := 0; i < len(ret); i++ {
//显示[32,126]之间的字符
if ret[i] < 32 || ret[i] > 126 {
continue
}
visiableOut = append(visiableOut, ret[i])
}
vmerr = errors.New(fmt.Sprintf("%s,detail: %s", vmerr.Error(), string(visiableOut)))
} else {
vmerr = errors.New(fmt.Sprintf("%s,detail: %s", vmerr.Error(), string(ret)))
}
return receipt, vmerr
}
......
......@@ -46,6 +46,8 @@ const (
ForkEVMYoloV1 = "ForkEVMYoloV1"
//ForkEVMTxGroup 交易组中的交易通过GAS检查
ForkEVMTxGroup = "ForkEVMTxGroup"
//ForkEVMRevertErrFormat 执行失败错误信息格式
ForkEVMRevertErrFormat = "ForkEVMRevertErrFormat"
)
var (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment