Skip to content

Conversation

@ws4charlie
Copy link
Contributor

@ws4charlie ws4charlie commented Sep 23, 2025

Description

The go-tss side modification is in PR 64

Closes #1038

How Has This Been Tested?

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Summary by CodeRabbit

  • New Features

    • Added support for configuring zetaclient with a public DNS name as an alternative to public IP.
    • Introduced --public-dns CLI flag during initialization.
    • Telemetry now accepts and exposes the DNS name (new /dns endpoint).
    • TSS setup accepts either Public IP or DNS for network configuration.
    • Localnet updated to map hostnames and use DNS in startup scripts.
  • Documentation

    • Changelog updated to reflect DNS support.
  • Chores

    • Updated go-tss dependency version.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 23, 2025

📝 Walkthrough

Walkthrough

Adds DNS hostname support alongside public IP for zetaclient: new CLI flag (--public-dns), config field (PublicDNS), telemetry DNS exposure (/dns, setters/getters), startup wiring to set DNS, TSS setup accepting DNS or IP and passing ExternalDNS, localnet docker DNS mappings, and a go-tss dependency update.

Changes

Cohort / File(s) Summary
Changelog
changelog.md
Added entry describing support for zetaclient public DNS name.
CLI and startup wiring
cmd/zetaclientd/initconfig.go, cmd/zetaclientd/start.go, contrib/localnet/scripts/start-zetaclientd.sh
Adds --public-dns flag, stores in config, sets telemetry DNS on startup, and updates localnet start script to use --public-dns for non-primary hosts. Minor operator flag text tweak.
Telemetry DNS support
zetaclient/metrics/telemetry.go
Adds dnsName field with SetDNSName/GetDNSName, new /dns handler returning DNS value, integrated into handlers with locking.
Config surface
zetaclient/config/types.go
Adds PublicDNS string (json:PublicDNS) to Config.
TSS setup logic
zetaclient/tss/setup.go
Validates presence of either PublicIP or PublicDNS; passes ExternalDNS from config into TSS network configuration.
Localnet DNS mappings
contrib/localnet/docker-compose.yml
Adds extra_hosts mapping zetaclient{0..3}.com to static container IPs.
Dependency update
go.mod
Bumps github.com/zeta-chain/go-tss to v0.6.4-0.20250923180519-1bbb3ac2ff31.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Operator
  participant CLI as zetaclientd (CLI)
  participant Cfg as Config
  participant Tele as TelemetryServer
  participant TSS as TSS Server

  Operator->>CLI: initialize --public-dns <name> (or --public-ip)
  CLI->>Cfg: InitializeConfig(opts)\nset Cfg.PublicDNS/PublicIP
  note right of Cfg: Config now includes PublicDNS

  Operator->>CLI: start
  CLI->>Tele: SetIPAddress(Cfg.PublicIP)
  CLI->>Tele: SetDNSName(Cfg.PublicDNS)
  Tele-->>Operator: /dns endpoint exposes DNS

  CLI->>TSS: NewServer(Cfg)
  alt Valid network identity
    TSS->>TSS: Validate Cfg.PublicIP || Cfg.PublicDNS
    TSS->>TSS: NetworkConfig{ExternalIP, ExternalDNS}
    TSS-->>CLI: Server ready
  else Missing identity
    TSS-->>CLI: Error (require IP or DNS)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed The title "feat: add support for zetaclient external DNS name" succinctly and accurately summarizes the primary intent of the changeset—adding external DNS name support for zetaclient—and is concise, specific, and readable for reviewers scanning history.
Linked Issues Check ✅ Passed The code changes address the primary coding objectives of issue [#1038] by adding a PublicDNS config field and a --public-dns CLI flag, passing ExternalDNS into the TSS network configuration, and updating the go-tss dependency to a version that supports hostnames, thereby enabling hostname-based TSS addresses; the approach uses a dedicated flag rather than altering --public-ip to accept hostnames, which is a small behavioral choice but functionally satisfies the issue requirements.
Out of Scope Changes Check ✅ Passed All modified files are related to enabling external DNS support and operational/testing convenience (CLI, config, TSS setup, telemetry endpoint, docker-compose, scripts, changelog) and the go.mod bump aligns with the required go-tss change; I do not see unrelated or off-topic changes introduced in this PR.
Description Check ✅ Passed The PR description follows the repository template by providing a summary, linking the go-tss PR, referencing and closing issue #1038, and including the testing checklist with localnet verified; however, it lacks detailed motivation/context, explicit reproduction or test steps, and CI/unit/integration test results which are useful for reviewers and maintainers.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-support-tss-externalDNS

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ws4charlie ws4charlie added zetaclient Issues related to ZetaClient and removed breaking:cli labels Sep 23, 2025
@ws4charlie ws4charlie changed the title feat: add support for external DNS name feat: add support for zetaclient external DNS name Sep 23, 2025
@codecov
Copy link

codecov bot commented Sep 23, 2025

Codecov Report

❌ Patch coverage is 0% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.97%. Comparing base (dda8e9e) to head (31e5065).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
zetaclient/metrics/telemetry.go 0.00% 12 Missing ⚠️
zetaclient/tss/setup.go 0.00% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4234      +/-   ##
==========================================
- Coverage   65.00%   64.97%   -0.03%     
==========================================
  Files         452      452              
  Lines       34124    34137      +13     
==========================================
  Hits        22182    22182              
- Misses      10967    10980      +13     
  Partials      975      975              
Files with missing lines Coverage Δ
zetaclient/config/types.go 71.85% <ø> (ø)
zetaclient/tss/setup.go 0.00% <0.00%> (ø)
zetaclient/metrics/telemetry.go 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ws4charlie ws4charlie added zetaclient Issues related to ZetaClient enhancement New feature or request and removed zetaclient Issues related to ZetaClient labels Sep 24, 2025
@ws4charlie ws4charlie marked this pull request as ready for review September 24, 2025 15:32
@ws4charlie ws4charlie requested a review from a team as a code owner September 24, 2025 15:32
@ws4charlie ws4charlie requested a review from a team September 24, 2025 15:32
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
contrib/localnet/scripts/start-zetaclientd.sh (1)

99-112: Fix Bash syntax: missing semicolon/newline before then.

if [[ … ]] then is invalid; it must be if [[ … ]]; then or place then on the next line. This will cause the script to fail.

Apply for this block (and mirror the same fix for the earlier if at Line 82):

-if [[ $HOSTNAME != "zetaclient0" && ! -f ~/.zetacored/config/zetaclient_config.json ]] then
+if [[ $HOSTNAME != "zetaclient0" && ! -f ~/.zetacored/config/zetaclient_config.json ]]; then

Optional hardening:

  • Add set -euo pipefail at the top to fail fast on errors.
🧹 Nitpick comments (6)
changelog.md (1)

21-21: Tighten wording for clarity.

Consider: “add support for zetaclient public DNS name” (drop “additional”).

cmd/zetaclientd/start.go (1)

227-228: Guard SetDNSName when empty.

If cfg.PublicDNS is empty, skip calling SetDNSName to avoid exposing blank state on /dns.

-telemetry.SetDNSName(cfg.PublicDNS)
+if cfg.PublicDNS != "" {
+  telemetry.SetDNSName(cfg.PublicDNS)
+}
cmd/zetaclientd/initconfig.go (1)

17-17: Validate public-dns/public-ip inputs and mutual exclusivity.

Enforce at least one of --public-ip or --public-dns; warn if both are set.

Add after opts are parsed in InitializeConfig():

// ensure addressing is provided
if opts.publicIP == "" && opts.publicDNS == "" {
  return errors.New("one of --public-ip or --public-dns must be set")
}
if opts.publicIP != "" && opts.publicDNS != "" {
  // non-fatal: prefer explicitness
  fmt.Println("warning: both --public-ip and --public-dns set; both will be stored")
}

Also applies to: 54-54, 66-66, 96-96

zetaclient/metrics/telemetry.go (3)

32-37: DNS field addition is fine; consider a unified accessor for external host

Callers often want “the externally reachable host,” regardless of whether it’s IP or DNS. Adding a helper reduces duplication and ambiguity across handlers/consumers.

Example helper (outside the selected range):

// GetExternalHost returns DNS name if set, otherwise the IP address.
func (t *TelemetryServer) GetExternalHost() string {
	t.mu.Lock()
	defer t.mu.Unlock()
	if t.dnsName != "" {
		return t.dnsName
	}
	return t.ipAddress
}

111-123: Normalize and sanitize the DNS on set (trim + lowercase)

Domain names are case-insensitive and often sourced from flags/env; normalizing prevents subtle mismatches. Minimal, safe change.

Apply within this block:

 func (t *TelemetryServer) SetDNSName(dns string) {
-	t.mu.Lock()
-	defer t.mu.Unlock()
-	t.dnsName = dns
+	dns = strings.ToLower(strings.TrimSpace(dns))
+	t.mu.Lock()
+	defer t.mu.Unlock()
+	t.dnsName = dns
 }

Add import (outside the selected range):

import "strings"

251-256: Set a Content-Type and return 204 when DNS is unset

Improve HTTP semantics and client interoperability by signaling absence and avoiding content sniffing.

-// dnsHandler returns the dns name
-func (t *TelemetryServer) dnsHandler(w http.ResponseWriter, _ *http.Request) {
-	w.WriteHeader(http.StatusOK)
-	fmt.Fprintf(w, "%s", t.GetDNSName())
-}
+// dnsHandler returns the DNS name
+func (t *TelemetryServer) dnsHandler(w http.ResponseWriter, _ *http.Request) {
+	dns := t.GetDNSName()
+	if dns == "" {
+		w.WriteHeader(http.StatusNoContent)
+		return
+	}
+	w.Header().Set("Content-Type", "text/plain; charset=utf-8")
+	fmt.Fprint(w, dns)
+}
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between dda8e9e and 31e5065.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (9)
  • changelog.md (1 hunks)
  • cmd/zetaclientd/initconfig.go (4 hunks)
  • cmd/zetaclientd/start.go (1 hunks)
  • contrib/localnet/docker-compose.yml (4 hunks)
  • contrib/localnet/scripts/start-zetaclientd.sh (1 hunks)
  • go.mod (1 hunks)
  • zetaclient/config/types.go (1 hunks)
  • zetaclient/metrics/telemetry.go (4 hunks)
  • zetaclient/tss/setup.go (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.go

⚙️ CodeRabbit configuration file

Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

Files:

  • zetaclient/config/types.go
  • zetaclient/tss/setup.go
  • cmd/zetaclientd/start.go
  • zetaclient/metrics/telemetry.go
  • cmd/zetaclientd/initconfig.go
**/*.sh

⚙️ CodeRabbit configuration file

Review the shell scripts, point out issues relative to security, performance, and maintainability.

Files:

  • contrib/localnet/scripts/start-zetaclientd.sh
🧠 Learnings (1)
📚 Learning: 2025-09-21T17:54:21.110Z
Learnt from: kingpinXD
PR: zeta-chain/node#4225
File: Makefile:383-385
Timestamp: 2025-09-21T17:54:21.110Z
Learning: In upgrade tests, docker-compose-upgrade.yml is used specifically to build older versions of zetacored and zetaclientd, while docker-compose.yml handles the newer version configuration. Environment variables like USE_ZETAE2E_ANTE are intended for the newer version and don't need to be propagated to the upgrade compose file.

Applied to files:

  • contrib/localnet/docker-compose.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: build-zetanode
  • GitHub Check: test-sim-import-export / sim
  • GitHub Check: test-sim-after-import / sim
  • GitHub Check: test-sim-nondeterminism / sim
  • GitHub Check: test-sim-fullappsimulation / sim
  • GitHub Check: gosec
  • GitHub Check: lint
  • GitHub Check: build-and-test
  • GitHub Check: build
  • GitHub Check: analyze (go)
🔇 Additional comments (3)
zetaclient/config/types.go (1)

101-101: LGTM: Config gains PublicDNS.

The field addition is straightforward and backward compatible with existing JSON.

Please confirm any external docs and sample configs are updated to mention PublicDNS.

go.mod (1)

309-309: Pin go‑tss to a released tag and verify NetworkConfig.ExternalDNS

  • go.mod currently uses a pseudo‑version (v0.6.4-...) while upstream tags stop at v0.6.3; repo search shows no NetworkConfig/ExternalDNS in go‑tss.
  • Action: pin to a released tag (prefer v0.6.3) or wait for an official v0.6.4, and confirm the chosen release exposes NetworkConfig.ExternalDNS; if it does not, update zetaclient/tss/setup.go ( ExternalDNS at zetaclient/tss/setup.go:228 ) to match the tagged API or vendor the specific commit with justification.
zetaclient/metrics/telemetry.go (1)

197-199: Update dashboards/probes/docs to consume the new /dns telemetry endpoint

Telemetry now exposes /dns; wiring confirmed — SetDNSName is called in cmd/zetaclientd/start.go:227 and PublicDNS is defined in zetaclient/config/types.go:101. Update dashboards, monitoring probes, and any docs that scrape telemetry to use /dns (or validate fallbacks to /ip).

Comment on lines +210 to 212
case cfg.PublicIP == "" && cfg.PublicDNS == "":
logger.Warn().Msg("no public IP or DNS is provided")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Require at least one of PublicIP/PublicDNS; fail fast.

Starting TSS without an externally reachable address will produce unreachable peers. Make this a hard error instead of a warning.

-  case cfg.PublicIP == "" && cfg.PublicDNS == "":
-    logger.Warn().Msg("no public IP or DNS is provided")
+  case cfg.PublicIP == "" && cfg.PublicDNS == "":
+    return nil, errors.New("no public IP or DNS provided; set --public-ip or --public-dns")

Also good to log both when set:

logger.Info().Str("external_ip", cfg.PublicIP).Str("external_dns", cfg.PublicDNS).Msg("tss external addressing")

Also applies to: 228-229

🤖 Prompt for AI Agents
In zetaclient/tss/setup.go around lines 210-212 (and similarly at 228-229),
change the warning for missing external addressing to a hard error that stops
startup: check if both cfg.PublicIP and cfg.PublicDNS are empty and return/log a
fatal error (or return an error from this function) instead of logger.Warn();
additionally, when either or both are set log them with logger.Info including
structured fields "external_ip" and "external_dns" as suggested to make the
configured external addressing explicit.

@lumtis lumtis marked this pull request as draft September 25, 2025 13:50
@lumtis
Copy link
Member

lumtis commented Sep 25, 2025

Note: will not be merged to the current develop branch

@lumtis
Copy link
Member

lumtis commented Sep 26, 2025

losing in favor of the develop PR

@lumtis lumtis closed this Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking:cli enhancement New feature or request zetaclient Issues related to ZetaClient

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support hostname in addition to public IP for zetaclient

3 participants