Add REVERT result to trace (#4434)

* Add REVERT result to trace

* topTrace error should be changed too
This commit is contained in:
iFA 2022-06-11 13:05:26 +02:00 committed by GitHub
parent 3f1e9948fa
commit 41c0a47485
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -365,26 +365,31 @@ func (ot *OeTracer) CaptureEnd(depth int, output []byte, startGas, endGas uint64
ignoreError = depth == 0 && topTrace.Type == CREATE
}
if err != nil && !ignoreError {
switch err {
case vm.ErrInvalidJump:
topTrace.Error = "Bad jump destination"
case vm.ErrContractAddressCollision, vm.ErrCodeStoreOutOfGas, vm.ErrOutOfGas, vm.ErrGasUintOverflow:
topTrace.Error = "Out of gas"
case vm.ErrExecutionReverted:
if err == vm.ErrExecutionReverted {
topTrace.Error = "Reverted"
case vm.ErrWriteProtection:
topTrace.Error = "Mutable Call In Static Context"
default:
switch err.(type) {
case *vm.ErrStackUnderflow:
topTrace.Error = "Stack underflow"
case *vm.ErrInvalidOpCode:
topTrace.Error = "Bad instruction"
topTrace.Result.(*TraceResult).GasUsed = new(hexutil.Big)
topTrace.Result.(*TraceResult).GasUsed.ToInt().SetUint64(startGas - endGas)
topTrace.Result.(*TraceResult).Output = common.CopyBytes(output)
} else {
topTrace.Result = nil
switch err {
case vm.ErrInvalidJump:
topTrace.Error = "Bad jump destination"
case vm.ErrContractAddressCollision, vm.ErrCodeStoreOutOfGas, vm.ErrOutOfGas, vm.ErrGasUintOverflow:
topTrace.Error = "Out of gas"
case vm.ErrWriteProtection:
topTrace.Error = "Mutable Call In Static Context"
default:
topTrace.Error = err.Error()
switch err.(type) {
case *vm.ErrStackUnderflow:
topTrace.Error = "Stack underflow"
case *vm.ErrInvalidOpCode:
topTrace.Error = "Bad instruction"
default:
topTrace.Error = err.Error()
}
}
}
topTrace.Result = nil
} else {
if len(output) > 0 {
switch topTrace.Type {