Skip to content

client: verify each rpc_url serves the configured chain at startup #3025

Backlog

Description

@alpergundogdu

Problem

The client never checks that a configured rpc_url serves the chain the config names. The node does: check_deployment_preflight (crates/node/src/runtime/mod.rs) fails bring-up when a payment chain's RPC reports a different eth_chainId.

On the client side:

  • build_provider (crates/client/src/provider.rs) uses .fetch_chain_id(), so it signs transactions for whatever chain the RPC reports.
  • build_read_provider reads without any chain check.
  • Only publish, sweep, receipt and node earnings compare eth_chainId themselves.

An RPC pointed at the wrong chain therefore runs decdn get, the pool commands, top-ups and decdn gateway against that chain with no error. Where a PaymentPool sits at the same address on the other chain (deterministic deploys across testnets), pool reads decode as "no record". #3015 would then retire the stored row of a funded pool.

Fix

  1. Add an async ChainConfig::verify() in decdn-client (session.rs). It reads eth_chainId once for each distinct RPC (governance chain and each payment pool) and fails on a mismatch, with the same message shape as the node's preflight.
  2. Call it once at the start of every client entry point: the SDK's pull/session setup (so the mobile apps and sponsord get it), decdn get, decdn gateway and the pool commands.
  3. In build_provider, pin the verified chain id with .with_chain_id(expected) in place of .fetch_chain_id(), so no transaction is signed for a chain the config does not name.
  4. Drop the per-command checks in publish, sweep, receipt and node earnings where the startup check now covers them.

Done when

  • A client command or SDK pull with a mismatched rpc_url fails before any chain read or write, naming the configured and served chain ids.
  • A test covers the mismatch for the SDK entry point and for decdn get.
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

    Fields

    Priority

    None yet

    Projects

    • Status
      Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions