Skip to content

Proxy panics on startup when DOWNSTREAM_HASHRATE env var is set #210

@Anshumancanrock

Description

@Anshumancanrock

Description

Setting the DOWNSTREAM_HASHRATE environment variable causes the proxy to panic immediately on startup with:

Root Cause

I think there is a copy-paste error in src/config.rs where the listening_addr field incorrectly reads from DOWNSTREAM_HASHRATE instead of a dedicated env var.

let listening_addr = args.listening_addr.or(config.listening_addr).or_else(|| {
    std::env::var("DOWNSTREAM_HASHRATE")  // should be a dedicated env var, e.g. LISTENING_ADDR
        .ok()
        .and_then(|s| s.parse().ok())
});

Since the return type is Option<String>, parsing a hashrate string like "100T" always succeeds. The value is then passed to TcpListener::bind, which fails to parse it as a SocketAddr and panics.

This also means there is currently no working environment variable to configure the downstream listening address.

Steps to Reproduce

DOWNSTREAM_HASHRATE=100T ./dmnd-client

Expected Behaviour

Setting DOWNSTREAM_HASHRATE should only affect the hashrate configuration and have no impact on the listening address.

Proposed Fix

Replace "DOWNSTREAM_HASHRATE" with an appropriate env var name (e.g. "LISTENING_ADDR") in the listening_addr resolution block.

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