Skip to content

feat(games/gacha): add pinocchio-simple variant - #680

Draft
amilz wants to merge 4 commits into
mainfrom
feat/gacha-simple-token-2022
Draft

feat(games/gacha): add pinocchio-simple variant#680
amilz wants to merge 4 commits into
mainfrom
feat/gacha-simple-token-2022

Conversation

@amilz

@amilz amilz commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds games/gacha/pinocchio-simple, a second gacha variant alongside games/gacha/pinocchio. Both share the same provably-fair draw semantics (select_tier/derive_alpha are byte-identical, pinned by shared test fixtures); they differ in how reveals are evidenced. The existing variant anchors each reveal in the cc-vrf registry by CPI; this one records the evidence in the prize itself.
  • settle_and_distribute merges settle + claim into one instruction (~82k CU, 11 accounts): selects the tier from beta, mints a Token-2022 prize NFT straight to the buyer, and closes the pull (rent refunded to the buyer).
  • The prize NFT is self-certifying: its token metadata carries rarity, pull, client_seed, beta, and proof, so anyone can verify the ECVRF reveal from the mint account alone. The TS client ships verifyPrizeProvenance for this.
  • One reveal per pull is structural: pull PDAs use a monotonic pool index, the prize mint PDA can only be created once, and the pull account closes at settle. Pull shrinks to 146 bytes (no status byte, no stored beta — the account existing means pending).
  • Self-contained nested workspace mirroring the sibling: Codama IDL → generated TS/Rust clients, LiteSVM integration tests, scripts (pool setup, buy, operator crank, offline demo), justfile, README/CLAUDE.md.

Test Plan

  • just test — 13 Rust unit tests, 36 LiteSVM integration tests (including the full settle-and-mint happy path with metadata provenance replay), 10 TS client tests
  • just check — cargo fmt + clippy -D warnings + prettier + eslint
  • just demo — offline operator/verifier ECVRF walkthrough

Closes DEV-848

A second gacha example with the same draw semantics but no external
protocol dependencies. settle_and_distribute selects the tier, mints a
Token-2022 prize NFT whose metadata carries the full reveal provenance
(pull, client_seed, beta, proof), and closes the pull in one instruction.
One reveal per pull is structural: monotonic pull index, once-only mint
PDA, and pull close at settle. The entire lifecycle, including the
settle-and-mint happy path, is testable in LiteSVM.
@amilz
amilz requested a review from dev-jodee as a code owner August 7, 2026 13:39
@greptile-apps

greptile-apps Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds a self-contained Pinocchio gacha variant that stores VRF reveal provenance in Token-2022 prize metadata and combines settlement with prize distribution.

  • Adds on-chain pool, pull, refund, settlement, fee-withdrawal, NFT-minting, and event flows.
  • Adds generated Rust/TypeScript clients, provenance-verification helpers, integration tests, scripts, and nested workspace tooling.
  • Documents the mint update-authority link used to authenticate the corresponding pool configuration.

Confidence Score: 4/5

The code changes appear sound, but the unverified pull request commits must be corrected before merging.

The previously reported provenance issues are resolved by binding the mint’s metadata update authority to the fetched pool address, but every commit in the pull request still lacks a verified signature required by repository policy.

Important Files Changed

Filename Overview
games/gacha/pinocchio-simple/clients/typescript/src/gacha.ts Adds cross-language draw helpers and a pool-bound prize verifier that addresses the previous unauthenticated-configuration concern.
games/gacha/pinocchio-simple/program/src/instructions/settle_and_distribute.rs Implements combined reveal, tier selection, prize minting, liability update, event emission, and pull closure.
games/gacha/pinocchio-simple/program/src/instructions/helpers/prize_nft.rs Constructs the Token-2022 prize and authenticates its pool association through the metadata update authority.
games/gacha/pinocchio-simple/README.md Documents the live mint-to-pool provenance-verification path and the new variant’s operational model.
games/gacha/pinocchio-simple/tests/integration-tests/src/test_settle_and_distribute.rs Exercises settlement and confirms the minted metadata, pool authority link, provenance, and lifecycle effects.

Reviews (4): Last reviewed commit: "fix(games/gacha): start account discrimi..." | Re-trigger Greptile

…n path

Register the pinocchio-simple crates in .github/.workspace-ignore, exclude
its generated IDL from the root prettier check, and format the gacha README
with the root config.

Document that the prize mint's metadata update authority is the pool PDA:
the NFT names its pool, and the pool account supplies the operator key and
tier weights that verifyPrizeProvenance takes as inputs.
Comment thread games/gacha/pinocchio-simple/clients/typescript/src/gacha.ts
amilz added 2 commits August 7, 2026 06:55
verifyPrizeAgainstPool takes the mint's metadata update authority, the
address the pool account was fetched from, and the decoded pool data,
and rejects the reveal unless the authority equals that address — so
pool configuration can only come from the pool the mint actually names.
All-zero account data must never carry a valid discriminator, so Pool
moves off 0.
@amilz amilz self-assigned this Aug 7, 2026
@linear

linear Bot commented Aug 7, 2026

Copy link
Copy Markdown

DEV-848

@amilz
amilz marked this pull request as draft August 7, 2026 14:31
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.

1 participant