Skip to content

Commit

Permalink
fix(api): filters_disabled should only affect HTTP endpoints (#1493)
Browse files Browse the repository at this point in the history
## What ❔

Follow-up on #1078 

## Why ❔

Websocket API does not suffer from the issues described in the original
PR, hence it can and should be used by users.

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [x] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [ ] Tests for the changes have been added / updated.
- [x] Documentation comments have been added / updated.
- [x] Code has been formatted via `zk fmt` and `zk lint`.
- [x] Spellcheck has been run via `zk spellcheck`.
- [x] Linkcheck has been run via `zk linkcheck`.
  • Loading branch information
itegulov committed Mar 28, 2024
1 parent 0c79a37 commit 8720568
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion core/bin/external_node/src/config/mod.rs
Expand Up @@ -156,7 +156,8 @@ pub struct OptionalENConfig {
latest_values_cache_size_mb: usize,
/// Enabled JSON RPC API namespaces.
api_namespaces: Option<Vec<Namespace>>,
/// Whether to support methods installing filters and querying filter changes.
/// Whether to support HTTP methods that install filters and query filter changes.
/// WS methods are unaffected.
///
/// When to set this value to `true`:
/// Filters are local to the specific node they were created at. Meaning if
Expand Down
3 changes: 2 additions & 1 deletion core/lib/config/src/configs/api.rs
Expand Up @@ -32,7 +32,8 @@ pub struct Web3JsonRpcConfig {
pub ws_url: String,
/// Max possible limit of entities to be requested once.
pub req_entities_limit: Option<u32>,
/// Whether to support methods installing filters and querying filter changes.
/// Whether to support HTTP methods that install filters and query filter changes.
/// WS methods are unaffected.
///
/// When to set this value to `true`:
/// Filters are local to the specific node they were created at. Meaning if
Expand Down
16 changes: 9 additions & 7 deletions core/lib/zksync_core/src/api_server/web3/mod.rs
Expand Up @@ -315,13 +315,15 @@ impl ApiServer {
let start_info = BlockStartInfo::new(&mut storage).await?;
drop(storage);

let installed_filters = if self.config.filters_disabled {
None
} else {
Some(Arc::new(Mutex::new(Filters::new(
self.optional.filters_limit,
))))
};
// Disable filter API for HTTP endpoints, WS endpoints are unaffected by the `filters_disabled` flag
let installed_filters =
if matches!(self.transport, ApiTransport::Http(_)) && self.config.filters_disabled {
None
} else {
Some(Arc::new(Mutex::new(Filters::new(
self.optional.filters_limit,
))))
};

Ok(RpcState {
current_method: self.method_tracer,
Expand Down

0 comments on commit 8720568

Please sign in to comment.