Skip to content

Implement dead chip / uncollected pot management contract (Issue #206) - #473

Merged
Marvy247 merged 2 commits into
HitEmPoka:mainfrom
MarcusDavidG:dead-chip-uncollected-pot-issue-206
Aug 29, 2026
Merged

Implement dead chip / uncollected pot management contract (Issue #206)#473
Marvy247 merged 2 commits into
HitEmPoka:mainfrom
MarcusDavidG:dead-chip-uncollected-pot-issue-206

Conversation

@MarcusDavidG

Copy link
Copy Markdown
Contributor

Summary

This PR implements dead chip / uncollected pot management as requested in Issue #206, allowing uncollected chips from abandoned tables to be swept to a treasury contract after a timeout, with a reclaim period for players to recover their chips.

Changes

Types (types.rs)

  • Added , , and to
  • Added to to track when table entered Settlement
  • Added struct to track swept amounts per player
  • Added data key for persistent storage
  • Added new error codes: TreasuryNotConfigured, DeadChipTimeoutNotConfigured, DeadChipsNotSweepable, DeadChipTimeoutNotReached, DeadChipsAlreadySwept, DeadChipsNotSwept, ReclaimPeriodNotConfigured, ReclaimPeriodElapsed, NoDeadChipsToReclaim, InvalidSignature

Contract Functions (lib.rs)

  • sweep_dead_chips(): Sweeps uncollected player stacks, pot, and side pots to treasury after timeout

    • Requires treasury configured, timeout > 0, table in Settlement phase, timeout elapsed
    • Records sweep state for potential reclaim
    • Emits dead_chips_swept event
  • reclaim_dead_chips(): Allows players to reclaim swept chips within reclaim period

    • Verifies Ed25519 signature for ownership proof
    • Transfers chips back from treasury to player
    • Emits dead_chips_reclaimed event
  • get_dead_chip_sweep_state(): View function to inspect sweep state

Settlement Tracking

  • Updated all Settlement phase transitions to record :
    • game.rs: settle_showdown, settle_fold_win, settle_rit
    • timeout.rs: emergency_refund
    • lib.rs: refund_table_players, execute_emergency_withdrawal
    • start_hand resets settlement_entered_ledger to 0

Error Codes

  • Fixed duplicate error codes in PokerTableError enum
  • Assigned unique values to all new error codes

Closes #206

Add verifiable random function (VRF) to the deal circuit.
- Prove that the shuffle seed was derived from a VRF output
- Enables public verifiability of randomness

Changes:
- circuits/lib/src/vrf.nr: New VRF module with prove/verify functions
- circuits/lib/src/lib.nr: Expose VRF module
- circuits/deal_valid/src/main.nr: Accept VRF inputs, derive shuffle seed
- circuits/deal_valid_2p/5p/6p/src/main.nr: Update parameterized circuits
- Added treasury contract address configuration to TableConfig
- Added dead_chip_timeout_ledgers and reclaim_period_ledgers to TableConfig
- Added settlement_entered_ledger field to TableState to track when table entered Settlement
- Added SweepState struct to track swept amounts per player
- Added DeadChipSweep data key for persistent storage
- Implemented sweep_dead_chips() function:
  * Sweeps uncollected player stacks, pot, and side pots to treasury
  * Only callable after dead_chip_timeout_ledgers have passed since Settlement
  * Requires treasury to be configured and timeout > 0
  * Records sweep state for potential reclaim
  * Emits dead_chips_swept event
- Implemented reclaim_dead_chips() function:
  * Allows players to reclaim swept chips within reclaim period
  * Verifies Ed25519 signature for ownership proof
  * Transfers chips back from treasury to player
  * Emits dead_chips_reclaimed event
- Implemented get_dead_chip_sweep_state() view function
- Updated all Settlement phase transitions to record settlement_entered_ledger
- Added new error codes for dead chip operations
- Updated PokerTableError enum with unique discriminant values
@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@MarcusDavidG Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Marvy247
Marvy247 merged commit 73bc6e3 into HitEmPoka:main Aug 29, 2026
6 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement a dead chip / uncollected pot management contract

2 participants