Merge pull request #6918 from filecoin-project/feat/print-runtime-send-update

Log more call context during errors
This commit is contained in:
Steven Allen 2021-07-28 20:47:15 -07:00 committed by GitHub
commit ca76822fde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 4 deletions

View File

@ -6,6 +6,8 @@ import (
"io"
"testing"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/network"
cbor "github.com/ipfs/go-ipld-cbor"
@ -80,6 +82,30 @@ func (basicContract) InvokeSomething10(rt runtime2.Runtime, params *basicParams)
return nil
}
type basicRtMessage struct{}
var _ runtime2.Message = (*basicRtMessage)(nil)
func (*basicRtMessage) Caller() address.Address {
a, err := address.NewIDAddress(0)
if err != nil {
panic(err)
}
return a
}
func (*basicRtMessage) Receiver() address.Address {
a, err := address.NewIDAddress(1)
if err != nil {
panic(err)
}
return a
}
func (*basicRtMessage) ValueReceived() abi.TokenAmount {
return big.NewInt(0)
}
func TestInvokerBasic(t *testing.T) {
inv := ActorRegistry{}
code, err := inv.transform(basicContract{})
@ -89,7 +115,7 @@ func TestInvokerBasic(t *testing.T) {
bParam, err := actors.SerializeParams(&basicParams{B: 1})
assert.NoError(t, err)
_, aerr := code[0](&Runtime{}, bParam)
_, aerr := code[0](&Runtime{Message: &basicRtMessage{}}, bParam)
assert.Equal(t, exitcode.ExitCode(1), aerrors.RetCode(aerr), "return code should be 1")
if aerrors.IsFatal(aerr) {
@ -101,7 +127,7 @@ func TestInvokerBasic(t *testing.T) {
bParam, err := actors.SerializeParams(&basicParams{B: 2})
assert.NoError(t, err)
_, aerr := code[10](&Runtime{}, bParam)
_, aerr := code[10](&Runtime{Message: &basicRtMessage{}}, bParam)
assert.Equal(t, exitcode.ExitCode(12), aerrors.RetCode(aerr), "return code should be 12")
if aerrors.IsFatal(aerr) {
t.Fatal("err should not be fatal")
@ -113,6 +139,7 @@ func TestInvokerBasic(t *testing.T) {
vm: &VM{ntwkVersion: func(ctx context.Context, epoch abi.ChainEpoch) network.Version {
return network.Version0
}},
Message: &basicRtMessage{},
}, []byte{99})
if aerrors.IsFatal(aerr) {
t.Fatal("err should not be fatal")
@ -125,6 +152,7 @@ func TestInvokerBasic(t *testing.T) {
vm: &VM{ntwkVersion: func(ctx context.Context, epoch abi.ChainEpoch) network.Version {
return network.Version7
}},
Message: &basicRtMessage{},
}, []byte{99})
if aerrors.IsFatal(aerr) {
t.Fatal("err should not be fatal")

View File

@ -146,7 +146,7 @@ func (rt *Runtime) shimCall(f func() interface{}) (rval []byte, aerr aerrors.Act
defer func() {
if r := recover(); r != nil {
if ar, ok := r.(aerrors.ActorError); ok {
log.Warnf("VM.Call failure: %+v", ar)
log.Warnf("VM.Call failure in call from: %s to %s: %+v", rt.Caller(), rt.Receiver(), ar)
aerr = ar
return
}
@ -391,7 +391,7 @@ func (rt *Runtime) Send(to address.Address, method abi.MethodNum, m cbor.Marshal
if err.IsFatal() {
panic(err)
}
log.Warnf("vmctx send failed: to: %s, method: %d: ret: %d, err: %s", to, method, ret, err)
log.Warnf("vmctx send failed: from: %s to: %s, method: %d: err: %s", rt.Receiver(), to, method, err)
return err.RetCode()
}
_ = rt.chargeGasSafe(gasOnActorExec)