Skip to content

Commit

Permalink
Merge pull request #6013 from filecoin-project/fix/more-chain-api
Browse files Browse the repository at this point in the history
fix: more chain api
  • Loading branch information
diwufeiwen authored Jun 12, 2023
2 parents 3aa830e + 7f5e847 commit 8da2ced
Show file tree
Hide file tree
Showing 5 changed files with 364 additions and 12 deletions.
23 changes: 18 additions & 5 deletions venus-shared/api/chain/v0/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,19 @@ type IChainInfo interface {
// Messages in the `apply` parameter must have the correct nonces, and gas
// values set.
StateCompute(context.Context, abi.ChainEpoch, []*types.Message, types.TipSetKey) (*types.ComputeStateOutput, error) //perm:read
// StateGetRandomnessFromTickets is used to sample the chain for randomness.
StateGetRandomnessFromTickets(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error) //perm:read
// StateGetRandomnessFromBeacon is used to sample the beacon for randomness.
StateGetRandomnessFromBeacon(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error) //perm:read
}

type IMinerState interface {
// StateReadState returns the indicated actor's state.
StateReadState(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.ActorState, error) //perm:read
// StateDecodeParams attempts to decode the provided params, based on the recipient actor address and method number.
StateDecodeParams(ctx context.Context, toAddr address.Address, method abi.MethodNum, params []byte, tsk types.TipSetKey) (interface{}, error) //perm:read
// StateListMessages looks back and returns all messages with a matching to or from address, stopping at the given height.
StateListMessages(ctx context.Context, match *types.MessageMatch, tsk types.TipSetKey, toht abi.ChainEpoch) ([]cid.Cid, error) //perm:read
StateMinerSectorAllocated(ctx context.Context, maddr address.Address, s abi.SectorNumber, tsk types.TipSetKey) (bool, error) //perm:read
StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (types.SectorPreCommitOnChainInfo, error) //perm:read
StateSectorGetInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*types.SectorOnChainInfo, error) //perm:read
Expand All @@ -128,11 +138,13 @@ type IMinerState interface {
StateMinerWorkerAddress(ctx context.Context, maddr address.Address, tsk types.TipSetKey) (address.Address, error) //perm:read
StateMinerRecoveries(ctx context.Context, maddr address.Address, tsk types.TipSetKey) (bitfield.BitField, error) //perm:read
StateMinerFaults(ctx context.Context, maddr address.Address, tsk types.TipSetKey) (bitfield.BitField, error) //perm:read
StateMinerProvingDeadline(ctx context.Context, maddr address.Address, tsk types.TipSetKey) (*dline.Info, error) //perm:read
StateMinerPartitions(ctx context.Context, maddr address.Address, dlIdx uint64, tsk types.TipSetKey) ([]types.Partition, error) //perm:read
StateMinerDeadlines(ctx context.Context, maddr address.Address, tsk types.TipSetKey) ([]types.Deadline, error) //perm:read
StateMinerSectors(ctx context.Context, maddr address.Address, sectorNos *bitfield.BitField, tsk types.TipSetKey) ([]*types.SectorOnChainInfo, error) //perm:read
StateMarketStorageDeal(ctx context.Context, dealID abi.DealID, tsk types.TipSetKey) (*types.MarketDeal, error) //perm:read
// StateAllMinerFaults returns all non-expired Faults that occur within lookback epochs of the given tipset
StateAllMinerFaults(ctx context.Context, lookback abi.ChainEpoch, ts types.TipSetKey) ([]*types.Fault, error) //perm:read
StateMinerProvingDeadline(ctx context.Context, maddr address.Address, tsk types.TipSetKey) (*dline.Info, error) //perm:read
StateMinerPartitions(ctx context.Context, maddr address.Address, dlIdx uint64, tsk types.TipSetKey) ([]types.Partition, error) //perm:read
StateMinerDeadlines(ctx context.Context, maddr address.Address, tsk types.TipSetKey) ([]types.Deadline, error) //perm:read
StateMinerSectors(ctx context.Context, maddr address.Address, sectorNos *bitfield.BitField, tsk types.TipSetKey) ([]*types.SectorOnChainInfo, error) //perm:read
StateMarketStorageDeal(ctx context.Context, dealID abi.DealID, tsk types.TipSetKey) (*types.MarketDeal, error) //perm:read
// StateGetAllocationForPendingDeal returns the allocation for a given deal ID of a pending deal. Returns nil if
// pending allocation is not found.
StateGetAllocationForPendingDeal(ctx context.Context, dealID abi.DealID, tsk types.TipSetKey) (*types.Allocation, error) //perm:read
Expand All @@ -156,6 +168,7 @@ type IMinerState interface {
StateMinerPower(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*types.MinerPower, error) //perm:read
StateMinerAvailableBalance(ctx context.Context, maddr address.Address, tsk types.TipSetKey) (big.Int, error) //perm:read
StateSectorExpiration(ctx context.Context, maddr address.Address, sectorNumber abi.SectorNumber, tsk types.TipSetKey) (*lminer.SectorExpiration, error) //perm:read
StateChangedActors(context.Context, cid.Cid, cid.Cid) (map[string]types.Actor, error) //perm:read
StateMinerSectorCount(ctx context.Context, addr address.Address, tsk types.TipSetKey) (types.MinerSectors, error) //perm:read
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
Expand Down
213 changes: 213 additions & 0 deletions venus-shared/api/chain/v0/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ curl http://<ip>:<port>/rpc/v0 -X POST -H "Content-Type: application/json" -H "
* [StateCall](#statecall)
* [StateCompute](#statecompute)
* [StateGetNetworkParams](#stategetnetworkparams)
* [StateGetRandomnessFromBeacon](#stategetrandomnessfrombeacon)
* [StateGetRandomnessFromTickets](#stategetrandomnessfromtickets)
* [StateGetReceipt](#stategetreceipt)
* [StateNetworkName](#statenetworkname)
* [StateNetworkVersion](#statenetworkversion)
Expand Down Expand Up @@ -90,14 +92,18 @@ curl http://<ip>:<port>/rpc/v0 -X POST -H "Content-Type: application/json" -H "
* [MpoolSetConfig](#mpoolsetconfig)
* [MpoolSub](#mpoolsub)
* [MinerState](#minerstate)
* [StateAllMinerFaults](#stateallminerfaults)
* [StateChangedActors](#statechangedactors)
* [StateCirculatingSupply](#statecirculatingsupply)
* [StateDealProviderCollateralBounds](#statedealprovidercollateralbounds)
* [StateDecodeParams](#statedecodeparams)
* [StateGetAllocation](#stategetallocation)
* [StateGetAllocationForPendingDeal](#stategetallocationforpendingdeal)
* [StateGetAllocations](#stategetallocations)
* [StateGetClaim](#stategetclaim)
* [StateGetClaims](#stategetclaims)
* [StateListActors](#statelistactors)
* [StateListMessages](#statelistmessages)
* [StateListMiners](#statelistminers)
* [StateLookupID](#statelookupid)
* [StateMarketBalance](#statemarketbalance)
Expand All @@ -119,6 +125,7 @@ curl http://<ip>:<port>/rpc/v0 -X POST -H "Content-Type: application/json" -H "
* [StateMinerSectorSize](#stateminersectorsize)
* [StateMinerSectors](#stateminersectors)
* [StateMinerWorkerAddress](#stateminerworkeraddress)
* [StateReadState](#statereadstate)
* [StateSectorExpiration](#statesectorexpiration)
* [StateSectorGetInfo](#statesectorgetinfo)
* [StateSectorPartition](#statesectorpartition)
Expand Down Expand Up @@ -1683,6 +1690,56 @@ Response:
}
```

### StateGetRandomnessFromBeacon
StateGetRandomnessFromBeacon is used to sample the beacon for randomness.


Perms: read

Inputs:
```json
[
2,
10101,
"Ynl0ZSBhcnJheQ==",
[
{
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
{
"/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve"
}
]
]
```

Response: `"Bw=="`

### StateGetRandomnessFromTickets
StateGetRandomnessFromTickets is used to sample the chain for randomness.


Perms: read

Inputs:
```json
[
2,
10101,
"Ynl0ZSBhcnJheQ==",
[
{
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
{
"/": "bafy2bzacebp3shtrn43k7g3unredz7fxn4gj533d3o43tqn2p2ipxxhrvchve"
}
]
]
```

Response: `"Bw=="`

### StateGetReceipt


Expand Down Expand Up @@ -3057,6 +3114,71 @@ Response:

## MinerState

### StateAllMinerFaults
StateAllMinerFaults returns all non-expired Faults that occur within lookback epochs of the given tipset


Perms: read

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

Response:
```json
[
{
"Miner": "f01234",
"Epoch": 10101
}
]
```

### StateChangedActors


Perms: read

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

Response:
```json
{
"t01236": {
"Code": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"Head": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"Nonce": 42,
"Balance": "0",
"Address": "f01234"
}
}
```

### StateCirculatingSupply


Expand Down Expand Up @@ -3107,6 +3229,31 @@ Response:
}
```

### StateDecodeParams
StateDecodeParams attempts to decode the provided params, based on the recipient actor address and method number.


Perms: read

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

Response: `{}`

### StateGetAllocation
StateGetAllocation returns the allocation for a given address and allocation ID.

Expand Down Expand Up @@ -3291,6 +3438,40 @@ Response:
]
```

### StateListMessages
StateListMessages looks back and returns all messages with a matching to or from address, stopping at the given height.


Perms: read

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

Response:
```json
[
{
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
}
]
```

### StateListMiners


Expand Down Expand Up @@ -4022,6 +4203,38 @@ Inputs:

Response: `"f01234"`

### StateReadState
StateReadState returns the indicated actor's state.


Perms: read

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

Response:
```json
{
"Balance": "0",
"Code": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"State": {}
}
```

### StateSectorExpiration


Expand Down
Loading

0 comments on commit 8da2ced

Please sign in to comment.