Skip to content

Commit

Permalink
Fix bounded channel being too small (#1747)
Browse files Browse the repository at this point in the history
* Fix bounded channel being too small

* PR link
  • Loading branch information
tomaka authored Apr 4, 2024
1 parent a6c2b5b commit fba1a8a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
11 changes: 3 additions & 8 deletions light-base/src/json_rpc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,16 @@ pub struct Config<TPlat: PlatformRef> {
///
/// This parameter is necessary in order to prevent users from using up too much memory within
/// the client.
// TODO: unused at the moment
pub max_pending_requests: NonZeroU32,

/// Maximum number of active subscriptions. Any additional subscription will be immediately
/// rejected.
///
/// This parameter is necessary in order to prevent users from using up too much memory within
/// the client.
pub max_subscriptions: u32,

/// Maximum number of JSON-RPC requests that can be processed simultaneously.
///
/// This parameter is necessary in order to prevent users from using up too much memory within
/// the client.
// TODO: unused at the moment
pub max_parallel_requests: NonZeroU32,
pub max_subscriptions: u32,
}

/// Creates a new JSON-RPC service with the given configuration.
Expand All @@ -96,7 +91,7 @@ pub struct Config<TPlat: PlatformRef> {
pub fn service<TPlat: PlatformRef>(config: Config<TPlat>) -> (Frontend<TPlat>, ServicePrototype) {
let log_target = format!("json-rpc-{}", config.log_name);

let (requests_tx, requests_rx) = async_channel::bounded(32); // TODO: capacity?
let (requests_tx, requests_rx) = async_channel::unbounded(); // TODO: capacity?
let (responses_tx, responses_rx) = async_channel::bounded(16); // TODO: capacity?

let frontend = Frontend {
Expand Down
7 changes: 0 additions & 7 deletions light-base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,13 +935,6 @@ impl<TPlat: platform::PlatformRef, TChain> Client<TPlat, TChain> {
log_name: log_name.clone(), // TODO: add a way to differentiate multiple different json-rpc services under the same chain
max_pending_requests,
max_subscriptions,
// Note that the settings below are intentionally not exposed in the publicly
// available configuration, as "good" values depend on the global number of tasks.
// In other words, these constants are relative to the number of other things that
// happen within the client rather than absolute values. Since the user isn't
// supposed to know what happens within the client, they can't rationally decide
// what value is appropriate.
max_parallel_requests: NonZeroU32::new(24).unwrap(),
});

service_starter.start(json_rpc_service::StartConfig {
Expand Down
4 changes: 4 additions & 0 deletions wasm-node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Fixed

- Fix `QueueFullError` being thrown even when the number of requests is way below the value passed to `jsonRpcMaxPendingRequests`. ([#1747](https://github.com/smol-dot/smoldot/pull/1747))

## 2.0.23 - 2024-03-20

### Changed
Expand Down

0 comments on commit fba1a8a

Please sign in to comment.