Skip to content

fix: replace hardcoded Koios URLs with public endpoints + koios.url config override#94

Merged
wcatz merged 1 commit intomasterfrom
fix/koios-url-config
Mar 8, 2026
Merged

fix: replace hardcoded Koios URLs with public endpoints + koios.url config override#94
wcatz merged 1 commit intomasterfrom
fix/koios-url-config

Conversation

@wcatz
Copy link
Copy Markdown
Owner

@wcatz wcatz commented Mar 8, 2026

Problem

Two separate bugs:

  1. Private endpoint in production code — all REST-based Koios calls (nonce fetch, pool history, epoch info, pool blocks, pool registration) hardcoded koios.tosidrop.me as the mainnet base URL. That's a private mirror, not a public default.

  2. Inconsistency between code paths — the Go client (i.koios) used api.koios.rest (public), while the raw REST helpers used tosidrop (private). Same logical operation, different backends.

  3. Tests hardcoded api.koios.rest directly, bypassing any config logic.

Fix

  • koiosRESTBase(networkMagic int): defaults to public koios.rest per network; reads koios.url config override first
  • koiosClientHost(networkMagic int): same logic for the Go client (returns just the hostname)
  • Both Koios code paths (Go client + raw REST) now route through the same config-aware helpers
  • cli.go Go client init simplified from 3-branch switch to one line
  • Tests use koiosRESTBase(MainnetNetworkMagic) instead of hardcoded strings
  • config.yaml.example: documents koios.url optional override
  • All tosidrop references removed from code, docs, and agent skill files

Default endpoints (no config override)

Network URL
Mainnet https://api.koios.rest/api/v1
Preprod https://preprod.koios.rest/api/v1
Preview https://preview.koios.rest/api/v1

Config override (optional)

koios:
  url: "https://your-private-mirror.example.com/api/v1"

…onfig override

Previously:
- Production code defaulted to koios.tosidrop.me (private mainnet mirror)
  for all REST calls (epoch_params, pool_history, pool_blocks, etc.)
- Go client used koios.MainnetHost (api.koios.rest) creating inconsistency
  between the two Koios call paths
- Tests hardcoded api.koios.rest regardless of config

Now:
- koiosRESTBase(networkMagic) defaults to public koios.rest endpoints:
    mainnet  -> https://api.koios.rest/api/v1
    preprod  -> https://preprod.koios.rest/api/v1
    preview  -> https://preview.koios.rest/api/v1
- koiosClientHost(networkMagic) mirrors the same logic for the Go client,
  extracting just the hostname (koios.PreProdHost / PreviewHost / MainnetHost)
- Both functions check koios.url config key first, so operators running a
  private Koios mirror can override with a single config line
- cli.go Go client init collapsed from 3-branch switch to one line using
  koiosClientHost(cc.networkMagic)
- Tests use koiosRESTBase(MainnetNetworkMagic) instead of hardcoded URLs so
  they stay consistent with whatever endpoint the config resolves to
- config.yaml.example documents koios.url (commented out, optional)
- All tosidrop references removed from code, docs, and agent skill files
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 8, 2026

Warning

Rate limit exceeded

@wcatz has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 16 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4934760a-9f73-45f1-8934-621aff627704

📥 Commits

Reviewing files that changed from the base of the PR and between e5a8da2 and 16204f5.

📒 Files selected for processing (8)
  • .omp/SYSTEM.md
  • .omp/skills/history-debug/SKILL.md
  • .omp/skills/verify-nonces/SKILL.md
  • cli.go
  • comprehensive_test.go
  • config.yaml.example
  • main.go
  • nonce_koios_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/koios-url-config

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.

@wcatz wcatz merged commit 07178ef into master Mar 8, 2026
5 checks passed
@wcatz wcatz deleted the fix/koios-url-config branch March 20, 2026 14:23
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.

1 participant