You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Where proof was generated (e.g. local, boundless, worker)
start_tx_hash
TEXT
Soroban transaction hash for match start
settle_tx_hash
TEXT
Soroban transaction hash for match settlement
wallet1_verified
INTEGER
0
Whether player 1 wallet was cryptographically verified (0/1)
wallet2_verified
INTEGER
0
Whether player 2 wallet was cryptographically verified (0/1)
transcript_data
TEXT
Full match replay transcript (JSON string)
transcript_cid
TEXT
IPFS CID of pinned transcript
boundless_request_id
TEXT
Boundless marketplace proving request ID
boundless_tx_hash
TEXT
Ethereum transaction hash from Boundless proof delivery
bot_vs_bot
INTEGER
0
Whether both players were bots (0/1)
prover_transcript_data
TEXT
Prover-specific transcript data (JSON string)
player_stats
Ranked mode ELO ratings and win/loss records.
Column
Type
Default
Description
username
TEXT
PK
Player username
elo
INTEGER
1000
Ranked ELO rating (K-factor = 32)
wins
INTEGER
0
Total ranked wins
losses
INTEGER
0
Total ranked losses
casual_elo
Casual mode ELO ratings (separate from ranked).
Column
Type
Default
Description
username
TEXT
PK
Player username
elo
INTEGER
800
Casual ELO rating (K-factor = 24)
games_played
INTEGER
0
Total casual games played
last_updated
INTEGER
Unix timestamp (ms) of last ELO update
Indexes
Index
Table
Column(s)
Purpose
idx_matches_room_id
matches
room_id
Fast transcript lookup by room ID
Migrations
All migrations are idempotent (wrapped in try/catch for "column already exists"). They run on every server start.
Migration
Column Added
Type
Default
1
match_start_time
INTEGER
2
proof_requested_at
INTEGER
3
proof_completed_at
INTEGER
4
proof_source
TEXT
5
start_tx_hash
TEXT
6
settle_tx_hash
TEXT
7
wallet1_verified
INTEGER
0
8
wallet2_verified
INTEGER
0
9
transcript_data
TEXT
10
transcript_cid
TEXT
11
boundless_request_id
TEXT
12
boundless_tx_hash
TEXT
13
bot_vs_bot
INTEGER
0
14
prover_transcript_data
TEXT
Key Queries
Match Operations
Function
Query
Description
insertMatch
INSERT INTO matches (...)
Insert a completed match record
getMatchById
SELECT * FROM matches WHERE id = $id
Fetch single match by ID
getRecentMatches
SELECT * FROM matches ORDER BY timestamp DESC LIMIT $limit
Fetch N most recent matches (default 50)
updateProofStatus
UPDATE matches SET proof_status = ...
Update proof lifecycle status, optionally with seal/journal/imageId
Proof Timeline
Function
Query
Description
updateStartTxHash
UPDATE matches SET start_tx_hash = $hash WHERE id = $id
Record Soroban start transaction
updateSettleTxHash
UPDATE matches SET settle_tx_hash = $hash WHERE id = $id
Record Soroban settle transaction
updateProofTimestamps
UPDATE matches SET proof_requested_at, proof_completed_at, proof_source ...
Record proof timing and source
updateMatchStartTime
UPDATE matches SET match_start_time = $time WHERE id = $id
Record when gameplay started
updateWalletVerified
UPDATE matches SET wallet1_verified, wallet2_verified ...
Record wallet verification status
Transcript Storage
Function
Query
Description
saveTranscript
UPDATE matches SET transcript_data = $data WHERE id = $id
Save JSON replay transcript
getTranscriptByMatchId
SELECT transcript_data FROM matches WHERE id = $id
Fetch transcript by match ID
getTranscriptByRoomId
SELECT transcript_data FROM matches WHERE room_id = $roomId ORDER BY timestamp DESC LIMIT 1
Fetch most recent transcript for a room
saveProverTranscript
UPDATE matches SET prover_transcript_data = $data WHERE id = $id
Save prover-specific transcript
getProverTranscript
SELECT prover_transcript_data FROM matches WHERE id = $id
Fetch prover transcript
updateTranscriptCid
UPDATE matches SET transcript_cid = $cid WHERE id = $id
Record IPFS CID after pinning
Boundless Proving
Function
Query
Description
updateBoundlessRequestId
UPDATE matches SET boundless_request_id = $rid WHERE id = $id
Record Boundless marketplace request ID
updateBoundlessTxHash
UPDATE matches SET boundless_tx_hash = $hash WHERE id = $id
Record Boundless proof delivery transaction
ELO (Ranked)
Function
Query
Description
updateElo
Upsert player_stats for both players
Standard ELO calculation (K=32, default 1000, floor 0)
getLeaderboard
SELECT * FROM player_stats ORDER BY elo DESC LIMIT $limit
Top N players by ranked ELO (default 20)
getPlayerStats
SELECT * FROM player_stats WHERE username = $username
Single player's ranked stats
ELO (Casual)
Function
Query
Description
getCasualElo
SELECT elo FROM casual_elo WHERE username = $username
Get casual ELO (default 800)
updateCasualElo
Upsert casual_elo
Casual ELO calculation (K=24, default 800, floor 0)
Data Retention
Bot Transcript Pruning
pruneBotVsBotTranscripts() nullifies transcript_data for bot-vs-bot matches, keeping only the 100 most recent. This prevents unbounded storage growth from automated bot matches.
UPDATE matches SET transcript_data =NULLWHERE bot_vs_bot =1AND transcript_data IS NOT NULLAND id NOT IN (
SELECT id FROM matches WHERE bot_vs_bot =1AND transcript_data IS NOT NULLORDER BYtimestampDESCLIMIT100
)
markBotVsBot(matchId) flags a match as bot-vs-bot (sets bot_vs_bot = 1).