Skip to content

Consensus CLI should reject execution WebSocket endpoints when IPC transport is selected #338

Description

@Kewe63

Summary

The consensus CLI allows a complete IPC transport configuration to be combined with --execution-ws-endpoint, even though the WebSocket endpoint is an RPC-only option.

The mixed configuration passes StartCmd::validate(). Later, StartConfig::engine_config() prioritizes IPC and constructs EngineConfig::Ipc, causing the explicitly supplied WebSocket endpoint to be silently ignored.

The CLI should reject this IPC/RPC conflict during startup validation instead of accepting a configuration it cannot fully honor.

Affected files

  • crates/malachite-cli/src/cmd/start.rs
  • crates/malachite-app/src/config.rs

The validation gap is in StartCmd::validate() in crates/malachite-cli/src/cmd/start.rs. StartConfig::engine_config() in crates/malachite-app/src/config.rs demonstrates the resulting behavior.

Observed behavior

StartCmd::validate() determines whether IPC options are present with:

let has_ipc_options = self.eth_socket.is_some() || self.execution_socket.is_some();

It determines whether RPC options are present with:

let has_rpc_options = self.eth_rpc_endpoint.is_some()
    || self.execution_endpoint.is_some()
    || self.execution_jwt.is_some();

execution_ws_endpoint is missing from has_rpc_options.

However, the same method explicitly classifies it as part of the RPC transport immediately afterward:

let uses_rpc_transport = self.eth_rpc_endpoint.is_some()
    || self.execution_endpoint.is_some()
    || self.execution_ws_endpoint.is_some()
    || self.execution_jwt.is_some();

This mixed configuration is therefore accepted:

--eth-socket /tmp/reth.ipc
--execution-socket /tmp/reth-auth.ipc
--execution-ws-endpoint ws://localhost:8546

StartConfig::engine_config() checks for a complete IPC configuration first. It consequently selects EngineConfig::Ipc, and execution_ws_endpoint is not included in that configuration.

Expected behavior

Any IPC transport option should conflict with any RPC transport option.

Because --execution-ws-endpoint is documented and handled as RPC-only, it should be included in has_rpc_options. Combining it with IPC options should fail with the existing IPC/RPC conflict error.

The conflict message's RPC option list should also include --execution-ws-endpoint.

Reproduction

The following focused regression test was run against current main:

#[test]
fn validate_err_when_mixing_ipc_and_execution_ws_endpoint() {
    let mut cmd = new_start_cmd();
    cmd.eth_socket = Some("/tmp/reth.ipc".to_string());
    cmd.execution_socket = Some("/tmp/reth-auth.ipc".to_string());
    cmd.execution_ws_endpoint = Some(dummy_url());

    assert!(
        cmd.validate().is_err(),
        "--execution-ws-endpoint is an RPC option and must conflict with IPC"
    );
}

Command:

cargo +1.94.0 test \
  -p arc-node-consensus-cli \
  validate_err_when_mixing_ipc_and_execution_ws_endpoint \
  -- --nocapture

Result on the pre-fix implementation:

test cmd::start::tests::validate_err_when_mixing_ipc_and_execution_ws_endpoint ... FAILED

The test was executed against commit:

97f8da0dc4faa703fe2d68ca007e40dab2c8a9ef

Root cause

The IPC/RPC conflict detection and RPC transport detection use different option sets.

execution_ws_endpoint is included in uses_rpc_transport but omitted from has_rpc_options. This allows it to be recognized as an RPC transport option without triggering the IPC/RPC conflict check.

Why this matters

Silently accepting and ignoring an explicit CLI argument can mislead operators. An operator may believe the configured WebSocket endpoint is being used for execution-layer events while the node has actually selected IPC and discarded the WebSocket setting.

Failing during validation would expose the configuration mistake immediately and ensure explicitly supplied options are not silently ignored.

Suggested fix

Include execution_ws_endpoint in has_rpc_options:

let has_rpc_options = self.eth_rpc_endpoint.is_some()
    || self.execution_endpoint.is_some()
    || self.execution_ws_endpoint.is_some()
    || self.execution_jwt.is_some();

Also include --execution-ws-endpoint in the existing conflict error's RPC option list.

No transport-selection behavior should need to change.

Potential regression tests

Verify that:

  • IPC configuration without RPC options remains valid;
  • RPC configuration with --execution-ws-endpoint remains valid;
  • IPC combined with --execution-ws-endpoint is rejected;
  • the returned error identifies the IPC/RPC conflict and lists --execution-ws-endpoint.

Duplicate check

Open and closed issues and pull requests were searched using:

  • execution-ws-endpoint
  • execution_ws_endpoint
  • execution websocket with eth-socket
  • Conflicting options detected
  • IPC and RPC

No prior direct duplicate was found. Issue #294 and PR #295 concern separated-host deprecation wording and do not address mixed IPC/WebSocket validation or the silently ignored endpoint.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions