Merge pull request #2711 from filecoin-project/feat/allow-send-to-fail
Allow messages with not enough funds for transfer to apply
This commit is contained in:
commit
c762770031
@ -320,7 +320,7 @@ workflows:
|
||||
ci:
|
||||
jobs:
|
||||
- lint-changes:
|
||||
args: "--new-from-rev origin/master"
|
||||
args: "--new-from-rev origin/next"
|
||||
- mod-tidy-check
|
||||
- gofmt
|
||||
- test:
|
||||
|
@ -106,10 +106,7 @@ func (m *Message) Cid() cid.Cid {
|
||||
}
|
||||
|
||||
func (m *Message) RequiredFunds() BigInt {
|
||||
return BigAdd(
|
||||
m.Value,
|
||||
BigMul(m.GasPrice, NewInt(uint64(m.GasLimit))),
|
||||
)
|
||||
return BigMul(m.GasPrice, NewInt(uint64(m.GasLimit)))
|
||||
}
|
||||
|
||||
func (m *Message) VMMessage() *Message {
|
||||
|
@ -5,10 +5,11 @@ import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
samarket "github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||
gruntime "runtime"
|
||||
"time"
|
||||
|
||||
samarket "github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||
@ -170,6 +171,8 @@ func (rt *Runtime) shimCall(f func() interface{}) (rval []byte, aerr aerrors.Act
|
||||
aerr = ar
|
||||
return
|
||||
}
|
||||
//log.Desugar().WithOptions(zap.AddStacktrace(zapcore.ErrorLevel)).
|
||||
//Sugar().Errorf("spec actors failure: %s", r)
|
||||
log.Errorf("spec actors failure: %s", r)
|
||||
aerr = aerrors.Newf(1, "spec actors failure: %s", r)
|
||||
}
|
||||
|
@ -371,7 +371,6 @@ func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// TODO: We should remove this, we might punish miners for no fault of their own
|
||||
if msg.Nonce != fromActor.Nonce {
|
||||
return &ApplyRet{
|
||||
MessageReceipt: types.MessageReceipt{
|
||||
@ -386,15 +385,14 @@ func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet,
|
||||
}
|
||||
|
||||
gascost := types.BigMul(types.NewInt(uint64(msg.GasLimit)), msg.GasPrice)
|
||||
totalCost := types.BigAdd(gascost, msg.Value)
|
||||
if fromActor.Balance.LessThan(totalCost) {
|
||||
if fromActor.Balance.LessThan(gascost) {
|
||||
return &ApplyRet{
|
||||
MessageReceipt: types.MessageReceipt{
|
||||
ExitCode: exitcode.SysErrSenderStateInvalid,
|
||||
GasUsed: 0,
|
||||
},
|
||||
ActorErr: aerrors.Newf(exitcode.SysErrSenderStateInvalid,
|
||||
"actor balance less than needed: %s < %s", types.FIL(fromActor.Balance), types.FIL(totalCost)),
|
||||
"actor balance less than needed: %s < %s", types.FIL(fromActor.Balance), types.FIL(gascost)),
|
||||
Penalty: minerPenaltyAmount,
|
||||
Duration: time.Since(start),
|
||||
}, nil
|
||||
|
2
go.mod
2
go.mod
@ -15,7 +15,7 @@ require (
|
||||
github.com/drand/drand v1.0.3-0.20200714175734-29705eaf09d4
|
||||
github.com/drand/kyber v1.1.1
|
||||
github.com/fatih/color v1.8.0
|
||||
github.com/filecoin-project/chain-validation v0.0.6-0.20200728204507-037308fa7af2
|
||||
github.com/filecoin-project/chain-validation v0.0.6-0.20200730144717-360111e740bd
|
||||
github.com/filecoin-project/filecoin-ffi v0.30.4-0.20200716204036-cddc56607e1d
|
||||
github.com/filecoin-project/go-address v0.0.2-0.20200504173055-8b6f2fb2b3ef
|
||||
github.com/filecoin-project/go-bitfield v0.1.1
|
||||
|
4
go.sum
4
go.sum
@ -216,8 +216,8 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv
|
||||
github.com/fatih/color v1.8.0 h1:5bzFgL+oy7JITMTxUPJ00n7VxmYd/PdMp5mHFX40/RY=
|
||||
github.com/fatih/color v1.8.0/go.mod h1:3l45GVGkyrnYNl9HoIjnp2NnNWvh6hLAqD8yTfGjnw8=
|
||||
github.com/fd/go-nat v1.0.0/go.mod h1:BTBu/CKvMmOMUPkKVef1pngt2WFH/lg7E6yQnulfp6E=
|
||||
github.com/filecoin-project/chain-validation v0.0.6-0.20200728204507-037308fa7af2 h1:N2mMgz9JdEMMZfNu+5jTV0KqnqKDDw+rWiAS+K6mbiU=
|
||||
github.com/filecoin-project/chain-validation v0.0.6-0.20200728204507-037308fa7af2/go.mod h1:bcpE1fm7OlH1gak8hfSy7+IM/OaT3GW/XFsbDVp4Dfo=
|
||||
github.com/filecoin-project/chain-validation v0.0.6-0.20200730144717-360111e740bd h1:XCZ50NipKQGYoyNwmt4QiCqXm72ePHhgzKtxZ5ziTUE=
|
||||
github.com/filecoin-project/chain-validation v0.0.6-0.20200730144717-360111e740bd/go.mod h1:bcpE1fm7OlH1gak8hfSy7+IM/OaT3GW/XFsbDVp4Dfo=
|
||||
github.com/filecoin-project/go-address v0.0.0-20200107215422-da8eea2842b5/go.mod h1:SAOwJoakQ8EPjwNIsiakIQKsoKdkcbx8U3IapgCg9R0=
|
||||
github.com/filecoin-project/go-address v0.0.2-0.20200218010043-eb9bb40ed5be/go.mod h1:SAOwJoakQ8EPjwNIsiakIQKsoKdkcbx8U3IapgCg9R0=
|
||||
github.com/filecoin-project/go-address v0.0.2-0.20200504173055-8b6f2fb2b3ef h1:Wi5E+P1QfHP8IF27eUiTx5vYfqQZwfPxzq3oFEq8w8U=
|
||||
|
Loading…
Reference in New Issue
Block a user