Skip to content

[Bug]:GethChain's Start method fails to dial host RPC due to using "0.0.0.0" as a connection address #1391

@0xChainDuck

Description

@0xChainDuck

What happened and what did you expect to happen?

  • Bug Description:
    I am using interchaintest v8 (specifically version v8.0.1-evm-comet1-inj) to set up a test environment that includes a Geth node. The geth.GethChain.Start method internally attempts to connect to its own RPC service via ethclient.Dial. However, this process fails, causing the entire test setup to fail.
  • Root Cause:
    The issue stems from the Start method relying on GetHostRPCAddress() to retrieve the connection string. This address is constructed from Docker's port mapping information. When a Docker container's port is mapped to all of the host's network interfaces, the Docker API returns 0.0.0.0 as the HostIP.
    The framework then directly uses this 0.0.0.0 to build the connection address (e.g., http://0.0.0.0:57086). However, 0.0.0.0 is a special address used for server binding ("listen on all interfaces") and is not a valid connection target for a client. This causes ethclient.Dial to fail.

`Expected Behavior:
The framework should recognize that 0.0.0.0 is not a valid connection IP and should automatically translate it to a usable address, such as localhost or 127.0.0.1. This would allow ethclient.Dial to connect successfully and the Start method to complete without errors.

  • Suggested Fix:
    In the chain/ethereum/ethererum_chain.go file, within the Start method, check and replace the address returned by GetHostRPCAddress() before it is used by ethclient.Dial.
    // file: chain/ethereum/ethererum_chain.go

    // ... inside Start() method
    hostRPCAddr := c.GetHostRPCAddress()
    if strings.HasPrefix(hostRPCAddr, "http://0.0.0.0") {
        hostRPCAddr = strings.Replace(hostRPCAddr, "0.0.0.0", "127.0.0.1", 1)
    }

    c.rpcClient, err = ethclient.Dial(hostRPCAddr)
    // ... rest of the logic

Describe how to reproduce the bug

  • Steps to Reproduce:
    1.Create an interchaintest test suite.
    2.In SetupTest, initialize a geth.GethChain.
    3.Call gethChain.Start(ctx).
    4.Observe that the call fails with an error similar to "failed to dial ETH rpc host(http://0.0.0.0:...) ...".

version

v8.0.1

Relevant logs or stack trace

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions