Add better error messages for message pre-execution errors

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2020-07-21 23:59:15 +02:00
parent 03b2a40e15
commit b3bac0c9e8
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA

View File

@ -347,6 +347,7 @@ func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet,
ExitCode: exitcode.SysErrSenderInvalid, ExitCode: exitcode.SysErrSenderInvalid,
GasUsed: 0, GasUsed: 0,
}, },
ActorErr: aerrors.Newf(exitcode.SysErrSenderInvalid, "actor not found: %s", msg.From),
Penalty: minerPenaltyAmount, Penalty: minerPenaltyAmount,
Duration: time.Since(start), Duration: time.Since(start),
}, nil }, nil
@ -361,6 +362,7 @@ func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet,
ExitCode: exitcode.SysErrSenderInvalid, ExitCode: exitcode.SysErrSenderInvalid,
GasUsed: 0, GasUsed: 0,
}, },
ActorErr: aerrors.Newf(exitcode.SysErrSenderInvalid, "send from not account actor: %s", fromActor.Code),
Penalty: minerPenaltyAmount, Penalty: minerPenaltyAmount,
Duration: time.Since(start), Duration: time.Since(start),
}, nil }, nil
@ -373,6 +375,8 @@ func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet,
ExitCode: exitcode.SysErrSenderStateInvalid, ExitCode: exitcode.SysErrSenderStateInvalid,
GasUsed: 0, GasUsed: 0,
}, },
ActorErr: aerrors.Newf(exitcode.SysErrSenderStateInvalid,
"actor nonce invalid: msg:%d != state:%d", msg.Nonce, fromActor.Nonce),
Penalty: minerPenaltyAmount, Penalty: minerPenaltyAmount,
Duration: time.Since(start), Duration: time.Since(start),
}, nil }, nil
@ -386,6 +390,8 @@ func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet,
ExitCode: exitcode.SysErrSenderStateInvalid, ExitCode: exitcode.SysErrSenderStateInvalid,
GasUsed: 0, GasUsed: 0,
}, },
ActorErr: aerrors.Newf(exitcode.SysErrSenderStateInvalid,
"actor balance less than needed: %s < %s", fromActor.Balance, totalCost),
Penalty: minerPenaltyAmount, Penalty: minerPenaltyAmount,
Duration: time.Since(start), Duration: time.Since(start),
}, nil }, nil