diff --git a/chain/stmgr/stmgr.go b/chain/stmgr/stmgr.go index c872048b0..5a6434c4e 100644 --- a/chain/stmgr/stmgr.go +++ b/chain/stmgr/stmgr.go @@ -8,6 +8,7 @@ import ( "github.com/filecoin-project/go-address" amt "github.com/filecoin-project/go-amt-ipld/v2" "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/store" @@ -236,7 +237,7 @@ func (sm *StateManager) ApplyBlocks(ctx context.Context, pstate cid.Cid, bms []B Nonce: ca.Nonce, Value: types.NewInt(0), GasPrice: types.NewInt(0), - GasLimit: 1 << 30, // Make super sure this is never too little + GasLimit: build.BlockGasLimit * 10, // Make super sure this is never too little Method: builtin.MethodsCron.EpochTick, Params: nil, } diff --git a/chain/vm/runtime.go b/chain/vm/runtime.go index 9e64275e3..039bccc0b 100644 --- a/chain/vm/runtime.go +++ b/chain/vm/runtime.go @@ -550,7 +550,8 @@ func (rt *Runtime) chargeGasInternal(gas GasCharge, skip int) aerrors.ActorError rt.lastGasChargeTime = now rt.lastGasCharge = &gasTrace - if rt.gasUsed+toUse > rt.gasAvailable { + // overflow safe + if rt.gasUsed > rt.gasAvailable-toUse { rt.gasUsed = rt.gasAvailable return aerrors.Newf(exitcode.SysErrOutOfGas, "not enough gas: used=%d, available=%d", rt.gasUsed, rt.gasAvailable)