Skip to content

Commit

Permalink
json-rpc: add option to only allow websocket traffic
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill authored and tharbert committed Mar 26, 2024
1 parent 5f2bfb1 commit a67a73b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions crates/sui-config/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ pub struct NodeConfig {
#[serde(default = "default_enable_index_processing")]
pub enable_index_processing: bool,

// only alow websocket connections for jsonrpc traffic
#[serde(default)]
pub websocket_only: bool,

#[serde(default)]
pub grpc_load_shed: Option<bool>,

Expand Down
8 changes: 7 additions & 1 deletion crates/sui-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use sui_core::consensus_adapter::SubmitToConsensus;
use sui_core::epoch::randomness::RandomnessManager;
use sui_core::execution_cache::ExecutionCacheMetrics;
use sui_core::execution_cache::NotifyReadWrapper;
use sui_json_rpc::ServerType;
use sui_json_rpc_api::JsonRpcMetrics;
use sui_network::randomness;
use sui_protocol_config::ProtocolVersion;
Expand Down Expand Up @@ -1929,7 +1930,12 @@ pub fn build_http_server(
))?;
server.register_module(MoveUtils::new(state))?;

server.to_router(None)?
let server_type = if config.websocket_only {
Some(ServerType::WebSocket)
} else {
None
};
server.to_router(server_type)?
};

router = router.merge(json_rpc_router);
Expand Down
2 changes: 2 additions & 0 deletions crates/sui-swarm-config/src/node_config_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ impl ValidatorConfigBuilder {
zklogin_oauth_providers: default_zklogin_oauth_providers(),
authority_overload_config: self.authority_overload_config.unwrap_or_default(),
run_with_range: None,
websocket_only: false,
}
}

Expand Down Expand Up @@ -447,6 +448,7 @@ impl FullnodeConfigBuilder {
zklogin_oauth_providers: default_zklogin_oauth_providers(),
authority_overload_config: Default::default(),
run_with_range: self.run_with_range,
websocket_only: false,
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ validator_configs:
request_batches_rate_limit: ~
enable-event-processing: false
enable-index-processing: true
websocket-only: false
grpc-load-shed: ~
grpc-concurrency-limit: 20000000000
p2p-config:
Expand Down Expand Up @@ -170,6 +171,7 @@ validator_configs:
request_batches_rate_limit: ~
enable-event-processing: false
enable-index-processing: true
websocket-only: false
grpc-load-shed: ~
grpc-concurrency-limit: 20000000000
p2p-config:
Expand Down Expand Up @@ -294,6 +296,7 @@ validator_configs:
request_batches_rate_limit: ~
enable-event-processing: false
enable-index-processing: true
websocket-only: false
grpc-load-shed: ~
grpc-concurrency-limit: 20000000000
p2p-config:
Expand Down Expand Up @@ -418,6 +421,7 @@ validator_configs:
request_batches_rate_limit: ~
enable-event-processing: false
enable-index-processing: true
websocket-only: false
grpc-load-shed: ~
grpc-concurrency-limit: 20000000000
p2p-config:
Expand Down Expand Up @@ -542,6 +546,7 @@ validator_configs:
request_batches_rate_limit: ~
enable-event-processing: false
enable-index-processing: true
websocket-only: false
grpc-load-shed: ~
grpc-concurrency-limit: 20000000000
p2p-config:
Expand Down Expand Up @@ -666,6 +671,7 @@ validator_configs:
request_batches_rate_limit: ~
enable-event-processing: false
enable-index-processing: true
websocket-only: false
grpc-load-shed: ~
grpc-concurrency-limit: 20000000000
p2p-config:
Expand Down Expand Up @@ -790,6 +796,7 @@ validator_configs:
request_batches_rate_limit: ~
enable-event-processing: false
enable-index-processing: true
websocket-only: false
grpc-load-shed: ~
grpc-concurrency-limit: 20000000000
p2p-config:
Expand Down Expand Up @@ -878,3 +885,4 @@ account_keys:
- mfPjCoE6SX0Sl84MnmNS/LS+tfPpkn7I8tziuk2g0WM=
- 5RWlYF22jS9i76zLl8jP2D3D8GC5ht+IP1dWUBGZxi8=
genesis: "[fake genesis]"

0 comments on commit a67a73b

Please sign in to comment.