Skip to content

Reuse gRPC clients #1804

@Mirko-von-Leipzig

Description

@Mirko-von-Leipzig

Currently the gRPC clients in the ntx builder are created once per network account actor. This might be the cause of #1746.

The code in question on main:

let block_producer = BlockProducerClient::new(actor_context.block_producer_url.clone());
let validator = Builder::new(actor_context.validator_url.clone())
.without_tls()
.with_timeout(Duration::from_secs(10))
.without_metadata_version()
.without_metadata_genesis()
.with_otel_context_injection()
.connect_lazy::<ValidatorClient>();
let prover = actor_context.tx_prover_url.clone().map(RemoteTransactionProver::new);
.

Instead of creating new clients, actors should be sharing the same underlying channel per endpoint, or at minimum some pool of channels.

I think gRPC/tonic already does this multi-plexing of a channel when a client is cloned, however it would be good to check this.

What needs doing

  1. Confirm that cloning a tonic gRPC client shares the underlying gRPC channel i.e. only consumes a single socket/file descriptor.
  2. Inspect other internal gRPC clients for similar issues.
    • Ensure RPC clients are cloned and not created anew from a URL.
  3. PR a fix into next
  4. PR a fix into main, linking to the PR in (2)Once we've deployed (3) to testnet, we can confirm whether this also fixes Node consumes excessive amounts of TCP connections #1746.

If (1) turns out to be false, then we'll have to figure out a connection pool instead.

Metadata

Metadata

Labels

network transactionsRelates to the network transactions feature

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions