Skip to content

Commit

Permalink
feat: add chain api StateMinerAllocated (#5325)
Browse files Browse the repository at this point in the history
  • Loading branch information
simlecode committed Oct 21, 2022
1 parent 8cf958f commit 56b5ef9
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/submodule/chain/miner_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1080,3 +1080,21 @@ func (msa *minerStateAPI) StateListMessages(ctx context.Context, match *types.Me

return out, nil
}

// StateMinerAllocated returns a bitfield containing all sector numbers marked as allocated in miner state
func (msa *minerStateAPI) StateMinerAllocated(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*bitfield.BitField, error) {
_, view, err := msa.Stmgr.ParentStateViewTsk(ctx, tsk)
if err != nil {
return nil, fmt.Errorf("loading tipset:%s parent state view: %v", tsk, err)
}

act, err := view.LoadActor(ctx, addr)
if err != nil {
return nil, err
}
mas, err := lminer.Load(msa.ChainReader.Store(ctx), act)
if err != nil {
return nil, err
}
return mas.GetAllocatedSectors()
}
2 changes: 2 additions & 0 deletions venus-shared/api/chain/v1/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,6 @@ type IMinerState interface {
StateMarketBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (types.MarketBalance, error) //perm:read
StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk types.TipSetKey) (types.DealCollateralBounds, error) //perm:read
StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, 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) //perm:read
}
29 changes: 29 additions & 0 deletions venus-shared/api/chain/v1/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
* [StateMarketDeals](#StateMarketDeals)
* [StateMarketStorageDeal](#StateMarketStorageDeal)
* [StateMinerActiveSectors](#StateMinerActiveSectors)
* [StateMinerAllocated](#StateMinerAllocated)
* [StateMinerAvailableBalance](#StateMinerAvailableBalance)
* [StateMinerDeadlines](#StateMinerDeadlines)
* [StateMinerFaults](#StateMinerFaults)
Expand Down Expand Up @@ -3313,6 +3314,34 @@ Response:
]
```

### StateMinerAllocated
StateMinerAllocated returns a bitfield containing all sector numbers marked as allocated in miner state


Perms: read

Inputs:
```json
[
"f01234",
[
{
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
{
"/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve"
}
]
]
```

Response:
```json
[
0
]
```

### StateMinerAvailableBalance


Expand Down
15 changes: 15 additions & 0 deletions venus-shared/api/chain/v1/mock/mock_fullnode.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions venus-shared/api/chain/v1/proxy_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions venus-shared/compatible-checks/api-diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v1.FullNode <> github.c
+ StateActorManifestCID
- StateCompute
> StateGetNetworkParams {[func(context.Context) (*types.NetworkParams, error) <> func(context.Context) (*api.NetworkParams, error)] base=func out type: #0 input; nested={[*types.NetworkParams <> *api.NetworkParams] base=pointed type; nested={[types.NetworkParams <> api.NetworkParams] base=struct field; nested={[types.NetworkParams <> api.NetworkParams] base=exported field type: #5 field named ForkUpgradeParams; nested={[types.ForkUpgradeParams <> api.ForkUpgradeParams] base=struct field; nested={[types.ForkUpgradeParams <> api.ForkUpgradeParams] base=exported field name: #8 field, BreezeGasTampingDuration != UpgradePriceListOopsHeight; nested=nil}}}}}}
+ StateMinerAllocated
+ StateMinerSectorSize
+ StateMinerWorkerAddress
- StateReplay
Expand Down
1 change: 1 addition & 0 deletions venus-shared/compatible-checks/api-perm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ v1: github.com/filecoin-project/venus/venus-shared/api/chain/v1 <> github.com/fi
- IChainInfo.ResolveToKeyAddr
- IChainInfo.StateActorManifestCID
- IChainInfo.VerifyEntry
- IMinerState.StateMinerAllocated
- IMinerState.StateMinerSectorSize
- IMinerState.StateMinerWorkerAddress
- IMessagePool.GasBatchEstimateMessageGas
Expand Down

0 comments on commit 56b5ef9

Please sign in to comment.