Incremental progress towards using new power state interface
This commit is contained in:
parent
90853e24cf
commit
72d19f369b
@ -17,7 +17,6 @@ import (
|
|||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
"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"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
@ -129,7 +128,7 @@ func infoCmdAct(cctx *cli.Context) error {
|
|||||||
faultyPercentage)
|
faultyPercentage)
|
||||||
}
|
}
|
||||||
|
|
||||||
if pow.MinerPower.RawBytePower.LessThan(power.ConsensusMinerMinPower) {
|
if !pow.HasMinPower {
|
||||||
fmt.Print("Below minimum power threshold, no blocks will be won")
|
fmt.Print("Below minimum power threshold, no blocks will be won")
|
||||||
} else {
|
} else {
|
||||||
expWinChance := float64(types.BigMul(qpercI, types.NewInt(build.BlocksPerEpoch)).Int64()) / 1000000
|
expWinChance := float64(types.BigMul(qpercI, types.NewInt(build.BlocksPerEpoch)).Int64()) / 1000000
|
||||||
|
@ -34,7 +34,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/market"
|
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||||
miner2 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
miner2 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
v0power "github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||||
|
|
||||||
lapi "github.com/filecoin-project/lotus/api"
|
lapi "github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
@ -633,7 +633,7 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
|
|||||||
return address.Undef, err
|
return address.Undef, err
|
||||||
}
|
}
|
||||||
|
|
||||||
params, err := actors.SerializeParams(&power.CreateMinerParams{
|
params, err := actors.SerializeParams(&v0power.CreateMinerParams{
|
||||||
Owner: owner,
|
Owner: owner,
|
||||||
Worker: worker,
|
Worker: worker,
|
||||||
SealProofType: spt,
|
SealProofType: spt,
|
||||||
@ -681,7 +681,7 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
|
|||||||
return address.Undef, xerrors.Errorf("create miner failed: exit code %d", mw.Receipt.ExitCode)
|
return address.Undef, xerrors.Errorf("create miner failed: exit code %d", mw.Receipt.ExitCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
var retval power.CreateMinerReturn
|
var retval v0power.CreateMinerReturn
|
||||||
if err := retval.UnmarshalCBOR(bytes.NewReader(mw.Receipt.Return)); err != nil {
|
if err := retval.UnmarshalCBOR(bytes.NewReader(mw.Receipt.Return)); err != nil {
|
||||||
return address.Undef, err
|
return address.Undef, err
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-state-types/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
"github.com/filecoin-project/lotus/lib/lotuslog"
|
"github.com/filecoin-project/lotus/lib/lotuslog"
|
||||||
saminer "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
saminer "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
v0power "github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ import (
|
|||||||
func init() {
|
func init() {
|
||||||
_ = logging.SetLogLevel("*", "INFO")
|
_ = logging.SetLogLevel("*", "INFO")
|
||||||
|
|
||||||
power.ConsensusMinerMinPower = big.NewInt(2048)
|
v0power.ConsensusMinerMinPower = big.NewInt(2048)
|
||||||
saminer.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
|
saminer.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
|
||||||
abi.RegisteredSealProof_StackedDrg2KiBV1: {},
|
abi.RegisteredSealProof_StackedDrg2KiBV1: {},
|
||||||
}
|
}
|
||||||
|
@ -10,14 +10,11 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/store"
|
"github.com/filecoin-project/lotus/chain/store"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"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/util/adt"
|
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
@ -255,55 +252,22 @@ func RecordTipsetStatePoints(ctx context.Context, api api.FullNode, pl *PointLis
|
|||||||
p := NewPoint("network.balance", netBalFilFloat)
|
p := NewPoint("network.balance", netBalFilFloat)
|
||||||
pl.AddPoint(p)
|
pl.AddPoint(p)
|
||||||
|
|
||||||
totalPower, err := api.StateMinerPower(ctx, address.Address{}, tipset.Key())
|
miners, err := api.StateListMiners(ctx, tipset.Key())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
p = NewPoint("chain.power", totalPower.TotalPower.QualityAdjPower.Int64())
|
for _, addr := range miners {
|
||||||
pl.AddPoint(p)
|
mp, err := api.StateMinerPower(ctx, addr, tipset.Key())
|
||||||
|
|
||||||
powerActor, err := api.StateGetActor(ctx, builtin.StoragePowerActorAddr, tipset.Key())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
powerRaw, err := api.ChainReadObj(ctx, powerActor.Head)
|
if !mp.MinerPower.QualityAdjPower.IsZero() {
|
||||||
if err != nil {
|
p = NewPoint("chain.miner_power", mp.MinerPower.QualityAdjPower.Int64())
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
var powerActorState power.State
|
|
||||||
|
|
||||||
if err := powerActorState.UnmarshalCBOR(bytes.NewReader(powerRaw)); err != nil {
|
|
||||||
return fmt.Errorf("failed to unmarshal power actor state: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
s := &apiIpldStore{ctx, api}
|
|
||||||
mp, err := adt.AsMap(s, powerActorState.Claims)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
var claim power.Claim
|
|
||||||
err = mp.ForEach(&claim, func(key string) error {
|
|
||||||
addr, err := address.NewFromBytes([]byte(key))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if claim.QualityAdjPower.Int64() == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
p = NewPoint("chain.miner_power", claim.QualityAdjPower.Int64())
|
|
||||||
p.AddTag("miner", addr.String())
|
p.AddTag("miner", addr.String())
|
||||||
pl.AddPoint(p)
|
pl.AddPoint(p)
|
||||||
|
}
|
||||||
return nil
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user