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(api): v2 API integrating with F3 #12719

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
141 changes: 141 additions & 0 deletions api/v2api/full.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
package v2api

import (
"context"

"github.com/filecoin-project/go-jsonrpc"
"github.com/filecoin-project/go-state-types/abi"

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/types"
)

//go:generate go run github.com/golang/mock/mockgen -destination=v2mocks/mock_full.go -package=v2mocks . FullNode

type FullNode interface {
// ChainNotify returns channel with chain head updates. Takes an optional
// EpochSelector argument to specify the point in the chain to follow, which
// can be either "latest" or "finalized". This defaults to "latest" if not
// specified.
//
// The first message is guaranteed to be of length == 1, and type ==
// "current".
//
// The optional argument is decoded as a types.OptionalEpochSelectorArg.
ChainNotify(ctx context.Context, p jsonrpc.RawParams) (<-chan []*api.HeadChange, error) //perm:read
rvagg marked this conversation as resolved.
Show resolved Hide resolved

// ChainHead returns the current head of the chain. Takens an optional
// EpochSelector argument to specify the point in the chain to query, which
// can be either "latest" or "finalized". This defaults to "latest" if not
// specified.
//
// The optional argument is decoded as a types.OptionalEpochSelectorArg.
ChainHead(ctx context.Context, p jsonrpc.RawParams) (*types.TipSet, error) //perm:read

// ChainGetMessagesInTipset returns message stores in current tipset. Takes
// a TipSetKey or an EpochSelector (either "latest" or "finalized") as an
// argument.
ChainGetMessagesInTipset(ctx context.Context, tss types.TipSetSelector) ([]api.Message, error) //perm:read

// ChainGetTipSetByHeight looks back for a tipset at at the specified epoch
// and returns the tipset at that epoch.
// If there are no blocks at the specified epoch because it was a null
// round, a tipset at an earlier epoch will be returned.
// The second argument is an optional TipSetKey or EpochSelector (either
// "latest" or "finalized") to specify the point in the chain to begin
// looking for the tipset.
ChainGetTipSetByHeight(ctx context.Context, epoch abi.ChainEpoch, tss types.TipSetSelector) (*types.TipSet, error) //perm:read

// ChainGetTipSetAfterHeight looks back for a tipset at the specified epoch
// and returns the tipset at that epoch.
// If there are no blocks at the specified epoch because it was a null
// round, a tipset at a later epoch will be returned.
// The second argument is an optional TipSetKey or EpochSelector (either
// "latest" or "finalized") to specify the point in the chain to begin
// looking for the tipset.
ChainGetTipSetAfterHeight(ctx context.Context, epoch abi.ChainEpoch, tss types.TipSetSelector) (*types.TipSet, error) //perm:read

// TODO: consider these for tsk argument extension using TipSetSelector
//
// ChainTipSetWeight
// ChainGetPath -- from [foo,bar] to "latest" would be neat, or from "finalized" to "latest"
// ChainExport -- maybe best to be explicit?
// GasEstimateFeeCap
// GasEstimateGasLimit
// GasEstimateGasPremium
// GasEstimateMessageGas
// MpoolPending - is this useful? what would it buy us?
// MpoolSelect - is this useful? what would it buy us?
// MinerGetBaseInfo - I don't think this is useful to extend, it's for mining base
// StateCall
// StateReplay
// StateGetActor
// StateReadState
// StateListMessages
// * StateDecodeParams - not in Common Node API, and maybe not so useful to augment?
// StateMinerSectors
// StateMinerActiveSectors
// StateMinerProvingDeadline
// StateMinerPower
// StateMinerInfo
// StateMinerDeadlines
// StateMinerPartitions
// StateMinerFaults
// * StateAllMinerFaults - not on Common Node API, probably used for CLI, check this
// StateMinerRecoveries
// StateMinerPreCommitDepositForPower
// StateMinerInitialPledgeForSector
// StateMinerAvailableBalance
// StateMinerSectorAllocated
// StateSectorPreCommitInfo
// StateSectorGetInfo
// StateSectorPartition
// StateSearchMsg -- not last argument
// StateListMiners
// StateListActors
// StateMarketBalance
// StateMarketParticipants
// StateMarketDeals
// StateMarketStorageDeal
// StateGetAllocationForPendingDeal
// StateGetAllocationIdForPendingDeal
// StateGetAllocation
// StateGetAllocations
// StateGetAllAllocations
// StateGetClaim
// StateGetClaims
// StateGetAllClaims
// * StateComputeDataCID - not in Common Node API, do people use this?
// StateLookupID
// StateAccountKey
// StateLookupRobustAddress
// StateMinerSectorCount
// StateMinerAllocated
// * StateCompute - not in Common Node API, is flexibility useful here?
// StateVerifierStatus
// StateVerifiedClientStatus
// StateVerifiedRegistryRootKey
// StateDealProviderCollateralBounds
// StateCirculatingSupply
// StateVMCirculatingSupplyInternal
// * StateNetworkVersion - not in Common Node API
// StateGetRandomnessFromTickets (not the randEpoch arg)
// StateGetRandomnessFromBeacon (not the randEpoch arg)
// StateGetRandomnessDigestFromTickets (not the randEpoch arg)
// StateGetRandomnessDigestFromBeacon (not the randEpoch arg)
// * MsigGetAvailableBalance - not in Common Node API
// * MsigGetVestingSchedule - not in Common Node API
// * MsigGetVested - not in Common Node API
// * MsigGetPending - not in Common Node API

// TODO: consider these for an optional extra argument EpochSelector
// WalletBalance
// StateWaitMsg - could we wait until "finalized"?

// ActorEventFilter for SubscribeActorEventsRaw and GetActorEventsRaw
// takes epochs in "from" and "to" fields, could be useful to extend
// with EpochSelector
// (not in Common Node API)

// StateGetBeaconEntry - has an epoch arg, probably not useful to augment
}
13 changes: 13 additions & 0 deletions api/v2api/permissioned.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package v2api

import (
"github.com/filecoin-project/go-jsonrpc/auth"

"github.com/filecoin-project/lotus/api"
)

func PermissionedFullAPI(a FullNode) FullNode {
var out FullNodeStruct
auth.PermissionedProxy(api.AllPermissions, api.DefaultPerms, a, &out.Internal)
return &out
}
93 changes: 93 additions & 0 deletions api/v2api/proxy_gen.go

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

116 changes: 116 additions & 0 deletions api/v2api/v2mocks/mock_full.go

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

Loading
Loading