Skip to content

Commit

Permalink
Merge pull request #31 from ipfs-force-community/chore/bump-v0.4.0-rc1
Browse files Browse the repository at this point in the history
chore: bump version to v0.4.0-rc1
  • Loading branch information
LinZexiao authored Feb 16, 2023
2 parents af21e75 + fb241fc commit 7399bf2
Show file tree
Hide file tree
Showing 8 changed files with 957 additions and 223 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v0.4.0-rc1

支持 Filecoin NV18 网络升级

* 升级 lotus 版本到 v1.20.0-rc1
* 升级 venus-auth 版本到 v1.10.0-rc1

## v0.3.1

-`ChainHead` 接口设置为本地 [[#28](https://github.com/ipfs-force-community/chain-co/pull/28)]
Expand Down
87 changes: 87 additions & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"time"

"github.com/filecoin-project/go-jsonrpc"
"github.com/filecoin-project/go-jsonrpc/auth"
apitypes "github.com/filecoin-project/lotus/api/types"
"github.com/filecoin-project/lotus/journal/alerting"
Expand All @@ -29,6 +30,7 @@ import (
"github.com/filecoin-project/lotus/api"
lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/types/ethtypes"
marketevents "github.com/filecoin-project/lotus/markets/loggers"
"github.com/filecoin-project/lotus/node/modules/dtypes"
metrics "github.com/libp2p/go-libp2p/core/metrics"
Expand Down Expand Up @@ -109,6 +111,9 @@ type Proxy interface {
// Would return `[revert(tBA), apply(tAB), apply(tAA)]`
ChainGetPath(ctx context.Context, from types.TipSetKey, to types.TipSetKey) ([]*api.HeadChange, error) //perm:read

// ChainGetEvents returns the events under an event AMT root CID.
ChainGetEvents(context.Context, cid.Cid) ([]types.Event, error) //perm:read

// MethodGroup: Beacon
// The Beacon method group contains methods for interacting with the random beacon (DRAND)

Expand Down Expand Up @@ -374,6 +379,82 @@ type Proxy interface {
ChainGetTipSetAfterHeight(ctx context.Context, epoch abi.ChainEpoch, key types.TipSetKey) (*types.TipSet, error) //perm:read
// Version provides information about API provider
Version(context.Context) (api.APIVersion, error) //perm:read

// eth nv18
// These methods are used for Ethereum-compatible JSON-RPC calls
//
// EthAccounts will always return [] since we don't expect Lotus to manage private keys
EthAccounts(ctx context.Context) ([]ethtypes.EthAddress, error) //perm:read
// EthBlockNumber returns the height of the latest (heaviest) TipSet
EthBlockNumber(ctx context.Context) (ethtypes.EthUint64, error) //perm:read
// EthGetBlockTransactionCountByNumber returns the number of messages in the TipSet
EthGetBlockTransactionCountByNumber(ctx context.Context, blkNum ethtypes.EthUint64) (ethtypes.EthUint64, error) //perm:read
// EthGetBlockTransactionCountByHash returns the number of messages in the TipSet
EthGetBlockTransactionCountByHash(ctx context.Context, blkHash ethtypes.EthHash) (ethtypes.EthUint64, error) //perm:read

EthGetBlockByHash(ctx context.Context, blkHash ethtypes.EthHash, fullTxInfo bool) (ethtypes.EthBlock, error) //perm:read
EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (ethtypes.EthBlock, error) //perm:read
EthGetTransactionByHash(ctx context.Context, txHash *ethtypes.EthHash) (*ethtypes.EthTx, error) //perm:read
EthGetTransactionHashByCid(ctx context.Context, cid cid.Cid) (*ethtypes.EthHash, error) //perm:read
EthGetMessageCidByTransactionHash(ctx context.Context, txHash *ethtypes.EthHash) (*cid.Cid, error) //perm:read
EthGetTransactionCount(ctx context.Context, sender ethtypes.EthAddress, blkOpt string) (ethtypes.EthUint64, error) //perm:read
EthGetTransactionReceipt(ctx context.Context, txHash ethtypes.EthHash) (*api.EthTxReceipt, error) //perm:read
EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash ethtypes.EthHash, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error) //perm:read
EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error) //perm:read

EthGetCode(ctx context.Context, address ethtypes.EthAddress, blkOpt string) (ethtypes.EthBytes, error) //perm:read
EthGetStorageAt(ctx context.Context, address ethtypes.EthAddress, position ethtypes.EthBytes, blkParam string) (ethtypes.EthBytes, error) //perm:read
EthGetBalance(ctx context.Context, address ethtypes.EthAddress, blkParam string) (ethtypes.EthBigInt, error) //perm:read
EthChainId(ctx context.Context) (ethtypes.EthUint64, error) //perm:read
NetVersion(ctx context.Context) (string, error) //perm:read
NetListening(ctx context.Context) (bool, error) //perm:read
EthProtocolVersion(ctx context.Context) (ethtypes.EthUint64, error) //perm:read
EthGasPrice(ctx context.Context) (ethtypes.EthBigInt, error) //perm:read
EthFeeHistory(ctx context.Context, p jsonrpc.RawParams) (ethtypes.EthFeeHistory, error) //perm:read

EthMaxPriorityFeePerGas(ctx context.Context) (ethtypes.EthBigInt, error) //perm:read
EthEstimateGas(ctx context.Context, tx ethtypes.EthCall) (ethtypes.EthUint64, error) //perm:read
EthCall(ctx context.Context, tx ethtypes.EthCall, blkParam string) (ethtypes.EthBytes, error) //perm:read

EthSendRawTransaction(ctx context.Context, rawTx ethtypes.EthBytes) (ethtypes.EthHash, error) //perm:read

// Returns the client version
Web3ClientVersion(ctx context.Context) (string, error) //perm:read

// Returns event logs matching given filter spec.
EthGetLogs(ctx context.Context, filter *ethtypes.EthFilterSpec) (*ethtypes.EthFilterResult, error) //perm:read

// Polling method for a filter, returns event logs which occurred since last poll.
// (requires write perm since timestamp of last filter execution will be written)
EthGetFilterChanges(ctx context.Context, id ethtypes.EthFilterID) (*ethtypes.EthFilterResult, error) //perm:write

// Returns event logs matching filter with given id.
// (requires write perm since timestamp of last filter execution will be written)
EthGetFilterLogs(ctx context.Context, id ethtypes.EthFilterID) (*ethtypes.EthFilterResult, error) //perm:write

// Installs a persistent filter based on given filter spec.
EthNewFilter(ctx context.Context, filter *ethtypes.EthFilterSpec) (ethtypes.EthFilterID, error) //perm:write

// Installs a persistent filter to notify when a new block arrives.
EthNewBlockFilter(ctx context.Context) (ethtypes.EthFilterID, error) //perm:write

// Installs a persistent filter to notify when new messages arrive in the message pool.
EthNewPendingTransactionFilter(ctx context.Context) (ethtypes.EthFilterID, error) //perm:write

// Uninstalls a filter with given id.
EthUninstallFilter(ctx context.Context, id ethtypes.EthFilterID) (bool, error) //perm:write

// Subscribe to different event types using websockets
// eventTypes is one or more of:
// - newHeads: notify when new blocks arrive.
// - pendingTransactions: notify when new messages arrive in the message pool.
// - logs: notify new event logs that match a criteria
// params contains additional parameters used with the log event type
// The client will receive a stream of EthSubscriptionResponse values until EthUnsubscribe is called.
EthSubscribe(ctx context.Context, params jsonrpc.RawParams) (ethtypes.EthSubscriptionID, error) //perm:write

// Unsubscribe from a websocket subscription
EthUnsubscribe(ctx context.Context, id ethtypes.EthSubscriptionID) (bool, error) //perm:write
}

// Local is a subset of api.FullNode.
Expand Down Expand Up @@ -450,6 +531,9 @@ type UnSupport interface {
// Session returns a random UUID of api provider session
Session(context.Context) (uuid.UUID, error) //perm:read

// StartTime returns node start time
StartTime(context.Context) (time.Time, error) //perm:read

Closing(context.Context) (<-chan struct{}, error) //perm:read

// ChainDeleteObj deletes node referenced by the given CID
Expand Down Expand Up @@ -832,4 +916,7 @@ type UnSupport interface {
// ChainPrune prunes the stored chain state and garbage collects; only supported if you
// are using the splitstore
ChainPrune(ctx context.Context, opts api.PruneOpts) error //perm:admin

RaftState(ctx context.Context) (*api.RaftStateData, error) //perm:read
RaftLeader(ctx context.Context) (peer.ID, error) //perm:read
}
13 changes: 5 additions & 8 deletions cmd/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ func serveRPC(ctx context.Context, authEndpoint, rateLimitRedis, listen string,
handler3 = &ochttp.Handler{Handler: handler3}
}

limitWrapper := full
pma := api.PermissionedFullAPI(full)

if len(rateLimitRedis) > 0 && remoteJwtCli != nil {
log.Infof("use rate limit %s", rateLimitRedis)
limiter, err := ratelimit.NewRateLimitHandler(
Expand All @@ -70,15 +71,11 @@ func serveRPC(ctx context.Context, authEndpoint, rateLimitRedis, listen string,
return err
}

var rateLimitAPI api.FullNodeStruct
limiter.WarpFunctions(full, &rateLimitAPI.Internal)
limiter.WarpFunctions(full, &rateLimitAPI.VenusAPIStruct.Internal)
limiter.WarpFunctions(full, &rateLimitAPI.CommonStruct.Internal)
limitWrapper = &rateLimitAPI
rateLimitAPI := &api.FullNodeStruct{}
limiter.WraperLimiter(pma, rateLimitAPI)
pma = rateLimitAPI
}

pma := api.PermissionedFullAPI(limitWrapper)

serveRpc := func(path string, hnd interface{}, handler http.Handler, rpcSer *jsonrpc.RPCServer) {
rpcSer.Register("Filecoin", hnd)
http.Handle(path, handler)
Expand Down
Loading

0 comments on commit 7399bf2

Please sign in to comment.