Skip to content

Commit

Permalink
Merge pull request #6290 from filecoin-project/asr/power-state
Browse files Browse the repository at this point in the history
Add a shed util to count 64 GiB miner stats
  • Loading branch information
arajasek authored May 19, 2021
2 parents 081a2ed + fc7ea8d commit 20a0d32
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions cmd/lotus-shed/miner-types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import (
"context"
"fmt"
"io"
"math/big"

big2 "github.com/filecoin-project/go-state-types/big"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
"github.com/filecoin-project/lotus/chain/state"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
Expand Down Expand Up @@ -84,6 +88,21 @@ var minerTypesCmd = &cli.Command{
}

typeMap := make(map[abi.RegisteredPoStProof]int64)
pa, err := tree.GetActor(power.Address)
if err != nil {
return err
}

ps, err := power.Load(store, pa)
if err != nil {
return err
}

dc := 0
dz := power.Claim{
RawBytePower: abi.NewStoragePower(0),
QualityAdjPower: abi.NewStoragePower(0),
}

err = tree.ForEach(func(addr address.Address, act *types.Actor) error {
if act.Code == builtin4.StorageMinerActorCodeID {
Expand All @@ -97,8 +116,17 @@ var minerTypesCmd = &cli.Command{
return err
}

if mi.WindowPoStProofType < abi.RegisteredPoStProof_StackedDrgWindow32GiBV1 {
fmt.Println(addr)
if mi.WindowPoStProofType == abi.RegisteredPoStProof_StackedDrgWindow64GiBV1 {
mp, f, err := ps.MinerPower(addr)
if err != nil {
return err
}

if f && mp.RawBytePower.Cmp(big.NewInt(10<<40)) >= 0 && mp.RawBytePower.Cmp(big.NewInt(20<<40)) < 0 {
dc = dc + 1
dz.RawBytePower = big2.Add(dz.RawBytePower, mp.RawBytePower)
dz.QualityAdjPower = big2.Add(dz.QualityAdjPower, mp.QualityAdjPower)
}
}

c, f := typeMap[mi.WindowPoStProofType]
Expand All @@ -118,6 +146,9 @@ var minerTypesCmd = &cli.Command{
fmt.Println("Type:", k, " Count: ", v)
}

fmt.Println("Mismatched power (raw, QA): ", dz.RawBytePower, " ", dz.QualityAdjPower)
fmt.Println("Mismatched 64 GiB miner count: ", dc)

return nil
},
}

0 comments on commit 20a0d32

Please sign in to comment.