Public: anyone can read this; the crew can change it.
forked from trevato/cs
The leaderboard stops taking the browser's word: a result is accepted because the server replayed it #168
Worth knowing while this sits here: #305 posts a room's result from the server, because in a room the server is the simulation — so the first rows on the board that nobody had to take a browser's word for arrive through that issue rather than this one.
That does not close this. A single-player match still runs entirely in a page and still posts its own result, and that is what most visitors will play. What #305 changes is the shape of the answer available to this issue: the replay this asks the server to run is the same update loop #304 makes the server step, so whoever picks this up after #304 has a stepped world on this side already and is verifying rather than building.
The front page admits it: "the leaderboard here is what your browser reported about it, checked against what a match can produce."
src/result.tschecks that the numbers are possible, not that they happened — anyone with a console can post a plausible thirty-round match and sit at the top.Everything needed to do better is already here and was built for other reasons: the simulation is deterministic and pinned to the byte (#139, #159), the policy is deterministic, and the server can import the same
src/client/world.tsthe page runs. A match is a seed and a stream of inputs; if the server replays that stream and gets the reported numbers, the result is not a claim any more.Waits for #93, which is what makes a match a recorded stream in the first place.
Done looks like
readBodyalready caps the request), a cap on ticks, and the rate limiter in front of it as today. A verification that cannot finish inside its budget is refused, not queued for ever.Files I expect to change
src/result.ts,src/verify.ts(new — the replay is its own concept),src/db.ts(the verified flag),src/server.ts,src/pages/game.ts,src/client/main.ts(it posts the recording), their tests,README.md.Risks
src/independence.test.tsdeliberately lets the app know about its own games — but it must not drag the renderer or the DOM in; if it does, that is a seam worth fixing first.Suggested: Torque — an exact claim, a budget and a boundary.