Merge pull request #3034 from filecoin-project/feat/stat-gas-limit-total
Add total gas used and limit to stats
This commit is contained in:
commit
5c0d86373e
@ -16,6 +16,7 @@ import (
|
|||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/multiformats/go-multihash"
|
"github.com/multiformats/go-multihash"
|
||||||
@ -104,7 +105,8 @@ func InfluxNewBatch() (client.BatchPoints, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewPoint(name string, value interface{}) models.Point {
|
func NewPoint(name string, value interface{}) models.Point {
|
||||||
pt, _ := models.NewPoint(name, models.Tags{}, map[string]interface{}{"value": value}, build.Clock.Now())
|
pt, _ := models.NewPoint(name, models.Tags{},
|
||||||
|
map[string]interface{}{"value": value}, build.Clock.Now().UTC())
|
||||||
return pt
|
return pt
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,6 +137,7 @@ func RecordTipsetPoints(ctx context.Context, api api.FullNode, pl *PointList, ti
|
|||||||
p = NewPoint("chain.basefee", baseFeeFloat)
|
p = NewPoint("chain.basefee", baseFeeFloat)
|
||||||
pl.AddPoint(p)
|
pl.AddPoint(p)
|
||||||
|
|
||||||
|
totalGasLimit := int64(0)
|
||||||
for _, blockheader := range tipset.Blocks() {
|
for _, blockheader := range tipset.Blocks() {
|
||||||
bs, err := blockheader.Serialize()
|
bs, err := blockheader.Serialize()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -146,7 +149,20 @@ func RecordTipsetPoints(ctx context.Context, api api.FullNode, pl *PointList, ti
|
|||||||
|
|
||||||
p = NewPoint("chain.blockheader_size", len(bs))
|
p = NewPoint("chain.blockheader_size", len(bs))
|
||||||
pl.AddPoint(p)
|
pl.AddPoint(p)
|
||||||
|
|
||||||
|
msgs, err := api.ChainGetBlockMessages(ctx, blockheader.Cid())
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("ChainGetBlockMessages failed: %w", msgs)
|
||||||
|
}
|
||||||
|
for _, m := range msgs.BlsMessages {
|
||||||
|
totalGasLimit += m.GasLimit
|
||||||
|
}
|
||||||
|
for _, m := range msgs.SecpkMessages {
|
||||||
|
totalGasLimit += m.Message.GasLimit
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
p = NewPoint("chain.gas_limit_total", totalGasLimit)
|
||||||
|
pl.AddPoint(p)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -286,8 +302,16 @@ func RecordTipsetMessagesPoints(ctx context.Context, api api.FullNode, pl *Point
|
|||||||
|
|
||||||
msgn := make(map[msgTag][]cid.Cid)
|
msgn := make(map[msgTag][]cid.Cid)
|
||||||
|
|
||||||
|
totalGasUsed := int64(0)
|
||||||
|
for _, r := range recp {
|
||||||
|
totalGasUsed += r.GasUsed
|
||||||
|
}
|
||||||
|
p := NewPoint("chain.gas_used_total", totalGasUsed)
|
||||||
|
pl.AddPoint(p)
|
||||||
|
|
||||||
for i, msg := range msgs {
|
for i, msg := range msgs {
|
||||||
// FIXME: use float so this doesn't overflow
|
// FIXME: use float so this doesn't overflow
|
||||||
|
// FIXME: this doesn't work as time points get overriden
|
||||||
p := NewPoint("chain.message_gaspremium", msg.Message.GasPremium.Int64())
|
p := NewPoint("chain.message_gaspremium", msg.Message.GasPremium.Int64())
|
||||||
pl.AddPoint(p)
|
pl.AddPoint(p)
|
||||||
p = NewPoint("chain.message_gasfeecap", msg.Message.GasFeeCap.Int64())
|
p = NewPoint("chain.message_gasfeecap", msg.Message.GasFeeCap.Int64())
|
||||||
|
Loading…
Reference in New Issue
Block a user