[PR #4945] [MERGED] Far terrain from a server (1/3): the horizon:lod wire format #5961

Closed
opened 2026-11-03 05:16:14 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4945
Author: @ludovic111
Created: 10/31/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: server-asks/lod-wire


📝 Commits (6)

  • 8a7bc78 Far terrain from a server: the horizon:lod wire format
  • fc9cf63 Far terrain wire: off by default, versioned offer, bounded replies
  • 2d79156 Far terrain: the span-cap test trips the cap, the encoder refuses past MAX_BIOMES
  • dc1fc94 Merge main into #4945
  • 7f47843 Far terrain wire: columns hold main's Spans
  • 1f6b07c Merge main into #4945

📊 Changes

2 files changed (+549 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/lib.rs (+1 -0)
➕ crates/horizon-client/src/lod_net.rs (+548 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

What and why

Part 1 of 3: far terrain (LOD) on dedicated servers and LAN worlds. The official server's host asked for it. Today a Horizon client gets no far terrain on a server. Its LOD samples the world's generator, which only single player has (Game::prepare_lod turns it off for any remote client). The client can't sample the world itself either: it doesn't have the seed, and a server shouldn't give the seed away. So the server samples the tiles and sends them over Horizon's own horizon:lod custom payload channel.

This PR is only the wire format, crates/horizon-client/src/lod_net.rs. Nothing sends or reads it yet.

  • Offer: what a server tells Horizon clients while they configure: its distance in chunks, how many requests may wait, and how many tiles a second.
  • Request: one far tile (16 x 16 columns from a block, a stride, Reduced detail), as lod::Lod samples it. allowed is the server's check: a whole aligned tile, with a power-of-two stride no coarser than the client's coarsest tile at that distance, whose nearest point is within the distance plus 8 chunks of slack.
  • The reply: the tile's columns, with biomes by name (so each side's own biome indices are used) and block states by id, or a refusal. The decoder rejects, before it allocates, anything a Horizon server doesn't send: a reply over 512 KiB, more than 16 384 spans in the tile (real tiles measure 4–6 spans a column with lod_grid_bench, so the cap averages 64), spans out of order, overlapping, empty or out of the height range, unknown states, a bad tile size, biome names over 256 bytes. The server refuses a tile it couldn't send within those limits.
  • VERSION, first in the offer: a client only uses an offer in its own version, so the format can change later without old clients misreading it.
  • Bucket, the token bucket both sides pace with, and how horizon-lod-distance is read: off (0) by default, 1024 at most. Far tiles show the generator's terrain far past view distance, which helps crack a world's seed, so an owner opts in.

Stack: this PR → #4946 (the server serves the tiles) → #4947 (clients ask for them; e2e check).

Checked

Unit tests: replies round-trip across different biome orders and refuse unknown states; hostile replies (overlapping, unordered, empty or out-of-range spans, a forged tile past the span cap, an oversized reply) are errors, and the encoder refuses a tile past the cap; requests and offers round-trip, another version's offer is ignored; the distance and shape checks.

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at c3905131b, 8 min 1 s)

Check Result
Scope ⚠️ 2 files, +544 −0; 544 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 495 passed (1 min 31 s)
rustfmt ✅ (5 s)
clippy ✅ (1 min 52 s)
tests: horizon-client ✅ 1344 passed (4 min 26 s)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 130 affected, to run in CI (--quick): ambient_sound, arrow, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_tint, block_transformer, breaking_model and 118 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

The Scope row is one file, the wire format and its tests (the hostile-reply test is ~70 lines of it); it doesn't ship in parts.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/4945 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `server-asks/lod-wire` --- ### 📝 Commits (6) - [`8a7bc78`](https://github.com/horizon-rust/horizon/commit/8a7bc780ed0a3da99d84fce79a62da9837ac6318) Far terrain from a server: the horizon:lod wire format - [`fc9cf63`](https://github.com/horizon-rust/horizon/commit/fc9cf63829575c6e2162ecc5f44cb9d8f2e0faf3) Far terrain wire: off by default, versioned offer, bounded replies - [`2d79156`](https://github.com/horizon-rust/horizon/commit/2d79156569b40e4641cd7cd1fb35e460c9886330) Far terrain: the span-cap test trips the cap, the encoder refuses past MAX_BIOMES - [`dc1fc94`](https://github.com/horizon-rust/horizon/commit/dc1fc94a4c5e1eb86eec2f0b7bddcb383913a8fd) Merge main into #4945 - [`7f47843`](https://github.com/horizon-rust/horizon/commit/7f4784397a73638d82055aff9234a82df884f504) Far terrain wire: columns hold main's Spans - [`1f6b07c`](https://github.com/horizon-rust/horizon/commit/1f6b07c82fae1ad71ce36099ee84ebe0086683c9) Merge main into #4945 ### 📊 Changes **2 files changed** (+549 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/lib.rs` (+1 -0) ➕ `crates/horizon-client/src/lod_net.rs` (+548 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What and why Part 1 of 3: **far terrain (LOD) on dedicated servers and LAN worlds**. The official server's host asked for it. Today a Horizon client gets no far terrain on a server. Its LOD samples the world's generator, which only single player has (`Game::prepare_lod` turns it off for any remote client). The client can't sample the world itself either: it doesn't have the seed, and a server shouldn't give the seed away. So the server samples the tiles and sends them over Horizon's own `horizon:lod` custom payload channel. This PR is only the wire format, `crates/horizon-client/src/lod_net.rs`. Nothing sends or reads it yet. - `Offer`: what a server tells Horizon clients while they configure: its distance in chunks, how many requests may wait, and how many tiles a second. - `Request`: one far tile (16 x 16 columns from a block, a stride, Reduced detail), as `lod::Lod` samples it. `allowed` is the server's check: a whole aligned tile, with a power-of-two stride no coarser than the client's coarsest tile at that distance, whose nearest point is within the distance plus 8 chunks of slack. - The reply: the tile's columns, with biomes by name (so each side's own biome indices are used) and block states by id, or a refusal. The decoder rejects, before it allocates, anything a Horizon server doesn't send: a reply over 512 KiB, more than 16 384 spans in the tile (real tiles measure 4–6 spans a column with `lod_grid_bench`, so the cap averages 64), spans out of order, overlapping, empty or out of the height range, unknown states, a bad tile size, biome names over 256 bytes. The server refuses a tile it couldn't send within those limits. - `VERSION`, first in the offer: a client only uses an offer in its own version, so the format can change later without old clients misreading it. - `Bucket`, the token bucket both sides pace with, and how `horizon-lod-distance` is read: **off (0) by default**, 1024 at most. Far tiles show the generator's terrain far past view distance, which helps crack a world's seed, so an owner opts in. Stack: **this PR** → #4946 (the server serves the tiles) → #4947 (clients ask for them; e2e check). ## Checked Unit tests: replies round-trip across different biome orders and refuse unknown states; hostile replies (overlapping, unordered, empty or out-of-range spans, a forged tile past the span cap, an oversized reply) are errors, and the encoder refuses a tile past the cap; requests and offers round-trip, another version's offer is ignored; the distance and shape checks. **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at c3905131b, 8 min 1 s) | Check | Result | | --- | --- | | Scope | ⚠️ 2 files, +544 −0; 544 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 495 passed (1 min 31 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (1 min 52 s) | | tests: horizon-client | ✅ 1344 passed (4 min 26 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 130 affected, to run in CI (--quick): ambient_sound, arrow, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_tint, block_transformer, breaking_model and 118 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | The Scope row is one file, the wire format and its tests (the hostile-reply test is ~70 lines of it); it doesn't ship in parts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:16:14 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#5961
No description provided.