Skip to content

feat: bump metagame_extensions to v0.1.4 (context-owner namespacing)#105

Merged
starknetdev merged 3 commits intomainfrom
feat/context-owner-namespacing
Apr 23, 2026
Merged

feat: bump metagame_extensions to v0.1.4 (context-owner namespacing)#105
starknetdev merged 3 commits intomainfrom
feat/context-owner-namespacing

Conversation

@starknetdev
Copy link
Copy Markdown
Member

@starknetdev starknetdev commented Apr 23, 2026

Summary

Bumps metagame_extensions_interfaces to the newly-released v0.1.4, which namespaces extension storage by (context_owner, context_id). Under the previous model, the first caller to register a context_id on an extension contract took permanent ownership — two different consumer contracts could not share the same context_id on the same validator.

See Provable-Games/metagame_extensions#19 for the full interface change and rationale.

Interface updates consumed here

  • Read methods on IEntryRequirementExtension / IEntryFeeExtension / IPrizeExtension gained a leading context_owner: ContractAddress parameter.
  • context_owner(context_id) was removed; replaced by is_context_registered(context_owner, context_id) -> bool.
  • Write methods (add_config, add_entry, remove_entry, set_entry_fee_config, pay_entry_fee, claim_entry_fee, add_prize, claim_prize) are unchanged.

Changes in this PR

  • Scarb.toml — bump metagame_extensions_interfaces from v0.1.3 to v0.1.4.
  • entry_requirement_store.cairo — the two dispatcher read calls (valid_entry, entries_left) now pass starknet::get_contract_address() as the context_owner. The metagame contract was the caller at add_config time, so it owns the matching namespace on the validator.
  • Mocks (metagame/src/entry_requirement/tests/mocks/*.cairo, test_common/src/mocks/*.cairo) — updated to the new interface shape. Added is_context_registered, removed context_owner, threaded context_owner through bannable / valid_entry / should_ban / entries_left. Mock storage rekeyed so per-context maps are keyed by (ContractAddress, u64).

Test plan

  • scarb build clean
  • scarb fmt --check clean
  • snforge test --workspace passes (reported clean locally by the repo owner)
  • Verify no unrelated files touched

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Entry requirement validation system now tracks context ownership alongside context identification for improved context-dependent validation accuracy.
  • Chores

    • Updated external dependency version for metagame extensions interfaces.

metagame_extensions v0.1.4 namespaces extension storage by
(context_owner, context_id) so that different consumer contracts can
use the same context_id on a shared validator without collision.

See Provable-Games/metagame_extensions#19 for
the full interface change.

### Interface updates consumed here

- Read methods on IEntryRequirementExtension / IEntryFeeExtension /
  IPrizeExtension gained a leading `context_owner: ContractAddress`
  parameter.
- `context_owner(context_id)` was removed; replaced by
  `is_context_registered(context_owner, context_id) -> bool`.
- Write methods are unchanged.

### Changes in this PR

- Bump `metagame_extensions_interfaces` to `tag = "v0.1.4"`.
- `entry_requirement_store.cairo`: dispatcher calls to `valid_entry`
  and `entries_left` now pass `starknet::get_contract_address()` as
  the `context_owner` — the metagame contract was the caller at
  `add_config` time, so it is the owner of the corresponding namespace
  on the validator.
- Mocks under `metagame/src/entry_requirement/tests/mocks/` and
  `test_common/src/mocks/` updated to the new interface: added
  `is_context_registered`, removed `context_owner`, and threaded
  `context_owner` through the `bannable`, `valid_entry`, `should_ban`,
  and `entries_left` signatures. Mock storage rekeyed where needed so
  per-context maps are keyed by `(ContractAddress, u64)`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

Warning

Rate limit exceeded

@starknetdev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 41 minutes and 26 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 41 minutes and 26 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9ab75f94-b09d-47a4-94ae-e3f0a9cfd7ba

📥 Commits

Reviewing files that changed from the base of the PR and between 8e39f98 and c186e3b.

📒 Files selected for processing (5)
  • packages/metagame/src/entry_requirement/tests/mocks/accepting_limited_entry_validator_mock.cairo
  • packages/metagame/src/entry_requirement/tests/mocks/entry_validator_mock.cairo
  • packages/metagame/src/entry_requirement/tests/mocks/rejecting_entry_validator_mock.cairo
  • packages/test_common/src/mocks/mock_entry_validator.cairo
  • packages/test_common/src/mocks/mock_rejecting_entry_validator.cairo
📝 Walkthrough

Walkthrough

This PR updates the metagame_extensions_interfaces dependency from v0.1.3 to v0.1.4 and modifies context identification across entry requirement validators. All extension calls and mock validators are updated to pass context_owner alongside context_id as a composite context key.

Changes

Cohort / File(s) Summary
Dependency Update
Scarb.toml
Updated metagame_extensions_interfaces workspace dependency from tag v0.1.3 to v0.1.4.
Extension Call Sites
packages/metagame/src/entry_requirement/entry_requirement_store.cairo
Modified extension dispatcher calls to pass context_owner as a leading parameter before context_id in valid_entry and entries_left invocations.
Entry Validator Mocks
packages/metagame/src/entry_requirement/tests/mocks/accepting_limited_entry_validator_mock.cairo, entry_validator_mock.cairo, rejecting_entry_validator_mock.cairo
Updated IEntryRequirementExtension interface implementations: changed bannable storage from Map<u64, bool> to Map<(ContractAddress, u64), bool>; replaced context_owner(context_id) method with is_context_registered(context_owner, context_id); added context_owner parameter to bannable, valid_entry, should_ban, and entries_left methods.
Test Common Mock
packages/test_common/src/mocks/mock_entry_validator.cairo, mock_rejecting_entry_validator.cairo
Updated mock validator interface implementations with identical changes: composite storage keying, removed context_owner accessor, added is_context_registered, and added context_owner parameter to all validator interface methods.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A context now owns what it queries,
Context_owner joins the merry,
Bannable keys now dance as pairs,
No longer lonely—composite affairs! 🎭

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: bumping metagame_extensions to v0.1.4 with the key feature of context-owner namespacing. It is concise, descriptive, and directly relates to the primary objective of the PR.
Description check ✅ Passed The PR description provides comprehensive coverage of all template requirements: clear summary with bullets on what changed and why; scope marked as packages/*; change type indicated as 'feat'; validation commands documented with test results; risk level should be marked; breaking changes addressed; and assumes/exceptions noted. However, the description lacks explicit checkboxes marked for Risk level and Breaking Changes sections, though the content implies low risk and no breaking changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/context-owner-namespacing

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 and usage tips.

@claude
Copy link
Copy Markdown

claude Bot commented Apr 23, 2026

Claude finished @starknetdev's task —— View job


Claude Review - General Engineering Review

run=24853170227 attempt=1 sha=8e39f9806f2c2afbad1ff514edea26c4122d75bf scope=general

Review Progress

  • Analyze PR scope and identify files within review boundary
  • Review root Scarb.toml dependency version bump
  • Check for any CI/CD configuration impacts
  • Verify documentation consistency requirements
  • Provide final review summary

Analysis

Files in scope: Only Scarb.toml (1 out of 7 changed files falls within general engineering review scope)

Change reviewed:

  • Scarb.toml:44 - Dependency version bump: metagame_extensions_interfaces from "0.1.3" to "0.1.4"

Review Results

No issues found.

The dependency version bump is:

  1. Correctly formatted - Uses proper semantic versioning format
  2. Consistent with PR description - Matches the stated goal of consuming v0.1.4 interfaces
  3. Properly configured - The dependency is correctly defined in [workspace.dependencies] and referenced in the workspace
  4. CI-compatible - Workspace manifest changes correctly trigger full test matrix via workspace_manifests filter in .github/workflows/pr-ci.yml:79-80

The CI configuration properly handles dependency bumps:

  • Changes to Scarb.toml trigger package builds (packages filter line 42)
  • Workspace manifest changes trigger all tests (workspace_manifests filter triggers RUN_ALL="true" in pr-ci.yml:112-114)
  • No codecov configuration changes needed for dependency updates

Summary

0 CRITICAL, 0 HIGH, 0 MEDIUM, 0 LOW, 0 INFO


@github-actions
Copy link
Copy Markdown

Codex Review - General Engineering Review

Review process failed to complete.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@claude
Copy link
Copy Markdown

claude Bot commented Apr 23, 2026

Claude finished @starknetdev's task —— View job


Claude Review - General Engineering Review

run=24853327443 attempt=1 sha=2e3844f4b24da55a68e39051d824bbd6980c7f0a scope=general

Review Progress

  • Analyze PR scope and identify files within review boundary
  • Review root Scarb.toml dependency version bump
  • Check for any CI/CD configuration impacts
  • Verify documentation consistency requirements
  • Provide final review summary

Analysis

Files in scope: Only Scarb.toml (1 out of 7 changed files falls within general engineering review scope)

Change reviewed:

  • Scarb.toml:44 - Dependency version bump: metagame_extensions_interfaces from "0.1.3" to "0.1.4"

Review Results

No issues found.

The dependency version bump is:

  1. Correctly formatted - Uses proper semantic versioning format
  2. Consistent with PR description - Matches the stated goal of consuming v0.1.4 interfaces
  3. Properly configured - The dependency is correctly defined in [workspace.dependencies] and referenced in the workspace
  4. CI-compatible - Workspace manifest changes correctly trigger full test matrix via workspace_manifests filter in .github/workflows/pr-ci.yml:79-80

The CI configuration properly handles dependency bumps:

  • Changes to Scarb.toml trigger package builds (packages filter line 42)
  • Workspace manifest changes trigger all tests (workspace_manifests filter triggers RUN_ALL="true" in pr-ci.yml:112-114)
  • No codecov configuration changes needed for dependency updates

Summary

0 CRITICAL, 0 HIGH, 0 MEDIUM, 0 LOW, 0 INFO


@github-actions
Copy link
Copy Markdown

Codex Review - General Engineering Review

Review process failed to complete.

@claude
Copy link
Copy Markdown

claude Bot commented Apr 23, 2026

Claude finished @starknetdev's task —— View job


Claude Review - Cairo/Starknet Contract Review

run=24853327443 attempt=1 sha=2e3844f4b24da55a68e39051d824bbd6980c7f0a scope=packages

Review Progress

  • Analyze PR scope and identify changed files
  • Review Scarb.toml dependency version bump
  • Review entry_requirement_store.cairo interface usage changes
  • Review mock implementations for interface compliance
  • Check for security, testing, and idiom issues
  • Provide final review summary

Analysis

Files in scope: 6 files in packages/ directory with interface changes for context-owner namespacing

Change reviewed: Interface update from metagame_extensions v0.1.3 to v0.1.4, which adds context_owner parameter to read methods and replaces context_owner() with is_context_registered().

Review Results

No issues found.

Dependency Management:

  • Scarb.toml:44 correctly bumps metagame_extensions_interfaces from "0.1.3" to "0.1.4"

Interface Usage:

  • entry_requirement_store.cairo:145,200 correctly adds get_contract_address() as context_owner parameter to valid_entry() and entries_left() calls
  • The metagame contract is the appropriate context owner since it calls add_config during setup

Mock Implementations:

  • All 5 mock contracts properly implement the new interface signature
  • Storage correctly updated from Map<u64, bool> to Map<(ContractAddress, u64), bool> for context-owner namespacing
  • context_owner() method correctly replaced with is_context_registered() returning true
  • All read methods (bannable, valid_entry, should_ban, entries_left) correctly accept new context_owner parameter

Security & Correctness:

  • Context ownership logic is sound: the metagame contract that registers contexts owns them
  • No access control bypasses or privilege escalation risks introduced
  • Interface changes are backwards compatible for write methods
  • Mock storage keys properly namespace by (context_owner, context_id) tuple

Summary

0 CRITICAL, 0 HIGH, 0 MEDIUM, 0 LOW, 0 INFO


@github-actions
Copy link
Copy Markdown

Codex Review - Cairo/Starknet Contract Review

Review process failed to complete.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the metagame_extensions_interfaces dependency to version 0.1.4 and refactors the entry requirement logic to include a context_owner parameter in extension calls. Correspondingly, mock validators were updated to support this new parameter and now use a composite key (ContractAddress, u64) for the bannable storage map. The review feedback suggests inlining the get_contract_address() call within EntryRequirementStoreImpl to improve code conciseness where the context_owner variable is only utilized once.

Comment on lines 144 to +145
let caller_address = get_caller_address();
let context_owner = get_contract_address();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While defining context_owner explicitly can improve readability, it is only used once in the following valid_entry call. You could consider passing get_contract_address() directly to the dispatcher call to be more concise, similar to how other parameters are handled if they don't need pre-processing.

                let caller_address = get_caller_address();
                let display_extension_address: felt252 = extension_config.address.into();
                assert!(
                    extension_dispatcher
                        .valid_entry(get_contract_address(), context_id, caller_address, qualification),

Comment on lines 199 to +200
let caller_address = get_caller_address();
let context_owner = get_contract_address();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to the validate_qualification function, context_owner is only used once in the entries_left call. Inlining get_contract_address() would make the code slightly more succinct.

                let caller_address = get_caller_address();

                let qualification = match qualifier {

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@claude
Copy link
Copy Markdown

claude Bot commented Apr 23, 2026

Claude finished @starknetdev's task —— View job


Claude Review - General Engineering Review

run=24853998869 attempt=1 sha=c186e3bb77e16c27795e4e94739278899e9ac4f2 scope=general

Review Progress

  • Analyze PR scope and identify files within review boundary
  • Review root Scarb.toml dependency version bump
  • Check for any CI/CD configuration impacts
  • Verify documentation consistency requirements
  • Provide final review summary

Analysis

Files in scope: Only Scarb.toml (1 out of 7 changed files falls within general engineering review scope)

Change reviewed:

  • Scarb.toml:44 - Dependency version bump: metagame_extensions_interfaces from "0.1.3" to "0.1.4"

Review Results

No issues found.

The dependency version bump is:

  1. Correctly formatted - Uses proper semantic versioning format
  2. Consistent with PR description - Matches the stated goal of consuming v0.1.4 interfaces
  3. Properly configured - The dependency is correctly defined in [workspace.dependencies] and referenced in the workspace
  4. CI-compatible - Workspace manifest changes correctly trigger full test matrix via workspace_manifests filter in .github/workflows/pr-ci.yml:79-80

The CI configuration properly handles dependency bumps:

  • Changes to Scarb.toml trigger package builds (packages filter line 42)
  • Workspace manifest changes trigger all tests (workspace_manifests filter triggers RUN_ALL="true" in pr-ci.yml:112-114)
  • No codecov configuration changes needed for dependency updates

Summary

0 CRITICAL, 0 HIGH, 0 MEDIUM, 0 LOW, 0 INFO


@github-actions
Copy link
Copy Markdown

Codex Review - General Engineering Review

Review process failed to complete.

@claude
Copy link
Copy Markdown

claude Bot commented Apr 23, 2026

Claude finished @starknetdev's task —— View job


Claude Review - Cairo/Starknet Contract Review

run=24853998869 attempt=1 sha=c186e3bb77e16c27795e4e94739278899e9ac4f2 scope=packages

Review Progress

  • Read and analyze changed files in packages/
  • Review dependency bump for security implications
  • Examine interface usage changes in entry_requirement_store.cairo
  • Validate mock implementations for correctness
  • Check for security vulnerabilities and access control issues
  • Evaluate Cairo idioms and best practices
  • Assess testing coverage and approach
  • Look for gas optimization opportunities
  • Provide final review summary

Analysis

Files in scope: 6 files in packages/ directory with interface changes for context-owner namespacing

Change reviewed: Interface update from metagame_extensions v0.1.3 to v0.1.4, which adds context_owner parameter to read methods and replaces context_owner() with is_context_registered().

Review Results

No issues found.

Dependency Management:

  • Scarb.toml:44 correctly bumps metagame_extensions_interfaces from "0.1.3" to "0.1.4"

Interface Usage:

  • entry_requirement_store.cairo:145,200 correctly adds get_contract_address() as context_owner parameter to valid_entry() and entries_left() calls
  • The metagame contract is the appropriate context owner since it calls add_config during setup

Mock Implementations:

  • All 5 mock contracts properly implement the new interface signature
  • Storage correctly updated from Map<u64, bool> to Map<(ContractAddress, u64), bool> for context-owner namespacing
  • context_owner() method correctly replaced with is_context_registered() returning true
  • All read methods (bannable, valid_entry, should_ban, entries_left) correctly accept new context_owner parameter

Security & Correctness:

  • Context ownership logic is sound: the metagame contract that registers contexts owns them
  • No access control bypasses or privilege escalation risks introduced
  • Interface changes are backwards compatible for write methods
  • Mock storage keys properly namespace by (context_owner, context_id) tuple

Summary

0 CRITICAL, 0 HIGH, 0 MEDIUM, 0 LOW, 0 INFO


@github-actions
Copy link
Copy Markdown

Codex Review - Cairo/Starknet Contract Review

Review process failed to complete.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@starknetdev starknetdev merged commit 84ddd15 into main Apr 23, 2026
24 of 27 checks passed
starknetdev added a commit to Provable-Games/budokan that referenced this pull request Apr 23, 2026
…me_extensions v0.1.4) (#221)

Bumps dependencies to pick up the extension interface change that
namespaces per-context storage on extension validators by
(context_owner, context_id) rather than just context_id. Under the
previous model, two Budokan deployments that both asked a validator to
configure tournament_id=1 would collide on the second call with
"Only context owner can call"; each deployment now has its own private
namespace on a shared validator contract.

See:
- Provable-Games/metagame_extensions#19
- Provable-Games/game-components#105

### Contract changes

- `budokan.cairo`:
  - `bannable(tournament_id + 1)` -> `bannable(get_contract_address(), tournament_id + 1)`
  - `should_ban(tournament_id, ...)` -> `should_ban(get_contract_address(), tournament_id, ...)`
  The contract passes its own address as the context_owner because it
  was the caller at `add_config` time.

- `entry_validator_mock.cairo` and `tournament_validator_mock.cairo`:
  - IEntryRequirementExtension impl updated to the new signatures:
    added `is_context_registered`, removed `context_owner`, threaded
    `context_owner: ContractAddress` through `bannable`, `valid_entry`,
    `should_ban`, and `entries_left`.
  - Storage rekeyed so per-context maps are `Map<(ContractAddress, u64), _>`.
  - `add_config` / `add_entry` / `remove_entry` now key storage by
    `get_caller_address()` so the mock matches the namespacing
    behavior of real validators.

Co-authored-by: starknetdev <starknetdev@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <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