Skip to content

Conversation

@guruhubb
Copy link
Member

Summary

  • Add InternalSharders field to State for fetching magic blocks via N2NHost
  • When use_localhost is enabled, always use 127.0.0.1 for external URLs (API)
  • Worker uses internal N2NHost addresses to fetch magic blocks from container

Problem

0dns running in Docker couldn't fetch magic blocks because it tried to reach 127.0.0.1 from inside the container, which doesn't work (localhost inside container ≠ host).

Solution

Separate URL handling:

  • External URLs (served to clients via /network): Use 127.0.0.1 when use_localhost: true
  • Internal URLs (used by worker to fetch MBs): Always use N2NHost addresses

Test plan

  • Start local chain with miners/sharders
  • Start 0dns with use_localhost: true
  • Verify /network returns localhost URLs
  • Verify magic block fetch succeeds (check logs for "Magic block updated successfully")
  • Trigger view change and verify 0dns updates network info

When use_localhost is enabled, 0dns now:
- Uses 127.0.0.1 for external URLs served to clients (API)
- Uses N2NHost for internal URLs when fetching magic blocks

This fixes the issue where 0dns running in Docker couldn't fetch
magic blocks because it tried to reach 127.0.0.1 from inside the
container. The worker now uses InternalSharders (N2NHost addresses)
for fetching, while clients receive localhost URLs via the API.
@guruhubb guruhubb force-pushed the fix/use-localhost-internal-fetch branch from 79f6e0d to d25d068 Compare January 30, 2026 22:06
@guruhubb guruhubb merged commit 459b60e into staging Jan 30, 2026
1 check failed
@guruhubb guruhubb deleted the fix/use-localhost-internal-fetch branch January 30, 2026 22:06
guruhubb added a commit that referenced this pull request Jan 30, 2026
When use_localhost is enabled, 0dns now:
- Uses 127.0.0.1 for external URLs served to clients (API)
- Uses N2NHost for internal URLs when fetching magic blocks

This fixes the issue where 0dns running in Docker couldn't fetch
magic blocks because it tried to reach 127.0.0.1 from inside the
container. The worker now uses InternalSharders (N2NHost addresses)
for fetching, while clients receive localhost URLs via the API.
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.

2 participants