Skip to content

v2.7.0-rc.0

Pre-release
Pre-release
Compare
Choose a tag to compare
@github-actions github-actions released this 26 Jun 14:59
· 131 commits to main since this release
00ef88e

Cairo release notes ➡️

Welcome to the release notes for Scarb v2.7.0-rc.0!

Warning

This version is not supported on Starknet! If you want to develop contracts deployable to the current Starknet, please stick with Scarb v2.6.5

This Scarb release includes multiple new developments:

  • Testing without gas calculation - If your package disables gas calculation with enable-gas flag on compiler config, no gas calculations will be performed in cairo-test.
  • Additional resource usage info while testing - You can now use new flag --print-resource-usage when testing package with cairo-test to print more verbose usage info.
  • Cairo profiler support - statement-function mappings - Scarb can now emit annotations that can be consumed by cairo-profiler to trace resource usage.
  • Diagnostic error codes - Compiler diagnostics (both errors and warnings) are now printed with numerical error code, which makes identification and understanding of root cause easier.
  • Stop overwriting existing git checkouts - Checkouts of git dependencies are not anymore overwriten on each Scarb run.
  • Stop enabling cfg(test) in package tested with integration tests - integration tests (from tests directory) in cairo-test should not rely on

But also, the introduction of few new features:

Conditional compilation with Scarb features

Features in Scarb provide a way to conditionally compile specific parts of the code during the build process.

A package defines a set of named features in the [features] section of the Scarb.toml file. Each defined feature can list other features that should be enabled with it. For example, a package supporting various hash functions might define features like this:

[features]
poseidon = []
pedersen = []
keccak = []

With these features set, conditional compilation (cfg) attributes can be used to selectively include code to support requested features during compile time, for example: #[cfg(feature: 'poseidon')].

You can read more on features in our conditional compilation docs.

Cairo test dependency

Since this release, all packages using cairo-test as a test runner have to define a dependency on cairo_test package, with version matching the Scarb version (similarly to the starknet package). The cairo_test package should be put in the dev-dependencies section of Scarb manifest file.

Example of dependency declaration:

[dev-dependencies]
cairo_test = "2.7.0-rc.0"

If you choose to replace cairo-test with another test runner (like starknet-foundry) you should remove the cairo_test package from your dependencies.

Forge project template

If you intend to use Starknet Foundry Forge to test your contracts, you can create an already set up Starknet Foundry project by running:

scarb new hello_world --snforge

This will create a Starknet package, with Forge already set up as your test runner. You can then execute Forge tests by
simply running:

scarb test

You can also build your package, like a regular Starknet package.

Scarb expand command

Before the actual compilation of your Cairo code, the Cairo compiler runs multiple pre-processing steps on it (these are usually called plugins).
Each of these steps takes parsed Cairo code as an input, modifies it and returns modified Cairo code back to the compiler.

Since this Scarb release, you can use scarb expand to see the Cairo code generated after all preprocessing steps. The expanded Cairo will be saved in a file in target directory.

Choose cairo-run function to execute

Until this release, scarb cairo-run would always look for a function called main to execute.
Since this release, a function to run can be specified with --function argument.
If your build does not include debug names (sierra-replace-ids set to false), you can now choose function to run by annotating it with #[main] attribute.
To use the attribute, you need to add cairo_run with version equal to Scarb version to your dependencies.

You can read more on cairo-run in our docs.

Merge manifest tool definitions recursively

Tool metadata (defined in the manifest [tool] section) can be overridden by a profile.
Since this release, merge strategy can be changed with merge-strategy property.

For example:

[tool.some-tool]
local = false
debug = false

[profile.dev.tool.some-tool]
merge-strategy = "merge"
debug = true

Would be translated to:

[tool.some-tool]
merge-strategy = "merge"
local = false
debug = true

Note, that before introduction of merge-strategy propery, this would translate to:

[tool.some-tool]
debug = true

You can read more on tool metadata in our docs.

Cairo Version

This version of Scarb comes with Cairo v2.7.0-rc.0.

What's Changed

New Contributors

Full Changelog: v2.6.5...v2.7.0-rc.0