Adjust gas values
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
ca7e5f5e16
commit
1e17ea3fff
@ -97,13 +97,16 @@ func (pl *pricelistV0) OnChainReturnValue(dataSize int) GasCharge {
|
|||||||
// OnMethodInvocation returns the gas used when invoking a method.
|
// OnMethodInvocation returns the gas used when invoking a method.
|
||||||
func (pl *pricelistV0) OnMethodInvocation(value abi.TokenAmount, methodNum abi.MethodNum) GasCharge {
|
func (pl *pricelistV0) OnMethodInvocation(value abi.TokenAmount, methodNum abi.MethodNum) GasCharge {
|
||||||
ret := pl.sendBase
|
ret := pl.sendBase
|
||||||
|
extra := ""
|
||||||
if value != abi.NewTokenAmount(0) {
|
if value != abi.NewTokenAmount(0) {
|
||||||
ret += pl.sendTransferFunds
|
ret += pl.sendTransferFunds
|
||||||
|
extra += "t"
|
||||||
}
|
}
|
||||||
if methodNum != builtin.MethodSend {
|
if methodNum != builtin.MethodSend {
|
||||||
ret += pl.sendInvokeMethod
|
ret += pl.sendInvokeMethod
|
||||||
|
extra += "i"
|
||||||
}
|
}
|
||||||
return newGasCharge("OnMethodInvocation", ret, 0).WithVirtual(ret*4600, 0)
|
return newGasCharge("OnMethodInvocation", ret, 0).WithVirtual(86315, 0).WithExtra(extra)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnIpldGet returns the gas used for storing an object
|
// OnIpldGet returns the gas used for storing an object
|
||||||
@ -113,12 +116,12 @@ func (pl *pricelistV0) OnIpldGet(dataSize int) GasCharge {
|
|||||||
|
|
||||||
// OnIpldPut returns the gas used for storing an object
|
// OnIpldPut returns the gas used for storing an object
|
||||||
func (pl *pricelistV0) OnIpldPut(dataSize int) GasCharge {
|
func (pl *pricelistV0) OnIpldPut(dataSize int) GasCharge {
|
||||||
return newGasCharge("OnIpldPut", pl.ipldPutBase, int64(dataSize)*pl.ipldPutPerByte).WithExtra(dataSize).WithVirtual(475*(pl.ipldPutBase+int64(dataSize)*pl.ipldPutPerByte), 0)
|
return newGasCharge("OnIpldPut", pl.ipldPutBase, int64(dataSize)*pl.ipldPutPerByte).WithExtra(dataSize).WithVirtual(9151, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnCreateActor returns the gas used for creating an actor
|
// OnCreateActor returns the gas used for creating an actor
|
||||||
func (pl *pricelistV0) OnCreateActor() GasCharge {
|
func (pl *pricelistV0) OnCreateActor() GasCharge {
|
||||||
return newGasCharge("OnCreateActor", pl.createActorBase, pl.createActorExtra).WithVirtual(162*pl.createActorBase, 0)
|
return newGasCharge("OnCreateActor", pl.createActorBase, pl.createActorExtra).WithVirtual(6549, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnDeleteActor returns the gas used for deleting an actor
|
// OnDeleteActor returns the gas used for deleting an actor
|
||||||
@ -139,28 +142,28 @@ func (pl *pricelistV0) OnVerifySignature(sigType crypto.SigType, planTextSize in
|
|||||||
|
|
||||||
// OnHashing
|
// OnHashing
|
||||||
func (pl *pricelistV0) OnHashing(dataSize int) GasCharge {
|
func (pl *pricelistV0) OnHashing(dataSize int) GasCharge {
|
||||||
return newGasCharge("OnHashing", pl.hashingBase+int64(dataSize)*pl.hashingPerByte, 0).WithExtra(dataSize).WithVirtual(256*(pl.hashingBase+int64(dataSize)*pl.hashingPerByte), 0)
|
return newGasCharge("OnHashing", pl.hashingBase+int64(dataSize)*pl.hashingPerByte, 0).WithExtra(dataSize).WithVirtual(7881, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnComputeUnsealedSectorCid
|
// OnComputeUnsealedSectorCid
|
||||||
func (pl *pricelistV0) OnComputeUnsealedSectorCid(proofType abi.RegisteredSealProof, pieces []abi.PieceInfo) GasCharge {
|
func (pl *pricelistV0) OnComputeUnsealedSectorCid(proofType abi.RegisteredSealProof, pieces []abi.PieceInfo) GasCharge {
|
||||||
// TODO: this needs more cost tunning, check with @lotus
|
// TODO: this needs more cost tunning, check with @lotus
|
||||||
return newGasCharge("OnComputeUnsealedSectorCid", pl.computeUnsealedSectorCidBase, 0).WithVirtual(pl.computeUnsealedSectorCidBase*405, 0)
|
return newGasCharge("OnComputeUnsealedSectorCid", pl.computeUnsealedSectorCidBase, 0).WithVirtual(40536, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnVerifySeal
|
// OnVerifySeal
|
||||||
func (pl *pricelistV0) OnVerifySeal(info abi.SealVerifyInfo) GasCharge {
|
func (pl *pricelistV0) OnVerifySeal(info abi.SealVerifyInfo) GasCharge {
|
||||||
// TODO: this needs more cost tunning, check with @lotus
|
// TODO: this needs more cost tunning, check with @lotus
|
||||||
return newGasCharge("OnVerifySeal", pl.verifySealBase, 0).WithVirtual(pl.verifySealBase*177500, 0)
|
return newGasCharge("OnVerifySeal", pl.verifySealBase, 0).WithVirtual(199954003, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnVerifyPost
|
// OnVerifyPost
|
||||||
func (pl *pricelistV0) OnVerifyPost(info abi.WindowPoStVerifyInfo) GasCharge {
|
func (pl *pricelistV0) OnVerifyPost(info abi.WindowPoStVerifyInfo) GasCharge {
|
||||||
// TODO: this needs more cost tunning, check with @lotus
|
// TODO: this needs more cost tunning, check with @lotus
|
||||||
return newGasCharge("OnVerifyPost", pl.verifyPostBase, 0).WithVirtual(pl.verifyPostBase*385100, 0)
|
return newGasCharge("OnVerifyPost", pl.verifyPostBase, 0).WithVirtual(269570688, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnVerifyConsensusFault
|
// OnVerifyConsensusFault
|
||||||
func (pl *pricelistV0) OnVerifyConsensusFault() GasCharge {
|
func (pl *pricelistV0) OnVerifyConsensusFault() GasCharge {
|
||||||
return newGasCharge("OnVerifyConsensusFault", pl.verifyConsensusFault, 0).WithVirtual(pl.verifyConsensusFault*5466, 0)
|
return newGasCharge("OnVerifyConsensusFault", pl.verifyConsensusFault, 0).WithVirtual(54665, 0)
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ type gasChargingBlocks struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (bs *gasChargingBlocks) Get(c cid.Cid) (block.Block, error) {
|
func (bs *gasChargingBlocks) Get(c cid.Cid) (block.Block, error) {
|
||||||
bs.chargeGas(newGasCharge("OnIpldGetStart", 0, 0))
|
bs.chargeGas(newGasCharge("OnIpldGetStart", 0, 0).WithVirtual(40175))
|
||||||
blk, err := bs.under.Get(c)
|
blk, err := bs.under.Get(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, aerrors.Escalate(err, "failed to get block from blockstore")
|
return nil, aerrors.Escalate(err, "failed to get block from blockstore")
|
||||||
|
@ -280,18 +280,6 @@ func (s1 *stats) Combine(s2 *stats) {
|
|||||||
|
|
||||||
func tallyGasCharges(charges map[string]*stats, et types.ExecutionTrace) {
|
func tallyGasCharges(charges map[string]*stats, et types.ExecutionTrace) {
|
||||||
for _, gc := range et.GasCharges {
|
for _, gc := range et.GasCharges {
|
||||||
|
|
||||||
compGas := gc.VirtualComputeGas
|
|
||||||
if compGas == 0 {
|
|
||||||
compGas = 1
|
|
||||||
}
|
|
||||||
compGas = 1
|
|
||||||
|
|
||||||
ratio := float64(compGas) / float64(gc.TimeTaken.Nanoseconds())
|
|
||||||
ratio = 1 / ratio
|
|
||||||
if math.IsNaN(ratio) {
|
|
||||||
log.Errorf("NaN: comGas: %f, taken: %d", compGas, gc.TimeTaken.Nanoseconds())
|
|
||||||
}
|
|
||||||
name := gc.Name
|
name := gc.Name
|
||||||
if eString, ok := gc.Extra.(string); ok {
|
if eString, ok := gc.Extra.(string); ok {
|
||||||
name += "-" + eString
|
name += "-" + eString
|
||||||
@ -300,10 +288,22 @@ func tallyGasCharges(charges map[string]*stats, et types.ExecutionTrace) {
|
|||||||
_ = eInt
|
_ = eInt
|
||||||
}
|
}
|
||||||
|
|
||||||
s := charges[gc.Name]
|
compGas := gc.VirtualComputeGas
|
||||||
|
if compGas == 0 {
|
||||||
|
name += "-zerogas"
|
||||||
|
compGas = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
ratio := float64(compGas) / float64(gc.TimeTaken.Nanoseconds())
|
||||||
|
ratio = 1 / ratio
|
||||||
|
if math.IsNaN(ratio) {
|
||||||
|
log.Errorf("NaN: comGas: %f, taken: %d", compGas, gc.TimeTaken.Nanoseconds())
|
||||||
|
}
|
||||||
|
|
||||||
|
s := charges[name]
|
||||||
if s == nil {
|
if s == nil {
|
||||||
s = new(stats)
|
s = new(stats)
|
||||||
charges[gc.Name] = s
|
charges[name] = s
|
||||||
}
|
}
|
||||||
|
|
||||||
s.AddPoint(ratio)
|
s.AddPoint(ratio)
|
||||||
|
Loading…
Reference in New Issue
Block a user