Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Feat: Configurable RPC Apis #349

Merged
merged 29 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f65707c
fix confusing name
crypto-facs Jul 22, 2021
84d475d
feat: Enable configurable grpc apis
crypto-facs Jul 23, 2021
6fb66fe
docs: Update docs and changelog
crypto-facs Jul 23, 2021
89416b5
Organized flags order
crypto-facs Jul 23, 2021
e097d36
merge conflicts
crypto-facs Jul 25, 2021
b65d49a
fix linter
crypto-facs Jul 25, 2021
ce5087d
fix linter
crypto-facs Jul 25, 2021
144b388
fix maligned struct
crypto-facs Jul 25, 2021
c131a06
Merge branch 'main' into configurable-rpcs
crypto-facs Jul 25, 2021
073aa9d
fix typo in docs
crypto-facs Jul 26, 2021
2929380
fix unnecesary duplicate
crypto-facs Jul 26, 2021
1c50243
Update cmd/ethermintd/config/config.go
crypto-facs Jul 26, 2021
dcebdc0
Update cmd/ethermintd/config/config.go
crypto-facs Jul 26, 2021
ebfb6de
Update cmd/ethermintd/config/config.go
crypto-facs Jul 26, 2021
2d93d8e
Update docs/basics/json_rpc.md
crypto-facs Jul 26, 2021
960cb40
fix eth to be manage as default
crypto-facs Jul 26, 2021
3010993
Update init.sh
crypto-facs Jul 26, 2021
ac03109
Update tests/solidity/init-test-node.sh
crypto-facs Jul 26, 2021
bb6bfa4
add default case
crypto-facs Jul 26, 2021
6ce870b
Merge branch 'configurable-rpcs' of github.com:crypto-facs/ethermint …
crypto-facs Jul 26, 2021
277bce6
add default enable api namespaces
crypto-facs Jul 26, 2021
5048f20
update changelog
crypto-facs Jul 26, 2021
d9a0ace
fix namespaces array handler
crypto-facs Jul 26, 2021
3c4032a
remove duplicated changelog
crypto-facs Jul 26, 2021
43b0f7b
fix typo
crypto-facs Jul 26, 2021
bb9aa27
remove duplicates namespaces and fix eth namespace issue
crypto-facs Jul 26, 2021
129f154
fix variable name
crypto-facs Jul 26, 2021
4e554bf
break line in docs
crypto-facs Jul 26, 2021
994b817
Merge branch 'main' into configurable-rpcs
fedekunze Jul 26, 2021
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
Prev Previous commit
Next Next commit
merge conflicts
  • Loading branch information
crypto-facs committed Jul 25, 2021
commit e097d36fb37336eadafb5e43931cb9d406175f51
6 changes: 2 additions & 4 deletions cmd/ethermintd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ type EVMRPCConfig struct {
Enable bool `mapstructure:"enable"`
// Api defines the api namespaces that should be enabled
API string `mapstructure:"api"`
// Address defines the HTTP server to listen on
RPCAddress string `mapstructure:"address"`
// Address defines the WebSocket server to listen on
WsAddress string `mapstructure:"ws-address"`
// EnableUnsafeCORS defines if CORS should be enabled (unsafe - use it at your own risk)
EnableUnsafeCORS bool `mapstructure:"enable-unsafe-cors"`
}

// DefaultEVMConfig returns an EVM config with the JSON-RPC API enabled by default
Expand Down
7 changes: 6 additions & 1 deletion server/evmrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package server
import (
"net"
"net/http"
"strings"
"time"

"github.com/gorilla/mux"
Expand All @@ -21,7 +22,11 @@ func StartEVMRPC(ctx *server.Context, clientCtx client.Context, tmRPCAddr string
tmWsClient := ConnectTmWS(tmRPCAddr, tmEndpoint)

rpcServer := ethrpc.NewServer()
apis := rpc.GetRPCAPIs(ctx, clientCtx, tmWsClient)

rpcapi := config.EVMRPC.API
rpcapi = strings.ReplaceAll(rpcapi, " ", "")
rpcapiArr := strings.Split(rpcapi, ",")
apis := rpc.GetRPCAPIs(ctx, clientCtx, tmWsClient, rpcapiArr)

for _, api := range apis {
if err := rpcServer.RegisterName(api.Namespace, api.Service); err != nil {
Expand Down
48 changes: 13 additions & 35 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"os"
"path/filepath"
"runtime/pprof"
"strings"
"time"

"github.com/cosmos/cosmos-sdk/codec"
Expand Down Expand Up @@ -70,12 +69,15 @@ const (

// GRPC-related flags.
const (
flagGRPCEnable = "grpc.enable"
flagGRPCAddress = "grpc.address"
flagEVMRPCEnable = "evm-rpc.enable"
flagEVMRPCAPI = "evm-rpc.api"
flagEVMRPCAddress = "evm-rpc.address"
flagEVMWSAddress = "evm-rpc.ws-address"
flagGRPCEnable = "grpc.enable"
flagGRPCAddress = "grpc.address"
flagEVMRPCEnable = "evm-rpc.enable"
flagEVMRPCAPI = "evm-rpc.api"
flagEVMRPCAddress = "evm-rpc.address"
flagEVMWSAddress = "evm-rpc.ws-address"
flagEVMEnableUnsafeCORS = "evm-rpc.enable-unsafe-cors"
flagGRPCWebEnable = "grpc-web.enable"
flagGRPCWebAddress = "grpc-web.address"
)

// State sync-related flags.
Expand Down Expand Up @@ -352,34 +354,10 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, appCreator ty
if err != nil {
return err
}
}

var httpSrv *http.Server
var httpSrvDone = make(chan struct{}, 1)
var wsSrv rpc.WebsocketsServer

ethlog.Root().SetHandler(ethlog.StdoutHandler)
if config.EVMRPC.Enable {
tmEndpoint := "/websocket"
tmRPCAddr := cfg.RPC.ListenAddress
logger.Info("EVM RPC Connecting to Tendermint WebSocket at", "address", tmRPCAddr+tmEndpoint)
tmWsClient := ConnectTmWS(tmRPCAddr, tmEndpoint)

rpcServer := ethrpc.NewServer()

rpcApi := config.EVMRPC.API
rpcApi = strings.ReplaceAll(rpcApi, " ", "")
rpcApiArr := strings.Split(rpcApi, ",")

apis := rpc.GetRPCAPIs(ctx, clientCtx, tmWsClient, rpcApiArr)

for _, api := range apis {
if err := rpcServer.RegisterName(api.Namespace, api.Service); err != nil {
logger.Error(
"failed to register service in EVM RPC namespace",
"namespace", api.Namespace,
"service", api.Service,
)
if config.GRPCWeb.Enable {
grpcWebSrv, err = servergrpc.StartGRPCWeb(grpcSrv, config.Config)
if err != nil {
ctx.Logger.Error("failed to start grpc-web http server: ", err)
return err
}
}
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.