2020-09-12 03:01:37 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/go-address"
|
2020-10-15 20:54:58 +00:00
|
|
|
"github.com/filecoin-project/go-bitfield"
|
2020-10-02 14:14:30 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
2020-10-13 20:31:20 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/crypto"
|
2020-10-15 23:27:49 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/dline"
|
2020-10-20 17:04:51 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/network"
|
2020-09-12 03:01:37 +00:00
|
|
|
"github.com/filecoin-project/lotus/api"
|
2020-10-02 14:14:30 +00:00
|
|
|
"github.com/filecoin-project/lotus/build"
|
2020-10-15 20:54:58 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
2020-09-12 03:01:37 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
2020-10-13 20:31:20 +00:00
|
|
|
"github.com/filecoin-project/lotus/lib/sigs"
|
|
|
|
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
|
|
|
|
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
|
2020-10-01 15:54:28 +00:00
|
|
|
"github.com/filecoin-project/lotus/node/impl/full"
|
2020-09-12 06:07:20 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
2020-09-12 03:01:37 +00:00
|
|
|
)
|
|
|
|
|
2020-10-02 14:14:30 +00:00
|
|
|
const (
|
2020-10-20 17:09:21 +00:00
|
|
|
LookbackCap = time.Hour * 24
|
2020-10-09 11:41:09 +00:00
|
|
|
StateWaitLookbackLimit = abi.ChainEpoch(20)
|
2020-10-02 14:14:30 +00:00
|
|
|
)
|
2020-09-12 03:01:37 +00:00
|
|
|
|
|
|
|
var (
|
|
|
|
ErrLookbackTooLong = fmt.Errorf("lookbacks of more than %s are disallowed", LookbackCap)
|
|
|
|
)
|
|
|
|
|
2020-10-07 11:59:32 +00:00
|
|
|
// gatewayDepsAPI defines the API methods that the GatewayAPI depends on
|
|
|
|
// (to make it easy to mock for tests)
|
|
|
|
type gatewayDepsAPI interface {
|
2021-03-05 21:01:20 +00:00
|
|
|
Version(context.Context) (api.APIVersion, error)
|
2020-10-09 11:41:09 +00:00
|
|
|
ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error)
|
|
|
|
ChainGetMessage(ctx context.Context, mc cid.Cid) (*types.Message, error)
|
|
|
|
ChainGetNode(ctx context.Context, p string) (*api.IpldObject, error)
|
2020-10-06 09:03:27 +00:00
|
|
|
ChainGetTipSet(ctx context.Context, tsk types.TipSetKey) (*types.TipSet, error)
|
|
|
|
ChainGetTipSetByHeight(ctx context.Context, h abi.ChainEpoch, tsk types.TipSetKey) (*types.TipSet, error)
|
2020-10-09 11:41:09 +00:00
|
|
|
ChainHasObj(context.Context, cid.Cid) (bool, error)
|
|
|
|
ChainHead(ctx context.Context) (*types.TipSet, error)
|
|
|
|
ChainNotify(context.Context) (<-chan []*api.HeadChange, error)
|
2020-10-15 10:15:21 +00:00
|
|
|
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
|
2020-10-06 09:03:27 +00:00
|
|
|
GasEstimateMessageGas(ctx context.Context, msg *types.Message, spec *api.MessageSendSpec, tsk types.TipSetKey) (*types.Message, error)
|
|
|
|
MpoolPushUntrusted(ctx context.Context, sm *types.SignedMessage) (cid.Cid, error)
|
2020-10-07 16:14:12 +00:00
|
|
|
MsigGetAvailableBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (types.BigInt, error)
|
|
|
|
MsigGetVested(ctx context.Context, addr address.Address, start types.TipSetKey, end types.TipSetKey) (types.BigInt, error)
|
2021-02-04 04:46:10 +00:00
|
|
|
MsigGetPending(ctx context.Context, addr address.Address, ts types.TipSetKey) ([]*api.MsigTransaction, error)
|
2020-10-06 09:03:27 +00:00
|
|
|
StateAccountKey(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error)
|
2020-10-09 11:41:09 +00:00
|
|
|
StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk types.TipSetKey) (api.DealCollateralBounds, error)
|
2020-10-06 09:03:27 +00:00
|
|
|
StateGetActor(ctx context.Context, actor address.Address, ts types.TipSetKey) (*types.Actor, error)
|
2020-10-09 11:41:09 +00:00
|
|
|
StateGetReceipt(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error)
|
2020-10-06 09:03:27 +00:00
|
|
|
StateLookupID(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error)
|
2020-10-09 11:41:09 +00:00
|
|
|
StateListMiners(ctx context.Context, tsk types.TipSetKey) ([]address.Address, error)
|
|
|
|
StateMarketBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (api.MarketBalance, error)
|
|
|
|
StateMarketStorageDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*api.MarketDeal, error)
|
|
|
|
StateNetworkVersion(context.Context, types.TipSetKey) (network.Version, error)
|
2021-01-19 10:19:31 +00:00
|
|
|
StateSearchMsgLimited(ctx context.Context, msg cid.Cid, lookbackLimit abi.ChainEpoch) (*api.MsgLookup, error)
|
2020-10-06 09:03:27 +00:00
|
|
|
StateWaitMsgLimited(ctx context.Context, msg cid.Cid, confidence uint64, h abi.ChainEpoch) (*api.MsgLookup, error)
|
2020-10-13 21:23:08 +00:00
|
|
|
StateReadState(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*api.ActorState, error)
|
2020-10-15 20:54:58 +00:00
|
|
|
StateMinerPower(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error)
|
|
|
|
StateMinerFaults(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error)
|
|
|
|
StateMinerRecoveries(context.Context, address.Address, types.TipSetKey) (bitfield.BitField, error)
|
|
|
|
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (miner.MinerInfo, error)
|
|
|
|
StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) ([]api.Deadline, error)
|
|
|
|
StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
|
2020-10-15 23:27:49 +00:00
|
|
|
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error)
|
|
|
|
StateCirculatingSupply(context.Context, types.TipSetKey) (abi.TokenAmount, error)
|
2020-11-20 16:30:17 +00:00
|
|
|
StateSectorGetInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*miner.SectorOnChainInfo, error)
|
2020-10-20 15:08:25 +00:00
|
|
|
StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error)
|
2020-10-15 23:36:45 +00:00
|
|
|
StateVMCirculatingSupplyInternal(context.Context, types.TipSetKey) (api.CirculatingSupply, error)
|
2020-10-06 09:03:27 +00:00
|
|
|
}
|
|
|
|
|
2020-09-12 03:01:37 +00:00
|
|
|
type GatewayAPI struct {
|
2020-10-09 11:41:09 +00:00
|
|
|
api gatewayDepsAPI
|
|
|
|
lookbackCap time.Duration
|
|
|
|
stateWaitLookbackLimit abi.ChainEpoch
|
2020-10-15 10:15:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewGatewayAPI creates a new GatewayAPI with the default lookback cap
|
|
|
|
func NewGatewayAPI(api gatewayDepsAPI) *GatewayAPI {
|
2020-10-09 11:41:09 +00:00
|
|
|
return newGatewayAPI(api, LookbackCap, StateWaitLookbackLimit)
|
2020-10-15 10:15:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// used by the tests
|
2020-10-09 11:41:09 +00:00
|
|
|
func newGatewayAPI(api gatewayDepsAPI, lookbackCap time.Duration, stateWaitLookbackLimit abi.ChainEpoch) *GatewayAPI {
|
|
|
|
return &GatewayAPI{api: api, lookbackCap: lookbackCap, stateWaitLookbackLimit: stateWaitLookbackLimit}
|
2020-09-12 03:01:37 +00:00
|
|
|
}
|
|
|
|
|
2020-10-02 14:14:30 +00:00
|
|
|
func (a *GatewayAPI) checkTipsetKey(ctx context.Context, tsk types.TipSetKey) error {
|
2020-09-12 03:01:37 +00:00
|
|
|
if tsk.IsEmpty() {
|
2020-10-02 14:14:30 +00:00
|
|
|
return nil
|
2020-09-12 03:01:37 +00:00
|
|
|
}
|
|
|
|
|
2020-10-07 11:59:32 +00:00
|
|
|
ts, err := a.api.ChainGetTipSet(ctx, tsk)
|
2020-09-12 03:01:37 +00:00
|
|
|
if err != nil {
|
2020-10-02 14:14:30 +00:00
|
|
|
return err
|
2020-09-12 03:01:37 +00:00
|
|
|
}
|
|
|
|
|
2020-10-02 14:14:30 +00:00
|
|
|
return a.checkTipset(ts)
|
2020-09-12 03:01:37 +00:00
|
|
|
}
|
|
|
|
|
2020-10-02 14:14:30 +00:00
|
|
|
func (a *GatewayAPI) checkTipset(ts *types.TipSet) error {
|
|
|
|
at := time.Unix(int64(ts.Blocks()[0].Timestamp), 0)
|
|
|
|
if err := a.checkTimestamp(at); err != nil {
|
|
|
|
return fmt.Errorf("bad tipset: %w", err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *GatewayAPI) checkTipsetHeight(ts *types.TipSet, h abi.ChainEpoch) error {
|
|
|
|
tsBlock := ts.Blocks()[0]
|
|
|
|
heightDelta := time.Duration(uint64(tsBlock.Height-h)*build.BlockDelaySecs) * time.Second
|
|
|
|
timeAtHeight := time.Unix(int64(tsBlock.Timestamp), 0).Add(-heightDelta)
|
|
|
|
|
|
|
|
if err := a.checkTimestamp(timeAtHeight); err != nil {
|
|
|
|
return fmt.Errorf("bad tipset height: %w", err)
|
2020-09-12 03:01:37 +00:00
|
|
|
}
|
2020-10-02 14:14:30 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-09-12 03:01:37 +00:00
|
|
|
|
2020-10-02 14:14:30 +00:00
|
|
|
func (a *GatewayAPI) checkTimestamp(at time.Time) error {
|
2020-10-15 10:15:21 +00:00
|
|
|
if time.Since(at) > a.lookbackCap {
|
2020-09-12 06:07:20 +00:00
|
|
|
return ErrLookbackTooLong
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-03-05 21:01:20 +00:00
|
|
|
func (a *GatewayAPI) Version(ctx context.Context) (api.APIVersion, error) {
|
2020-10-20 17:04:51 +00:00
|
|
|
return a.api.Version(ctx)
|
|
|
|
}
|
|
|
|
|
2020-10-09 11:41:09 +00:00
|
|
|
func (a *GatewayAPI) ChainGetBlockMessages(ctx context.Context, c cid.Cid) (*api.BlockMessages, error) {
|
|
|
|
return a.api.ChainGetBlockMessages(ctx, c)
|
|
|
|
}
|
|
|
|
|
2020-10-15 10:15:21 +00:00
|
|
|
func (a *GatewayAPI) ChainHasObj(ctx context.Context, c cid.Cid) (bool, error) {
|
|
|
|
return a.api.ChainHasObj(ctx, c)
|
|
|
|
}
|
|
|
|
|
2020-09-12 06:07:20 +00:00
|
|
|
func (a *GatewayAPI) ChainHead(ctx context.Context) (*types.TipSet, error) {
|
|
|
|
// TODO: cache and invalidate cache when timestamp is up (or have internal ChainNotify)
|
|
|
|
|
2020-10-07 11:59:32 +00:00
|
|
|
return a.api.ChainHead(ctx)
|
2020-09-12 06:07:20 +00:00
|
|
|
}
|
|
|
|
|
2020-10-09 11:41:09 +00:00
|
|
|
func (a *GatewayAPI) ChainGetMessage(ctx context.Context, mc cid.Cid) (*types.Message, error) {
|
|
|
|
return a.api.ChainGetMessage(ctx, mc)
|
|
|
|
}
|
|
|
|
|
2020-09-12 06:07:20 +00:00
|
|
|
func (a *GatewayAPI) ChainGetTipSet(ctx context.Context, tsk types.TipSetKey) (*types.TipSet, error) {
|
2020-10-07 11:59:32 +00:00
|
|
|
return a.api.ChainGetTipSet(ctx, tsk)
|
2020-10-02 14:14:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *GatewayAPI) ChainGetTipSetByHeight(ctx context.Context, h abi.ChainEpoch, tsk types.TipSetKey) (*types.TipSet, error) {
|
2020-10-15 23:49:25 +00:00
|
|
|
var ts *types.TipSet
|
|
|
|
if tsk.IsEmpty() {
|
|
|
|
head, err := a.api.ChainHead(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ts = head
|
|
|
|
} else {
|
|
|
|
gts, err := a.api.ChainGetTipSet(ctx, tsk)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ts = gts
|
2020-09-12 06:07:20 +00:00
|
|
|
}
|
|
|
|
|
2020-10-02 14:14:30 +00:00
|
|
|
// Check if the tipset key refers to a tipset that's too far in the past
|
|
|
|
if err := a.checkTipset(ts); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the height is too far in the past
|
|
|
|
if err := a.checkTipsetHeight(ts, h); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-10-07 11:59:32 +00:00
|
|
|
return a.api.ChainGetTipSetByHeight(ctx, h, tsk)
|
2020-10-06 09:03:27 +00:00
|
|
|
}
|
|
|
|
|
2020-10-15 23:27:49 +00:00
|
|
|
func (a *GatewayAPI) ChainGetNode(ctx context.Context, p string) (*api.IpldObject, error) {
|
|
|
|
return a.api.ChainGetNode(ctx, p)
|
|
|
|
}
|
|
|
|
|
2020-10-09 11:41:09 +00:00
|
|
|
func (a *GatewayAPI) ChainNotify(ctx context.Context) (<-chan []*api.HeadChange, error) {
|
|
|
|
return a.api.ChainNotify(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *GatewayAPI) ChainReadObj(ctx context.Context, c cid.Cid) ([]byte, error) {
|
|
|
|
return a.api.ChainReadObj(ctx, c)
|
|
|
|
}
|
|
|
|
|
2020-10-06 09:03:27 +00:00
|
|
|
func (a *GatewayAPI) GasEstimateMessageGas(ctx context.Context, msg *types.Message, spec *api.MessageSendSpec, tsk types.TipSetKey) (*types.Message, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-10-07 11:59:32 +00:00
|
|
|
return a.api.GasEstimateMessageGas(ctx, msg, spec, tsk)
|
2020-09-12 06:07:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *GatewayAPI) MpoolPush(ctx context.Context, sm *types.SignedMessage) (cid.Cid, error) {
|
|
|
|
// TODO: additional anti-spam checks
|
2020-10-07 11:59:32 +00:00
|
|
|
return a.api.MpoolPushUntrusted(ctx, sm)
|
2020-09-12 06:07:20 +00:00
|
|
|
}
|
2020-09-29 15:25:45 +00:00
|
|
|
|
2020-10-07 16:14:12 +00:00
|
|
|
func (a *GatewayAPI) MsigGetAvailableBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (types.BigInt, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return types.NewInt(0), err
|
|
|
|
}
|
|
|
|
|
|
|
|
return a.api.MsigGetAvailableBalance(ctx, addr, tsk)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *GatewayAPI) MsigGetVested(ctx context.Context, addr address.Address, start types.TipSetKey, end types.TipSetKey) (types.BigInt, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, start); err != nil {
|
|
|
|
return types.NewInt(0), err
|
|
|
|
}
|
|
|
|
if err := a.checkTipsetKey(ctx, end); err != nil {
|
|
|
|
return types.NewInt(0), err
|
|
|
|
}
|
|
|
|
|
|
|
|
return a.api.MsigGetVested(ctx, addr, start, end)
|
|
|
|
}
|
|
|
|
|
2021-02-04 04:46:10 +00:00
|
|
|
func (a *GatewayAPI) MsigGetPending(ctx context.Context, addr address.Address, tsk types.TipSetKey) ([]*api.MsigTransaction, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return a.api.MsigGetPending(ctx, addr, tsk)
|
|
|
|
}
|
|
|
|
|
2020-09-30 14:36:16 +00:00
|
|
|
func (a *GatewayAPI) StateAccountKey(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error) {
|
2020-10-02 14:14:30 +00:00
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return address.Undef, err
|
2020-09-30 14:36:16 +00:00
|
|
|
}
|
|
|
|
|
2020-10-07 11:59:32 +00:00
|
|
|
return a.api.StateAccountKey(ctx, addr, tsk)
|
2020-10-05 15:09:21 +00:00
|
|
|
}
|
|
|
|
|
2020-10-09 11:41:09 +00:00
|
|
|
func (a *GatewayAPI) StateDealProviderCollateralBounds(ctx context.Context, size abi.PaddedPieceSize, verified bool, tsk types.TipSetKey) (api.DealCollateralBounds, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return api.DealCollateralBounds{}, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return a.api.StateDealProviderCollateralBounds(ctx, size, verified, tsk)
|
|
|
|
}
|
|
|
|
|
2020-09-30 14:36:16 +00:00
|
|
|
func (a *GatewayAPI) StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error) {
|
2020-10-02 14:14:30 +00:00
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return nil, err
|
2020-09-29 15:25:45 +00:00
|
|
|
}
|
|
|
|
|
2020-10-07 11:59:32 +00:00
|
|
|
return a.api.StateGetActor(ctx, actor, tsk)
|
2020-09-29 15:25:45 +00:00
|
|
|
}
|
|
|
|
|
2020-10-09 11:41:09 +00:00
|
|
|
func (a *GatewayAPI) StateGetReceipt(ctx context.Context, c cid.Cid, tsk types.TipSetKey) (*types.MessageReceipt, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return a.api.StateGetReceipt(ctx, c, tsk)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *GatewayAPI) StateListMiners(ctx context.Context, tsk types.TipSetKey) ([]address.Address, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return a.api.StateListMiners(ctx, tsk)
|
|
|
|
}
|
|
|
|
|
2020-09-30 14:36:16 +00:00
|
|
|
func (a *GatewayAPI) StateLookupID(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error) {
|
2020-10-02 14:14:30 +00:00
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return address.Undef, err
|
2020-09-29 15:25:45 +00:00
|
|
|
}
|
|
|
|
|
2020-10-07 11:59:32 +00:00
|
|
|
return a.api.StateLookupID(ctx, addr, tsk)
|
2020-09-29 15:25:45 +00:00
|
|
|
}
|
2020-09-30 14:36:16 +00:00
|
|
|
|
2020-10-09 11:41:09 +00:00
|
|
|
func (a *GatewayAPI) StateMarketBalance(ctx context.Context, addr address.Address, tsk types.TipSetKey) (api.MarketBalance, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return api.MarketBalance{}, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return a.api.StateMarketBalance(ctx, addr, tsk)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *GatewayAPI) StateMarketStorageDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*api.MarketDeal, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return a.api.StateMarketStorageDeal(ctx, dealId, tsk)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *GatewayAPI) StateNetworkVersion(ctx context.Context, tsk types.TipSetKey) (network.Version, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return network.VersionMax, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return a.api.StateNetworkVersion(ctx, tsk)
|
|
|
|
}
|
|
|
|
|
2021-01-19 10:19:31 +00:00
|
|
|
func (a *GatewayAPI) StateSearchMsg(ctx context.Context, msg cid.Cid) (*api.MsgLookup, error) {
|
|
|
|
return a.api.StateSearchMsgLimited(ctx, msg, a.stateWaitLookbackLimit)
|
|
|
|
}
|
|
|
|
|
2020-10-02 14:14:30 +00:00
|
|
|
func (a *GatewayAPI) StateWaitMsg(ctx context.Context, msg cid.Cid, confidence uint64) (*api.MsgLookup, error) {
|
2020-10-09 11:41:09 +00:00
|
|
|
return a.api.StateWaitMsgLimited(ctx, msg, confidence, a.stateWaitLookbackLimit)
|
2020-10-02 14:14:30 +00:00
|
|
|
}
|
|
|
|
|
2020-10-13 21:23:08 +00:00
|
|
|
func (a *GatewayAPI) StateReadState(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*api.ActorState, error) {
|
2020-10-14 14:22:25 +00:00
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2020-10-13 21:23:08 +00:00
|
|
|
return a.api.StateReadState(ctx, actor, tsk)
|
|
|
|
}
|
|
|
|
|
2020-10-15 20:54:58 +00:00
|
|
|
func (a *GatewayAPI) StateMinerPower(ctx context.Context, m address.Address, tsk types.TipSetKey) (*api.MinerPower, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return a.api.StateMinerPower(ctx, m, tsk)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *GatewayAPI) StateMinerFaults(ctx context.Context, m address.Address, tsk types.TipSetKey) (bitfield.BitField, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return bitfield.BitField{}, err
|
|
|
|
}
|
|
|
|
return a.api.StateMinerFaults(ctx, m, tsk)
|
|
|
|
}
|
|
|
|
func (a *GatewayAPI) StateMinerRecoveries(ctx context.Context, m address.Address, tsk types.TipSetKey) (bitfield.BitField, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return bitfield.BitField{}, err
|
|
|
|
}
|
|
|
|
return a.api.StateMinerRecoveries(ctx, m, tsk)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *GatewayAPI) StateMinerInfo(ctx context.Context, m address.Address, tsk types.TipSetKey) (miner.MinerInfo, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return miner.MinerInfo{}, err
|
|
|
|
}
|
|
|
|
return a.api.StateMinerInfo(ctx, m, tsk)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *GatewayAPI) StateMinerDeadlines(ctx context.Context, m address.Address, tsk types.TipSetKey) ([]api.Deadline, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return a.api.StateMinerDeadlines(ctx, m, tsk)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *GatewayAPI) StateMinerAvailableBalance(ctx context.Context, m address.Address, tsk types.TipSetKey) (types.BigInt, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return types.BigInt{}, err
|
|
|
|
}
|
|
|
|
return a.api.StateMinerAvailableBalance(ctx, m, tsk)
|
|
|
|
}
|
|
|
|
|
2020-10-15 23:27:49 +00:00
|
|
|
func (a *GatewayAPI) StateMinerProvingDeadline(ctx context.Context, m address.Address, tsk types.TipSetKey) (*dline.Info, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return a.api.StateMinerProvingDeadline(ctx, m, tsk)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *GatewayAPI) StateCirculatingSupply(ctx context.Context, tsk types.TipSetKey) (abi.TokenAmount, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return types.BigInt{}, err
|
|
|
|
}
|
|
|
|
return a.api.StateCirculatingSupply(ctx, tsk)
|
2020-11-20 16:30:17 +00:00
|
|
|
}
|
2020-10-15 23:27:49 +00:00
|
|
|
|
2020-11-20 16:30:17 +00:00
|
|
|
func (a *GatewayAPI) StateSectorGetInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*miner.SectorOnChainInfo, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return a.api.StateSectorGetInfo(ctx, maddr, n, tsk)
|
2020-10-15 23:27:49 +00:00
|
|
|
}
|
|
|
|
|
2020-10-20 15:08:25 +00:00
|
|
|
func (a *GatewayAPI) StateVerifiedClientStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return a.api.StateVerifiedClientStatus(ctx, addr, tsk)
|
|
|
|
}
|
|
|
|
|
2020-10-15 23:36:45 +00:00
|
|
|
func (a *GatewayAPI) StateVMCirculatingSupplyInternal(ctx context.Context, tsk types.TipSetKey) (api.CirculatingSupply, error) {
|
|
|
|
if err := a.checkTipsetKey(ctx, tsk); err != nil {
|
|
|
|
return api.CirculatingSupply{}, err
|
|
|
|
}
|
|
|
|
return a.api.StateVMCirculatingSupplyInternal(ctx, tsk)
|
|
|
|
}
|
|
|
|
|
2020-10-15 20:54:58 +00:00
|
|
|
func (a *GatewayAPI) WalletVerify(ctx context.Context, k address.Address, msg []byte, sig *crypto.Signature) (bool, error) {
|
|
|
|
return sigs.Verify(sig, k, msg) == nil, nil
|
|
|
|
}
|
|
|
|
|
2020-10-02 14:14:30 +00:00
|
|
|
var _ api.GatewayAPI = (*GatewayAPI)(nil)
|
2020-10-01 15:54:28 +00:00
|
|
|
var _ full.ChainModuleAPI = (*GatewayAPI)(nil)
|
2020-10-05 15:09:21 +00:00
|
|
|
var _ full.GasModuleAPI = (*GatewayAPI)(nil)
|
2020-10-01 15:54:28 +00:00
|
|
|
var _ full.MpoolModuleAPI = (*GatewayAPI)(nil)
|
|
|
|
var _ full.StateModuleAPI = (*GatewayAPI)(nil)
|