Skip to content

fix(deploy,wallet,doctor): derive sequencer URL from [localnet] port#145

Closed
wozos wants to merge 1 commit into
logos-co:masterfrom
wozos:wozos/claude/scaffold-wozos-issue-impl-20260512-012013
Closed

fix(deploy,wallet,doctor): derive sequencer URL from [localnet] port#145
wozos wants to merge 1 commit into
logos-co:masterfrom
wozos:wozos/claude/scaffold-wozos-issue-impl-20260512-012013

Conversation

@wozos
Copy link
Copy Markdown
Contributor

@wozos wozos commented May 11, 2026

Description

logos-scaffold users on non-default localnet ports ([localnet] port = 14321 etc.) had three sites still hardcoding the default http://127.0.0.1:3040: deploy's sequencer fallback, is_connectivity_failure's substring needles, and doctor's wallet network-config check. The first stranded deploy against the wrong RPC when wallet_config.json omitted sequencer_addr; the second silently downgraded genuine functional failures (RPC rejection, signature mismatch) to transient connectivity warnings whenever the wallet echoed the URL in its error output; the third blindly substring-matched 127.0.0.1:3040 against the raw config text, so any non-default port produced a false Warn and a brittle whitespace match could swing the verdict either way. #40 established the port-config-respect invariant; this PR finishes propagating it.

Solution

  • WalletRuntimeContext.sequencer_addr is now resolved once in load_wallet_runtime: wallet_config.json#sequencer_addr when present, otherwise http://127.0.0.1:<[localnet] port> (default 3040 if [localnet] is omitted, matching the existing LocalnetConfig::default). Field changes from Option<String> to String so call sites in deploy.rs and wallet.rs no longer carry their own copies of the fallback URL — both just clone wallet.sequencer_addr. DEFAULT_SEQUENCER_ADDR constant in deploy.rs is gone; the "http://127.0.0.1:3040" literal in wallet.rs is gone.
  • is_connectivity_failure (src/commands/wallet_support.rs:226) drops the "127.0.0.1:3040" / "localhost:3040" needles. The remaining transport-error tokens (connection refused, tcp connect error, network is unreachable, etc.) cover the actual transport failure modes; the address literals were noise that caused two distinct false-positive shapes (non-default port loses the heuristic; functional failure echoing the URL gets misclassified).
  • doctor's wallet-network-config check is now check_wallet_network_config in src/commands/doctor.rs. It parses wallet_config.json with serde_json, extracts sequencer_addr, and Passes iff the URL host is 127.0.0.1 or localhost and the port equals project.config.localnet.port. Missing sequencer_addr is also a Pass because the runtime falls back to the local URL; missing file / parse failure / non-string sequencer_addr / remote-host Warn with remediations that name the project's expected URL (not a hardcoded 3040). The URL-shape predicate (sequencer_addr_targets_local_port) is its own function for unit testability.
  • 15 new tests cover: the retained transport-error tokens (positive), bare-URL and RPC-rejection shapes (negative), default URL derivation on 3040 and 14321, and every check_wallet_network_config branch (matching/mismatched port, localhost alias, missing field, missing file, malformed JSON, non-string value, remote host) plus the URL matcher.

cargo build and cargo test --all-targets both pass on the worktree (250 lib tests, 135 integration tests). cargo fmt clean. No new cargo clippy warnings on the touched files; pre-existing warnings in basecamp.rs are unchanged.

Notes

Closes #118


Run ID: 20260512-012013
Authored by: scaffold-wozos-issue-impl recurring task (claude-code worker)

@wozos wozos requested a review from a team May 11, 2026 23:28
logos-co#40 covered doctor's port-check label hardcoding 127.0.0.1:3040. Three
sites still embedded the same default after that fix:

1. deploy.rs DEFAULT_SEQUENCER_ADDR fallback ignored [localnet] port.
2. wallet_support::is_connectivity_failure substring-matched the literal
   addresses, which both ignored non-default localnet ports (the
   configured URL embeds whatever port is in scaffold.toml) and
   misclassified functional failures that echoed the URL in their error
   context (RPC rejection, signature mismatch, malformed payload) as
   transient connectivity errors.
3. doctor's wallet network-config check substring-matched the literal
   addresses against the raw wallet_config.json text instead of parsing
   the JSON, brittle to whitespace/formatting and blind to non-default
   ports.

The new behavior:

- WalletRuntimeContext.sequencer_addr is now resolved once in
  load_wallet_runtime (String, not Option<String>). Missing
  wallet_config.json#sequencer_addr falls back to
  http://127.0.0.1:<localnet.port>. deploy and wallet topup just use
  wallet.sequencer_addr directly.
- is_connectivity_failure keeps only transport-error tokens; address
  literals were dropped.
- doctor's wallet network-config check parses the JSON with serde_json,
  reads sequencer_addr, and PASSes when it points at
  http(s)://(127.0.0.1|localhost):<localnet.port>. Missing field PASSes
  because the runtime fallback produces the local URL. Anything else
  WARNs with a remediation that names the expected URL for this
  project's localnet port.

Tests added (15 new):

- wallet_support: is_connectivity_failure positive coverage for the
  retained transport-error tokens; negative coverage for bare-URL and
  RPC-rejection shapes that no longer trigger; default sequencer URL
  derivation on 3040 and 14321.
- doctor: check_wallet_network_config covering matching/mismatched
  ports, localhost alias, missing field, remote host, malformed JSON,
  missing file, non-string sequencer_addr, and the
  sequencer_addr_targets_local_port URL matcher (positive and
  negative).

Closes logos-co#118
@wozos wozos force-pushed the wozos/claude/scaffold-wozos-issue-impl-20260512-012013 branch from 8500476 to e8ed638 Compare May 12, 2026 22:21
@weboko weboko closed this May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hardcoded port-3040 sites beyond #40 (deploy.rs DEFAULT_SEQUENCER_ADDR + 2 substring-match callsites)

2 participants