Fix StateMinerProvingSet

This commit is contained in:
Łukasz Magiera 2020-07-17 16:21:00 +02:00
parent 0a471bb12c
commit bbc2657023
4 changed files with 47 additions and 19 deletions

View File

@ -437,11 +437,8 @@ func (cg *ChainGen) makeBlock(parents *types.TipSet, m address.Address, vrfticke
// ResyncBankerNonce is used for dealing with messages made when
// simulating forks
func (cg *ChainGen) ResyncBankerNonce(ts *types.TipSet) error {
var act *types.Actor
err := cg.sm.WithParentState(ts, cg.sm.WithActor(cg.banker, func(a *types.Actor) error {
act = a
return nil
}))
var act types.Actor
err := cg.sm.WithParentState(ts, cg.sm.WithActor(cg.banker, stmgr.GetActor(&act)))
if err != nil {
return err
}

View File

@ -246,19 +246,19 @@ var stateProvingSetCmd = &cli.Command{
Usage: "Query the proving set of a miner",
ArgsUsage: "[minerAddress]",
Action: func(cctx *cli.Context) error {
/*api, closer, err := GetFullNodeAPI(cctx)
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
return err
}
defer closer()
ctx := ReqContext(cctx)*/
ctx := ReqContext(cctx)
if !cctx.Args().Present() {
return fmt.Errorf("must specify miner to list sectors for")
}
/*maddr, err := address.NewFromString(cctx.Args().First())
maddr, err := address.NewFromString(cctx.Args().First())
if err != nil {
return err
}
@ -267,17 +267,15 @@ var stateProvingSetCmd = &cli.Command{
if err != nil {
return err
}
*/
// TODO: Fix me
/*sectors, err := api.StateMinerProvingSet(ctx, maddr, ts.Key())
sectors, err := api.StateMinerProvingSet(ctx, maddr, ts.Key())
if err != nil {
return err
}
for _, s := range sectors {
fmt.Printf("%d: %x\n", s.Info.SectorNumber, s.Info.SealedCID)
}*/
}
return nil
},

View File

@ -138,20 +138,20 @@ var sectorsListCmd = &cli.Command{
return err
}
/*pset, err := fullApi.StateMinerProvingSet(ctx, maddr, types.EmptyTSK)
pset, err := fullApi.StateMinerProvingSet(ctx, maddr, types.EmptyTSK)
if err != nil {
return err
}
provingIDs := make(map[abi.SectorNumber]struct{}, len(pset))
for _, info := range pset {
provingIDs[info.ID] = struct{}{}
}*/
}
sset, err := fullApi.StateMinerSectors(ctx, maddr, nil, true, types.EmptyTSK)
if err != nil {
return err
}
commitedIDs := make(map[abi.SectorNumber]struct{}, 0) //, len(pset))
commitedIDs := make(map[abi.SectorNumber]struct{}, len(pset))
for _, info := range sset {
commitedIDs[info.ID] = struct{}{}
}
@ -170,7 +170,7 @@ var sectorsListCmd = &cli.Command{
}
_, inSSet := commitedIDs[s]
inPSet := true //_, inPSet := provingIDs[s] // TODO: Fix maaaybe
_, inPSet := provingIDs[s]
fmt.Fprintf(w, "%d: %s\tsSet: %s\tpSet: %s\ttktH: %d\tseedH: %d\tdeals: %v\n",
s,

View File

@ -70,9 +70,42 @@ func (a *StateAPI) StateMinerSectors(ctx context.Context, addr address.Address,
return stmgr.GetMinerSectorSet(ctx, a.StateManager, ts, addr, filter, filterOut)
}
func (a *StateAPI) StateMinerProvingSet(ctx context.Context, addr address.Address, tsk types.TipSetKey) ([]*api.ChainSectorInfo, error) {
// TODO
return nil, xerrors.Errorf("TODO FIXME")
func (a *StateAPI) StateMinerProvingSet(ctx context.Context, maddr address.Address, tsk types.TipSetKey) ([]*api.ChainSectorInfo, error) {
var out []*api.ChainSectorInfo
err := a.StateManager.WithParentStateTsk(tsk,
a.StateManager.WithActor(maddr,
a.StateManager.WithActorState(ctx, func(store adt.Store, mas *miner.State) error {
var allActive []*abi.BitField
err := a.StateManager.WithDeadlines(
a.StateManager.WithEachDeadline(
a.StateManager.WithEachPartition(func(store adt.Store, partIdx uint64, partition *miner.Partition) error {
active, err := partition.ActiveSectors()
if err != nil {
return xerrors.Errorf("partition.ActiveSectors: %w", err)
}
allActive = append(allActive, active)
return nil
})))(store, mas)
if err != nil {
return xerrors.Errorf("with deadlines: %w", err)
}
active, err := bitfield.MultiMerge(allActive...)
if err != nil {
return xerrors.Errorf("merging active sector bitfields: %w", err)
}
out, err = stmgr.LoadSectorsFromSet(ctx, a.Chain.Blockstore(), mas.Sectors, active, false)
return err
})))
if err != nil {
return nil, xerrors.Errorf("getting active sectors from partitions: %w", err)
}
return out, nil
}
func (a *StateAPI) StateMinerInfo(ctx context.Context, actor address.Address, tsk types.TipSetKey) (api.MinerInfo, error) {