Skip to content

Commit

Permalink
[devnet tool] separare logging (#7531)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
  • Loading branch information
AlexeyAkhunov and Alex Sharp authored May 17, 2023
1 parent 10848ad commit 05597cb
Show file tree
Hide file tree
Showing 19 changed files with 115 additions and 97 deletions.
8 changes: 5 additions & 3 deletions cmd/erigon-el/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,8 @@ func NewBackend(stack *node.Node, config *ethconfig.Config, logger log.Logger) (
stack.Config().PrivateApiAddr,
stack.Config().PrivateApiRateLimit,
creds,
stack.Config().HealthCheck)
stack.Config().HealthCheck,
logger)
if err != nil {
return nil, fmt.Errorf("private api: %w", err)
}
Expand Down Expand Up @@ -651,7 +652,8 @@ func NewBackend(stack *node.Node, config *ethconfig.Config, logger log.Logger) (
}
// start HTTP API
httpRpcCfg := stack.Config().Http
ethRpcClient, txPoolRpcClient, miningRpcClient, stateCache, ff, err := cli.EmbeddedServices(ctx, chainKv, httpRpcCfg.StateCache, backend.blockReader, ethBackendRPC, backend.txPool2GrpcServer, miningRPC, stateDiffClient)
ethRpcClient, txPoolRpcClient, miningRpcClient, stateCache, ff, err := cli.EmbeddedServices(ctx, chainKv, httpRpcCfg.StateCache, backend.blockReader, ethBackendRPC,
backend.txPool2GrpcServer, miningRPC, stateDiffClient, logger)
if err != nil {
return nil, err
}
Expand All @@ -663,7 +665,7 @@ func NewBackend(stack *node.Node, config *ethconfig.Config, logger log.Logger) (
apiList := commands.APIList(chainKv, borDb, ethRpcClient, txPoolRpcClient, miningRpcClient, ff, stateCache, backend.blockReader, backend.agg, httpRpcCfg, backend.engine, logger)
authApiList := commands.AuthAPIList(chainKv, ethRpcClient, txPoolRpcClient, miningRpcClient, ff, stateCache, backend.blockReader, backend.agg, httpRpcCfg, backend.engine, logger)
go func() {
if err := cli.StartRpcServer(ctx, httpRpcCfg, apiList, authApiList); err != nil {
if err := cli.StartRpcServer(ctx, httpRpcCfg, apiList, authApiList, logger); err != nil {
logger.Error(err.Error())
return
}
Expand Down
63 changes: 32 additions & 31 deletions cmd/rpcdaemon/cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ func EmbeddedServices(ctx context.Context,
erigonDB kv.RoDB, stateCacheCfg kvcache.CoherentConfig,
blockReader services.FullBlockReader, ethBackendServer remote.ETHBACKENDServer, txPoolServer txpool.TxpoolServer,
miningServer txpool.MiningServer, stateDiffClient StateChangesClient,
logger log.Logger,
) (eth rpchelper.ApiBackend, txPool txpool.TxpoolClient, mining txpool.MiningClient, stateCache kvcache.Cache, ff *rpchelper.Filters, err error) {
if stateCacheCfg.CacheSize > 0 {
// notification about new blocks (state stream) doesn't work now inside erigon - because
Expand All @@ -263,7 +264,7 @@ func EmbeddedServices(ctx context.Context,
eth = rpcservices.NewRemoteBackend(directClient, erigonDB, blockReader)
txPool = direct.NewTxPoolClient(txPoolServer)
mining = direct.NewMiningClient(miningServer)
ff = rpchelper.New(ctx, eth, txPool, mining, func() {})
ff = rpchelper.New(ctx, eth, txPool, mining, func() {}, logger)

return
}
Expand Down Expand Up @@ -473,31 +474,31 @@ func RemoteServices(ctx context.Context, cfg httpcfg.HttpCfg, logger log.Logger,
}
}()

ff = rpchelper.New(ctx, eth, txPool, mining, onNewSnapshot)
ff = rpchelper.New(ctx, eth, txPool, mining, onNewSnapshot, logger)
return db, borDb, eth, txPool, mining, stateCache, blockReader, ff, agg, err
}

func StartRpcServer(ctx context.Context, cfg httpcfg.HttpCfg, rpcAPI []rpc.API, authAPI []rpc.API) error {
func StartRpcServer(ctx context.Context, cfg httpcfg.HttpCfg, rpcAPI []rpc.API, authAPI []rpc.API, logger log.Logger) error {
if len(authAPI) > 0 {
engineInfo, err := startAuthenticatedRpcServer(cfg, authAPI)
engineInfo, err := startAuthenticatedRpcServer(cfg, authAPI, logger)
if err != nil {
return err
}
go stopAuthenticatedRpcServer(ctx, engineInfo)
go stopAuthenticatedRpcServer(ctx, engineInfo, logger)
}

if cfg.Enabled {
return startRegularRpcServer(ctx, cfg, rpcAPI)
return startRegularRpcServer(ctx, cfg, rpcAPI, logger)
}

return nil
}

func startRegularRpcServer(ctx context.Context, cfg httpcfg.HttpCfg, rpcAPI []rpc.API) error {
func startRegularRpcServer(ctx context.Context, cfg httpcfg.HttpCfg, rpcAPI []rpc.API, logger log.Logger) error {
// register apis and create handler stack
httpEndpoint := fmt.Sprintf("%s:%d", cfg.HttpListenAddress, cfg.HttpPort)

log.Trace("TraceRequests = %t\n", cfg.TraceRequests)
logger.Trace("TraceRequests = %t\n", cfg.TraceRequests)
srv := rpc.NewServer(cfg.RpcBatchConcurrency, cfg.TraceRequests, cfg.RpcStreamingDisable)

allowListForRPC, err := parseAllowListForRPC(cfg.RpcAllowListFilePath)
Expand All @@ -523,14 +524,14 @@ func startRegularRpcServer(ctx context.Context, cfg httpcfg.HttpCfg, rpcAPI []rp
}
}

if err := node.RegisterApisFromWhitelist(defaultAPIList, apiFlags, srv, false); err != nil {
if err := node.RegisterApisFromWhitelist(defaultAPIList, apiFlags, srv, false, logger); err != nil {
return fmt.Errorf("could not start register RPC apis: %w", err)
}

httpHandler := node.NewHTTPHandlerStack(srv, cfg.HttpCORSDomain, cfg.HttpVirtualHost, cfg.HttpCompression)
var wsHandler http.Handler
if cfg.WebsocketEnabled {
wsHandler = srv.WebsocketHandler([]string{"*"}, nil, cfg.WebsocketCompression)
wsHandler = srv.WebsocketHandler([]string{"*"}, nil, cfg.WebsocketCompression, logger)
}

graphQLHandler := graphql.CreateHandler(defaultAPIList)
Expand All @@ -555,10 +556,10 @@ func startRegularRpcServer(ctx context.Context, cfg httpcfg.HttpCfg, rpcAPI []rp
defer tcpListener.Close()
err := srv.ServeListener(tcpListener)
if err != nil {
log.Error("TCP Listener Fatal Error", "err", err)
logger.Error("TCP Listener Fatal Error", "err", err)
}
}()
log.Info("TCP Endpoint opened", "url", tcpEndpoint)
logger.Info("TCP Endpoint opened", "url", tcpEndpoint)
}

info := []interface{}{
Expand Down Expand Up @@ -586,26 +587,26 @@ func startRegularRpcServer(ctx context.Context, cfg httpcfg.HttpCfg, rpcAPI []rp
info = append(info, "grpc.port", cfg.GRPCPort)
}

log.Info("HTTP endpoint opened", info...)
logger.Info("HTTP endpoint opened", info...)

defer func() {
srv.Stop()
shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
_ = listener.Shutdown(shutdownCtx)
log.Info("HTTP endpoint closed", "url", httpAddr)
logger.Info("HTTP endpoint closed", "url", httpAddr)

if cfg.GRPCServerEnabled {
if cfg.GRPCHealthCheckEnabled {
healthServer.Shutdown()
}
grpcServer.GracefulStop()
_ = grpcListener.Close()
log.Info("GRPC endpoint closed", "url", grpcEndpoint)
logger.Info("GRPC endpoint closed", "url", grpcEndpoint)
}
}()
<-ctx.Done()
log.Info("Exiting...")
logger.Info("Exiting...")
return nil
}

Expand All @@ -616,18 +617,18 @@ type engineInfo struct {
EngineHttpEndpoint string
}

func startAuthenticatedRpcServer(cfg httpcfg.HttpCfg, rpcAPI []rpc.API) (*engineInfo, error) {
log.Trace("TraceRequests = %t\n", cfg.TraceRequests)
func startAuthenticatedRpcServer(cfg httpcfg.HttpCfg, rpcAPI []rpc.API, logger log.Logger) (*engineInfo, error) {
logger.Trace("TraceRequests = %t\n", cfg.TraceRequests)
srv := rpc.NewServer(cfg.RpcBatchConcurrency, cfg.TraceRequests, cfg.RpcStreamingDisable)

engineListener, engineSrv, engineHttpEndpoint, err := createEngineListener(cfg, rpcAPI)
engineListener, engineSrv, engineHttpEndpoint, err := createEngineListener(cfg, rpcAPI, logger)
if err != nil {
return nil, fmt.Errorf("could not start RPC api for engine: %w", err)
}
return &engineInfo{Srv: srv, EngineSrv: engineSrv, EngineListener: engineListener, EngineHttpEndpoint: engineHttpEndpoint}, nil
}

func stopAuthenticatedRpcServer(ctx context.Context, engineInfo *engineInfo) {
func stopAuthenticatedRpcServer(ctx context.Context, engineInfo *engineInfo, logger log.Logger) {
defer func() {
engineInfo.Srv.Stop()
if engineInfo.EngineSrv != nil {
Expand All @@ -638,11 +639,11 @@ func stopAuthenticatedRpcServer(ctx context.Context, engineInfo *engineInfo) {

if engineInfo.EngineListener != nil {
_ = engineInfo.EngineListener.Shutdown(shutdownCtx)
log.Info("Engine HTTP endpoint close", "url", engineInfo.EngineHttpEndpoint)
logger.Info("Engine HTTP endpoint close", "url", engineInfo.EngineHttpEndpoint)
}
}()
<-ctx.Done()
log.Info("Exiting Engine...")
logger.Info("Exiting Engine...")
}

// isWebsocket checks the header of a http request for a websocket upgrade request.
Expand All @@ -654,9 +655,9 @@ func isWebsocket(r *http.Request) bool {
// obtainJWTSecret loads the jwt-secret, either from the provided config,
// or from the default location. If neither of those are present, it generates
// a new secret and stores to the default location.
func obtainJWTSecret(cfg httpcfg.HttpCfg) ([]byte, error) {
func obtainJWTSecret(cfg httpcfg.HttpCfg, logger log.Logger) ([]byte, error) {
// try reading from file
log.Info("Reading JWT secret", "path", cfg.JWTSecretPath)
logger.Info("Reading JWT secret", "path", cfg.JWTSecretPath)
// If we run the rpcdaemon and datadir is not specified we just use jwt.hex in current directory.
if len(cfg.JWTSecretPath) == 0 {
cfg.JWTSecretPath = "jwt.hex"
Expand All @@ -666,7 +667,7 @@ func obtainJWTSecret(cfg httpcfg.HttpCfg) ([]byte, error) {
if len(jwtSecret) == 32 {
return jwtSecret, nil
}
log.Error("Invalid JWT secret", "path", cfg.JWTSecretPath, "length", len(jwtSecret))
logger.Error("Invalid JWT secret", "path", cfg.JWTSecretPath, "length", len(jwtSecret))
return nil, errors.New("invalid JWT secret")
}
// Need to generate one
Expand All @@ -676,7 +677,7 @@ func obtainJWTSecret(cfg httpcfg.HttpCfg) ([]byte, error) {
if err := os.WriteFile(cfg.JWTSecretPath, []byte(hexutility.Encode(jwtSecret)), 0600); err != nil {
return nil, err
}
log.Info("Generated JWT secret", "path", cfg.JWTSecretPath)
logger.Info("Generated JWT secret", "path", cfg.JWTSecretPath)
return jwtSecret, nil
}

Expand Down Expand Up @@ -705,21 +706,21 @@ func createHandler(cfg httpcfg.HttpCfg, apiList []rpc.API, httpHandler http.Hand
return handler, nil
}

func createEngineListener(cfg httpcfg.HttpCfg, engineApi []rpc.API) (*http.Server, *rpc.Server, string, error) {
func createEngineListener(cfg httpcfg.HttpCfg, engineApi []rpc.API, logger log.Logger) (*http.Server, *rpc.Server, string, error) {
engineHttpEndpoint := fmt.Sprintf("%s:%d", cfg.AuthRpcHTTPListenAddress, cfg.AuthRpcPort)

engineSrv := rpc.NewServer(cfg.RpcBatchConcurrency, cfg.TraceRequests, true)

if err := node.RegisterApisFromWhitelist(engineApi, nil, engineSrv, true); err != nil {
if err := node.RegisterApisFromWhitelist(engineApi, nil, engineSrv, true, logger); err != nil {
return nil, nil, "", fmt.Errorf("could not start register RPC engine api: %w", err)
}

jwtSecret, err := obtainJWTSecret(cfg)
jwtSecret, err := obtainJWTSecret(cfg, logger)
if err != nil {
return nil, nil, "", err
}

wsHandler := engineSrv.WebsocketHandler([]string{"*"}, jwtSecret, cfg.WebsocketCompression)
wsHandler := engineSrv.WebsocketHandler([]string{"*"}, jwtSecret, cfg.WebsocketCompression, logger)

engineHttpHandler := node.NewHTTPHandlerStack(engineSrv, nil /* authCors */, cfg.AuthRpcVirtualHost, cfg.HttpCompression)

Expand All @@ -736,7 +737,7 @@ func createEngineListener(cfg httpcfg.HttpCfg, engineApi []rpc.API) (*http.Serve
}

engineInfo := []interface{}{"url", engineAddr, "ws", true, "ws.compression", cfg.WebsocketCompression}
log.Info("HTTP endpoint opened for Engine API", engineInfo...)
logger.Info("HTTP endpoint opened for Engine API", engineInfo...)

return engineListener, engineSrv, engineAddr.String(), nil
}
2 changes: 1 addition & 1 deletion cmd/rpcdaemon/commands/eth_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestGetBlockByNumberWithPendingTag(t *testing.T) {

ctx, conn := rpcdaemontest.CreateTestGrpcConn(t, m)
txPool := txpool.NewTxpoolClient(conn)
ff := rpchelper.New(ctx, nil, txPool, txpool.NewMiningClient(conn), func() {})
ff := rpchelper.New(ctx, nil, txPool, txpool.NewMiningClient(conn), func() {}, m.Log)

expected := 1
header := &types.Header{
Expand Down
2 changes: 1 addition & 1 deletion cmd/rpcdaemon/commands/eth_call_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestEstimateGas(t *testing.T) {
stateCache := kvcache.New(kvcache.DefaultCoherentConfig)
ctx, conn := rpcdaemontest.CreateTestGrpcConn(t, stages.Mock(t))
mining := txpool.NewMiningClient(conn)
ff := rpchelper.New(ctx, nil, nil, mining, func() {})
ff := rpchelper.New(ctx, nil, nil, mining, func() {}, m.Log)
api := NewEthAPI(NewBaseApi(ff, stateCache, br, agg, false, rpccfg.DefaultEvmCallTimeout, m.Engine, m.Dirs), m.DB, nil, nil, nil, 5000000, 100_000, log.New())
var from = libcommon.HexToAddress("0x71562b71999873db5b286df957af199ec94617f7")
var to = libcommon.HexToAddress("0x0d3ab14bbad3d99f4203bd7a11acb94882050e7e")
Expand Down
7 changes: 4 additions & 3 deletions cmd/rpcdaemon/commands/eth_filters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestNewFilters(t *testing.T) {
stateCache := kvcache.New(kvcache.DefaultCoherentConfig)
ctx, conn := rpcdaemontest.CreateTestGrpcConn(t, stages.Mock(t))
mining := txpool.NewMiningClient(conn)
ff := rpchelper.New(ctx, nil, nil, mining, func() {})
ff := rpchelper.New(ctx, nil, nil, mining, func() {}, m.Log)
api := NewEthAPI(NewBaseApi(ff, stateCache, br, agg, false, rpccfg.DefaultEvmCallTimeout, m.Engine, m.Dirs), m.DB, nil, nil, nil, 5000000, 100_000, log.New())

ptf, err := api.NewPendingTransactionFilter(ctx)
Expand All @@ -57,9 +57,10 @@ func TestNewFilters(t *testing.T) {
}

func TestLogsSubscribeAndUnsubscribe_WithoutConcurrentMapIssue(t *testing.T) {
ctx, conn := rpcdaemontest.CreateTestGrpcConn(t, stages.Mock(t))
m := stages.Mock(t)
ctx, conn := rpcdaemontest.CreateTestGrpcConn(t, m)
mining := txpool.NewMiningClient(conn)
ff := rpchelper.New(ctx, nil, nil, mining, func() {})
ff := rpchelper.New(ctx, nil, nil, mining, func() {}, m.Log)

// generate some random topics
topics := make([][]libcommon.Hash, 0)
Expand Down
7 changes: 4 additions & 3 deletions cmd/rpcdaemon/commands/eth_mining_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestPendingBlock(t *testing.T) {
m := stages.Mock(t)
ctx, conn := rpcdaemontest.CreateTestGrpcConn(t, stages.Mock(t))
mining := txpool.NewMiningClient(conn)
ff := rpchelper.New(ctx, nil, nil, mining, func() {})
ff := rpchelper.New(ctx, nil, nil, mining, func() {}, m.Log)
stateCache := kvcache.New(kvcache.DefaultCoherentConfig)
engine := ethash.NewFaker()
api := NewEthAPI(NewBaseApi(ff, stateCache, snapshotsync.NewBlockReaderWithSnapshots(m.BlockSnapshots, m.TransactionsV3), nil, false, rpccfg.DefaultEvmCallTimeout, engine,
Expand All @@ -48,9 +48,10 @@ func TestPendingBlock(t *testing.T) {
}

func TestPendingLogs(t *testing.T) {
ctx, conn := rpcdaemontest.CreateTestGrpcConn(t, stages.Mock(t))
m := stages.Mock(t)
ctx, conn := rpcdaemontest.CreateTestGrpcConn(t, m)
mining := txpool.NewMiningClient(conn)
ff := rpchelper.New(ctx, nil, nil, mining, func() {})
ff := rpchelper.New(ctx, nil, nil, mining, func() {}, m.Log)
expect := []byte{211}

ch, id := ff.SubscribePendingLogs(1)
Expand Down
2 changes: 1 addition & 1 deletion cmd/rpcdaemon/commands/eth_subscribe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestEthSubscribe(t *testing.T) {
backendServer := privateapi.NewEthBackendServer(ctx, nil, m.DB, m.Notifications.Events, br, nil, nil, nil, false, logger)
backendClient := direct.NewEthBackendClientDirect(backendServer)
backend := rpcservices.NewRemoteBackend(backendClient, m.DB, br)
ff := rpchelper.New(ctx, backend, nil, nil, func() {})
ff := rpchelper.New(ctx, backend, nil, nil, func() {}, m.Log)

newHeads, id := ff.SubscribeNewHeads(16)
defer ff.UnsubscribeHeads(id)
Expand Down
2 changes: 1 addition & 1 deletion cmd/rpcdaemon/commands/send_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestSendRawTransaction(t *testing.T) {

ctx, conn := rpcdaemontest.CreateTestGrpcConn(t, m)
txPool := txpool.NewTxpoolClient(conn)
ff := rpchelper.New(ctx, nil, txPool, txpool.NewMiningClient(conn), func() {})
ff := rpchelper.New(ctx, nil, txPool, txpool.NewMiningClient(conn), func() {}, m.Log)
stateCache := kvcache.New(kvcache.DefaultCoherentConfig)
br := snapshotsync.NewBlockReaderWithSnapshots(m.BlockSnapshots, m.TransactionsV3)
api := commands.NewEthAPI(commands.NewBaseApi(ff, stateCache, br, nil, false, rpccfg.DefaultEvmCallTimeout, m.Engine, m.Dirs), m.DB, nil, txPool, nil, 5000000, 100_000, logger)
Expand Down
2 changes: 1 addition & 1 deletion cmd/rpcdaemon/commands/txpool_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestTxPoolContent(t *testing.T) {

ctx, conn := rpcdaemontest.CreateTestGrpcConn(t, m)
txPool := txpool.NewTxpoolClient(conn)
ff := rpchelper.New(ctx, nil, txPool, txpool.NewMiningClient(conn), func() {})
ff := rpchelper.New(ctx, nil, txPool, txpool.NewMiningClient(conn), func() {}, m.Log)
agg := m.HistoryV3Components()
br := snapshotsync.NewBlockReaderWithSnapshots(m.BlockSnapshots, m.TransactionsV3)
api := NewTxPoolAPI(NewBaseApi(ff, kvcache.New(kvcache.DefaultCoherentConfig), br, agg, false, rpccfg.DefaultEvmCallTimeout, m.Engine, m.Dirs), m.DB, txPool)
Expand Down
2 changes: 1 addition & 1 deletion cmd/rpcdaemon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func main() {
// TODO: Replace with correct consensus Engine
engine := ethash.NewFaker()
apiList := commands.APIList(db, borDb, backend, txPool, mining, ff, stateCache, blockReader, agg, *cfg, engine, logger)
if err := cli.StartRpcServer(ctx, *cfg, apiList, nil); err != nil {
if err := cli.StartRpcServer(ctx, *cfg, apiList, nil, logger); err != nil {
logger.Error(err.Error())
return nil
}
Expand Down
8 changes: 5 additions & 3 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere
stack.Config().PrivateApiAddr,
stack.Config().PrivateApiRateLimit,
creds,
stack.Config().HealthCheck)
stack.Config().HealthCheck,
logger)
if err != nil {
return nil, fmt.Errorf("private api: %w", err)
}
Expand Down Expand Up @@ -740,7 +741,8 @@ func (backend *Ethereum) Init(stack *node.Node, config *ethconfig.Config) error
}
// start HTTP API
httpRpcCfg := stack.Config().Http
ethRpcClient, txPoolRpcClient, miningRpcClient, stateCache, ff, err := cli.EmbeddedServices(ctx, chainKv, httpRpcCfg.StateCache, blockReader, ethBackendRPC, backend.txPool2GrpcServer, miningRPC, stateDiffClient)
ethRpcClient, txPoolRpcClient, miningRpcClient, stateCache, ff, err := cli.EmbeddedServices(ctx, chainKv, httpRpcCfg.StateCache, blockReader, ethBackendRPC,
backend.txPool2GrpcServer, miningRPC, stateDiffClient, backend.logger)
if err != nil {
return err
}
Expand All @@ -752,7 +754,7 @@ func (backend *Ethereum) Init(stack *node.Node, config *ethconfig.Config) error
apiList := commands.APIList(chainKv, borDb, ethRpcClient, txPoolRpcClient, miningRpcClient, ff, stateCache, blockReader, backend.agg, httpRpcCfg, backend.engine, backend.logger)
authApiList := commands.AuthAPIList(chainKv, ethRpcClient, txPoolRpcClient, miningRpcClient, ff, stateCache, blockReader, backend.agg, httpRpcCfg, backend.engine, backend.logger)
go func() {
if err := cli.StartRpcServer(ctx, httpRpcCfg, apiList, authApiList); err != nil {
if err := cli.StartRpcServer(ctx, httpRpcCfg, apiList, authApiList, backend.logger); err != nil {
backend.logger.Error(err.Error())
return
}
Expand Down
6 changes: 3 additions & 3 deletions ethdb/privateapi/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (

func StartGrpc(kv *remotedbserver.KvServer, ethBackendSrv *EthBackendServer, txPoolServer txpool_proto.TxpoolServer,
miningServer txpool_proto.MiningServer, addr string, rateLimit uint32, creds credentials.TransportCredentials,
healthCheck bool) (*grpc.Server, error) {
log.Info("Starting private RPC server", "on", addr)
healthCheck bool, logger log.Logger) (*grpc.Server, error) {
logger.Info("Starting private RPC server", "on", addr)
lis, err := net.Listen("tcp", addr)
if err != nil {
return nil, fmt.Errorf("could not create listener: %w, addr=%s", err, addr)
Expand All @@ -43,7 +43,7 @@ func StartGrpc(kv *remotedbserver.KvServer, ethBackendSrv *EthBackendServer, txP
defer healthServer.Shutdown()
}
if err := grpcServer.Serve(lis); err != nil {
log.Error("private RPC server fail", "err", err)
logger.Error("private RPC server fail", "err", err)
}
}()

Expand Down
Loading

0 comments on commit 05597cb

Please sign in to comment.