Skip to content

feat(token_lite): single-game gas-optimized token component (denshokan lite) - #123

Open
starknetdev wants to merge 2 commits into
mainfrom
feat/token-lite
Open

feat(token_lite): single-game gas-optimized token component (denshokan lite)#123
starknetdev wants to merge 2 commits into
mainfrom
feat/token-lite

Conversation

@starknetdev

Copy link
Copy Markdown
Member

Summary

Adds a token_lite module to embeddable_game_standard: a single-game, storage-minimal replacement for the full minigame token, designed for deployments like super-death-mountain that never used the multi-game registry, objectives, context, skills, per-token renderers, client urls, or enumerable — and that keep game-over / objective-completion authority in the game contract itself.

Design

Decision Consequence
One game, configured at init No registry, no game_id_from_address on mint, no SRC5 probes anywhere
No mutable token state No update_game, no metagame callbacks, no game_over latch; is_playable = lifecycle window only, zero storage reads (pure unpack of the packed token id)
New assert_owner_and_playable(token_id, expected_owner) Merges the per-action owner_of + assert_is_playable pair into one external call (one storage read total)
mint keeps the exact IMinigameToken::mint ABI Existing dungeon call sites and the minigame::mint helper work unchanged; unsupported params are rejected loudly, never silently ignored
Canonical 251-bit pack_token_id layout unchanged Consumers that unpack settings_id/minted_by/lifecycle from the id, and indexers, keep working; unused fields are written as zero
Registers IMINIGAME_TOKEN_LITE_ID + legacy IMINIGAME_TOKEN_ID, exposes zero game_registry_address() MinigameComponent::initializer accepts a lite token without modification

Context: super-death-mountain's own gas bench measures update_game as a ~6.73M L2 gas subtree, dominated by the two game_over()/score() callbacks (~1.56M each). With no mutable state there is nothing to sync — games gate dead runs themselves and call refresh_metadata (ERC-4906) after actions.

Changes

  • packages/interfaces/src/token/lite.cairoIMinigameTokenLite + IMINIGAME_TOKEN_LITE_ID (derived via src5_rs, excluding refresh_metadata* per convention)
  • packages/embeddable_game_standard/src/token_lite/CoreTokenLiteComponent, module AGENTS.md, wiring example contract, 30 tests
  • CI: both workflow matrices + codecov.yml bumped to 18 modules; root AGENTS.md matrix table refreshed (was stale at 16, missing merkledrop)

Test plan

  • scarb build --workspace
  • snforge test -p game_components_embeddable_game_standard "::token_lite::" — 30/30 passing (packing fields, lifecycle windows/clamping, all rejected params, soulbound transfer guard, combined owner+playable guard, minter map, ERC-4906 events, SRC5 registration)
  • scarb fmt --check

🤖 Generated with Claude Code

…hokan lite)

Adds a CoreTokenLiteComponent for single-game deployments (e.g.
super-death-mountain) that never used the multi-game registry, objectives,
context, skills, per-token renderers, or enumerable, and that keep
game-over/objective authority in the game contract:

- No mutable token state: no update_game, no metagame callbacks, no
  game_over latch. is_playable/assert_is_playable check the lifecycle
  window only — zero storage reads (pure unpack of the packed token id).
- New assert_owner_and_playable merges the per-action owner_of +
  assert_is_playable pair into one external call.
- Mint does no SRC5 probe, no registry lookup, no settings/objective
  validation; keeps the exact IMinigameToken::mint ABI and rejects
  unsupported params loudly. 251-bit pack_token_id layout is unchanged.
- Registers IMINIGAME_TOKEN_LITE_ID plus the legacy IMINIGAME_TOKEN_ID and
  exposes a zero game_registry_address() so MinigameComponent::initializer
  accepts a lite token unchanged.

Includes IMinigameTokenLite in the interfaces package, a wiring example
contract, 30 tests, CI matrix + codecov updates (18 modules), and doc
refreshes (root AGENTS.md matrix table was stale).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@starknetdev, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 13 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4a443d25-8c58-4629-975e-acef3fb3fd3f

📥 Commits

Reviewing files that changed from the base of the PR and between 17558e9 and 135540f.

📒 Files selected for processing (17)
  • .github/workflows/main-ci.yml
  • .github/workflows/pr-ci.yml
  • AGENTS.md
  • codecov.yml
  • packages/embeddable_game_standard/src/lib.cairo
  • packages/embeddable_game_standard/src/token_lite.cairo
  • packages/embeddable_game_standard/src/token_lite/AGENTS.md
  • packages/embeddable_game_standard/src/token_lite/interface.cairo
  • packages/embeddable_game_standard/src/token_lite/tests.cairo
  • packages/embeddable_game_standard/src/token_lite/tests/examples.cairo
  • packages/embeddable_game_standard/src/token_lite/tests/examples/token_lite_contract.cairo
  • packages/embeddable_game_standard/src/token_lite/tests/test_gas_bench.cairo
  • packages/embeddable_game_standard/src/token_lite/tests/test_token_lite.cairo
  • packages/embeddable_game_standard/src/token_lite/token_lite_component.cairo
  • packages/interfaces/src/AGENTS.md
  • packages/interfaces/src/token.cairo
  • packages/interfaces/src/token/lite.cairo

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

GPT Code Review

Review execution failed (exit code 1).

The Codex CLI log was not posted because it can contain the full review prompt.
See the workflow run for job status: https://github.com/Provable-Games/game-components/actions/runs/31002016447

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

GPT Code Review

Review execution failed (exit code 1).

The Codex CLI log was not posted because it can contain the full review prompt.
See the workflow run for job status: https://github.com/Provable-Games/game-components/actions/runs/31002016447

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Claude Code Review

All the numbers reconcile: main-ci matrix = 18 modules, pr-ci add lines = 18, codecov after_n_builds = 18, AGENTS.md table = 18 rows with "18 modules" header. The validate-config check will pass.

Minor wording inconsistencies (codecov.yml:4 says "package count" but the check counts modules; AGENTS.md:131 example still shows after_n_builds: 15) are pre-existing and outside this PR's diff, so not actionable here.

The scoped changes are internally consistent and correct.

lgtm

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Claude Code Review

This reveals two divergences from the full token:

  1. update_player_name: The full token checks exists(token_id) before the ownership check (token_component.cairo:837). The lite version (token_lite_component.cairo:271-284) skips the existence check and relies on _owner_of == caller. For a nonexistent token, _owner_of returns zero; if caller is also zero it could pass — but get_caller_address in a real tx is never zero, so effectively it's guarded. Minor, not a real vuln. The full token's is_playable/token_metadata also don't check existence, so lite matches there.

Both are consistent with the full token's design. No regression.

I've now thoroughly reviewed the component, interface, tests, example wiring, packing parity, lifecycle math (bit-identical to full token), the compat shim (only mint/assert_is_playable/player_name are called by minigame consumers — all present), soulbound guard, and SRC5 registration.

The one item worth flagging as a low-severity finding: the interface ID constant is hardcoded and no test independently verifies it against src5_rs — but that's consistent with how other interface IDs in this repo are handled, so not actionable.

Let me double-check the assert_owner_and_playable doesn't have a self: @ vs mutable issue and that _owner_of is accessible on a @ component — it is (view). The logic is correct.

No actionable, in-scope findings backed by concrete regressions or bugs.

lgtm

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.00000% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...standard/src/token_lite/token_lite_component.cairo 88.00% 9 Missing ⚠️

📢 Thoughts on this report? Let us know!

Baseline/op-x10 test pairs measuring warm mint, per-action ownership+
playability guard, and post-action sync on the lite component against
FullTokenContract in its deployed-denshokan configuration (registry-backed
multi-game, all extensions).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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