code wiki / _hdl_build / nx_netsync_gate.nx

nx_netsync_gate.nx

buildroot/runtime/_hdl_build/nx_netsync_gate.nx

20109 B483 linesdepth 5pulls 10 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_netsync_gate.nx -- CERTIFICATION of nx_netsync (gamebench gap-queue rank 1: networking-multiplayer). The existing nx_lockstep/nx_rollback gates prove netcode mechanisms on a TOY stepper; this gate proves the same laws hold when the simulation is the REAL certified world (nx_worldsim) and the snapshots are REAL save files (nx_gamesave) -- the composition the capability actually demands. T1 LOCKSTEP DETERMINISM -- two peers, same commands, different within-tick arrival order, 200 ticks -> checksums equal EVERY tick and shared state word-exact T2 STALL-NOT-GUESS -- missing one peer's input for a tick freezes the session (no advance, no state change) until it arrives; advancing on partial input is THE lockstep desync bug T3 ARRIVAL-CHAOS IMMUNE -- the full 400-command schedule delivered in a shuffled order with duplicates -> final state EXACTLY equals the in-order run; a conflicting resend is REFUSED T4 DESYNC LOCALIZED -- a 1-unit wealth mint injected into one peer at tick 120 is first visible in the checksum stream AT tick 120 (never earlier, never missed) T5 ROLLBACK ON THE REAL SIM -- speculative head with predicted inputs diverges when the prediction was wrong; discard + resim from the confirmed state converges bit-exact to ground truth; a CORRECT prediction triggers no divergence (no false rollback) T6 LATE-JOIN VIA nx_gamesave -- a peer that loads a mid-session snapshot file into a ZEROED arena tracks the original checksum-for-checksum to the end (GX-9 transparency) T7 BOUNDED + LOUD -- out-of-range tick/peer and conflicting input each refuse with a DISTINCT code and change nothing T8 ANTI-VACUITY -- the session actually traded and grew (a frozen or all-no-op world would pass T1-T3 while proving nothing) T9 ARTIFACT -- the final session round-trips through a real save file and RESUMES identically; knowledge/nx_netsync_session.sav is the board evidence license_tier: ORIGINAL expect_exit: 0

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_netsync.nx nx_gamesave.nx nx_net_chan.nx nx_netsync_gate.nx

imports: nx_syscalls.nxnx_netsync.nxnx_gamesave.nxnx_net_chan.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main pw sys_write ns_words ws_words sys_unlinkat sys_mmap mksess ns_init ws_init ws_o_res ws_o_pop ws_nfac ws_o_terr ws_nfac ↻ ws_o_rel ws_nfac ↻ ns_world ns_o_world ns_maxticks ns_npeers ns_world ↻ ws_set_res ws_o_res ↻ ws_set_pop ws_o_pop ↻ ws_clamp ws_set_terr ws_o_terr ↻ ws_clamp ↻ ns_offer ns_maxticks ↻ ns_npeers ↻ ns_o_cmd ns_o_have ns_maxticks ↻ ns_npeers ↻ cmd_for ns_step ns_can_advance

structs

none

consts

29const K_MAGIC_25214903917: i64 = 25214903917
30const K_MAGIC_2654435761: i64 = 2654435761
31const K_MAGIC_100000000: i64 = 100000000
32const K_MAGIC_1000000: i64 = 1000000
33const K_MAGIC_4242: i64 = 4242
34const K_MAGIC_20260730: i64 = 20260730
35const K_MAGIC_60621: i64 = 60621
36const K_MAGIC_1785425000: i64 = 1785425000
37const K_MAGIC_9750: i64 = 9750
38const K_MAGIC_60620: i64 = 60620
39const K_MAGIC_38921: i64 = 38921
40const K_MAGIC_31337: i64 = 31337
67const GMAXT: i64 = 300
68const GNFAC: i64 = 6

functions

42func pw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main calls 1: sys_write
43func pn(v: i64) -> i64
called by 1: main calls 2: sys_writesys_mmap
52func lcg(s: *i64) -> i64 { s[0] = ((s[0]*K_MAGIC_25214903917)+11) & 0x7FFFFFFFFFFF; return s[0] }
called by 1: main
56func cmd_for(t: i64, p: i64) -> i64
called by 1: main
70func mksess(a: *i64, self_id: i64, seed: i64) -> i64
83func main() -> i64