Skip to content
Open
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
4 changes: 2 additions & 2 deletions cmd/juno/juno.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ const (
rpcMaxBatchResponseSizeUsage = "Size (in MBs) at which a batch stops being processed. " +
"The calls answered so far are returned, the rest are not executed. " +
"0 disables the limit."
rpcBatchConcurrencyUsage = "Maximum batch calls that run at the same time, per RPC version. " +
"All batch requests to a version share this limit. " +
rpcBatchConcurrencyUsage = "Maximum batch calls that run at the same time. " +
"Every batch request shares this limit, across all RPC versions. " +
"Default is set based on available hardware resources."
maxConcurrentCompilationsUsage = "Maximum concurrent Sierra compilations. " +
"Default is set based on available hardware resources."
Expand Down
12 changes: 12 additions & 0 deletions jsonrpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,18 @@ func NewServer(poolMaxGoroutines int, logger log.StructuredLogger) *Server {
return s
}

// NewServer instantiates a JSONRPC server with pool

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc comment still says "NewServer" — leftover from before the WithPoolNewServerWithPool rename. Should read // NewServerWithPool instantiates a JSONRPC server with a shared pool (staticcheck's ST1020 convention expects the comment to start with the function name).

Suggested change
// NewServer instantiates a JSONRPC server with pool
// NewServerWithPool instantiates a JSONRPC server with a shared pool

func NewServerWithPool(pool *pool.Pool, logger log.StructuredLogger) *Server {
s := &Server{
logger: logger,
methods: make(map[string]Method),
pool: pool,
listener: &SelectiveListener{},
}

return s
}

// WithValidator registers a validator to validate handler struct arguments
func (s *Server) WithValidator(validator Validator) *Server {
s.validator = validator
Expand Down
9 changes: 6 additions & 3 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
"github.com/NethermindEth/juno/vm"
"github.com/consensys/gnark-crypto/ecc/stark-curve/ecdsa"
"github.com/sourcegraph/conc"
"github.com/sourcegraph/conc/pool"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
Expand Down Expand Up @@ -541,7 +542,9 @@ func New(cfg *Config, version string, logLevel *log.Level) (*Node, error) {
}
maxBatchResponseBytes := int(cfg.RPCMaxBatchResponseSize) * db.Megabyte

jsonrpcServerV10 := jsonrpc.NewServer(maxGoroutines, logger).
batchPool := pool.New().WithMaxGoroutines(maxGoroutines)

jsonrpcServerV10 := jsonrpc.NewServerWithPool(batchPool, logger).
WithValidator(rpcv10.Validator()).
WithMaxBatchElements(int(cfg.RPCMaxBatchSize)).
WithMaxBatchResponseBytes(maxBatchResponseBytes).
Expand All @@ -551,7 +554,7 @@ func New(cfg *Config, version string, logLevel *log.Level) (*Node, error) {
return nil, err
}

jsonrpcServerV09 := jsonrpc.NewServer(maxGoroutines, logger).
jsonrpcServerV09 := jsonrpc.NewServerWithPool(batchPool, logger).
WithValidator(rpcv9.Validator()).
WithMaxBatchElements(int(cfg.RPCMaxBatchSize)).
WithMaxBatchResponseBytes(maxBatchResponseBytes).
Expand All @@ -561,7 +564,7 @@ func New(cfg *Config, version string, logLevel *log.Level) (*Node, error) {
return nil, err
}

jsonrpcServerV08 := jsonrpc.NewServer(maxGoroutines, logger).
jsonrpcServerV08 := jsonrpc.NewServerWithPool(batchPool, logger).
WithValidator(rpcv8.Validator()).
WithMaxBatchElements(int(cfg.RPCMaxBatchSize)).
WithMaxBatchResponseBytes(maxBatchResponseBytes).
Expand Down
Loading