Merge pull request #2343 from filecoin-project/feat/more-gas
Make virtual gas real
This commit is contained in:
commit
4553af505f
@ -91,7 +91,7 @@ const VerifSigCacheSize = 32000
|
||||
|
||||
// TODO: If this is gonna stay, it should move to specs-actors
|
||||
const BlockMessageLimit = 512
|
||||
const BlockGasLimit = 100_000_000_000
|
||||
const BlockGasLimit = 7_500_000_000
|
||||
|
||||
var DrandConfig = dtypes.DrandConfig{
|
||||
Servers: []string{
|
||||
|
@ -468,7 +468,7 @@ func getRandomMessages(cg *ChainGen) ([]*types.SignedMessage, error) {
|
||||
|
||||
Method: 0,
|
||||
|
||||
GasLimit: 10000,
|
||||
GasLimit: 100_000_000,
|
||||
GasPrice: types.NewInt(0),
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ func (fm *FundMgr) EnsureAvailable(ctx context.Context, addr, wallet address.Add
|
||||
From: wallet,
|
||||
Value: toAdd,
|
||||
GasPrice: types.NewInt(0),
|
||||
GasLimit: 1000000,
|
||||
GasLimit: 100_000_000,
|
||||
Method: builtin.MethodsMarket.AddBalance,
|
||||
Params: params,
|
||||
})
|
||||
|
@ -179,7 +179,7 @@ func TestForkHeightTriggers(t *testing.T) {
|
||||
To: builtin.InitActorAddr,
|
||||
Method: builtin.MethodsInit.Exec,
|
||||
Params: enc,
|
||||
GasLimit: 10000,
|
||||
GasLimit: 100_000_000,
|
||||
GasPrice: types.NewInt(0),
|
||||
}
|
||||
sig, err := cg.Wallet().Sign(ctx, cg.Banker(), m.Cid().Bytes())
|
||||
@ -206,7 +206,7 @@ func TestForkHeightTriggers(t *testing.T) {
|
||||
Method: 2,
|
||||
Params: nil,
|
||||
Nonce: nonce,
|
||||
GasLimit: 10000,
|
||||
GasLimit: 100_000_000,
|
||||
GasPrice: types.NewInt(0),
|
||||
}
|
||||
nonce++
|
||||
|
@ -19,7 +19,7 @@ func TestSignedMessageJsonRoundtrip(t *testing.T) {
|
||||
Method: 1235126,
|
||||
Value: types.NewInt(123123),
|
||||
GasPrice: types.NewInt(1234),
|
||||
GasLimit: 9992969384,
|
||||
GasLimit: 100_000_000,
|
||||
Nonce: 123123,
|
||||
},
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ type Pricelist interface {
|
||||
OnMethodInvocation(value abi.TokenAmount, methodNum abi.MethodNum) GasCharge
|
||||
|
||||
// OnIpldGet returns the gas used for storing an object
|
||||
OnIpldGet(dataSize int) GasCharge
|
||||
OnIpldGet() GasCharge
|
||||
// OnIpldPut returns the gas used for storing an object
|
||||
OnIpldPut(dataSize int) GasCharge
|
||||
|
||||
@ -84,30 +84,35 @@ type Pricelist interface {
|
||||
|
||||
var prices = map[abi.ChainEpoch]Pricelist{
|
||||
abi.ChainEpoch(0): &pricelistV0{
|
||||
onChainMessageBase: 0,
|
||||
onChainMessagePerByte: 2,
|
||||
onChainReturnValuePerByte: 8,
|
||||
sendBase: 5,
|
||||
sendTransferFunds: 5,
|
||||
sendInvokeMethod: 10,
|
||||
ipldGetBase: 10,
|
||||
ipldGetPerByte: 1,
|
||||
ipldPutBase: 20,
|
||||
ipldPutPerByte: 2,
|
||||
createActorBase: 40, // IPLD put + 20
|
||||
createActorExtra: 500,
|
||||
deleteActor: -500, // -createActorExtra
|
||||
// Dragons: this cost is not persistable, create a LinearCost{a,b} struct that has a `.Cost(x) -> ax + b`
|
||||
verifySignature: map[crypto.SigType]func(int64) int64{
|
||||
crypto.SigTypeBLS: func(x int64) int64 { return 3*x + 2 },
|
||||
crypto.SigTypeSecp256k1: func(x int64) int64 { return 3*x + 2 },
|
||||
onChainMessageComputeBase: 137137,
|
||||
onChainMessageStorageBase: 0, // TODO gas
|
||||
onChainMessageStoragePerByte: 2, // TODO gas
|
||||
|
||||
onChainReturnValuePerByte: 8, // TODO gas
|
||||
|
||||
sendBase: 97236,
|
||||
sendTransferFunds: 96812,
|
||||
sendTransferOnlyPremium: 347806,
|
||||
sendInvokeMethod: -3110,
|
||||
|
||||
ipldGetBase: 417230,
|
||||
ipldPutBase: 396100,
|
||||
ipldPutPerByte: 2, // TODO gas
|
||||
|
||||
createActorCompute: 750011,
|
||||
createActorStorage: 500, // TODO gas
|
||||
deleteActor: -500, // -createActorStorage
|
||||
|
||||
verifySignature: map[crypto.SigType]int64{
|
||||
crypto.SigTypeBLS: 219946580,
|
||||
crypto.SigTypeSecp256k1: 6726720,
|
||||
},
|
||||
hashingBase: 5,
|
||||
hashingPerByte: 2,
|
||||
computeUnsealedSectorCidBase: 100,
|
||||
verifySealBase: 2000,
|
||||
verifyPostBase: 700,
|
||||
verifyConsensusFault: 10,
|
||||
|
||||
hashingBase: 110685,
|
||||
computeUnsealedSectorCidBase: 431890,
|
||||
verifySealBase: 2000, // TODO gas , it VerifySeal syscall is not used
|
||||
verifyPostBase: 2621447835,
|
||||
verifyConsensusFault: 495422,
|
||||
},
|
||||
}
|
||||
|
||||
@ -198,14 +203,14 @@ func (ps pricedSyscalls) VerifyConsensusFault(h1 []byte, h2 []byte, extra []byte
|
||||
}
|
||||
|
||||
func (ps pricedSyscalls) BatchVerifySeals(inp map[address.Address][]abi.SealVerifyInfo) (map[address.Address][]bool, error) {
|
||||
var gasChargeSum GasCharge
|
||||
gasChargeSum.Name = "BatchVerifySeals"
|
||||
count := int64(0)
|
||||
for _, svis := range inp {
|
||||
count += int64(len(svis))
|
||||
}
|
||||
gasChargeSum = gasChargeSum.WithExtra(count).WithVirtual(129778623*count+716683250, 0)
|
||||
ps.chargeGas(gasChargeSum) // TODO: this is only called by the cron actor. Should we even charge gas?
|
||||
|
||||
gasChargeSum := newGasCharge("BatchVerifySeals", 0, 0)
|
||||
gasChargeSum = gasChargeSum.WithExtra(count).WithVirtual(15075005*count+899741502, 0)
|
||||
ps.chargeGas(gasChargeSum) // real gas charged by actors
|
||||
defer ps.chargeGas(gasOnActorExec)
|
||||
|
||||
return ps.under.BatchVerifySeals(inp)
|
||||
|
@ -20,8 +20,9 @@ type pricelistV0 struct {
|
||||
// Together, these account for the cost of message propagation and validation,
|
||||
// up to but excluding any actual processing by the VM.
|
||||
// This is the cost a block producer burns when including an invalid message.
|
||||
onChainMessageBase int64
|
||||
onChainMessagePerByte int64
|
||||
onChainMessageComputeBase int64
|
||||
onChainMessageStorageBase int64
|
||||
onChainMessageStoragePerByte int64
|
||||
|
||||
// Gas cost charged to the originator of a non-nil return value produced
|
||||
// by an on-chain message is given by:
|
||||
@ -41,15 +42,17 @@ type pricelistV0 struct {
|
||||
// already accounted for).
|
||||
sendTransferFunds int64
|
||||
|
||||
// Gsa cost charged, in addition to SendBase, if message only transfers funds.
|
||||
sendTransferOnlyPremium int64
|
||||
|
||||
// Gas cost charged, in addition to SendBase, if a message invokes
|
||||
// a method on the receiver.
|
||||
// Accounts for the cost of loading receiver code and method dispatch.
|
||||
sendInvokeMethod int64
|
||||
|
||||
// Gas cost (Base + len*PerByte) for any Get operation to the IPLD store
|
||||
// Gas cost for any Get operation to the IPLD store
|
||||
// in the runtime VM context.
|
||||
ipldGetBase int64
|
||||
ipldGetPerByte int64
|
||||
ipldGetBase int64
|
||||
|
||||
// Gas cost (Base + len*PerByte) for any Put operation to the IPLD store
|
||||
// in the runtime VM context.
|
||||
@ -64,18 +67,17 @@ type pricelistV0 struct {
|
||||
//
|
||||
// Note: this costs assume that the extra will be partially or totally refunded while
|
||||
// the base is covering for the put.
|
||||
createActorBase int64
|
||||
createActorExtra int64
|
||||
createActorCompute int64
|
||||
createActorStorage int64
|
||||
|
||||
// Gas cost for deleting an actor.
|
||||
//
|
||||
// Note: this partially refunds the create cost to incentivise the deletion of the actors.
|
||||
deleteActor int64
|
||||
|
||||
verifySignature map[crypto.SigType]func(len int64) int64
|
||||
verifySignature map[crypto.SigType]int64
|
||||
|
||||
hashingBase int64
|
||||
hashingPerByte int64
|
||||
hashingBase int64
|
||||
|
||||
computeUnsealedSectorCidBase int64
|
||||
verifySealBase int64
|
||||
@ -87,57 +89,51 @@ var _ Pricelist = (*pricelistV0)(nil)
|
||||
|
||||
// OnChainMessage returns the gas used for storing a message of a given size in the chain.
|
||||
func (pl *pricelistV0) OnChainMessage(msgSize int) GasCharge {
|
||||
return newGasCharge("OnChainMessage", 0, pl.onChainMessageBase+pl.onChainMessagePerByte*int64(msgSize)).WithVirtual(77302, 0)
|
||||
return newGasCharge("OnChainMessage", pl.onChainMessageComputeBase,
|
||||
pl.onChainMessageStorageBase+pl.onChainMessageStoragePerByte*int64(msgSize))
|
||||
}
|
||||
|
||||
// OnChainReturnValue returns the gas used for storing the response of a message in the chain.
|
||||
func (pl *pricelistV0) OnChainReturnValue(dataSize int) GasCharge {
|
||||
return newGasCharge("OnChainReturnValue", 0, int64(dataSize)*pl.onChainReturnValuePerByte).WithVirtual(107294, 0)
|
||||
return newGasCharge("OnChainReturnValue", 0, int64(dataSize)*pl.onChainReturnValuePerByte)
|
||||
}
|
||||
|
||||
// OnMethodInvocation returns the gas used when invoking a method.
|
||||
func (pl *pricelistV0) OnMethodInvocation(value abi.TokenAmount, methodNum abi.MethodNum) GasCharge {
|
||||
ret := pl.sendBase
|
||||
extra := ""
|
||||
virtGas := int64(1072944)
|
||||
|
||||
if value != abi.NewTokenAmount(0) {
|
||||
// TODO: fix this, it is comparing pointers instead of values
|
||||
// see vv
|
||||
ret += pl.sendTransferFunds
|
||||
}
|
||||
if big.Cmp(value, abi.NewTokenAmount(0)) != 0 {
|
||||
virtGas += 497495
|
||||
ret += pl.sendTransferFunds
|
||||
if methodNum == builtin.MethodSend {
|
||||
// transfer only
|
||||
virtGas += 973940
|
||||
ret += pl.sendTransferOnlyPremium
|
||||
}
|
||||
extra += "t"
|
||||
}
|
||||
|
||||
if methodNum != builtin.MethodSend {
|
||||
ret += pl.sendInvokeMethod
|
||||
extra += "i"
|
||||
// running actors is cheaper becase we hand over to actors
|
||||
virtGas += -295779
|
||||
ret += pl.sendInvokeMethod
|
||||
}
|
||||
return newGasCharge("OnMethodInvocation", ret, 0).WithVirtual(virtGas, 0).WithExtra(extra)
|
||||
return newGasCharge("OnMethodInvocation", ret, 0).WithExtra(extra)
|
||||
}
|
||||
|
||||
// OnIpldGet returns the gas used for storing an object
|
||||
func (pl *pricelistV0) OnIpldGet(dataSize int) GasCharge {
|
||||
return newGasCharge("OnIpldGet", pl.ipldGetBase+int64(dataSize)*pl.ipldGetPerByte, 0).
|
||||
WithExtra(dataSize).WithVirtual(433685, 0)
|
||||
func (pl *pricelistV0) OnIpldGet() GasCharge {
|
||||
return newGasCharge("OnIpldGet", pl.ipldGetBase, 0)
|
||||
}
|
||||
|
||||
// OnIpldPut returns the gas used for storing an object
|
||||
func (pl *pricelistV0) OnIpldPut(dataSize int) GasCharge {
|
||||
return newGasCharge("OnIpldPut", pl.ipldPutBase, int64(dataSize)*pl.ipldPutPerByte).
|
||||
WithExtra(dataSize).WithVirtual(88970, 0)
|
||||
WithExtra(dataSize)
|
||||
}
|
||||
|
||||
// OnCreateActor returns the gas used for creating an actor
|
||||
func (pl *pricelistV0) OnCreateActor() GasCharge {
|
||||
return newGasCharge("OnCreateActor", pl.createActorBase, pl.createActorExtra).WithVirtual(65636, 0)
|
||||
return newGasCharge("OnCreateActor", pl.createActorCompute, pl.createActorStorage)
|
||||
}
|
||||
|
||||
// OnDeleteActor returns the gas used for deleting an actor
|
||||
@ -148,50 +144,42 @@ func (pl *pricelistV0) OnDeleteActor() GasCharge {
|
||||
// OnVerifySignature
|
||||
|
||||
func (pl *pricelistV0) OnVerifySignature(sigType crypto.SigType, planTextSize int) (GasCharge, error) {
|
||||
costFn, ok := pl.verifySignature[sigType]
|
||||
cost, ok := pl.verifySignature[sigType]
|
||||
if !ok {
|
||||
return GasCharge{}, fmt.Errorf("cost function for signature type %d not supported", sigType)
|
||||
}
|
||||
sigName, _ := sigType.Name()
|
||||
virtGas := int64(0)
|
||||
switch sigType {
|
||||
case crypto.SigTypeBLS:
|
||||
virtGas = 220138570
|
||||
case crypto.SigTypeSecp256k1:
|
||||
virtGas = 7053730
|
||||
}
|
||||
|
||||
return newGasCharge("OnVerifySignature", costFn(int64(planTextSize)), 0).
|
||||
sigName, _ := sigType.Name()
|
||||
return newGasCharge("OnVerifySignature", cost, 0).
|
||||
WithExtra(map[string]interface{}{
|
||||
"type": sigName,
|
||||
"size": planTextSize,
|
||||
}).WithVirtual(virtGas, 0), nil
|
||||
}), nil
|
||||
}
|
||||
|
||||
// OnHashing
|
||||
func (pl *pricelistV0) OnHashing(dataSize int) GasCharge {
|
||||
return newGasCharge("OnHashing", pl.hashingBase+int64(dataSize)*pl.hashingPerByte, 0).WithExtra(dataSize).WithVirtual(77300, 0)
|
||||
return newGasCharge("OnHashing", pl.hashingBase, 0).WithExtra(dataSize)
|
||||
}
|
||||
|
||||
// OnComputeUnsealedSectorCid
|
||||
func (pl *pricelistV0) OnComputeUnsealedSectorCid(proofType abi.RegisteredSealProof, pieces []abi.PieceInfo) GasCharge {
|
||||
// TODO: this needs more cost tunning, check with @lotus
|
||||
return newGasCharge("OnComputeUnsealedSectorCid", pl.computeUnsealedSectorCidBase, 0).WithVirtual(382370, 0)
|
||||
return newGasCharge("OnComputeUnsealedSectorCid", pl.computeUnsealedSectorCidBase, 0)
|
||||
}
|
||||
|
||||
// OnVerifySeal
|
||||
func (pl *pricelistV0) OnVerifySeal(info abi.SealVerifyInfo) GasCharge {
|
||||
// TODO: this needs more cost tunning, check with @lotus
|
||||
return newGasCharge("OnVerifySeal", pl.verifySealBase, 0).WithVirtual(199954003, 0)
|
||||
// this is not used
|
||||
return newGasCharge("OnVerifySeal", pl.verifySealBase, 0)
|
||||
}
|
||||
|
||||
// OnVerifyPost
|
||||
func (pl *pricelistV0) OnVerifyPost(info abi.WindowPoStVerifyInfo) GasCharge {
|
||||
// TODO: this needs more cost tunning, check with @lotus
|
||||
return newGasCharge("OnVerifyPost", pl.verifyPostBase, 0).WithVirtual(2629471704, 0).WithExtra(len(info.ChallengedSectors))
|
||||
return newGasCharge("OnVerifyPost", pl.verifyPostBase, 0).WithExtra(len(info.ChallengedSectors))
|
||||
}
|
||||
|
||||
// OnVerifyConsensusFault
|
||||
func (pl *pricelistV0) OnVerifyConsensusFault() GasCharge {
|
||||
return newGasCharge("OnVerifyConsensusFault", pl.verifyConsensusFault, 0).WithVirtual(551935, 0)
|
||||
return newGasCharge("OnVerifyConsensusFault", pl.verifyConsensusFault, 0)
|
||||
}
|
||||
|
@ -30,6 +30,10 @@ var EmptyObjectCid cid.Cid
|
||||
|
||||
// TryCreateAccountActor creates account actors from only BLS/SECP256K1 addresses.
|
||||
func TryCreateAccountActor(rt *Runtime, addr address.Address) (*types.Actor, aerrors.ActorError) {
|
||||
if err := rt.chargeGasSafe(PricelistByEpoch(rt.height).OnCreateActor()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
addrID, err := rt.state.RegisterNewAddress(addr)
|
||||
if err != nil {
|
||||
return nil, aerrors.Escalate(err, "registering actor address")
|
||||
@ -50,10 +54,6 @@ func TryCreateAccountActor(rt *Runtime, addr address.Address) (*types.Actor, aer
|
||||
}
|
||||
// call constructor on account
|
||||
|
||||
if err := rt.chargeGasSafe(PricelistByEpoch(rt.height).OnCreateActor()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, aerr = rt.internalSend(builtin.SystemActorAddr, addrID, builtin.MethodsAccount.Constructor, big.Zero(), p)
|
||||
if aerr != nil {
|
||||
return nil, aerrors.Wrap(aerr, "failed to invoke account constructor")
|
||||
|
@ -71,12 +71,12 @@ type gasChargingBlocks struct {
|
||||
}
|
||||
|
||||
func (bs *gasChargingBlocks) Get(c cid.Cid) (block.Block, error) {
|
||||
bs.chargeGas(newGasCharge("OnIpldGetStart", 0, 0))
|
||||
bs.chargeGas(bs.pricelist.OnIpldGet())
|
||||
blk, err := bs.under.Get(c)
|
||||
if err != nil {
|
||||
return nil, aerrors.Escalate(err, "failed to get block from blockstore")
|
||||
}
|
||||
bs.chargeGas(bs.pricelist.OnIpldGet(len(blk.RawData())))
|
||||
bs.chargeGas(newGasCharge("OnIpldGetEnd", 0, 0).WithExtra(len(blk.RawData())))
|
||||
bs.chargeGas(gasOnActorExec)
|
||||
|
||||
return blk, nil
|
||||
@ -211,7 +211,6 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
|
||||
parent.lastGasCharge = rt.lastGasCharge
|
||||
}()
|
||||
}
|
||||
|
||||
if gasCharge != nil {
|
||||
if err := rt.chargeGasSafe(*gasCharge); err != nil {
|
||||
// this should never happen
|
||||
@ -220,10 +219,7 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
|
||||
}
|
||||
|
||||
ret, err := func() ([]byte, aerrors.ActorError) {
|
||||
if aerr := rt.chargeGasSafe(rt.Pricelist().OnMethodInvocation(msg.Value, msg.Method)); aerr != nil {
|
||||
return nil, aerrors.Wrap(aerr, "not enough gas for method invocation")
|
||||
}
|
||||
|
||||
_ = rt.chargeGasSafe(newGasCharge("OnGetActor", 0, 0))
|
||||
toActor, err := st.GetActor(msg.To)
|
||||
if err != nil {
|
||||
if xerrors.Is(err, init_.ErrAddressNotFound) {
|
||||
@ -237,6 +233,11 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
|
||||
}
|
||||
}
|
||||
|
||||
if aerr := rt.chargeGasSafe(rt.Pricelist().OnMethodInvocation(msg.Value, msg.Method)); aerr != nil {
|
||||
return nil, aerrors.Wrap(aerr, "not enough gas for method invocation")
|
||||
}
|
||||
defer rt.chargeGasSafe(newGasCharge("OnMethodInvocationDone", 0, 0))
|
||||
|
||||
if types.BigCmp(msg.Value, types.NewInt(0)) != 0 {
|
||||
if err := vm.transfer(msg.From, msg.To, msg.Value); err != nil {
|
||||
return nil, aerrors.Wrap(err, "failed to transfer funds")
|
||||
@ -247,7 +248,6 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime,
|
||||
var ret []byte
|
||||
_ = rt.chargeGasSafe(gasOnActorExec)
|
||||
ret, err := vm.Invoke(toActor, rt, msg.Method, msg.Params)
|
||||
_ = rt.chargeGasSafe(newGasCharge("OnActorExecDone", 0, 0))
|
||||
return ret, err
|
||||
}
|
||||
return nil, nil
|
||||
@ -441,6 +441,9 @@ func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet,
|
||||
return nil, xerrors.Errorf("revert state failed: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
rt.finilizeGasTracing()
|
||||
|
||||
gasUsed = rt.gasUsed
|
||||
if gasUsed < 0 {
|
||||
gasUsed = 0
|
||||
@ -460,8 +463,6 @@ func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet,
|
||||
return nil, xerrors.Errorf("gas handling math is wrong")
|
||||
}
|
||||
|
||||
rt.finilizeGasTracing()
|
||||
|
||||
return &ApplyRet{
|
||||
MessageReceipt: types.MessageReceipt{
|
||||
ExitCode: errcode,
|
||||
|
@ -935,7 +935,7 @@ var slashConsensusFault = &cli.Command{
|
||||
From: def,
|
||||
Value: types.NewInt(0),
|
||||
GasPrice: types.NewInt(1),
|
||||
GasLimit: 10000000,
|
||||
GasLimit: 100_000_000,
|
||||
Method: builtin.MethodsMiner.ReportConsensusFault,
|
||||
Params: enc,
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ var sendCmd = &cli.Command{
|
||||
From: fromAddr,
|
||||
To: toAddr,
|
||||
Value: types.BigInt(val),
|
||||
GasLimit: 10000,
|
||||
GasLimit: 100_000_000,
|
||||
GasPrice: gp,
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ func sendSmallFundsTxs(ctx context.Context, api api.FullNode, from address.Addre
|
||||
From: from,
|
||||
To: sendSet[rand.Intn(20)],
|
||||
Value: types.NewInt(1),
|
||||
GasLimit: 100000,
|
||||
GasLimit: 100_000_000,
|
||||
GasPrice: types.NewInt(0),
|
||||
}
|
||||
|
||||
|
@ -405,16 +405,19 @@ func getExtras(ex interface{}) (*string, *float64) {
|
||||
func tallyGasCharges(charges map[string]*stats, et types.ExecutionTrace) {
|
||||
for i, gc := range et.GasCharges {
|
||||
name := gc.Name
|
||||
if name == "OnIpldGetStart" {
|
||||
if name == "OnIpldGetEnd" {
|
||||
continue
|
||||
}
|
||||
tt := float64(gc.TimeTaken.Nanoseconds())
|
||||
if name == "OnIpldGet" {
|
||||
prev := et.GasCharges[i-1]
|
||||
if prev.Name != "OnIpldGetStart" {
|
||||
log.Warn("OnIpldGet without OnIpldGetStart")
|
||||
next := &types.GasTrace{}
|
||||
if i+1 < len(et.GasCharges) {
|
||||
next = et.GasCharges[i+1]
|
||||
}
|
||||
tt += float64(prev.TimeTaken.Nanoseconds())
|
||||
if next.Name != "OnIpldGetEnd" {
|
||||
log.Warn("OnIpldGet without OnIpldGetEnd")
|
||||
}
|
||||
tt += float64(next.TimeTaken.Nanoseconds())
|
||||
}
|
||||
eType, eSize := getExtras(gc.Extra)
|
||||
if eType != nil {
|
||||
@ -604,7 +607,7 @@ var importAnalyzeCmd = &cli.Command{
|
||||
timeInActors := actorExec.timeTaken.Mean() * actorExec.timeTaken.n
|
||||
fmt.Printf("Avarage time per epoch in actors: %s (%.1f%%)\n", time.Duration(timeInActors)/time.Duration(totalTipsets), timeInActors/float64(totalTime)*100)
|
||||
}
|
||||
if actorExecDone, ok := charges["OnActorExecDone"]; ok {
|
||||
if actorExecDone, ok := charges["OnMethodInvocationDone"]; ok {
|
||||
timeInActors := actorExecDone.timeTaken.Mean() * actorExecDone.timeTaken.n
|
||||
fmt.Printf("Avarage time per epoch in OnActorExecDone %s (%.1f%%)\n", time.Duration(timeInActors)/time.Duration(totalTipsets), timeInActors/float64(totalTime)*100)
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ func (h *handler) send(w http.ResponseWriter, r *http.Request) {
|
||||
To: to,
|
||||
|
||||
GasPrice: types.NewInt(0),
|
||||
GasLimit: 10000,
|
||||
GasLimit: 100_000_000,
|
||||
})
|
||||
if err != nil {
|
||||
w.WriteHeader(400)
|
||||
@ -355,7 +355,7 @@ func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) {
|
||||
To: owner,
|
||||
|
||||
GasPrice: types.NewInt(0),
|
||||
GasLimit: 10000,
|
||||
GasLimit: 100_000_000,
|
||||
})
|
||||
if err != nil {
|
||||
w.WriteHeader(400)
|
||||
@ -391,7 +391,7 @@ func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) {
|
||||
Method: builtin.MethodsPower.CreateMiner,
|
||||
Params: params,
|
||||
|
||||
GasLimit: 10000000,
|
||||
GasLimit: 100_000_000,
|
||||
GasPrice: types.NewInt(0),
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ var noncefix = &cli.Command{
|
||||
From: addr,
|
||||
To: addr,
|
||||
Value: types.NewInt(1),
|
||||
GasLimit: 10000,
|
||||
GasLimit: 100_000_000,
|
||||
GasPrice: types.NewInt(1),
|
||||
Nonce: i,
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ var verifRegAddVerifierCmd = &cli.Command{
|
||||
From: fromk,
|
||||
Method: builtin.MethodsVerifiedRegistry.AddVerifier,
|
||||
GasPrice: types.NewInt(1),
|
||||
GasLimit: 300000,
|
||||
GasLimit: 100_000_000,
|
||||
Params: params,
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ var verifRegVerifyClientCmd = &cli.Command{
|
||||
From: fromk,
|
||||
Method: builtin.MethodsVerifiedRegistry.AddVerifiedClient,
|
||||
GasPrice: types.NewInt(1),
|
||||
GasLimit: 300000,
|
||||
GasLimit: 100_000_000,
|
||||
Params: params,
|
||||
}
|
||||
|
||||
|
@ -557,7 +557,7 @@ func configureStorageMiner(ctx context.Context, api lapi.FullNode, addr address.
|
||||
Params: enc,
|
||||
Value: types.NewInt(0),
|
||||
GasPrice: gasPrice,
|
||||
GasLimit: 99999999,
|
||||
GasLimit: 100_000_000,
|
||||
}
|
||||
|
||||
smsg, err := api.MpoolPushMessage(ctx, msg)
|
||||
@ -636,7 +636,7 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
|
||||
Method: builtin.MethodsPower.CreateMiner,
|
||||
Params: params,
|
||||
|
||||
GasLimit: 10000000,
|
||||
GasLimit: 100_000_000,
|
||||
GasPrice: gasPrice,
|
||||
}
|
||||
|
||||
|
4
go.mod
4
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.20200713102302-1bc823b1e01d
|
||||
github.com/filecoin-project/chain-validation v0.0.6-0.20200713115604-652494bba69e
|
||||
github.com/filecoin-project/filecoin-ffi v0.26.1-0.20200508175440-05b30afeb00d
|
||||
github.com/filecoin-project/go-address v0.0.2-0.20200504173055-8b6f2fb2b3ef
|
||||
github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200424220931-6263827e49f2
|
||||
@ -32,7 +32,7 @@ require (
|
||||
github.com/filecoin-project/sector-storage v0.0.0-20200712023225-1d67dcfa3c15
|
||||
github.com/filecoin-project/specs-actors v0.7.2
|
||||
github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea
|
||||
github.com/filecoin-project/storage-fsm v0.0.0-20200712045002-6e92d6a6f080
|
||||
github.com/filecoin-project/storage-fsm v0.0.0-20200715191202-7e92e888bf41
|
||||
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1
|
||||
github.com/go-kit/kit v0.10.0
|
||||
github.com/go-ole/go-ole v1.2.4 // indirect
|
||||
|
10
go.sum
10
go.sum
@ -215,8 +215,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.20200713102302-1bc823b1e01d h1:6mOOHCn8iJfWPRELM7LPE4X9mBmCTvQORsgzsA/u0Wg=
|
||||
github.com/filecoin-project/chain-validation v0.0.6-0.20200713102302-1bc823b1e01d/go.mod h1:293UFGwKduXCuIC2/5pIepH7lof+L9fNiPku/+arST4=
|
||||
github.com/filecoin-project/chain-validation v0.0.6-0.20200713115604-652494bba69e h1:oCdk3QSDcHu3l6dWpZcHhaUVz5RQi1mXNyv8hgcK1zA=
|
||||
github.com/filecoin-project/chain-validation v0.0.6-0.20200713115604-652494bba69e/go.mod h1:293UFGwKduXCuIC2/5pIepH7lof+L9fNiPku/+arST4=
|
||||
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=
|
||||
@ -258,8 +258,6 @@ github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZO
|
||||
github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b h1:fkRZSPrYpk42PV3/lIXiL0LHetxde7vyYYvSsttQtfg=
|
||||
github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b/go.mod h1:Q0GQOBtKf1oE10eSXSlhN45kDBdGvEcVOqMiffqX+N8=
|
||||
github.com/filecoin-project/sector-storage v0.0.0-20200615154852-728a47ab99d6/go.mod h1:M59QnAeA/oV+Z8oHFLoNpGMv0LZ8Rll+vHVXX7GirPM=
|
||||
github.com/filecoin-project/sector-storage v0.0.0-20200625154333-98ef8e4ef246 h1:NfYQRmVRe0LzlNbK5Ket3vbBOwFD5TvtcNtfo/Sd8mg=
|
||||
github.com/filecoin-project/sector-storage v0.0.0-20200625154333-98ef8e4ef246/go.mod h1:8f0hWDzzIi1hKs4IVKH9RnDsO4LEHVz8BNat0okDOuY=
|
||||
github.com/filecoin-project/sector-storage v0.0.0-20200712023225-1d67dcfa3c15 h1:miw6hiusb/MkV1ryoqUKKWnvHhPW00AYtyeCj0L8pqo=
|
||||
github.com/filecoin-project/sector-storage v0.0.0-20200712023225-1d67dcfa3c15/go.mod h1:salgVdX7qeXFo/xaiEQE29J4pPkjn71T0kt0n+VDBzo=
|
||||
github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA=
|
||||
@ -274,8 +272,8 @@ github.com/filecoin-project/specs-storage v0.1.0 h1:PkDgTOT5W5Ao7752onjDl4QSv+sg
|
||||
github.com/filecoin-project/specs-storage v0.1.0/go.mod h1:Pr5ntAaxsh+sLG/LYiL4tKzvA83Vk5vLODYhfNwOg7k=
|
||||
github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea h1:iixjULRQFPn7Q9KlIqfwLJnlAXO10bbkI+xy5GKGdLY=
|
||||
github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea/go.mod h1:Pr5ntAaxsh+sLG/LYiL4tKzvA83Vk5vLODYhfNwOg7k=
|
||||
github.com/filecoin-project/storage-fsm v0.0.0-20200712045002-6e92d6a6f080 h1:WZonjI7/GFLi4NxziBCefS9x7bm8S405RWkmFuDfRLA=
|
||||
github.com/filecoin-project/storage-fsm v0.0.0-20200712045002-6e92d6a6f080/go.mod h1:SXO4VnXG056B/lXHL8HZv54eMqlsyynm+v93BlLwlOY=
|
||||
github.com/filecoin-project/storage-fsm v0.0.0-20200715191202-7e92e888bf41 h1:K2DI5+IKuY0cOjX/r1Agy6rYcAhU89LVNOjutCUib4g=
|
||||
github.com/filecoin-project/storage-fsm v0.0.0-20200715191202-7e92e888bf41/go.mod h1:TDNjb0HYG2fppxWH5EsiNCZu97iJZNuPYmivSK13Ao0=
|
||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||
github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6 h1:u/UEqS66A5ckRmS4yNpjmVH56sVtS/RfclBAYocb4as=
|
||||
github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:1i71OnUq3iUe1ma7Lr6yG6/rjvM3emb6yoL7xLFzcVQ=
|
||||
|
@ -138,7 +138,7 @@ func (c *ClientNodeAdapter) AddFunds(ctx context.Context, addr address.Address,
|
||||
From: addr,
|
||||
Value: amount,
|
||||
GasPrice: types.NewInt(0),
|
||||
GasLimit: 1000000,
|
||||
GasLimit: 200_000_000,
|
||||
Method: builtin.MethodsMarket.AddBalance,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -78,7 +78,7 @@ func (n *ProviderNodeAdapter) PublishDeals(ctx context.Context, deal storagemark
|
||||
From: mi.Worker,
|
||||
Value: types.NewInt(0),
|
||||
GasPrice: types.NewInt(0),
|
||||
GasLimit: 1000000,
|
||||
GasLimit: 600_000_000,
|
||||
Method: builtin.MethodsMarket.PublishStorageDeals,
|
||||
Params: params,
|
||||
})
|
||||
@ -175,7 +175,7 @@ func (n *ProviderNodeAdapter) AddFunds(ctx context.Context, addr address.Address
|
||||
From: addr,
|
||||
Value: amount,
|
||||
GasPrice: types.NewInt(0),
|
||||
GasLimit: 1000000,
|
||||
GasLimit: 200_000_000,
|
||||
Method: builtin.MethodsMarket.AddBalance,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func mustIDAddr(i uint64) address.Address {
|
||||
@ -26,11 +27,11 @@ func TestMessageFiltering(t *testing.T) {
|
||||
actors := map[address.Address]*types.Actor{
|
||||
a1: {
|
||||
Nonce: 3,
|
||||
Balance: types.NewInt(1200),
|
||||
Balance: types.FromFil(1200),
|
||||
},
|
||||
a2: {
|
||||
Nonce: 1,
|
||||
Balance: types.NewInt(1000),
|
||||
Balance: types.FromFil(1000),
|
||||
},
|
||||
}
|
||||
|
||||
@ -43,39 +44,39 @@ func TestMessageFiltering(t *testing.T) {
|
||||
From: a1,
|
||||
To: a1,
|
||||
Nonce: 3,
|
||||
Value: types.NewInt(500),
|
||||
GasLimit: 50,
|
||||
Value: types.FromFil(500),
|
||||
GasLimit: 100_000_000,
|
||||
GasPrice: types.NewInt(1),
|
||||
},
|
||||
{
|
||||
From: a1,
|
||||
To: a1,
|
||||
Nonce: 4,
|
||||
Value: types.NewInt(500),
|
||||
GasLimit: 50,
|
||||
Value: types.FromFil(500),
|
||||
GasLimit: 100_000_000,
|
||||
GasPrice: types.NewInt(1),
|
||||
},
|
||||
{
|
||||
From: a2,
|
||||
To: a1,
|
||||
Nonce: 1,
|
||||
Value: types.NewInt(800),
|
||||
GasLimit: 100,
|
||||
Value: types.FromFil(800),
|
||||
GasLimit: 100_000_000,
|
||||
GasPrice: types.NewInt(1),
|
||||
},
|
||||
{
|
||||
From: a2,
|
||||
To: a1,
|
||||
Nonce: 0,
|
||||
Value: types.NewInt(800),
|
||||
GasLimit: 100,
|
||||
Value: types.FromFil(800),
|
||||
GasLimit: 100_000_000,
|
||||
GasPrice: types.NewInt(1),
|
||||
},
|
||||
{
|
||||
From: a2,
|
||||
To: a1,
|
||||
Nonce: 2,
|
||||
Value: types.NewInt(150),
|
||||
Value: types.FromFil(150),
|
||||
GasLimit: 100,
|
||||
GasPrice: types.NewInt(1),
|
||||
},
|
||||
@ -86,9 +87,7 @@ func TestMessageFiltering(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if len(outmsgs) != 3 {
|
||||
t.Fatal("filtering didnt work as expected")
|
||||
}
|
||||
assert.Len(t, outmsgs, 3, "filtering didnt work as expected")
|
||||
|
||||
was, expected := outmsgs[0].Message, msgs[2]
|
||||
if was.From != expected.From || was.Nonce != expected.Nonce {
|
||||
|
@ -90,6 +90,12 @@ func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message) (*t
|
||||
if msg.Nonce != 0 {
|
||||
return nil, xerrors.Errorf("MpoolPushMessage expects message nonce to be 0, was %d", msg.Nonce)
|
||||
}
|
||||
if msg.GasLimit == 0 {
|
||||
msg.GasLimit = 100_000_000 // TODO: gas limit estimation
|
||||
}
|
||||
if types.BigCmp(msg.GasPrice, types.NewInt(0)) == 0 {
|
||||
msg.GasPrice = types.NewInt(1) // TODO: gas price estimation
|
||||
}
|
||||
|
||||
return a.Mpool.PushWithNonce(ctx, msg.From, func(from address.Address, nonce uint64) (*types.SignedMessage, error) {
|
||||
msg.Nonce = nonce
|
||||
|
@ -76,7 +76,7 @@ func (a *MsigAPI) MsigCreate(ctx context.Context, req uint64, addrs []address.Ad
|
||||
Method: builtin.MethodsInit.Exec,
|
||||
Params: enc,
|
||||
GasPrice: gp,
|
||||
GasLimit: 1000000,
|
||||
GasLimit: 100_000_000,
|
||||
Value: val,
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ func (a *MsigAPI) MsigPropose(ctx context.Context, msig address.Address, to addr
|
||||
Value: types.NewInt(0),
|
||||
Method: builtin.MethodsMultisig.Propose,
|
||||
Params: enc,
|
||||
GasLimit: 100000,
|
||||
GasLimit: 100_000_000,
|
||||
GasPrice: types.NewInt(1),
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ func (a *MsigAPI) msigApproveOrCancel(ctx context.Context, operation api.MsigPro
|
||||
Value: types.NewInt(0),
|
||||
Method: msigResponseMethod,
|
||||
Params: enc,
|
||||
GasLimit: 100000,
|
||||
GasLimit: 100_000_000,
|
||||
GasPrice: types.NewInt(1),
|
||||
}
|
||||
|
||||
|
@ -779,7 +779,7 @@ func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr
|
||||
From: maddr,
|
||||
To: builtin.StorageMarketActorAddr,
|
||||
Method: builtin.MethodsMarket.VerifyDealsForActivation,
|
||||
GasLimit: 100000000000,
|
||||
GasLimit: 100_000_000,
|
||||
GasPrice: types.NewInt(0),
|
||||
Params: params,
|
||||
}, ts)
|
||||
|
@ -125,7 +125,7 @@ func (a *PaychAPI) PaychClose(ctx context.Context, addr address.Address) (cid.Ci
|
||||
Method: builtin.MethodsPaych.Settle,
|
||||
Nonce: nonce,
|
||||
|
||||
GasLimit: 10000,
|
||||
GasLimit: 100_000_000,
|
||||
GasPrice: types.NewInt(0),
|
||||
}
|
||||
|
||||
@ -240,7 +240,7 @@ func (a *PaychAPI) PaychVoucherSubmit(ctx context.Context, ch address.Address, s
|
||||
Nonce: nonce,
|
||||
Method: builtin.MethodsPaych.UpdateChannelState,
|
||||
Params: enc,
|
||||
GasLimit: 100000,
|
||||
GasLimit: 100_000_000,
|
||||
GasPrice: types.NewInt(0),
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ func testStorageNode(ctx context.Context, t *testing.T, waddr address.Address, a
|
||||
Params: enc,
|
||||
Value: types.NewInt(0),
|
||||
GasPrice: types.NewInt(0),
|
||||
GasLimit: 1000000,
|
||||
GasLimit: 100_000_000,
|
||||
}
|
||||
|
||||
_, err = tnd.MpoolPushMessage(ctx, msg)
|
||||
|
@ -37,7 +37,7 @@ func (pm *Manager) createPaych(ctx context.Context, from, to address.Address, am
|
||||
Value: amt,
|
||||
Method: builtin.MethodsInit.Exec,
|
||||
Params: enc,
|
||||
GasLimit: 1000000,
|
||||
GasLimit: 100_000_000,
|
||||
GasPrice: types.NewInt(0),
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ func (pm *Manager) addFunds(ctx context.Context, ch address.Address, from addres
|
||||
From: from,
|
||||
Value: amt,
|
||||
Method: 0,
|
||||
GasLimit: 1000000,
|
||||
GasLimit: 100_000_000,
|
||||
GasPrice: types.NewInt(0),
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ func (s SealingAPIAdapter) StateComputeDataCommitment(ctx context.Context, maddr
|
||||
From: maddr,
|
||||
Value: types.NewInt(0),
|
||||
GasPrice: types.NewInt(0),
|
||||
GasLimit: 9999999999,
|
||||
GasLimit: 100_000_000,
|
||||
Method: builtin.MethodsMarket.ComputeDataCommitment,
|
||||
Params: ccparams,
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ func (s *WindowPoStScheduler) checkNextRecoveries(ctx context.Context, deadline
|
||||
Method: builtin.MethodsMiner.DeclareFaultsRecovered,
|
||||
Params: enc,
|
||||
Value: types.NewInt(0),
|
||||
GasLimit: 10000000, // i dont know help
|
||||
GasLimit: 100_000_000, // i dont know help
|
||||
GasPrice: types.NewInt(2),
|
||||
}
|
||||
|
||||
@ -256,7 +256,7 @@ func (s *WindowPoStScheduler) checkNextFaults(ctx context.Context, deadline uint
|
||||
Method: builtin.MethodsMiner.DeclareFaults,
|
||||
Params: enc,
|
||||
Value: types.NewInt(0), // TODO: Is there a fee?
|
||||
GasLimit: 10000000, // i dont know help
|
||||
GasLimit: 100_000_000, // i dont know help
|
||||
GasPrice: types.NewInt(2),
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user