From 9917d8569d3beedc438e816c616087496a094532 Mon Sep 17 00:00:00 2001 From: Nuelo Date: Mon, 28 Oct 2024 07:55:15 +0100 Subject: [PATCH 1/5] doc: update doc for casm = true in scarb.toml --- docs/src/appendix/scarb-toml.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/appendix/scarb-toml.md b/docs/src/appendix/scarb-toml.md index c0dfc5fa11..36c633a844 100644 --- a/docs/src/appendix/scarb-toml.md +++ b/docs/src/appendix/scarb-toml.md @@ -166,7 +166,7 @@ sierra = true #### `casm` -See more about [CASM contract class generation](https://docs.swmansion.com/scarb/docs/extensions/starknet/contract-target.html#casm-contract-class-generation) in Scarb documentation. +Enabling `casm = true` in Scarb.toml causes unnecessary overhead. Tools like `snforge` and `sncast` recompile Sierra to CASM separately, resulting in redundant processing. This duplicates CASM generation, significantly impacting performance, especially for large Sierra programs. It increases build size by several megabytes and slows down compilation. To avoid this, leave `casm = false`(the default) and let tools handle CASM generation only when needed. The Sequencer performs CASM compilation for execution, making local generation redundant unless required for offline verification or specific development workflows. See more about [CASM contract class generation](https://docs.swmansion.com/scarb/docs/extensions/starknet/contract-target.html#casm-contract-class-generation) in Scarb documentation. ```toml [[target.starknet-contract]] From 4d2e430b89b862770e1d850d74e0975919317823 Mon Sep 17 00:00:00 2001 From: Nuelo Date: Mon, 28 Oct 2024 10:29:52 +0100 Subject: [PATCH 2/5] doc: update doc with reference --- docs/src/appendix/scarb-toml.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/appendix/scarb-toml.md b/docs/src/appendix/scarb-toml.md index 36c633a844..32adfe6cff 100644 --- a/docs/src/appendix/scarb-toml.md +++ b/docs/src/appendix/scarb-toml.md @@ -166,7 +166,7 @@ sierra = true #### `casm` -Enabling `casm = true` in Scarb.toml causes unnecessary overhead. Tools like `snforge` and `sncast` recompile Sierra to CASM separately, resulting in redundant processing. This duplicates CASM generation, significantly impacting performance, especially for large Sierra programs. It increases build size by several megabytes and slows down compilation. To avoid this, leave `casm = false`(the default) and let tools handle CASM generation only when needed. The Sequencer performs CASM compilation for execution, making local generation redundant unless required for offline verification or specific development workflows. See more about [CASM contract class generation](https://docs.swmansion.com/scarb/docs/extensions/starknet/contract-target.html#casm-contract-class-generation) in Scarb documentation. +Enabling [`casm = true`](https://github.com/foundry-rs/starknet-foundry/releases/tag/v0.23.0) in Scarb.toml causes unnecessary overhead. Tools like `snforge` and `sncast` recompile Sierra to CASM separately, resulting in redundant processing. This duplicates CASM generation, significantly impacting performance, especially for large Sierra programs. It increases build size by several megabytes and slows down compilation. To avoid this, leave `casm = false`(the default) and let tools handle CASM generation only when needed. The Sequencer performs CASM compilation for execution, making local generation redundant unless required for offline verification or specific development workflows. See more about [CASM contract class generation](https://docs.swmansion.com/scarb/docs/extensions/starknet/contract-target.html#casm-contract-class-generation) in Scarb documentation. ```toml [[target.starknet-contract]] From 5fea5788f153c8893a29b240241358d1578e9210 Mon Sep 17 00:00:00 2001 From: Nuelo Date: Mon, 28 Oct 2024 10:34:53 +0100 Subject: [PATCH 3/5] fix: make doc less verbose --- docs/src/appendix/scarb-toml.md | 39 ++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/docs/src/appendix/scarb-toml.md b/docs/src/appendix/scarb-toml.md index 32adfe6cff..dd1fd3fa31 100644 --- a/docs/src/appendix/scarb-toml.md +++ b/docs/src/appendix/scarb-toml.md @@ -5,13 +5,16 @@ The `Scarb.toml` contains the package manifest that is needed in package compila ## `Scarb.toml` Contents ### `[tool.snforge]` + ```toml [tool.snforge] # ... ``` + Allows to configure `snforge` settings. All fields are optional. #### `exit_first` + The `exit_first` fields specifies whether to stop tests execution immediately upon the first failure. See more about [stopping test execution after first failed test](https://foundry-rs.github.io/starknet-foundry/testing/running-tests.html#stopping-test-execution-after-first-failed-test). ```toml @@ -20,9 +23,11 @@ exit_first = true ``` #### `fuzzer_runs` -The `fuzzer_runs` field specifies the number of runs of the random fuzzer. + +The `fuzzer_runs` field specifies the number of runs of the random fuzzer. #### `fuzzer_seed` + The `fuzzer_seed` field specifies the seed for the random fuzzer. See more about [fuzzer](https://foundry-rs.github.io/starknet-foundry/testing/test-attributes.html#fuzzer). @@ -36,27 +41,34 @@ fuzzer_seed = 1111 ``` ### `[[tool.snforge.fork]]` + ```toml [[tool.snforge.fork]] # ... ``` + Allows to configure forked tests. If defined, all fields outlined below must also be defined. See more about [fork testing](https://foundry-rs.github.io/starknet-foundry/testing/test-attributes.html#fork). #### `name` + The `name` field specifies the name of the fork. + ```toml [[tool.snforge.fork]] name = "SOME_NAME" ``` #### `url` + The `url` field specifies the address of RPC provider. + ```toml [[tool.snforge.fork]] url = "http://your.rpc.url" ``` #### `block_id.` + The `block_id` field specifies the block to fork from. It can be specified by `tag`, `number` or `hash`. ```toml @@ -79,6 +91,7 @@ block_id.number = "123" ``` ### `[profile..cairo]` + By default, these arguments do not need to be defined. Only set them to use [profiler](https://foundry-rs.github.io/starknet-foundry/snforge-advanced-features/profiling.html#profiling) or [coverage](https://foundry-rs.github.io/starknet-foundry/testing/coverage.html#coverage). Adjust Cairo compiler configuration parameters when compiling this package. These options are not taken into consideration when this package is used as a dependency for another package. All fields are optional. @@ -89,6 +102,7 @@ Adjust Cairo compiler configuration parameters when compiling this package. Thes ``` #### `unstable-add-statements-code-locations-debug-info` + See [`unstable-add-statements-code-locations-debug-info`](https://docs.swmansion.com/scarb/docs/reference/manifest.html#unstable-add-statements-code-locations-debug-info) in Scarb documentation. ```toml @@ -97,20 +111,25 @@ unstable-add-statements-code-locations-debug-info = true ``` #### `unstable-add-statements-functions-debug-info` + See [`unstable-add-statements-functions-debug-info`](https://docs.swmansion.com/scarb/docs/reference/manifest.html#unstable-add-statements-functions-debug-info) in Scarb documentation. + ```toml [profile.dev.cairo] unstable-add-statements-functions-debug-info = true ``` #### `inlining-strategy` + See [`inlining-strategy`](https://docs.swmansion.com/scarb/docs/reference/manifest.html#inlining-strategy) in Scarb documentation. + ```toml [profile.dev.cairo] inlining-strategy = "avoid" ``` #### Example of configuration which allows [coverage](https://foundry-rs.github.io/starknet-foundry/testing/coverage.html) report generation + ```toml [profile.dev.cairo] unstable-add-statements-code-locations-debug-info = true @@ -119,22 +138,28 @@ inlining-strategy = "avoid" ``` ### `[features]` + A package defines a set of named features in the `[features]` section of `Scarb.toml` file. Each defined feature can list other features that should be enabled with it. All fields are optional. + ```toml [features] # ... ``` #### `` + The `` field specifies the name of the feature and list of other features that should be enabled with it. See [features](https://docs.swmansion.com/scarb/docs/reference/conditional-compilation.html#features) in Scarb documentation. + ```toml [features] enable_for_tests = [] ``` #### Example of `Scarb.toml` allowing conditional contracts compilation + Firstly, define a contract in the src directory with a `#[cfg(feature: '')]` attribute: + ```rust #[starknet::contract] #[cfg(feature: 'enable_for_tests')] @@ -144,12 +169,14 @@ mod MockContract { ``` Then update Scarb.toml so it includes the following lines: + ```toml [features] enable_for_tests = [] ``` ### `[[target.starknet-contract]]` + The `starknet-contract` target allows to build the package as a Starknet Contract. See more about [Starknet Contract Target](https://docs.swmansion.com/scarb/docs/extensions/starknet/contract-target.html#starknet-contract-target) in Scarb documentation. ```toml @@ -158,7 +185,9 @@ The `starknet-contract` target allows to build the package as a Starknet Contrac ``` #### `sierra` + See more about [Sierra contract class generation](https://docs.swmansion.com/scarb/docs/extensions/starknet/contract-target.html#sierra-contract-class-generation) in Scarb documentation. + ```toml [[target.starknet-contract]] sierra = true @@ -166,7 +195,8 @@ sierra = true #### `casm` -Enabling [`casm = true`](https://github.com/foundry-rs/starknet-foundry/releases/tag/v0.23.0) in Scarb.toml causes unnecessary overhead. Tools like `snforge` and `sncast` recompile Sierra to CASM separately, resulting in redundant processing. This duplicates CASM generation, significantly impacting performance, especially for large Sierra programs. It increases build size by several megabytes and slows down compilation. To avoid this, leave `casm = false`(the default) and let tools handle CASM generation only when needed. The Sequencer performs CASM compilation for execution, making local generation redundant unless required for offline verification or specific development workflows. See more about [CASM contract class generation](https://docs.swmansion.com/scarb/docs/extensions/starknet/contract-target.html#casm-contract-class-generation) in Scarb documentation. +Enabling [`casm = true`](https://github.com/foundry-rs/starknet-foundry/releases/tag/v0.23.0) in Scarb.toml causes unnecessary overhead and should be disabled unless required by other tools. Tools like `snforge` and `sncast` recompile Sierra to CASM separately, resulting in redundant processing. This duplicates CASM generation, significantly impacting performance, especially for large Sierra programs. +See more about [CASM contract class generation](https://docs.swmansion.com/scarb/docs/extensions/starknet/contract-target.html#casm-contract-class-generation) in Scarb documentation. ```toml [[target.starknet-contract]] @@ -174,7 +204,8 @@ casm = true ``` #### `build-external-contracts` -The `build-external-contracts` allows to use contracts from your dependencies inside your tests. It accepts a list of strings, each of which is a reference to a contract defined in a dependency. You need to add dependency which implements this contracts to your Scarb.toml. See more about [compiling external contracts](https://docs.swmansion.com/scarb/docs/extensions/starknet/contract-target.html#compiling-external-contracts) in Scarb documentation. + +The `build-external-contracts` allows to use contracts from your dependencies inside your tests. It accepts a list of strings, each of which is a reference to a contract defined in a dependency. You need to add dependency which implements this contracts to your Scarb.toml. See more about [compiling external contracts](https://docs.swmansion.com/scarb/docs/extensions/starknet/contract-target.html#compiling-external-contracts) in Scarb documentation. ```toml [[target.starknet-contract]] @@ -182,6 +213,7 @@ build-external-contracts = ["openzeppelin::account::account::Account"] ``` #### Example of configuration which allows to use external contracts in tests + ```toml # ... [dependencies] @@ -194,6 +226,7 @@ build-external-contracts = ["openzeppelin::account::account::Account"] ``` #### Complete example of `Scarb.toml` + ```toml [package] name = "example_package" From 7541a84f946e7bc04d64875c138cff202f5b81e1 Mon Sep 17 00:00:00 2001 From: Emmanuel A Akalo <124416278+NueloSE@users.noreply.github.com> Date: Mon, 28 Oct 2024 15:17:43 +0100 Subject: [PATCH 4/5] Update docs/src/appendix/scarb-toml.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Artur MichaƂek <52135326+cptartur@users.noreply.github.com> --- docs/src/appendix/scarb-toml.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/appendix/scarb-toml.md b/docs/src/appendix/scarb-toml.md index dd1fd3fa31..1120110170 100644 --- a/docs/src/appendix/scarb-toml.md +++ b/docs/src/appendix/scarb-toml.md @@ -195,7 +195,7 @@ sierra = true #### `casm` -Enabling [`casm = true`](https://github.com/foundry-rs/starknet-foundry/releases/tag/v0.23.0) in Scarb.toml causes unnecessary overhead and should be disabled unless required by other tools. Tools like `snforge` and `sncast` recompile Sierra to CASM separately, resulting in redundant processing. This duplicates CASM generation, significantly impacting performance, especially for large Sierra programs. +Enabling [`casm = true`](https://github.com/foundry-rs/starknet-foundry/releases/tag/v0.23.0) in Scarb.toml causes unnecessary overhead and should be disabled unless required by other tools. Starknet Foundry compiles Sierra to CASM separately, resulting in redundant processing. This duplicates CASM generation, significantly impacting performance, especially for large Sierra programs. See more about [CASM contract class generation](https://docs.swmansion.com/scarb/docs/extensions/starknet/contract-target.html#casm-contract-class-generation) in Scarb documentation. ```toml From 31cd23920912baf9ba3b1301e7a212728de310e5 Mon Sep 17 00:00:00 2001 From: Nuelo Date: Tue, 29 Oct 2024 17:13:10 +0100 Subject: [PATCH 5/5] chore: format docs --- docs/src/appendix/scarb-toml.md | 40 ++++----------------------------- 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/docs/src/appendix/scarb-toml.md b/docs/src/appendix/scarb-toml.md index 1120110170..d2976494f2 100644 --- a/docs/src/appendix/scarb-toml.md +++ b/docs/src/appendix/scarb-toml.md @@ -5,16 +5,13 @@ The `Scarb.toml` contains the package manifest that is needed in package compila ## `Scarb.toml` Contents ### `[tool.snforge]` - ```toml [tool.snforge] # ... ``` - Allows to configure `snforge` settings. All fields are optional. #### `exit_first` - The `exit_first` fields specifies whether to stop tests execution immediately upon the first failure. See more about [stopping test execution after first failed test](https://foundry-rs.github.io/starknet-foundry/testing/running-tests.html#stopping-test-execution-after-first-failed-test). ```toml @@ -23,11 +20,9 @@ exit_first = true ``` #### `fuzzer_runs` - -The `fuzzer_runs` field specifies the number of runs of the random fuzzer. +The `fuzzer_runs` field specifies the number of runs of the random fuzzer. #### `fuzzer_seed` - The `fuzzer_seed` field specifies the seed for the random fuzzer. See more about [fuzzer](https://foundry-rs.github.io/starknet-foundry/testing/test-attributes.html#fuzzer). @@ -41,34 +36,27 @@ fuzzer_seed = 1111 ``` ### `[[tool.snforge.fork]]` - ```toml [[tool.snforge.fork]] # ... ``` - Allows to configure forked tests. If defined, all fields outlined below must also be defined. See more about [fork testing](https://foundry-rs.github.io/starknet-foundry/testing/test-attributes.html#fork). #### `name` - The `name` field specifies the name of the fork. - ```toml [[tool.snforge.fork]] name = "SOME_NAME" ``` #### `url` - The `url` field specifies the address of RPC provider. - ```toml [[tool.snforge.fork]] url = "http://your.rpc.url" ``` #### `block_id.` - The `block_id` field specifies the block to fork from. It can be specified by `tag`, `number` or `hash`. ```toml @@ -91,7 +79,6 @@ block_id.number = "123" ``` ### `[profile..cairo]` - By default, these arguments do not need to be defined. Only set them to use [profiler](https://foundry-rs.github.io/starknet-foundry/snforge-advanced-features/profiling.html#profiling) or [coverage](https://foundry-rs.github.io/starknet-foundry/testing/coverage.html#coverage). Adjust Cairo compiler configuration parameters when compiling this package. These options are not taken into consideration when this package is used as a dependency for another package. All fields are optional. @@ -102,7 +89,6 @@ Adjust Cairo compiler configuration parameters when compiling this package. Thes ``` #### `unstable-add-statements-code-locations-debug-info` - See [`unstable-add-statements-code-locations-debug-info`](https://docs.swmansion.com/scarb/docs/reference/manifest.html#unstable-add-statements-code-locations-debug-info) in Scarb documentation. ```toml @@ -111,25 +97,20 @@ unstable-add-statements-code-locations-debug-info = true ``` #### `unstable-add-statements-functions-debug-info` - See [`unstable-add-statements-functions-debug-info`](https://docs.swmansion.com/scarb/docs/reference/manifest.html#unstable-add-statements-functions-debug-info) in Scarb documentation. - ```toml [profile.dev.cairo] unstable-add-statements-functions-debug-info = true ``` #### `inlining-strategy` - See [`inlining-strategy`](https://docs.swmansion.com/scarb/docs/reference/manifest.html#inlining-strategy) in Scarb documentation. - ```toml [profile.dev.cairo] inlining-strategy = "avoid" ``` #### Example of configuration which allows [coverage](https://foundry-rs.github.io/starknet-foundry/testing/coverage.html) report generation - ```toml [profile.dev.cairo] unstable-add-statements-code-locations-debug-info = true @@ -138,28 +119,22 @@ inlining-strategy = "avoid" ``` ### `[features]` - A package defines a set of named features in the `[features]` section of `Scarb.toml` file. Each defined feature can list other features that should be enabled with it. All fields are optional. - ```toml [features] # ... ``` #### `` - The `` field specifies the name of the feature and list of other features that should be enabled with it. See [features](https://docs.swmansion.com/scarb/docs/reference/conditional-compilation.html#features) in Scarb documentation. - ```toml [features] enable_for_tests = [] ``` #### Example of `Scarb.toml` allowing conditional contracts compilation - Firstly, define a contract in the src directory with a `#[cfg(feature: '')]` attribute: - ```rust #[starknet::contract] #[cfg(feature: 'enable_for_tests')] @@ -169,14 +144,12 @@ mod MockContract { ``` Then update Scarb.toml so it includes the following lines: - ```toml [features] enable_for_tests = [] ``` ### `[[target.starknet-contract]]` - The `starknet-contract` target allows to build the package as a Starknet Contract. See more about [Starknet Contract Target](https://docs.swmansion.com/scarb/docs/extensions/starknet/contract-target.html#starknet-contract-target) in Scarb documentation. ```toml @@ -185,9 +158,7 @@ The `starknet-contract` target allows to build the package as a Starknet Contrac ``` #### `sierra` - See more about [Sierra contract class generation](https://docs.swmansion.com/scarb/docs/extensions/starknet/contract-target.html#sierra-contract-class-generation) in Scarb documentation. - ```toml [[target.starknet-contract]] sierra = true @@ -195,8 +166,8 @@ sierra = true #### `casm` -Enabling [`casm = true`](https://github.com/foundry-rs/starknet-foundry/releases/tag/v0.23.0) in Scarb.toml causes unnecessary overhead and should be disabled unless required by other tools. Starknet Foundry compiles Sierra to CASM separately, resulting in redundant processing. This duplicates CASM generation, significantly impacting performance, especially for large Sierra programs. -See more about [CASM contract class generation](https://docs.swmansion.com/scarb/docs/extensions/starknet/contract-target.html#casm-contract-class-generation) in Scarb documentation. +Enabling `casm = true` in Scarb.toml causes unnecessary overhead and should be disabled unless required by other tools. Tools like `snforge` and `sncast` recompile Sierra to CASM separately, resulting in redundant processing. This duplicates CASM generation, significantly impacting performance, especially for large Sierra programs. See more about [CASM contract class generation](https://docs.swmansion.com/scarb/docs/extensions/starknet/contract-target.html#casm-contract-class-generation) in Scarb documentation. + ```toml [[target.starknet-contract]] @@ -204,8 +175,7 @@ casm = true ``` #### `build-external-contracts` - -The `build-external-contracts` allows to use contracts from your dependencies inside your tests. It accepts a list of strings, each of which is a reference to a contract defined in a dependency. You need to add dependency which implements this contracts to your Scarb.toml. See more about [compiling external contracts](https://docs.swmansion.com/scarb/docs/extensions/starknet/contract-target.html#compiling-external-contracts) in Scarb documentation. +The `build-external-contracts` allows to use contracts from your dependencies inside your tests. It accepts a list of strings, each of which is a reference to a contract defined in a dependency. You need to add dependency which implements this contracts to your Scarb.toml. See more about [compiling external contracts](https://docs.swmansion.com/scarb/docs/extensions/starknet/contract-target.html#compiling-external-contracts) in Scarb documentation. ```toml [[target.starknet-contract]] @@ -213,7 +183,6 @@ build-external-contracts = ["openzeppelin::account::account::Account"] ``` #### Example of configuration which allows to use external contracts in tests - ```toml # ... [dependencies] @@ -226,7 +195,6 @@ build-external-contracts = ["openzeppelin::account::account::Account"] ``` #### Complete example of `Scarb.toml` - ```toml [package] name = "example_package"