H13: Say which part of the world differs when a soak hash does
When a client's world hash differs from the server's, the soak report now names the part that differs (tide, props, pieces or loot), the client's ClientWorld tick, and each piece whose entry differs on the two sides, so the next transient mismatch can be traced. - NetWorld.world_detail(): part hashes and a piece list. world_hash() is unchanged: the same bytes, hashed in four parts. - The server's world_hash log lines and the soak clients' hash lines carry the detail. A full soak with this (24 clients, 2 matches) compared 3,743 hashes with 0 differing, so the mismatch didn't come back to trace yet. Refs #80 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+40
-1
@@ -118,8 +118,10 @@ func check(server: Array[Dictionary], clients: Array[Dictionary], client_count:
|
||||
result["client_mem_growth_bytes"] = _client_growth(clients)
|
||||
# The world, compared hash by hash.
|
||||
var server_hashes: Dictionary = {}
|
||||
var server_detail: Dictionary = {}
|
||||
for record: Dictionary in _all(server, "world_hash"):
|
||||
server_hashes[Vector2i(int(record["match"]), int(record["sim_tick"]))] = String(record["hash"])
|
||||
server_detail[Vector2i(int(record["match"]), int(record["sim_tick"]))] = record.get("detail", {})
|
||||
var compared: int = 0
|
||||
var differ: int = 0
|
||||
var per_client: Dictionary = {}
|
||||
@@ -132,7 +134,7 @@ func check(server: Array[Dictionary], clients: Array[Dictionary], client_count:
|
||||
if server_hashes[key] != String(record["hash"]):
|
||||
differ += 1
|
||||
if differ <= 5:
|
||||
_fail("client %d's world differs from the server's in match %d at tick %d" % [record["client"], key.x, key.y])
|
||||
_fail("client %d's world differs from the server's in match %d at tick %d (replica tick %s): %s" % [record["client"], key.x, key.y, record.get("replica_tick", "?"), describe_difference(server_detail.get(key, {}), record.get("detail", {}))])
|
||||
result["hashes_compared"] = compared
|
||||
result["hashes_differing"] = differ
|
||||
if differ > 5:
|
||||
@@ -233,3 +235,40 @@ func _all(lines: Array[Dictionary], event: String) -> Array[Dictionary]:
|
||||
|
||||
func _count(lines: Array[Dictionary], event: String) -> int:
|
||||
return _all(lines, event).size()
|
||||
|
||||
|
||||
## Which parts of two NetWorld.world_detail() records differ, and for the pieces, each
|
||||
## piece whose entry differs, as "id: server [...] client [...]" (at most eight).
|
||||
static func describe_difference(server: Dictionary, client: Dictionary) -> String:
|
||||
if server.is_empty() or client.is_empty():
|
||||
return "no detail logged"
|
||||
var parts: Array[String] = []
|
||||
for name: String in ["tide", "props", "pieces", "loot"]:
|
||||
if String(server.get(name, "")) != String(client.get(name, "")):
|
||||
parts.append(name)
|
||||
var notes: Array[String] = ["parts differing: %s" % (", ".join(parts) if not parts.is_empty() else "none")]
|
||||
var theirs: Dictionary = {}
|
||||
for entry: Array in client.get("piece_list", []):
|
||||
theirs[int(entry[0])] = entry
|
||||
var ours: Dictionary = {}
|
||||
for entry: Array in server.get("piece_list", []):
|
||||
ours[int(entry[0])] = entry
|
||||
var ids: Dictionary = {}
|
||||
for piece_id: int in ours:
|
||||
ids[piece_id] = true
|
||||
for piece_id: int in theirs:
|
||||
ids[piece_id] = true
|
||||
var sorted: Array = ids.keys()
|
||||
sorted.sort()
|
||||
var shown: int = 0
|
||||
for piece_id: int in sorted:
|
||||
var server_entry: Variant = ours.get(piece_id)
|
||||
var client_entry: Variant = theirs.get(piece_id)
|
||||
if server_entry != null and client_entry != null and str(server_entry) == str(client_entry):
|
||||
continue
|
||||
shown += 1
|
||||
if shown <= 8:
|
||||
notes.append("piece %d: server %s client %s" % [piece_id, str(server_entry), str(client_entry)])
|
||||
if shown > 8:
|
||||
notes.append("and %d more pieces" % (shown - 8))
|
||||
return "; ".join(notes)
|
||||
|
||||
Reference in New Issue
Block a user