sealing: numassign: take on-chain allocated numbers into account
This commit is contained in:
parent
ef2080a800
commit
00bef607ca
@ -540,6 +540,8 @@ type FullNode interface {
|
||||
StateChangedActors(context.Context, cid.Cid, cid.Cid) (map[string]types.Actor, error) //perm:read
|
||||
// StateMinerSectorCount returns the number of sectors in a miner's sector set and proving set
|
||||
StateMinerSectorCount(context.Context, address.Address, types.TipSetKey) (MinerSectors, error) //perm:read
|
||||
// StateMinerAllocated returns a bitfield containing all sector numbers marked as allocated in miner state
|
||||
StateMinerAllocated(context.Context, address.Address, types.TipSetKey) (*bitfield.BitField, error)
|
||||
// StateCompute is a flexible command that applies the given messages on the given tipset.
|
||||
// The messages are run as though the VM were at the provided height.
|
||||
//
|
||||
|
@ -2662,6 +2662,21 @@ func (mr *MockFullNodeMockRecorder) StateMinerActiveSectors(arg0, arg1, arg2 int
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateMinerActiveSectors", reflect.TypeOf((*MockFullNode)(nil).StateMinerActiveSectors), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// StateMinerAllocated mocks base method.
|
||||
func (m *MockFullNode) StateMinerAllocated(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (*bitfield.BitField, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "StateMinerAllocated", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(*bitfield.BitField)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// StateMinerAllocated indicates an expected call of StateMinerAllocated.
|
||||
func (mr *MockFullNodeMockRecorder) StateMinerAllocated(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateMinerAllocated", reflect.TypeOf((*MockFullNode)(nil).StateMinerAllocated), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// StateMinerAvailableBalance mocks base method.
|
||||
func (m *MockFullNode) StateMinerAvailableBalance(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (big.Int, error) {
|
||||
m.ctrl.T.Helper()
|
||||
|
@ -391,6 +391,8 @@ type FullNodeStruct struct {
|
||||
|
||||
StateMinerActiveSectors func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) ([]*miner.SectorOnChainInfo, error) `perm:"read"`
|
||||
|
||||
StateMinerAllocated func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*bitfield.BitField, error) ``
|
||||
|
||||
StateMinerAvailableBalance func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
||||
|
||||
StateMinerDeadlines func(p0 context.Context, p1 address.Address, p2 types.TipSetKey) ([]Deadline, error) `perm:"read"`
|
||||
@ -2719,6 +2721,17 @@ func (s *FullNodeStub) StateMinerActiveSectors(p0 context.Context, p1 address.Ad
|
||||
return *new([]*miner.SectorOnChainInfo), ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) StateMinerAllocated(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*bitfield.BitField, error) {
|
||||
if s.Internal.StateMinerAllocated == nil {
|
||||
return nil, ErrNotSupported
|
||||
}
|
||||
return s.Internal.StateMinerAllocated(p0, p1, p2)
|
||||
}
|
||||
|
||||
func (s *FullNodeStub) StateMinerAllocated(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (*bitfield.BitField, error) {
|
||||
return nil, ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) StateMinerAvailableBalance(p0 context.Context, p1 address.Address, p2 types.TipSetKey) (types.BigInt, error) {
|
||||
if s.Internal.StateMinerAvailableBalance == nil {
|
||||
return *new(types.BigInt), ErrNotSupported
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -191,6 +191,7 @@
|
||||
* [StateMarketParticipants](#StateMarketParticipants)
|
||||
* [StateMarketStorageDeal](#StateMarketStorageDeal)
|
||||
* [StateMinerActiveSectors](#StateMinerActiveSectors)
|
||||
* [StateMinerAllocated](#StateMinerAllocated)
|
||||
* [StateMinerAvailableBalance](#StateMinerAvailableBalance)
|
||||
* [StateMinerDeadlines](#StateMinerDeadlines)
|
||||
* [StateMinerFaults](#StateMinerFaults)
|
||||
@ -6154,6 +6155,34 @@ Response:
|
||||
]
|
||||
```
|
||||
|
||||
### StateMinerAllocated
|
||||
StateMinerAllocated returns a bitfield containing all sector numbers marked as allocated in miner state
|
||||
|
||||
|
||||
Perms:
|
||||
|
||||
Inputs:
|
||||
```json
|
||||
[
|
||||
"f01234",
|
||||
[
|
||||
{
|
||||
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
|
||||
},
|
||||
{
|
||||
"/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve"
|
||||
}
|
||||
]
|
||||
]
|
||||
```
|
||||
|
||||
Response:
|
||||
```json
|
||||
[
|
||||
0
|
||||
]
|
||||
```
|
||||
|
||||
### StateMinerAvailableBalance
|
||||
StateMinerAvailableBalance returns the portion of a miner's balance that can be withdrawn or spent
|
||||
|
||||
|
@ -880,6 +880,18 @@ func (a *StateAPI) StateMinerSectorCount(ctx context.Context, addr address.Addre
|
||||
return api.MinerSectors{Live: liveCount, Active: activeCount, Faulty: faultyCount}, nil
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateMinerAllocated(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*bitfield.BitField, error) {
|
||||
act, err := a.StateManager.LoadActorTsk(ctx, addr, tsk)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mas, err := miner.Load(a.Chain.ActorStore(ctx), act)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return mas.GetAllocatedSectors()
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
ts, err := a.Chain.GetTipSetFromKey(ctx, tsk)
|
||||
if err != nil {
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
cid "github.com/ipfs/go-cid"
|
||||
|
||||
address "github.com/filecoin-project/go-address"
|
||||
bitfield "github.com/filecoin-project/go-bitfield"
|
||||
abi "github.com/filecoin-project/go-state-types/abi"
|
||||
big "github.com/filecoin-project/go-state-types/big"
|
||||
miner "github.com/filecoin-project/go-state-types/builtin/v8/miner"
|
||||
@ -197,6 +198,21 @@ func (mr *MockSealingAPIMockRecorder) StateMarketStorageDeal(arg0, arg1, arg2 in
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateMarketStorageDeal", reflect.TypeOf((*MockSealingAPI)(nil).StateMarketStorageDeal), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// StateMinerAllocated mocks base method.
|
||||
func (m *MockSealingAPI) StateMinerAllocated(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (*bitfield.BitField, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "StateMinerAllocated", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(*bitfield.BitField)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// StateMinerAllocated indicates an expected call of StateMinerAllocated.
|
||||
func (mr *MockSealingAPIMockRecorder) StateMinerAllocated(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StateMinerAllocated", reflect.TypeOf((*MockSealingAPI)(nil).StateMinerAllocated), arg0, arg1, arg2)
|
||||
}
|
||||
|
||||
// StateMinerAvailableBalance mocks base method.
|
||||
func (m *MockSealingAPI) StateMinerAvailableBalance(arg0 context.Context, arg1 address.Address, arg2 types.TipSetKey) (big.Int, error) {
|
||||
m.ctrl.T.Helper()
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
|
||||
var StorageCounterDSPrefix = "/storage/nextid"
|
||||
@ -135,6 +136,15 @@ func (m *Sealing) numAssignerMetaLocked(ctx context.Context) (api.NumAssignerMet
|
||||
return api.NumAssignerMeta{}, xerrors.Errorf("merge reserved/allocated: %w", err)
|
||||
}
|
||||
|
||||
stateAllocated, err := m.Api.StateMinerAllocated(ctx, m.maddr, types.EmptyTSK)
|
||||
if err != nil || stateAllocated == nil {
|
||||
return api.NumAssignerMeta{}, xerrors.Errorf("getting state-allocated sector numbers: %w", err)
|
||||
}
|
||||
inuse, err = bitfield.MergeBitFields(inuse, *stateAllocated)
|
||||
if err != nil {
|
||||
return api.NumAssignerMeta{}, xerrors.Errorf("merge inuse/stateAllocated: %w", err)
|
||||
}
|
||||
|
||||
// find first available sector number
|
||||
iri, err := inuse.RunIterator()
|
||||
if err != nil {
|
||||
@ -160,6 +170,7 @@ func (m *Sealing) numAssignerMetaLocked(ctx context.Context) (api.NumAssignerMet
|
||||
}, nil
|
||||
}
|
||||
|
||||
// NumReservations returns a list of named sector reservations
|
||||
func (m *Sealing) NumReservations(ctx context.Context) (map[string]bitfield.BitField, error) {
|
||||
res, err := m.ds.Query(ctx, dsq.Query{Prefix: SectorReservationsDSPrefix})
|
||||
if err != nil {
|
||||
@ -190,6 +201,7 @@ func (m *Sealing) NumReservations(ctx context.Context) (map[string]bitfield.BitF
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// NumReserve creates a new sector reservation
|
||||
func (m *Sealing) NumReserve(ctx context.Context, name string, reserving bitfield.BitField, force bool) error {
|
||||
m.sclk.Lock()
|
||||
defer m.sclk.Unlock()
|
||||
@ -280,6 +292,7 @@ func (m *Sealing) NumReserve(ctx context.Context, name string, reserving bitfiel
|
||||
return nil
|
||||
}
|
||||
|
||||
// NumFree removes a named sector reservation
|
||||
func (m *Sealing) NumFree(ctx context.Context, name string) error {
|
||||
rk, err := reservationKey(name)
|
||||
if err != nil {
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-bitfield"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
"github.com/filecoin-project/go-state-types/builtin/v8/miner"
|
||||
@ -67,6 +68,7 @@ type SealingAPI interface {
|
||||
StateGetRandomnessFromBeacon(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error)
|
||||
StateGetRandomnessFromTickets(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error)
|
||||
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
|
||||
StateMinerAllocated(context.Context, address.Address, types.TipSetKey) (*bitfield.BitField, error)
|
||||
|
||||
// Address selector
|
||||
WalletBalance(context.Context, address.Address) (types.BigInt, error)
|
||||
|
Loading…
Reference in New Issue
Block a user