Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add chain api StateMinerAllocated #5325

Merged
merged 1 commit into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -3312,6 +3313,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 @@ -202,6 +202,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