diff --git a/chain/vm/gas.go b/chain/vm/gas.go index 449984ed1..81a5fc8e3 100644 --- a/chain/vm/gas.go +++ b/chain/vm/gas.go @@ -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 diff --git a/chain/vm/gas_v0.go b/chain/vm/gas_v0.go index 39e24d2cf..068726d74 100644 --- a/chain/vm/gas_v0.go +++ b/chain/vm/gas_v0.go @@ -121,7 +121,7 @@ func (pl *pricelistV0) OnMethodInvocation(value abi.TokenAmount, methodNum abi.M } // OnIpldGet returns the gas used for storing an object -func (pl *pricelistV0) OnIpldGet(dataSize int) GasCharge { +func (pl *pricelistV0) OnIpldGet() GasCharge { return newGasCharge("OnIpldGet", pl.ipldGetBase, 0) } diff --git a/chain/vm/vm.go b/chain/vm/vm.go index ce02f9ac8..dd1d23513 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -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 diff --git a/cmd/lotus-bench/import.go b/cmd/lotus-bench/import.go index ec1815ac0..3c56a5707 100644 --- a/cmd/lotus-bench/import.go +++ b/cmd/lotus-bench/import.go @@ -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 {