fix(sim): cap crash point so extreme seeds cannot overflow or bankrupt
At u=1 the unsigned quotient exceeded int64 and wrapped negative, so the rarest and most valuable outcome silently became an instant 1.00x loss. At u=2 it produced a 2.1-billion-times payout the house could never cover, which would have left settlement failing and the player unpaid. The crash point is now capped at the largest multiplier the curve can express, which is unreachable anyway since the round hits its tick ceiling first. FromInt now panics outside the Q32.32 integer range instead of wrapping a positive input into a negative value. Raises coverage to 88% overall; adds a Makefile with db-reset, since the append-only ledger steadily consumes bridge headroom across test runs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -99,11 +99,11 @@ func RoundSeed(server ServerSeed, client [32]byte, nonce uint64) [32]byte {
|
||||
// Proof is everything a player needs to verify one outcome without trusting
|
||||
// any server response. It is what the verification endpoint returns.
|
||||
type Proof struct {
|
||||
Commitment string `json:"commitment"` // published before the round
|
||||
ServerSeed string `json:"server_seed"` // revealed after settlement
|
||||
Participants []string `json:"participants"` // hex public keys, join order
|
||||
Commitment string `json:"commitment"` // published before the round
|
||||
ServerSeed string `json:"server_seed"` // revealed after settlement
|
||||
Participants []string `json:"participants"` // hex public keys, join order
|
||||
Nonce uint64 `json:"nonce"`
|
||||
RoundSeed string `json:"round_seed"` // derived, shown for convenience
|
||||
RoundSeed string `json:"round_seed"` // derived, shown for convenience
|
||||
}
|
||||
|
||||
// BuildProof assembles the verification record for a settled round.
|
||||
|
||||
Reference in New Issue
Block a user