Skip to content

chore: bump to cairo 2.13 and update world constructor#3372

Merged
glihm merged 8 commits intodojoengine:mainfrom
glihm:feat/cairo-2.13
Oct 31, 2025
Merged

chore: bump to cairo 2.13 and update world constructor#3372
glihm merged 8 commits intodojoengine:mainfrom
glihm:feat/cairo-2.13

Conversation

@glihm
Copy link
Collaborator

@glihm glihm commented Oct 31, 2025

The world constructor doesn't require the world class hash anymore since starknet has the new syscall available.

Also, this PR bumps Cairo to 2.13 for all packages.

Summary by CodeRabbit

  • New Features

    • Added mainnet deployment configuration support for example projects.
  • Chores

    • Updated Cairo, Starknet, and Scarb toolchain versions (2.12 → 2.13, Scarb 2.12.2 → 2.13.1, Starknet Foundry 0.50 → 0.51).
    • Updated build and test dependencies across projects.
  • Tests

    • Updated test configurations and expected values to reflect changes in system behavior.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 31, 2025

Caution

Review failed

The pull request is closed.

Ohayo sensei! 👋

Walkthrough

This PR upgrades Dojo's development toolchain from Cairo/Scarb 2.12.x to 2.13.x and refactors macro helpers to use lifetime-parameterized AST types with database-aware string conversions. The world contract constructor signature is simplified to retrieve the class hash via syscall instead of accepting it as a parameter.

Changes

Cohort / File(s) Summary
Tool & Dependency Version Upgrades
.github/workflows/release-dispatch-macros.yml, release-dispatch.yml, release-macros.yml, release.yml, test.yml, .tool-versions, Cargo.toml
Scarb bumped from 2.12.2 to 2.13.1; starknet-foundry upgraded to 0.51.0; cairo-lang-starknet-classes updated to 2.13.1 across build artifacts and workflows.
Scarb Manifest Updates
crates/dojo/core-tests/Scarb.toml, crates/dojo/core/Scarb.toml, crates/dojo/dojo-cairo-test/Scarb.toml, crates/dojo/dojo-snf-test/Scarb.toml, examples/game-lib/Scarb.toml, examples/game-lib/armory/Scarb.toml, examples/game-lib/bestiary/Scarb.toml, examples/simple/Scarb.toml, examples/spawn-and-move/Scarb.toml
Cairo and dependency versions unified: starknet 2.12→2.13, snforge_std 0.50→0.51, cairo_test 2.12→2.13, assert_macros 2.12→2.13; cairo-version field removed from package declarations.
Macro Cargo Dependency Updates
crates/dojo/macros/Cargo.toml
All cairo-lang crates bumped from 2.12.2 to 2.13.1 (cairo-lang-parser, defs, syntax, starknet-classes, etc.).
Macro Helper API Refactoring
crates/dojo/macros/src/attributes/contract.rs, library.rs, crates/dojo/macros/src/derives/dojo_store.rs, introspect/enums.rs, introspect/layout.rs, introspect/size.rs, introspect/structs.rs, introspect/ty.rs, inlines/bytearray_hash.rs, inlines/selector_from_tag.rs
Systematic replacement of to_string() with to_string(db) for database-aware AST text extraction and name comparisons across derive and inline macros.
Macro Helper Signature Updates
crates/dojo/macros/src/helpers/checker.rs, helpers/formatter.rs, helpers/misc.rs, helpers/parser.rs
Function signatures updated with lifetime parameters ('a) and AST type adjustments: check_derive_conflicts, serialize_keys_and_values, compute_unique_hash, parse_and_find_struct/module, parse_inline_args, parse_members, extract_derive_attr_names now properly bound to lifetime contexts for borrowed AST traversal.
World Contract Constructor Refactoring
crates/dojo/core/src/world/world_contract.cairo
Constructor signature changed from fn constructor(ref self: ContractState, world_class_hash: ClassHash) to fn constructor(ref self: ContractState), now retrieves class hash at runtime via syscall within the constructor body.
Test Deployment Logic Updates
crates/dojo/dojo-cairo-test/src/world.cairo, dojo-snf-test/src/world.cairo, crates/dojo/world/src/utils.rs, crates/sozo/ops/src/migrate/mod.rs
World deployment calldata simplified from [world_class_hash.into()].span() to [].span() in deploy_syscall calls; compute_world_address constructor_args changed from [world_class_hash] to [].
Test Expectation Updates
crates/dojo/core-tests/src/tests/model/model.cairo, world/acl.cairo, world/contract.cairo, world/event.cairo, world/metadata.cairo, world/model.cairo, world/world.cairo, crates/dojo/world/src/contracts/contract_info.rs, bin/sozo/tests/test_data/policies.json
Contract addresses in should_panic expected strings and policy JSON targets updated; key spans in tests now explicitly annotated with type hints.
New Configuration & Manifest Files
examples/simple/dojo_mainnet.toml, examples/simple/manifest_mainnet.json, examples/spawn-and-move/dojo_dev.toml, examples/simple/dojo_sepolia.toml
New mainnet configuration and manifest files added; existing configs updated with new seed values and world addresses.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Areas requiring extra attention:

  • Macro helper lifetime refactoring (helpers/parser.rs, helpers/checker.rs, helpers/formatter.rs, helpers/misc.rs): Verify all AST lifetime parameters are correctly threaded through call chains and that string conversion semantics remain preserved with to_string(db) conversions.
  • World contract constructor syscall integration (world_contract.cairo, utils.rs, migrate/mod.rs): Ensure syscall-based class hash retrieval is sound across all deployment paths and that removing the constructor parameter doesn't break instantiation semantics.
  • Test address mappings (policies.json, **/tests/world/*.cairo): Validate that all reordered policy targets and updated should_panic contract addresses match the new test environment expectations.
  • New configuration & manifest files (examples/simple/manifest_mainnet.json): Large JSON file with extensive ABI and type definitions should be reviewed for structural correctness and consistency with the framework's manifest format.

Possibly related PRs

  • chore: bump to cairo 2.12.2 #3335: Directly related to macro helper API signature changes (lifetime parameters and string conversion refactoring in check_derive_conflicts and parser/formatter functions).
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 25ce202 and 8e5499b.

⛔ Files ignored due to path filters (6)
  • Cargo.lock is excluded by !**/*.lock
  • crates/dojo/core-tests/Scarb.lock is excluded by !**/*.lock
  • crates/dojo/dojo-snf-test/Scarb.lock is excluded by !**/*.lock
  • crates/dojo/macros/Cargo.lock is excluded by !**/*.lock
  • examples/spawn-and-move/Scarb.lock is excluded by !**/*.lock
  • spawn-and-move-db.tar.gz is excluded by !**/*.gz
📒 Files selected for processing (49)
  • .github/workflows/release-dispatch-macros.yml (1 hunks)
  • .github/workflows/release-dispatch.yml (1 hunks)
  • .github/workflows/release-macros.yml (1 hunks)
  • .github/workflows/release.yml (2 hunks)
  • .github/workflows/test.yml (4 hunks)
  • .tool-versions (1 hunks)
  • Cargo.toml (1 hunks)
  • bin/sozo/tests/test_data/policies.json (3 hunks)
  • crates/dojo/core-tests/Scarb.toml (1 hunks)
  • crates/dojo/core-tests/src/tests/model/model.cairo (2 hunks)
  • crates/dojo/core-tests/src/tests/world/acl.cairo (4 hunks)
  • crates/dojo/core-tests/src/tests/world/contract.cairo (2 hunks)
  • crates/dojo/core-tests/src/tests/world/event.cairo (1 hunks)
  • crates/dojo/core-tests/src/tests/world/metadata.cairo (1 hunks)
  • crates/dojo/core-tests/src/tests/world/model.cairo (1 hunks)
  • crates/dojo/core-tests/src/tests/world/world.cairo (1 hunks)
  • crates/dojo/core/Scarb.toml (1 hunks)
  • crates/dojo/core/src/world/world_contract.cairo (2 hunks)
  • crates/dojo/dojo-cairo-test/Scarb.toml (1 hunks)
  • crates/dojo/dojo-cairo-test/src/world.cairo (1 hunks)
  • crates/dojo/dojo-snf-test/Scarb.toml (1 hunks)
  • crates/dojo/dojo-snf-test/src/world.cairo (1 hunks)
  • crates/dojo/macros/Cargo.toml (1 hunks)
  • crates/dojo/macros/src/attributes/contract.rs (2 hunks)
  • crates/dojo/macros/src/attributes/library.rs (2 hunks)
  • crates/dojo/macros/src/derives/dojo_store.rs (5 hunks)
  • crates/dojo/macros/src/derives/introspect/enums.rs (2 hunks)
  • crates/dojo/macros/src/derives/introspect/layout.rs (2 hunks)
  • crates/dojo/macros/src/derives/introspect/size.rs (1 hunks)
  • crates/dojo/macros/src/derives/introspect/structs.rs (3 hunks)
  • crates/dojo/macros/src/derives/introspect/ty.rs (1 hunks)
  • crates/dojo/macros/src/helpers/checker.rs (2 hunks)
  • crates/dojo/macros/src/helpers/formatter.rs (4 hunks)
  • crates/dojo/macros/src/helpers/misc.rs (2 hunks)
  • crates/dojo/macros/src/helpers/parser.rs (7 hunks)
  • crates/dojo/macros/src/inlines/bytearray_hash.rs (2 hunks)
  • crates/dojo/macros/src/inlines/selector_from_tag.rs (2 hunks)
  • crates/dojo/world/src/contracts/contract_info.rs (1 hunks)
  • crates/dojo/world/src/utils.rs (1 hunks)
  • crates/sozo/ops/src/migrate/mod.rs (1 hunks)
  • examples/game-lib/Scarb.toml (1 hunks)
  • examples/game-lib/armory/Scarb.toml (1 hunks)
  • examples/game-lib/bestiary/Scarb.toml (1 hunks)
  • examples/simple/Scarb.toml (1 hunks)
  • examples/simple/dojo_mainnet.toml (1 hunks)
  • examples/simple/dojo_sepolia.toml (1 hunks)
  • examples/simple/manifest_mainnet.json (1 hunks)
  • examples/spawn-and-move/Scarb.toml (1 hunks)
  • examples/spawn-and-move/dojo_dev.toml (1 hunks)

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

@glihm glihm merged commit 0301216 into dojoengine:main Oct 31, 2025
9 of 10 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.

1 participant