Skip to content

v2.3.0-rc0

Pre-release
Pre-release
Compare
Choose a tag to compare
@github-actions github-actions released this 27 Sep 14:07
· 627 commits to main since this release
ad30433

Cairo release notes ➡️

Scarb and Cairo releases are getting synchronized

We are happy to announce that starting with this release, Scarb will follow Cairo version numbering! From now on, Scarb vX.Y.Z will always ship with matching Cairo vX.Y release. It is possible that we will make patch releases for Scarb that will not come with compiler updates.

BREAKING: New artifacts extensions convention

This Scarb release starts and implements a new convention of file extensions in Cairo & Starknet ecosystems:

  • Textual Sierra representation, meant for debugging use and compiler tests, stays as: crate.sierra
  • Textual CASM code of compiled Sierra, executable in Cairo VM, stays as: crate.casm
  • JSON representation of Sierra, used to be much more reliable than textual dump becomes: crate.sierra.json
    • alternative serialization formats will naturally be crate.sierra.X
  • JSON containing Sierra code of Starknet contract class becomes: contract.contract_class.json
  • JSON containing CASM code of Starknet contract class becomes: contract.compiled_contract_class.json

See the related proposal in Cairo discussions for more elaborate description.

BREAKING: [lib] target now emits Sierra in new JSON format

The default [lib] target now by default emits Sierra in a new JSON format (.sierra.json), that is derived from Cairo compiler data structures instead of textual Sierra (.sierra).

If you want to emit old format in your packages, add the following to your Scarb.toml:

[lib]
sierra-text = true

Important

We ask though to migrate your tools & workflows to .sierra.json immediately, as .sierra files parser is known to misread programs and the JSON format does not have this issue.

BREAKING: Package names must be lowercase

Starting with this release, Scarb will refuse to work on packages that contain uppercase letters. Technically this is a breaking change, but we have not detected such packages existing in the open-source world, so we expect no affected users.

Moving tests compilation from cairo-test to scarb build

scarb cairo-test does not bundle the entire Cairo compiler now, and instead calls scarb build in order to build Cairo tests. This is now possible thanks to the addition of a new Scarb target: [[test]].

This feature is currently mostly behind the scenes. We plan to iterate on it, and make it publicly documented when we'll ensure it is rock solid. As part of this effort, our plan is to standardize generated artefacts for tests, and therefore allow Starknet Foundry to also delegate their build process entirely to Scarb. This will also make it much easier to implement other custom Cairo test runners, as we'll effectively decouple Cairo compilation from actual testing.

The tests directory

This improvement also allows Scarb to kill two birds with one stone:

  1. Starknet Foundry's tests directory is now properly handled by scarb cairo-language-server.
  2. scarb cairo-test got support for running tests from the tests directory.

We will be polishing and documenting this feature in future Scarb releases.

Note

These improvements are only available in Scarb's distributions of cairo-test and Cairo LS. The low-level binaries generated by Cairo compiler team do not have such capabilities.

Sorting imports in Cairo code

scarb fmt can now sort use statements etc. in Cairo code. This feature tends to generate big diffs, so it is disabled by default. To enable it, add the following to your Scarb.toml:

[tool.fmt]
sort-module-level-items = true

See relevant documentation for more information

Wildcard support in build-external-contracts

The build-external-contracts property of the starknet-contract target allows asking Scarb to build contracts from package dependencies as part of proper package build, for example for use in tests. This release adds a possibility to request building many contracts from a module tree at once. For example, the following snippet:

[[target.starknet-contract]]
build-external-contracts = [
    "dojo_erc::erc721::components::Balance",
    "dojo_erc::erc721::components::OperatorApproval",
    "dojo_erc::erc721::components::Owner",
    "dojo_erc::erc721::components::TokenApproval",
    "dojo_erc::erc721::erc721::ERC721",
    "dojo_erc::erc721::systems::erc721_approve",
    "dojo_erc::erc721::systems::erc721_burn",
    "dojo_erc::erc721::systems::erc721_mint",
    "dojo_erc::erc721::systems::erc721_set_approval_for_all",
    "dojo_erc::erc721::systems::erc721_transfer_from",
]

can now be written as:

[[target.dojo]]
build-external-contracts = [
    "dojo_erc::erc721::*",
]

Thanks to @ametel01 for contribution!

Minor changes

  • Commands executed via Scarb scripts may now use coloured output in some cases.
  • scarb clean refuses to work if it's executed outside Scarb workspace.
  • On Linux and macOS, Scarb now uses the exec(3) syscall for running subcommands, which means that subcommands now replace scarb process instead of being wrapped by it. Alongside this, we have improved the corresponding implementation on Windows, which should, among others, improve handling of killing processes.
  • scarb new/init now show an error or a warning if created package's name is a Cairo keyword or other ecosystem reserved name.
  • Added an internal support for target-specific dependencies.
    • test targets will now depend on a new magic package: test_plugin, which provides cairo-test compiler plugin.
    • This change will manifest itself in scarb metadata output.
  • Scarb will now attempt to infer the value of package.readme field if missing, but a readme file is present.

Cairo Version

This version of Scarb comes with Cairo v2.3.0-rc0.

What's Changed

Full Changelog: v0.7.0...v2.3.0-rc0