Increase cron gas
Make gas check overflow safe
This commit is contained in:
parent
389d148a60
commit
aafafce083
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
amt "github.com/filecoin-project/go-amt-ipld/v2"
|
amt "github.com/filecoin-project/go-amt-ipld/v2"
|
||||||
"github.com/filecoin-project/lotus/api"
|
"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/actors"
|
||||||
"github.com/filecoin-project/lotus/chain/state"
|
"github.com/filecoin-project/lotus/chain/state"
|
||||||
"github.com/filecoin-project/lotus/chain/store"
|
"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,
|
Nonce: ca.Nonce,
|
||||||
Value: types.NewInt(0),
|
Value: types.NewInt(0),
|
||||||
GasPrice: 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,
|
Method: builtin.MethodsCron.EpochTick,
|
||||||
Params: nil,
|
Params: nil,
|
||||||
}
|
}
|
||||||
|
@ -550,7 +550,8 @@ func (rt *Runtime) chargeGasInternal(gas GasCharge, skip int) aerrors.ActorError
|
|||||||
rt.lastGasChargeTime = now
|
rt.lastGasChargeTime = now
|
||||||
rt.lastGasCharge = &gasTrace
|
rt.lastGasCharge = &gasTrace
|
||||||
|
|
||||||
if rt.gasUsed+toUse > rt.gasAvailable {
|
// overflow safe
|
||||||
|
if rt.gasUsed > rt.gasAvailable-toUse {
|
||||||
rt.gasUsed = rt.gasAvailable
|
rt.gasUsed = rt.gasAvailable
|
||||||
return aerrors.Newf(exitcode.SysErrOutOfGas, "not enough gas: used=%d, available=%d",
|
return aerrors.Newf(exitcode.SysErrOutOfGas, "not enough gas: used=%d, available=%d",
|
||||||
rt.gasUsed, rt.gasAvailable)
|
rt.gasUsed, rt.gasAvailable)
|
||||||
|
Loading…
Reference in New Issue
Block a user