Cairo-lang

Latest version: v0.13.3

Safety actively analyzes 688792 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 7 of 11

0.10.1pre

**StarkNet**:
* Add `DeployAccount` transaction (which will replace the `Deploy` transaction for deploying account contracts). To use it, you should first add enough funds to your account address to pay the transaction fee, and then you can invoke `DeployAccount`
* Split the `starknet deploy_account` CLI command into `starknet new_account` and `starknet deploy_account`
* Account contracts that are expected to be deployed this way should implement the `__validate_deploy__()` entry point, which should check the signature of the `DeployAccount` transaction
* Improve L1 fee computation: the fee is computed according to the diff of the storage state
* API: Remove `entry_point_type` field from transaction information

**Cairo**:
* Add `uint256_mul_div_mod` to `uint256.cairo`

0.10.0

**StarkNet**:
* Contract (*breaking changes*):
* `external` and `view` functions should be imported directly by the main compiled file. Otherwise, they will not be usable as external functions
* Forbid using the same storage variable name in two modules
* New transaction version (version 1) for `invoke` and `declare` transactions:
* Transactions of version 0 are deprecated and will not be supported in StarkNet from the next version (v0.11.0). **Please update your systems to use the new version**
* Note that to use transactions of version 1 you will need to upgrade your account contracts
* Add `nonce` field to the transactions. Nonce validation is now part of the StarkNet protocol and is enforced to be executed sequentially
* Invoke:
* Split `__execute__` to two functions: `__validate__` (only validates the transaction) and `__execute__` (only executes the transaction)
* Remove the `selector` (which is now always `__execute__`) field, following the above change.
* Declare:
* `declare` transaction should now be sent from an account (and is validated using `__validate_declare__` in the account contract)
* Support fee for sending L1 messages. At this point, it's not mandatory and messages with no fee will still be handled. Starting from the next version it will become mandatory.
* Add a fee field to `LogMessageToL2` event in the L1 Core Contract
* New API and StarkNet CLI commands:
* `get_nonce` - Returns the next expected nonce of an account contract (see [here](https://www.starknet.io/docs/0.10.0/hello_starknet/cli.html#get-nonce))
* `simulate_transaction` - Simulates the transaction and returns the transaction trace and estimated fee (see [here](https://www.starknet.io/docs/0.10.0/hello_starknet/cli.html#simulate-transaction))
* `estimate_message_fee` - Estimates the message fee (see [here](https://www.starknet.io/docs/0.10.0/hello_starknet/l1l2.html#estimate-message-fee))
* API changes
* New fields in transaction trace: `validate_invocation` and `fee_transfer_invocation`.
* `get_block` and `get_transaction`:
* Add `nonce` and `version` fields to invoke transactions
* Add L1 handler type
* Onchain data:
* Remove the contract constructor arguments
* Add the new nonce
* See [here](https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/core/os/state.cairo)
* Support the `EC-op` builtin. This allows doing arbitrary elliptic curve operations on the STARK-friendly curve. In particular, it is now possible to verify that an ECDSA signature *fails*
* Add the solidity code of the StarkNet Core Contract to the repo
* Refactor StarkNet code to use an abstract class called `State`, which provides a cleaner definition of the StarkNet state interface.

**Cairo**:
* Syntax changes in Cairo (to make it more similar to rust and C++):
* **You can use the `cairo-migrate` script to convert old code to the new syntax**. Use the `-i` flag to apply the changes to the files
* End statements with `;`
* Note that new lines are still part of the language at this point, and you cannot put more than one instruction per line. This will change in Cairo1.0.
* Use `{ … }` for code blocks (instead of `:` and `end`)
* Add `()` around the condition of `if` statements
* Remove the `member` keyword in structs
* Change comment to use `//` instead of ``
* Use `..., ap++` instead of `...; ap++` in low level Cairo code
* Support return types that are not tuples. For example, `func foo() -> felt` (instead of `func foo() -> (r: felt)`)
* As a result, it's now mandatory to specify return types. `func foo() -> (res)` should be replaced by `func foo() -> (res: felt)`. The `cairo-migrate` tool does that automatically.
* Return statement accepts expressions, rather than only tuples. For example, you can write `let x = (5,); return x;`
* A few standard library functions were changed to return `felt`. The `cairo-migrate` script also fixes calls to those functions
* Support using functions as expressions
* This only applies to functions with `-> felt` signature, whose `ap` change is known at compile-time (e.g., recursive functions cannot be used this way)
* Bug fixes:
* Fix a bug in `uint256_unsigned_div_rem` which allowed a malicious prover to return a wrong result. Contracts using this function or any other function which uses it (`uint256_signed_div_rem` or `uint256_shr` for the standard library) should be recompiled & redeployed with version >= 0.10.0.
* Fix a bug in the secp signature verification code that allowed a malicious prover to ignore the value of `v` (this does not let the prover fake a signature, but allows it to claim that a valid signature is invalid).

* Add Cairo code for the recursive STARK verifier

Technical changes:
* Move from `python3.7` to `python3.9`

0.10.0pre

**StarkNet**:
* Contract (*breaking changes*):
* `external` and `view` functions should be imported directly by the main compiled file. Otherwise, they will not be usable as external functions
* Forbid using the same storage variable name in two modules
* New transaction version (version 1) for `invoke` and `declare` transactions:
* Transactions of version 0 are deprecated and will not be supported in StarkNet from the next version (v0.11.0). **Please update your systems to use the new version**
* Note that to use transactions of version 1 you will need to upgrade your account contracts
* Add `nonce` field to the transactions. Nonce validation is now part of the StarkNet protocol and is enforced to be executed sequentially
* Invoke:
* Split `__execute__` to two functions: `__validate__` (only validates the transaction) and `__execute__` (only executes the transaction)
* Remove the `selector` (which is now always `__execute__`) field, following the above change.
* Declare:
* `declare` transaction should now be sent from an account (and is validated using `__validate_declare__` in the account contract)
* Support fee for sending L1 messages. At this point, it's not mandatory and messages with no fee will still be handled. Starting from the next version it will become mandatory.
* Add a fee field to `LogMessageToL2` event in the L1 Core Contract
* New API and StarkNet CLI commands:
* `get_nonce` - Returns the next expected nonce of an account contract (see [here](https://www.starknet.io/docs/0.10.0/hello_starknet/cli.html#get-nonce))
* `simulate_transaction` - Simulates the transaction and returns the transaction trace and estimated fee (see [here](https://www.starknet.io/docs/0.10.0/hello_starknet/cli.html#simulate-transaction))
* `estimate_message_fee` - Estimates the message fee (see [here](https://www.starknet.io/docs/0.10.0/hello_starknet/l1l2.html#estimate-message-fee))
* API changes
* New fields in transaction trace: `validate_invocation` and `fee_transfer_invocation`.
* `get_block` and `get_transaction`:
* Add `nonce` and `version` fields to invoke transactions
* Add L1 handler type
* Onchain data:
* Remove the contract constructor arguments
* Add the new nonce
* See [here](https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/core/os/state.cairo)
* Support the `EC-op` builtin. This allows doing arbitrary elliptic curve operations on the STARK-friendly curve. In particular, it is now possible to verify that an ECDSA signature *fails*
* Add the solidity code of the StarkNet Core Contract to the repo
* Refactor StarkNet code to use an abstract class called `State`, which provides a cleaner definition of the StarkNet state interface.

**Cairo**:
* Syntax changes in Cairo (to make it more similar to rust and C++):
* **You can use the `cairo-migrate` script to convert old code to the new syntax**. Use the `-i` flag to apply the changes to the files
* End statements with `;`
* Note that new lines are still part of the language at this point, and you cannot put more than one instruction per line. This will change in Cairo1.0.
* Use `{ … }` for code blocks (instead of `:` and `end`)
* Add `()` around the condition of `if` statements
* Remove the `member` keyword in structs
* Change comment to use `//` instead of ``
* Use `..., ap++` instead of `...; ap++` in low level Cairo code
* Support return types that are not tuples. For example, `func foo() -> felt` (instead of `func foo() -> (r: felt)`)
* As a result, it's now mandatory to specify return types. `func foo() -> (res)` should be replaced by `func foo() -> (res: felt)`. The `cairo-migrate` tool does that automatically.
* Return statement accepts expressions, rather than only tuples. For example, you can write `let x = (5,); return x;`
* A few standard library functions were changed to return `felt`. The `cairo-migrate` script also fixes calls to those functions
* Support using functions as expressions
* This only applies to functions with `-> felt` signature, whose `ap` change is known at compile-time (e.g., recursive functions cannot be used this way)
* Fix a bug in the secp signature verification code that allowed a malicious prover to ignore the value of `v` (this does not let the prover fake a signature, but allows it to claim that a valid signature is invalid).
* Add Cairo code for the recursive STARK verifier

Technical changes:
* Move from `python3.7` to `python3.9`

0.9.1

Not secure
**StarkNet**:
* API changes:
* Add `get_block_traces` API - returns all the transaction traces of a given block
* Add a list of declared contracts in `get_state_update`
* Add a `0x` prefix for class hash in the API
* Add `starknet_version` field for blocks (only applies to new blocks)
* StarkNet CLI:
* Change the default block number to `pending`
* Using a wallet is the default, `--no_wallet` must be specified explicitly to override this
* Deploying contracts:
* Add `deploy_contract` function to the account contract created by `starknet deploy_account`
* Use this function to deploy contract (unless using `--no_wallet`). In particular, deploy should be used after *declaring* the contract (it expects the contract class hash)
* Support `--dry_run` to get the transaction information without signing or sending it
* Support `deploy_from_zero` in the deploy syscall to deploy a contract to an address that does not depend on the deployer

**Cairo**:
* Support `and` in `if` statements (`if x == y and z == w`). Note that at the moment other boolean combinations are not supported

0.9.0

Not secure
**StarkNet:**
* Enforce fees - `max_fee` must not be set to zero, and `selector` must be `__execute__`
* Split the concepts of contract class and contract instance. See [here](https://starknet.io/docs/hello_starknet/intro.html#declare-the-contract-on-the-starknet-testnet)
* Add declare transaction type
* New API and CLI commands:
* `declare` - Declares a contract class
* `get_class_by_hash` - Returns the contract class given its hash
* `get_class_hash_at` - Returns the class hash for a given contract instance address
* Rename `delegate_call` to `library_call`, and change the contract address argument to class hash. See [here](https://starknet.io/docs/hello_starknet/calling_contracts.html#library-calls)
* Add a deploy system call. See [here](https://starknet.io/docs/hello_starknet/deploying_from_contracts.html)
* Rename `ContractDefinition` to `ContractClass`
* Reduce the compiled contract file's size by removing unnecessary identifiers (this optimization can be disabled using `--dont_filter_identifiers`)

**Cairo:**
* Initial support for the "EC-op" builtin (scalar multiplication over the STARK curve). Not supported in StarkNet yet.
* Add additional helper methods to `blake2s.cairo`, including big-endian support
* Technical changes:
* Change function's return type from a struct to a named tuple. In particular, `foo.Return.SIZE` is no longer supported.

0.8.2

Not secure
**StarkNet**:

* Performance improvements in the `get_block` and `get_state_update` APIs
* Fix a bug in the block hash response of `get_block`
* Add `gas_price` and `sequencer_address` fields to block info
* Add an option to explicitly pass `latest` in the `blockNumber` argument (you can pass `latest` or `pending` in addition to a block number).

**Cairo**:

* New library functions:
* keccak hash function - Cairo implementation
* secp256k1 ECDSA (Ethereum compatible signature verification) - Cairo implementation
* Auto-formatting of multiline tuple types

Page 7 of 11

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.