Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: namespaces #2148

Merged
merged 29 commits into from
Jul 7, 2024
Merged

feat: namespaces #2148

merged 29 commits into from
Jul 7, 2024

Conversation

glihm
Copy link
Collaborator

@glihm glihm commented Jul 6, 2024

Description

This PR introduces the namespaces for contracts and models.

This implies that anytime one wants to refer to a contract or a model, the namespace + the name of the contract/model must be provided.

A new term is introduce: a tag. A tag is a unique identifier or a contract/model containing the namespace and the name of the contract/model separated by -:
dojo_examples-actions or dojo_examples-Position.

For model names, the regex is [_a-zA-Z] enforced by Cairo. The exact same regex is expected for the namespace, and will be enforced by sozo (currently not enforced by the contract, but Torii will be updated to ignore any invalid namespace).

Currently, the default namespace is the package of the Scarb.toml, which allows sozo to automatically pick up this if no namespace is provided.

To provide a namespace:

#[dojo::model(namespace: "nm")]
struct MyModel {
...
}

#[dojo::contract(namespace: "nm2")]
mod actions {
...
}

Sozo commands have been updated to take in account this tag, or if no namespace is given, the default namespace is used.

# Before
sozo execute dojo_examples::actions::actions spawn

# Implicit default namespace
sozo execute actions spawn

# Explicit namespace
sozo execute nm2-other_contract spawn

Torii has also been updated to use this tag in order to query a specific model.

  • merging main with new Felt type

remybar and others added 22 commits June 17, 2024 12:24
* fix(migrate): when `init_calldata` depends on contract that was already deployed (#2058)

* fix(migrate): when `init_calldata` depends on contract that was already deployed

* add tests

* fix(ci): ensure katana runs in debian:bookworm-slim (#2073)

* Ensure katana runs in debian:bookworm-slim

* chore: switch to cartridge fork and adjust CI to 4 core to build Katana

* chore: add old prover-sdk version to check CI fail

* fix katana bin permissions

* chore: add ensure-docker as requirement for big jobs

* chore: point to http-prover using rustls-tls

* dbg

* wip

* chore: bump to artifacts v4

* fix: typo

* wip

* fix: don't use path explicitely

* wip

* fix: fix artifacts managment

* add ls

* fix: use other path with checkout

* fix: remove prints

---------

Co-authored-by: glihm <[email protected]>

* [dojo-core]: update gas logs (#1877)

dojo-core: update gas logs

Co-authored-by: glihm <[email protected]>

* Prepare release: v0.7.1 (#2076)

Co-authored-by: glihm <[email protected]>

* fix: allow the use of self and world in an exclusive manner (#2063)

* fix: allow the use of self and world in an exclusive manner

* fix: fmt

* fix: cairo fmt

* fix: ensure a warning is emitted with generate trait and world

* fix: cairo fmt

* Update devcontainer image: v0.7.1 (#2077)

Co-authored-by: glihm <[email protected]>

* Namespace feature

---------

Co-authored-by: lambda-0x <[email protected]>
Co-authored-by: Tarrence van As <[email protected]>
Co-authored-by: glihm <[email protected]>
Co-authored-by: notV4l <[email protected]>
Co-authored-by: glihm <[email protected]>
* standardize model/system interface for name/namespace/selectors

* wip
* load custom overlay manifests

* update metadata management + some fixes

* update sozo commands with namespace
* update sozo auth command + auto-auth feature

* fix: fix some tests

---------

Co-authored-by: glihm <[email protected]>
* replace {WORLD,BASE}_CONTRACT_NAME by {WORLD,BASE}_CONTRACT_TAG

* fix: ensure model selector correctly computed in tests

* fix: wip on tests and use Katana Runner

---------

Co-authored-by: glihm <[email protected]>
* initial commit

* add seed to manifest and remove from cli

* add overlays for dojo_init

* make tests compile

* fix some tests

* fix lints

* fix: use same name for seed tests

---------

Co-authored-by: glihm <[email protected]>
* feat(torii-core): namespace in processor & db migration

* refactor: selector logic and model readers for new namespace

* feat: compute correct selector on model register

* fix: contract address in event data

* refactor: update proto for new namespace

* feat: update torii client for new namespaces

* refactor: cache and schema types

* feat: rebase from main update to new types

* feat: update grpc service to support namespaces

* feat: add namespace to broker

* feat: fix libp2p and update grpc subs for pattern on models

* feat: finish up refactor on grpc

* chore: revert changes on proto to use onlky model field

* feat: first graphql support

* fix: composite clauses & wrap up

* fix: storage and tests

* refactor: storage to use selector

* fix: storage subscriptions

* escape composite tbales

* Overlays (#2127)

* load custom overlay manifests

* update metadata management + some fixes

* update sozo commands with namespace

* fix: change tag separator to `-` (#2132)

* wip

* fix tests

* merge and remove print

* fix: remove print

* fix: fmt and clippy wip

* fix: graphql tests

* model tests

* query test

* fmt

* fix: query

* chore: graphql subscription tests

* wip: fix testing

* wip: wip on testing

* fix: fix typo

* fix: use correct model name

* wip: testing

* feat: add namespace to model object

* fix: fix subscription tests

* fix: fix tests

* fix: fmt

* fix: clippy

* wip: latest torii test

* fix: fmt

* fix(torii-libp2p): validate namespace message

* fix(torii-libp2p): escape table name

* fmt

---------

Co-authored-by: Rémy Baranx <[email protected]>
Co-authored-by: glihm <[email protected]>
…2141)

* fix: fix compiler diags by rewriting the function with rewrite node

* fix: ensure dojo init also shows correct diagnostics

* fix: fmt + clippy

* fix: ensure impl is correctly impl with RewriteNode
* fix: test fixes for wasm32 changes

* fix: fix cairo tests
* fix: clean should only remove target/manifest file of particular profile by defaul

* fix lints

* fix formatting

* fix: ensure every target is considered independently

---------

Co-authored-by: glihm <[email protected]>
Copy link

coderabbitai bot commented Jul 6, 2024

Important

Review skipped

More than 25% of the files skipped due to max files limit. The review is being skipped to prevent a low-quality review.

105 files out of 263 files are above the max files limit of 50. Please upgrade to Pro plan to get higher limits.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@glihm glihm changed the title Feat/namespace feat: namespaces Jul 6, 2024
Copy link

codecov bot commented Jul 6, 2024

Codecov Report

Attention: Patch coverage is 79.60454% with 557 lines in your changes missing coverage. Please review.

Project coverage is 67.90%. Comparing base (0c50c7d) to head (de5344b).

Files Patch % Lines
crates/torii/grpc/src/server/mod.rs 10.37% 95 Missing ⚠️
crates/dojo-lang/src/contract.rs 80.45% 52 Missing ⚠️
crates/sozo/ops/src/migration/mod.rs 48.42% 49 Missing ⚠️
crates/dojo-world/src/manifest/mod.rs 67.15% 45 Missing ⚠️
bin/sozo/src/commands/model.rs 0.00% 27 Missing ⚠️
...ates/torii/grpc/src/server/subscriptions/entity.rs 0.00% 25 Missing ⚠️
...rii/grpc/src/server/subscriptions/event_message.rs 0.00% 25 Missing ⚠️
bin/sozo/src/commands/auth.rs 83.46% 21 Missing ⚠️
crates/dojo-lang/src/model.rs 77.17% 21 Missing ⚠️
crates/torii/client/src/client/mod.rs 0.00% 17 Missing ⚠️
... and 36 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2148      +/-   ##
==========================================
+ Coverage   67.82%   67.90%   +0.07%     
==========================================
  Files         334      336       +2     
  Lines       42048    43086    +1038     
==========================================
+ Hits        28519    29256     +737     
- Misses      13529    13830     +301     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@glihm glihm merged commit ed9f0ce into main Jul 7, 2024
15 checks passed
@glihm glihm deleted the feat/namespace branch July 7, 2024 00:12
@lambda-0x lambda-0x restored the feat/namespace branch July 7, 2024 08:12
@lambda-0x lambda-0x deleted the feat/namespace branch July 7, 2024 08:44
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.

5 participants