# Starknet v0.13.1 pre-release notes

**URL:** <https://community.starknet.io/t/starknet-v0-13-1-pre-release-notes/113664>\
**Category:** 🆙 Versions Upgrade\
**Created:** [February 29, 2024, 7:13pm UTC](https://community.starknet.io/t/starknet-v0-13-1-pre-release-notes/113664 "2024-02-29T19:13:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ilia](https://dub1.discourse-cdn.com/flex005/user_avatar/community.starknet.io/ilia/32/1318_2.png) [@ilia](https://community.starknet.io/u/ilia)\
**Post date:** [February 29, 2024, 7:13pm UTC](https://community.starknet.io/t/starknet-v0-13-1-pre-release-notes/113664/1 "2024-02-29T19:13:34Z")

</div>

`Sepolia Testnet` – March 5  
`Goerli Testnet` – March 7  
`Mainnet` – March 12

# Conceptual Changes

Starknet v0.13.1 deals mostly with stability and performance improvements. The following items cover the changes feature-wise:

1. Starknet will use EIP4844 and send state diffs as blobs rather than `calldata`. This means that we need to add the notion of `data_gas` to Starknet blocks.

2. Pricing

3. Bytecode segmentation – changing the definition of a compiled class hash so that only the used functions of a contract will be loaded into memory during the proof.

4. Changes in behavior of time-related syscalls when called from `validate`:

# API Changes

## FGW request/response

1. Adding the `l1_da_mode` field to the block header (including the pending block), a string enum that takes the values “CALLDATA” or “BLOB” and indicates the DA solution that is used for this particular block

2. Adding the `l1_data_gas_price` field to the block header (including the pending block).

3. Similarly to the above, the existing fields `eth_l1_gas_price` and `strk_l1_gas_price `will be under a new field `l1_gas_price`.

4. `get_compiled_class_by_class_hash` will return the updated compiled class structure, i.e. including segments data.

5. Transactions + events commitments are added to `get_block` endpoint.

6. Transaction receipt refactor:

The source of truth for the feeder gateway response is [FGW response objects](https://github.com/starkware-libs/cairo-lang/blob/v0.13.1a0/src/starkware/starknet/services/api/feeder_gateway/response_objects.py).

## JSON RPC

**It is completely fine to continue using rpc v0.6.0 to interact with SN 0.13.1.** Responses from 0.13.1 can be mapped naturally into v0.6.0 objects (see the next section).

A new version of the RPC, 0.7.0, will be released to accommodate the changes induced by using EIP4844:

1. Addition of EIP4844 `l1_data_gas_price` field in block header.

2. Addition of the `l1_da_mode` field to the block header. This is an enum that indicates whether this block will use calldata or blobdata and can take the following values:

3. `FEE_ESTIMATE`

4. We are adding data availability resources to the receipts and traces

5. `EXECUTION_RESOURCES`

### Conventions to embed new RPC version in old

Nodes serving RPC 0.6.0 are expected to:

- Ignore the new blob-related fields in the various getBlock requests

- Keep starknet\_estimateFee/starknet\_simulateTransactions unchanged. Fee estimations will continue to assume only calldata is used to send state diffs to L1, hence can be significantly larger than the fee charged in practice.

### FGW response object → RPC response object

1. Map `l1_data_gas_price` FGW response to `l1_data_gas_price` RPC response.

2. Map `l1_gas_price` FGW response to `l1_gas_price` RPC response.

## (SDKs/Wallets) How to use the new fee estimates?

When we communicate with a node serving rpc 0.7.0, the `estimateFee` response is richer, and `gas_consumed` does not account for the resources associated with storage updates (this is encapsulated in `data_gas_consumed`).

In Starknet v0.13.1,v3 transactions don’t send `data_gas` related fields (max price or max amount). This may change in the future, but it means that we need to define how to map `(gas_consumed, gas_price, data_gas_consumed, data_gas_price, overall_fee)` into `max_amount` and `max_price_per_unit` in the `L1_GAS` resource (in the future, we might add fields in the resource mapping of v3 transactions, in which case we’ll have a natural mapping between the fee estimate and the signed transaction fields, but this is not yet the case).

The suggested behavior for SDKs, wallets, or any party sending v3 transactions, is to sign over the following fields:

- `L1_GAS:`

Where `gas_safety_margin` and `fee_safety_margin` are overheads placed by the sdk/wallet to ensure the transaction won’t be rejected due to price fluctuations (the former safety margin isn’t really related to the price, but rather to the potential state changes by the time the tx is processed, leading to a slightly different execution resulting in a minor gas difference). Currently, [starknet.js](https://github.com/starknet-io/starknet.js/blob/65bea53ab03a04fdd4c122ba2fecbb1010100e18/src/utils/stark.ts#L107) sets those numbers to 1.1 and 1.5 correspondingly.

Note that the `data_gas_consumed` field is only used indirectly from the `overall_fee` field. This trick allows us to fold the two cost dimensions (`data_gas` and `gas`) into the single `L1_GAS` resource, which is currently in the v3 transaction `resource_bounds` field.

**⚠Note** : unlike in the old fee estimates, `max_amount` now depends on the ratio `data_gas_price/gas_price` at the time of estimation, and not only on the state of Starknet. Hence, price fluctuations will affect `max_amount` and not only `gas_price`. **Therefore we need a larger safety margin** (larger than today’s 10%).

For transactions of version ≤2, this is a non-issue since we’re signing `max_fee`, which can still be `overall_fee` `×` `fee_safety_margin`.

# Cairo

We will have Cairo v2.6.0 / Sierra v1.5.0 with the following changes:

- The CasmContractClass struct changes and includes [bytecode\_segments\_length](https://github.com/starkware-libs/cairo/blob/c609a8b51233b7cd6348c060e6e6f5079cd6645e/crates/cairo-lang-starknet/src/casm_contract_class.rs#L106)

- New libfuncs are added that require the new compiler

- Hash computation of compiled contract classes changes

The source of truth on the computation of compiled class hashes is in [compiled\_class\_hash.py](https://github.com/starkware-libs/cairo-lang/blob/v0.13.1a0/src/starkware/starknet/core/os/contract_class/compiled_class_hash.py)

# Execution Changes

## Blockifier

- Added `data_gas_price` to block context ([see PR](https://github.com/starkware-libs/blockifier/pull/1336/files)).

- Added `use_kzg_da` bit to the block context ([see PR](https://github.com/starkware-libs/blockifier/pull/1336/files)) - this field will allow getting estimates both old and new fee estimates (note that RPC v0.6.0 should always pass `false` here, otherwise `gas_consumed` will be too low).

- A configuration with parameters that can affect execution will be added to the `BlockContext` struct and be used in `execute`: ([see PR](https://github.com/starkware-libs/blockifier/pull/1348/files))

- Added a `preprocess_block` function that takes a state at the end of block X-1 and returns the block context + state for the beginning of block X (namely, adding the block hash of block X-10 to the state)

# Pricing changes

## Computation

The Cairo step price is reduced by a factor of 2x, and will now cost **0.0025 gas/step**. This also means that the costs of all builtins are halved accordingly.

## Calldata and signatures

Each felt in the `calldata` and `signature` arrays of all transaction types is now priced at **0.128gas/felt**

## Class declaration

Each felt of `sierra_program` in the contract class and of `bytecode` in the compiled contract class is now priced at **28 gas/felt** (note that for v1 declares, we only have `bytecode`).

Additionally, each character in the ABI costs **0.875 gas**

## Events

An additional felt to the `data` array of an event now costs **0.128 gas/felt** (similarly to calldata). An additional felt to the `keys` array now costs **0.256 gas/felt**.

# Action items

## Full nodes

- Release a new version that can sync with SN 0.13.1 before the Testnet upgrade

- Upgrade the compiler and blockifier dependencies (cairo 2.6.0 / blockifier 0.5.0)

- Serve RPC 0.7.0

## API providers

- Upgrade to the new node version before the Testnet upgrade

- Nice to have: offer 0.7.0 endpoints

## SDKs

- Release a version that supports RPC 0.7.0 and properly sign v3 txs in accordance with the above suggestion

## Wallets

- Use the new SDK versions to get more accurate fee estimates, and sign v3 txs in accordance with the above suggestion.

## DApps

- RPC version 0.4.0 will no longer be supported by nodes, dapps are expected to update their SDK and work with rpc version \>= 0.5.0 (preferably, the more update 0.6.0 which is already supported by all SDKs)
