From 4dabab5ce649137ee0f240122e1dbbbea1e84182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 15 Sep 2020 13:04:45 +0200 Subject: [PATCH] state manager progress --- api/api_full.go | 9 +- api/apistruct/struct.go | 30 ++--- chain/actors/builtin/miner/miner.go | 6 + chain/actors/builtin/miner/utils.go | 28 +++++ chain/actors/builtin/miner/v0.go | 39 +++++++ chain/stmgr/utils.go | 167 ++++++++++++++-------------- node/impl/full/state.go | 8 +- storage/miner.go | 3 +- 8 files changed, 178 insertions(+), 112 deletions(-) create mode 100644 chain/actors/builtin/miner/utils.go diff --git a/api/api_full.go b/api/api_full.go index 035c7de43..c76b9038c 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -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. // 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. - 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(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 // and returns the deadline-related calculations. StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error) @@ -538,11 +538,6 @@ type Message struct { Message *types.Message } -type ChainSectorInfo struct { - Info miner.SectorOnChainInfo - ID abi.SectorNumber -} - type ActorState struct { Balance types.BigInt State interface{} diff --git a/api/apistruct/struct.go b/api/apistruct/struct.go index 1eac858a0..ea8c311a0 100644 --- a/api/apistruct/struct.go +++ b/api/apistruct/struct.go @@ -161,19 +161,19 @@ type FullNodeStruct struct { ClientDataTransferUpdates func(ctx context.Context) (<-chan api.DataTransferChannel, error) `perm:"write"` ClientRetrieveTryRestartInsufficientFunds func(ctx context.Context, paymentChannel address.Address) error `perm:"write"` - 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"` - StateMinerActiveSectors func(context.Context, address.Address, types.TipSetKey) ([]*api.ChainSectorInfo, 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"` - StateMinerInfo func(context.Context, address.Address, types.TipSetKey) (miner2.MinerInfo, error) `perm:"read"` - StateMinerFaults func(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error) `perm:"read"` - StateAllMinerFaults func(context.Context, abi.ChainEpoch, types.TipSetKey) ([]*api.Fault, error) `perm:"read"` - StateMinerRecoveries func(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error) `perm:"read"` - StateMinerPreCommitDepositForPower func(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error) `perm:"read"` - StateMinerInitialPledgeCollateral func(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error) `perm:"read"` - StateMinerAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"` - StateSectorPreCommitInfo func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) `perm:"read"` + StateNetworkName func(context.Context) (dtypes.NetworkName, 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) ([]*miner2.ChainSectorInfo, 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"` + StateMinerInfo func(context.Context, address.Address, types.TipSetKey) (miner2.MinerInfo, error) `perm:"read"` + StateMinerFaults func(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error) `perm:"read"` + StateAllMinerFaults func(context.Context, abi.ChainEpoch, types.TipSetKey) ([]*api.Fault, error) `perm:"read"` + StateMinerRecoveries func(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error) `perm:"read"` + StateMinerPreCommitDepositForPower func(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error) `perm:"read"` + StateMinerInitialPledgeCollateral func(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error) `perm:"read"` + StateMinerAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"` + StateSectorPreCommitInfo func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) `perm:"read"` StateSectorGetInfo func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error) `perm:"read"` StateSectorExpiration func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*api.SectorExpiration, error) `perm:"read"` StateSectorPartition func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*api.SectorLocation, error) `perm:"read"` @@ -730,11 +730,11 @@ func (c *FullNodeStruct) StateNetworkName(ctx context.Context) (dtypes.NetworkNa 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) } -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) } diff --git a/chain/actors/builtin/miner/miner.go b/chain/actors/builtin/miner/miner.go index eb70d1457..6f3bbe4bb 100644 --- a/chain/actors/builtin/miner/miner.go +++ b/chain/actors/builtin/miner/miner.go @@ -35,6 +35,7 @@ type State interface { GetSector(abi.SectorNumber) (*SectorOnChainInfo, error) GetPrecommittedSector(abi.SectorNumber) (*SectorPreCommitOnChainInfo, error) + LoadSectorsFromSet(filter *bitfield.BitField, filterOut bool) ([]*ChainSectorInfo, error) LoadDeadline(idx uint64) (Deadline, error) ForEachDeadline(cb func(idx uint64, dl Deadline) error) error @@ -71,3 +72,8 @@ type MinerInfo struct { SectorSize abi.SectorSize WindowPoStPartitionSectors uint64 } + +type ChainSectorInfo struct { + Info SectorOnChainInfo + ID abi.SectorNumber +} diff --git a/chain/actors/builtin/miner/utils.go b/chain/actors/builtin/miner/utils.go new file mode 100644 index 000000000..052d2da60 --- /dev/null +++ b/chain/actors/builtin/miner/utils.go @@ -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...) +} \ No newline at end of file diff --git a/chain/actors/builtin/miner/v0.go b/chain/actors/builtin/miner/v0.go index 40b9e4cc6..0fb75795c 100644 --- a/chain/actors/builtin/miner/v0.go +++ b/chain/actors/builtin/miner/v0.go @@ -5,7 +5,11 @@ import ( "github.com/filecoin-project/go-bitfield" "github.com/filecoin-project/go-state-types/abi" "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" + cbg "github.com/whyrusleeping/cbor-gen" + "golang.org/x/xerrors" "github.com/filecoin-project/specs-actors/actors/builtin/miner" ) @@ -43,6 +47,41 @@ func (s *v0State) GetPrecommittedSector(num abi.SectorNumber) (*SectorPreCommitO 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) { dls, err := s.State.LoadDeadlines(s.store) if err != nil { diff --git a/chain/stmgr/utils.go b/chain/stmgr/utils.go index 11eedb512..0217bd91e 100644 --- a/chain/stmgr/utils.go +++ b/chain/stmgr/utils.go @@ -140,60 +140,35 @@ func MinerSectorInfo(ctx context.Context, sm *StateManager, maddr address.Addres 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) { - var mas miner.State - _, err := sm.LoadActorState(ctx, maddr, &mas, ts) +func GetMinerSectorSet(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address, filter *bitfield.BitField, filterOut bool) ([]*miner.ChainSectorInfo, error) { + act, err := sm.LoadActor(ctx, maddr, 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 { 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) { - var partsProving []bitfield.BitField - 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 { - return xerrors.Errorf("getting miner info: %w", err) - } - - deadlines, err := mas.LoadDeadlines(store) - if err != nil { - return xerrors.Errorf("loading deadlines: %w", err) - } - - return deadlines.ForEach(store, func(dlIdx uint64, deadline *miner.Deadline) error { - partitions, err := deadline.PartitionsArray(store) - if err != nil { - return xerrors.Errorf("getting partition array: %w", err) - } - - var partition miner.Partition - 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 - }) - }) - }))) + act, err := sm.LoadActorRaw(ctx, maddr, st) if err != nil { - return nil, err + return nil, xerrors.Errorf("failed to load miner actor: %w", err) } - provingSectors, err := bitfield.MultiMerge(partsProving...) + mas, err := miner.Load(sm.cs.Store(ctx), act) + if err != nil { + return nil, xerrors.Errorf("failed to load miner actor state: %w", err) + } + + // TODO (!!): This was partition.Sectors-partition.Faults originally, which was likely very wrong, and will need to be an upgrade + // ^ THE CURRENT THING HERE WON'T SYNC v + + provingSectors, err := miner.AllPartSectors(mas, miner.Partition.ActiveSectors) if err != nil { 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 } + info, err := mas.Info() + if err != nil { + return nil, xerrors.Errorf("getting miner info: %w", err) + } + spt, err := ffiwrapper.SealProofTypeFromSectorSize(info.SectorSize) if err != nil { 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) } - sectors, err := provingSectors.All(miner.SectorsMax) + sectors, err := mas.LoadSectorsFromSet(&provingSectors, false) if err != nil { - return nil, xerrors.Errorf("failed to enumerate all sector IDs: %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) + return nil, xerrors.Errorf("loading proving sectors: %w", err) } out := make([]proof.SectorInfo, len(ids)) for i, n := range ids { - sid := 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) - } + s := sectors[n] out[i] = proof.SectorInfo{ SealProof: spt, - SectorNumber: sinfo.SectorNumber, - SealedCID: sinfo.SealedCID, + SectorNumber: s.ID, + 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) { - var mas miner.State - _, err := sm.LoadActorStateRaw(ctx, maddr, &mas, ts.ParentState()) + act, err := sm.LoadActor(ctx, maddr, ts) 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) { - var spas power.State - _, err := sm.LoadActorState(ctx, builtin.StoragePowerActorAddr, &spas, ts) + act, err := sm.LoadActor(ctx, builtin.StoragePowerActorAddr, ts) 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) @@ -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) { - var state market.State - if _, err := sm.LoadActorState(ctx, builtin.StorageMarketActorAddr, &state, ts); err != nil { - return nil, err + act, err := sm.LoadActor(ctx, builtin.StorageMarketActorAddr, ts) + if err != nil { + 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) 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) { - var state power.State - if _, err := sm.LoadActorState(ctx, builtin.StoragePowerActorAddr, &state, ts); err != nil { - return nil, err + act, err := sm.LoadActor(ctx, builtin.StoragePowerActorAddr, ts) + if err != nil { + 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) @@ -364,13 +356,13 @@ func ListMinerActors(ctx context.Context, sm *StateManager, ts *types.TipSet) ([ 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) if err != nil { return nil, err } - var sset []*api.ChainSectorInfo + var sset []*miner.ChainSectorInfo var v cbg.Deferred if err := a.ForEach(&v, func(i int64) error { 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 { return err } - sset = append(sset, &api.ChainSectorInfo{ + sset = append(sset, &miner.ChainSectorInfo{ Info: oci, ID: abi.SectorNumber(i), }) @@ -420,7 +412,7 @@ func ComputeState(ctx context.Context, sm *StateManager, height abi.ChainEpoch, NtwkVersion: sm.GetNtwkVersion, BaseFee: ts.Blocks()[0].ParentBaseFee, } - vmi, err := vm.NewVM(vmopt) + vmi, err := vm.NewVM(ctx, vmopt) if err != nil { return cid.Undef, nil, err } @@ -508,9 +500,14 @@ func MinerGetBaseInfo(ctx context.Context, sm *StateManager, bcs beacon.Schedule return nil, err } - var mas miner.State - if _, err := sm.LoadActorStateRaw(ctx, maddr, &mas, lbst); err != nil { - return nil, err + act, err := sm.LoadActorRaw(ctx, maddr, lbst) + if err != nil { + 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) @@ -537,7 +534,7 @@ func MinerGetBaseInfo(ctx context.Context, sm *StateManager, bcs beacon.Schedule 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 { 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) { - var act types.Actor - if err := sm.WithParentState(ts, sm.WithActor(to, GetActor(&act))); err != nil { - return nil, xerrors.Errorf("getting actor: %w", err) + act, err := sm.LoadActor(ctx, to, ts) + if err != nil { + return nil, xerrors.Errorf("(get sset) failed to load miner actor: %w", err) } m, found := MethodsMap[act.Code][method] diff --git a/node/impl/full/state.go b/node/impl/full/state.go index 75f06e636..f61ebea49 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -30,11 +30,11 @@ import ( "github.com/filecoin-project/lotus/api" "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/gen" "github.com/filecoin-project/lotus/chain/state" "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/types" "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()) } -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) if err != nil { 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) } -func (a *StateAPI) StateMinerActiveSectors(ctx context.Context, maddr address.Address, tsk types.TipSetKey) ([]*api.ChainSectorInfo, error) { - var out []*api.ChainSectorInfo +func (a *StateAPI) StateMinerActiveSectors(ctx context.Context, maddr address.Address, tsk types.TipSetKey) ([]*miner.ChainSectorInfo, error) { // TODO: only used in cli + var out []*miner.ChainSectorInfo err := a.StateManager.WithParentStateTsk(tsk, a.StateManager.WithActor(maddr, diff --git a/storage/miner.go b/storage/miner.go index d2af4be2c..47f50ce71 100644 --- a/storage/miner.go +++ b/storage/miner.go @@ -3,6 +3,7 @@ package storage import ( "context" "errors" + miner2 "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "time" "github.com/filecoin-project/go-state-types/dline" @@ -67,7 +68,7 @@ type SealingStateEvt struct { type storageMinerApi interface { // Call a read only method on actors (no interaction with the chain required) 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) 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)