state manager progress
This commit is contained in:
parent
36f920bcd7
commit
4dabab5ce6
@ -315,9 +315,9 @@ type FullNode interface {
|
|||||||
// StateMinerSectors returns info about the given miner's sectors. If the filter bitfield is nil, all sectors are included.
|
// StateMinerSectors returns info about the given miner's sectors. If the filter bitfield is nil, all sectors are included.
|
||||||
// If the filterOut boolean is set to true, any sectors in the filter are excluded.
|
// If the filterOut boolean is set to true, any sectors in the filter are excluded.
|
||||||
// If false, only those sectors in the filter are included.
|
// If false, only those sectors in the filter are included.
|
||||||
StateMinerSectors(context.Context, address.Address, *bitfield.BitField, bool, types.TipSetKey) ([]*ChainSectorInfo, error)
|
StateMinerSectors(context.Context, address.Address, *bitfield.BitField, bool, types.TipSetKey) ([]*miner2.ChainSectorInfo, error)
|
||||||
// StateMinerActiveSectors returns info about sectors that a given miner is actively proving.
|
// StateMinerActiveSectors returns info about sectors that a given miner is actively proving.
|
||||||
StateMinerActiveSectors(context.Context, address.Address, types.TipSetKey) ([]*ChainSectorInfo, error)
|
StateMinerActiveSectors(context.Context, address.Address, types.TipSetKey) ([]*miner2.ChainSectorInfo, error)
|
||||||
// StateMinerProvingDeadline calculates the deadline at some epoch for a proving period
|
// StateMinerProvingDeadline calculates the deadline at some epoch for a proving period
|
||||||
// and returns the deadline-related calculations.
|
// and returns the deadline-related calculations.
|
||||||
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error)
|
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error)
|
||||||
@ -538,11 +538,6 @@ type Message struct {
|
|||||||
Message *types.Message
|
Message *types.Message
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChainSectorInfo struct {
|
|
||||||
Info miner.SectorOnChainInfo
|
|
||||||
ID abi.SectorNumber
|
|
||||||
}
|
|
||||||
|
|
||||||
type ActorState struct {
|
type ActorState struct {
|
||||||
Balance types.BigInt
|
Balance types.BigInt
|
||||||
State interface{}
|
State interface{}
|
||||||
|
@ -162,8 +162,8 @@ type FullNodeStruct struct {
|
|||||||
ClientRetrieveTryRestartInsufficientFunds func(ctx context.Context, paymentChannel address.Address) error `perm:"write"`
|
ClientRetrieveTryRestartInsufficientFunds func(ctx context.Context, paymentChannel address.Address) error `perm:"write"`
|
||||||
|
|
||||||
StateNetworkName func(context.Context) (dtypes.NetworkName, error) `perm:"read"`
|
StateNetworkName func(context.Context) (dtypes.NetworkName, error) `perm:"read"`
|
||||||
StateMinerSectors func(context.Context, address.Address, *bitfield.BitField, bool, types.TipSetKey) ([]*api.ChainSectorInfo, error) `perm:"read"`
|
StateMinerSectors func(context.Context, address.Address, *bitfield.BitField, bool, types.TipSetKey) ([]*miner2.ChainSectorInfo, error) `perm:"read"`
|
||||||
StateMinerActiveSectors func(context.Context, address.Address, types.TipSetKey) ([]*api.ChainSectorInfo, error) `perm:"read"`
|
StateMinerActiveSectors func(context.Context, address.Address, types.TipSetKey) ([]*miner2.ChainSectorInfo, error) `perm:"read"`
|
||||||
StateMinerProvingDeadline func(context.Context, address.Address, types.TipSetKey) (*dline.Info, error) `perm:"read"`
|
StateMinerProvingDeadline func(context.Context, address.Address, types.TipSetKey) (*dline.Info, error) `perm:"read"`
|
||||||
StateMinerPower func(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error) `perm:"read"`
|
StateMinerPower func(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error) `perm:"read"`
|
||||||
StateMinerInfo func(context.Context, address.Address, types.TipSetKey) (miner2.MinerInfo, error) `perm:"read"`
|
StateMinerInfo func(context.Context, address.Address, types.TipSetKey) (miner2.MinerInfo, error) `perm:"read"`
|
||||||
@ -730,11 +730,11 @@ func (c *FullNodeStruct) StateNetworkName(ctx context.Context) (dtypes.NetworkNa
|
|||||||
return c.Internal.StateNetworkName(ctx)
|
return c.Internal.StateNetworkName(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateMinerSectors(ctx context.Context, addr address.Address, filter *bitfield.BitField, filterOut bool, tsk types.TipSetKey) ([]*api.ChainSectorInfo, error) {
|
func (c *FullNodeStruct) StateMinerSectors(ctx context.Context, addr address.Address, filter *bitfield.BitField, filterOut bool, tsk types.TipSetKey) ([]*miner2.ChainSectorInfo, error) {
|
||||||
return c.Internal.StateMinerSectors(ctx, addr, filter, filterOut, tsk)
|
return c.Internal.StateMinerSectors(ctx, addr, filter, filterOut, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateMinerActiveSectors(ctx context.Context, addr address.Address, tsk types.TipSetKey) ([]*api.ChainSectorInfo, error) {
|
func (c *FullNodeStruct) StateMinerActiveSectors(ctx context.Context, addr address.Address, tsk types.TipSetKey) ([]*miner2.ChainSectorInfo, error) {
|
||||||
return c.Internal.StateMinerActiveSectors(ctx, addr, tsk)
|
return c.Internal.StateMinerActiveSectors(ctx, addr, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ type State interface {
|
|||||||
|
|
||||||
GetSector(abi.SectorNumber) (*SectorOnChainInfo, error)
|
GetSector(abi.SectorNumber) (*SectorOnChainInfo, error)
|
||||||
GetPrecommittedSector(abi.SectorNumber) (*SectorPreCommitOnChainInfo, error)
|
GetPrecommittedSector(abi.SectorNumber) (*SectorPreCommitOnChainInfo, error)
|
||||||
|
LoadSectorsFromSet(filter *bitfield.BitField, filterOut bool) ([]*ChainSectorInfo, error)
|
||||||
|
|
||||||
LoadDeadline(idx uint64) (Deadline, error)
|
LoadDeadline(idx uint64) (Deadline, error)
|
||||||
ForEachDeadline(cb func(idx uint64, dl Deadline) error) error
|
ForEachDeadline(cb func(idx uint64, dl Deadline) error) error
|
||||||
@ -71,3 +72,8 @@ type MinerInfo struct {
|
|||||||
SectorSize abi.SectorSize
|
SectorSize abi.SectorSize
|
||||||
WindowPoStPartitionSectors uint64
|
WindowPoStPartitionSectors uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ChainSectorInfo struct {
|
||||||
|
Info SectorOnChainInfo
|
||||||
|
ID abi.SectorNumber
|
||||||
|
}
|
||||||
|
28
chain/actors/builtin/miner/utils.go
Normal file
28
chain/actors/builtin/miner/utils.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package miner
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-bitfield"
|
||||||
|
)
|
||||||
|
|
||||||
|
func AllPartSectors(mas State, sget func(Partition) (bitfield.BitField, error)) (bitfield.BitField, error) {
|
||||||
|
var parts []bitfield.BitField
|
||||||
|
|
||||||
|
err := mas.ForEachDeadline(func(dlidx uint64, dl Deadline) error {
|
||||||
|
return dl.ForEachPartition(func(partidx uint64, part Partition) error {
|
||||||
|
s, err := sget(part)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("getting sector list (dl: %d, part %d): %w", dlidx, partidx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
parts = append(parts, s)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return bitfield.BitField{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return bitfield.MultiMerge(parts...)
|
||||||
|
}
|
@ -5,7 +5,11 @@ import (
|
|||||||
"github.com/filecoin-project/go-bitfield"
|
"github.com/filecoin-project/go-bitfield"
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/adt"
|
"github.com/filecoin-project/lotus/chain/actors/adt"
|
||||||
|
v0adt "github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
|
cbor "github.com/ipfs/go-ipld-cbor"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
)
|
)
|
||||||
@ -43,6 +47,41 @@ func (s *v0State) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitO
|
|||||||
return info, nil
|
return info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *v0State) LoadSectorsFromSet(filter *bitfield.BitField, filterOut bool) ([]*ChainSectorInfo, error) {
|
||||||
|
a, err := v0adt.AsArray(s.store, s.State.Sectors)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var sset []*ChainSectorInfo
|
||||||
|
var v cbg.Deferred
|
||||||
|
if err := a.ForEach(&v, func(i int64) error {
|
||||||
|
if filter != nil {
|
||||||
|
set, err := filter.IsSet(uint64(i))
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("filter check error: %w", err)
|
||||||
|
}
|
||||||
|
if set == filterOut {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var oci miner.SectorOnChainInfo
|
||||||
|
if err := cbor.DecodeInto(v.Raw, &oci); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
sset = append(sset, &ChainSectorInfo{
|
||||||
|
Info: oci,
|
||||||
|
ID: abi.SectorNumber(i),
|
||||||
|
})
|
||||||
|
return nil
|
||||||
|
}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return sset, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *v0State) LoadDeadline(idx uint64) (Deadline, error) {
|
func (s *v0State) LoadDeadline(idx uint64) (Deadline, error) {
|
||||||
dls, err := s.State.LoadDeadlines(s.store)
|
dls, err := s.State.LoadDeadlines(s.store)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -140,60 +140,35 @@ func MinerSectorInfo(ctx context.Context, sm *StateManager, maddr address.Addres
|
|||||||
return mas.GetSector(sid)
|
return mas.GetSector(sid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetMinerSectorSet(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address, filter *bitfield.BitField, filterOut bool) ([]*api.ChainSectorInfo, error) {
|
func GetMinerSectorSet(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address, filter *bitfield.BitField, filterOut bool) ([]*miner.ChainSectorInfo, error) {
|
||||||
var mas miner.State
|
act, err := sm.LoadActor(ctx, maddr, ts)
|
||||||
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("(get sset) failed to load miner actor: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
mas, err := miner.Load(sm.cs.Store(ctx), act)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("(get sset) failed to load miner actor state: %w", err)
|
return nil, xerrors.Errorf("(get sset) failed to load miner actor state: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return LoadSectorsFromSet(ctx, sm.ChainStore().Blockstore(), mas.Sectors, filter, filterOut)
|
return mas.LoadSectorsFromSet(filter, filterOut)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetSectorsForWinningPoSt(ctx context.Context, pv ffiwrapper.Verifier, sm *StateManager, st cid.Cid, maddr address.Address, rand abi.PoStRandomness) ([]proof.SectorInfo, error) {
|
func GetSectorsForWinningPoSt(ctx context.Context, pv ffiwrapper.Verifier, sm *StateManager, st cid.Cid, maddr address.Address, rand abi.PoStRandomness) ([]proof.SectorInfo, error) {
|
||||||
var partsProving []bitfield.BitField
|
act, err := sm.LoadActorRaw(ctx, maddr, st)
|
||||||
var mas *miner.State
|
|
||||||
var info *miner.MinerInfo
|
|
||||||
|
|
||||||
err := sm.WithStateTree(st, sm.WithActor(maddr, sm.WithActorState(ctx, func(store adt.Store, mst *miner.State) error {
|
|
||||||
var err error
|
|
||||||
|
|
||||||
mas = mst
|
|
||||||
|
|
||||||
info, err = mas.GetInfo(store)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("getting miner info: %w", err)
|
return nil, xerrors.Errorf("failed to load miner actor: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
deadlines, err := mas.LoadDeadlines(store)
|
mas, err := miner.Load(sm.cs.Store(ctx), act)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("loading deadlines: %w", err)
|
return nil, xerrors.Errorf("failed to load miner actor state: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return deadlines.ForEach(store, func(dlIdx uint64, deadline *miner.Deadline) error {
|
// TODO (!!): This was partition.Sectors-partition.Faults originally, which was likely very wrong, and will need to be an upgrade
|
||||||
partitions, err := deadline.PartitionsArray(store)
|
// ^ THE CURRENT THING HERE WON'T SYNC v
|
||||||
if err != nil {
|
|
||||||
return xerrors.Errorf("getting partition array: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
var partition miner.Partition
|
provingSectors, err := miner.AllPartSectors(mas, miner.Partition.ActiveSectors)
|
||||||
return partitions.ForEach(&partition, func(partIdx int64) error {
|
|
||||||
p, err := bitfield.SubtractBitField(partition.Sectors, partition.Faults)
|
|
||||||
if err != nil {
|
|
||||||
return xerrors.Errorf("subtract faults from partition sectors: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
partsProving = append(partsProving, p)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
provingSectors, err := bitfield.MultiMerge(partsProving...)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("merge partition proving sets: %w", err)
|
return nil, xerrors.Errorf("merge partition proving sets: %w", err)
|
||||||
}
|
}
|
||||||
@ -208,6 +183,11 @@ func GetSectorsForWinningPoSt(ctx context.Context, pv ffiwrapper.Verifier, sm *S
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
info, err := mas.Info()
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("getting miner info: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
spt, err := ffiwrapper.SealProofTypeFromSectorSize(info.SectorSize)
|
spt, err := ffiwrapper.SealProofTypeFromSectorSize(info.SectorSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("getting seal proof type: %w", err)
|
return nil, xerrors.Errorf("getting seal proof type: %w", err)
|
||||||
@ -228,31 +208,19 @@ func GetSectorsForWinningPoSt(ctx context.Context, pv ffiwrapper.Verifier, sm *S
|
|||||||
return nil, xerrors.Errorf("generating winning post challenges: %w", err)
|
return nil, xerrors.Errorf("generating winning post challenges: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sectors, err := provingSectors.All(miner.SectorsMax)
|
sectors, err := mas.LoadSectorsFromSet(&provingSectors, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("failed to enumerate all sector IDs: %w", err)
|
return nil, xerrors.Errorf("loading proving sectors: %w", err)
|
||||||
}
|
|
||||||
|
|
||||||
sectorAmt, err := adt.AsArray(sm.cs.Store(ctx), mas.Sectors)
|
|
||||||
if err != nil {
|
|
||||||
return nil, xerrors.Errorf("failed to load sectors amt: %w", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out := make([]proof.SectorInfo, len(ids))
|
out := make([]proof.SectorInfo, len(ids))
|
||||||
for i, n := range ids {
|
for i, n := range ids {
|
||||||
sid := sectors[n]
|
s := sectors[n]
|
||||||
|
|
||||||
var sinfo miner.SectorOnChainInfo
|
|
||||||
if found, err := sectorAmt.Get(sid, &sinfo); err != nil {
|
|
||||||
return nil, xerrors.Errorf("failed to get sector %d: %w", sid, err)
|
|
||||||
} else if !found {
|
|
||||||
return nil, xerrors.Errorf("failed to find sector %d", sid)
|
|
||||||
}
|
|
||||||
|
|
||||||
out[i] = proof.SectorInfo{
|
out[i] = proof.SectorInfo{
|
||||||
SealProof: spt,
|
SealProof: spt,
|
||||||
SectorNumber: sinfo.SectorNumber,
|
SectorNumber: s.ID,
|
||||||
SealedCID: sinfo.SealedCID,
|
SealedCID: s.Info.SealedCID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,20 +228,33 @@ func GetSectorsForWinningPoSt(ctx context.Context, pv ffiwrapper.Verifier, sm *S
|
|||||||
}
|
}
|
||||||
|
|
||||||
func StateMinerInfo(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (*miner.MinerInfo, error) {
|
func StateMinerInfo(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (*miner.MinerInfo, error) {
|
||||||
var mas miner.State
|
act, err := sm.LoadActor(ctx, maddr, ts)
|
||||||
_, err := sm.LoadActorStateRaw(ctx, maddr, &mas, ts.ParentState())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("(get ssize) failed to load miner actor state: %w", err)
|
return nil, xerrors.Errorf("failed to load miner actor: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return mas.GetInfo(sm.cs.Store(ctx))
|
mas, err := miner.Load(sm.cs.Store(ctx), act)
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("failed to load miner actor state: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
mi, err := mas.Info()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &mi, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetMinerSlashed(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (bool, error) {
|
func GetMinerSlashed(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (bool, error) {
|
||||||
var spas power.State
|
act, err := sm.LoadActor(ctx, builtin.StoragePowerActorAddr, ts)
|
||||||
_, err := sm.LoadActorState(ctx, builtin.StoragePowerActorAddr, &spas, ts)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, xerrors.Errorf("(get miner slashed) failed to load power actor state")
|
return false, xerrors.Errorf("failed to load power actor: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
spas, err := power.Load(sm.cs.Store(ctx), act)
|
||||||
|
if err != nil {
|
||||||
|
return false, xerrors.Errorf("failed to load power actor state: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
store := sm.cs.Store(ctx)
|
store := sm.cs.Store(ctx)
|
||||||
@ -295,10 +276,16 @@ func GetMinerSlashed(ctx context.Context, sm *StateManager, ts *types.TipSet, ma
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetStorageDeal(ctx context.Context, sm *StateManager, dealID abi.DealID, ts *types.TipSet) (*api.MarketDeal, error) {
|
func GetStorageDeal(ctx context.Context, sm *StateManager, dealID abi.DealID, ts *types.TipSet) (*api.MarketDeal, error) {
|
||||||
var state market.State
|
act, err := sm.LoadActor(ctx, builtin.StorageMarketActorAddr, ts)
|
||||||
if _, err := sm.LoadActorState(ctx, builtin.StorageMarketActorAddr, &state, ts); err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, xerrors.Errorf("failed to load market actor: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state, err := market.Load(sm.cs.Store(ctx), act)
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("failed to load market actor state: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
store := sm.ChainStore().Store(ctx)
|
store := sm.ChainStore().Store(ctx)
|
||||||
|
|
||||||
da, err := adt.AsArray(store, state.Proposals)
|
da, err := adt.AsArray(store, state.Proposals)
|
||||||
@ -338,9 +325,14 @@ func GetStorageDeal(ctx context.Context, sm *StateManager, dealID abi.DealID, ts
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ListMinerActors(ctx context.Context, sm *StateManager, ts *types.TipSet) ([]address.Address, error) {
|
func ListMinerActors(ctx context.Context, sm *StateManager, ts *types.TipSet) ([]address.Address, error) {
|
||||||
var state power.State
|
act, err := sm.LoadActor(ctx, builtin.StoragePowerActorAddr, ts)
|
||||||
if _, err := sm.LoadActorState(ctx, builtin.StoragePowerActorAddr, &state, ts); err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, xerrors.Errorf("failed to load power actor: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
state, err := power.Load(sm.cs.Store(ctx), act)
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("failed to load power actor state: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
m, err := adt.AsMap(sm.cs.Store(ctx), state.Claims)
|
m, err := adt.AsMap(sm.cs.Store(ctx), state.Claims)
|
||||||
@ -364,13 +356,13 @@ func ListMinerActors(ctx context.Context, sm *StateManager, ts *types.TipSet) ([
|
|||||||
return miners, nil
|
return miners, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadSectorsFromSet(ctx context.Context, bs blockstore.Blockstore, ssc cid.Cid, filter *bitfield.BitField, filterOut bool) ([]*api.ChainSectorInfo, error) {
|
func LoadSectorsFromSet(ctx context.Context, bs blockstore.Blockstore, ssc cid.Cid, filter *bitfield.BitField, filterOut bool) ([]*miner.ChainSectorInfo, error) {
|
||||||
a, err := adt.AsArray(store.ActorStore(ctx, bs), ssc)
|
a, err := adt.AsArray(store.ActorStore(ctx, bs), ssc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var sset []*api.ChainSectorInfo
|
var sset []*miner.ChainSectorInfo
|
||||||
var v cbg.Deferred
|
var v cbg.Deferred
|
||||||
if err := a.ForEach(&v, func(i int64) error {
|
if err := a.ForEach(&v, func(i int64) error {
|
||||||
if filter != nil {
|
if filter != nil {
|
||||||
@ -387,7 +379,7 @@ func LoadSectorsFromSet(ctx context.Context, bs blockstore.Blockstore, ssc cid.C
|
|||||||
if err := cbor.DecodeInto(v.Raw, &oci); err != nil {
|
if err := cbor.DecodeInto(v.Raw, &oci); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
sset = append(sset, &api.ChainSectorInfo{
|
sset = append(sset, &miner.ChainSectorInfo{
|
||||||
Info: oci,
|
Info: oci,
|
||||||
ID: abi.SectorNumber(i),
|
ID: abi.SectorNumber(i),
|
||||||
})
|
})
|
||||||
@ -420,7 +412,7 @@ func ComputeState(ctx context.Context, sm *StateManager, height abi.ChainEpoch,
|
|||||||
NtwkVersion: sm.GetNtwkVersion,
|
NtwkVersion: sm.GetNtwkVersion,
|
||||||
BaseFee: ts.Blocks()[0].ParentBaseFee,
|
BaseFee: ts.Blocks()[0].ParentBaseFee,
|
||||||
}
|
}
|
||||||
vmi, err := vm.NewVM(vmopt)
|
vmi, err := vm.NewVM(ctx, vmopt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, nil, err
|
return cid.Undef, nil, err
|
||||||
}
|
}
|
||||||
@ -508,9 +500,14 @@ func MinerGetBaseInfo(ctx context.Context, sm *StateManager, bcs beacon.Schedule
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var mas miner.State
|
act, err := sm.LoadActorRaw(ctx, maddr, lbst)
|
||||||
if _, err := sm.LoadActorStateRaw(ctx, maddr, &mas, lbst); err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, xerrors.Errorf("failed to load miner actor: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
mas, err := miner.Load(sm.cs.Store(ctx), act)
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("failed to load miner actor state: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
@ -537,7 +534,7 @@ func MinerGetBaseInfo(ctx context.Context, sm *StateManager, bcs beacon.Schedule
|
|||||||
return nil, xerrors.Errorf("failed to get power: %w", err)
|
return nil, xerrors.Errorf("failed to get power: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
info, err := mas.GetInfo(sm.cs.Store(ctx))
|
info, err := mas.Info()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -652,9 +649,9 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetReturnType(ctx context.Context, sm *StateManager, to address.Address, method abi.MethodNum, ts *types.TipSet) (cbg.CBORUnmarshaler, error) {
|
func GetReturnType(ctx context.Context, sm *StateManager, to address.Address, method abi.MethodNum, ts *types.TipSet) (cbg.CBORUnmarshaler, error) {
|
||||||
var act types.Actor
|
act, err := sm.LoadActor(ctx, to, ts)
|
||||||
if err := sm.WithParentState(ts, sm.WithActor(to, GetActor(&act))); err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("getting actor: %w", err)
|
return nil, xerrors.Errorf("(get sset) failed to load miner actor: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
m, found := MethodsMap[act.Code][method]
|
m, found := MethodsMap[act.Code][method]
|
||||||
|
@ -30,11 +30,11 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||||
"github.com/filecoin-project/lotus/chain/beacon"
|
"github.com/filecoin-project/lotus/chain/beacon"
|
||||||
"github.com/filecoin-project/lotus/chain/gen"
|
"github.com/filecoin-project/lotus/chain/gen"
|
||||||
"github.com/filecoin-project/lotus/chain/state"
|
"github.com/filecoin-project/lotus/chain/state"
|
||||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
|
||||||
"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/lotus/chain/vm"
|
"github.com/filecoin-project/lotus/chain/vm"
|
||||||
@ -62,7 +62,7 @@ func (a *StateAPI) StateNetworkName(ctx context.Context) (dtypes.NetworkName, er
|
|||||||
return stmgr.GetNetworkName(ctx, a.StateManager, a.Chain.GetHeaviestTipSet().ParentState())
|
return stmgr.GetNetworkName(ctx, a.StateManager, a.Chain.GetHeaviestTipSet().ParentState())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *StateAPI) StateMinerSectors(ctx context.Context, addr address.Address, filter *bitfield.BitField, filterOut bool, tsk types.TipSetKey) ([]*api.ChainSectorInfo, error) {
|
func (a *StateAPI) StateMinerSectors(ctx context.Context, addr address.Address, filter *bitfield.BitField, filterOut bool, tsk types.TipSetKey) ([]*miner.ChainSectorInfo, error) {
|
||||||
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||||
@ -70,8 +70,8 @@ func (a *StateAPI) StateMinerSectors(ctx context.Context, addr address.Address,
|
|||||||
return stmgr.GetMinerSectorSet(ctx, a.StateManager, ts, addr, filter, filterOut)
|
return stmgr.GetMinerSectorSet(ctx, a.StateManager, ts, addr, filter, filterOut)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *StateAPI) StateMinerActiveSectors(ctx context.Context, maddr address.Address, tsk types.TipSetKey) ([]*api.ChainSectorInfo, error) {
|
func (a *StateAPI) StateMinerActiveSectors(ctx context.Context, maddr address.Address, tsk types.TipSetKey) ([]*miner.ChainSectorInfo, error) { // TODO: only used in cli
|
||||||
var out []*api.ChainSectorInfo
|
var out []*miner.ChainSectorInfo
|
||||||
|
|
||||||
err := a.StateManager.WithParentStateTsk(tsk,
|
err := a.StateManager.WithParentStateTsk(tsk,
|
||||||
a.StateManager.WithActor(maddr,
|
a.StateManager.WithActor(maddr,
|
||||||
|
@ -3,6 +3,7 @@ package storage
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
miner2 "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/dline"
|
"github.com/filecoin-project/go-state-types/dline"
|
||||||
@ -67,7 +68,7 @@ type SealingStateEvt struct {
|
|||||||
type storageMinerApi interface {
|
type storageMinerApi interface {
|
||||||
// Call a read only method on actors (no interaction with the chain required)
|
// Call a read only method on actors (no interaction with the chain required)
|
||||||
StateCall(context.Context, *types.Message, types.TipSetKey) (*api.InvocResult, error)
|
StateCall(context.Context, *types.Message, types.TipSetKey) (*api.InvocResult, error)
|
||||||
StateMinerSectors(context.Context, address.Address, *bitfield.BitField, bool, types.TipSetKey) ([]*api.ChainSectorInfo, error)
|
StateMinerSectors(context.Context, address.Address, *bitfield.BitField, bool, types.TipSetKey) ([]*miner2.ChainSectorInfo, error)
|
||||||
StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error)
|
StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error)
|
||||||
StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error)
|
StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error)
|
||||||
StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*api.SectorLocation, error)
|
StateSectorPartition(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tok types.TipSetKey) (*api.SectorLocation, error)
|
||||||
|
Loading…
Reference in New Issue
Block a user