Skip to content

Commit 67ab7c2

Browse files
authored
feat: bump Starknet version to 0.13.4 (#169)
Starknet version ties heavily to the minimum Cairo version the network supports - deploying a Cairo contract that was compiled with unsupported compiler version may result in an error. Assuming that Dojo wants to use Cairo compiler version >=2.10, Katana should at least be using Starknet version **0.13.4** as Cairo 2.10 introduces new changes that are only supported starting from **0.13.4**. We maintain the default Starknet version used in the genesis block - this is to ensure we change the computed genesis block hash. --- The issue for this particular case, currently Katana is failing with a `Syscall gas cost must be greater than base syscall gas cost` error when executing a contract that uses the `get_class_hash_at_syscall`. The syscall was first introduced in Cairo **2.10.0**, and thus requires at least Starknet **0.13.4** as mentioned in the [release notes](https://community.starknet.io/t/cairo-v2-10-0-is-out/115362).
1 parent fe6a223 commit 67ab7c2

5 files changed

Lines changed: 19 additions & 8 deletions

File tree

crates/chain-spec/src/dev.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use katana_primitives::genesis::constant::{
1717
use katana_primitives::genesis::Genesis;
1818
use katana_primitives::state::StateUpdatesWithClasses;
1919
use katana_primitives::utils::split_u256;
20-
use katana_primitives::version::CURRENT_STARKNET_VERSION;
20+
use katana_primitives::version::StarknetVersion;
2121
use katana_primitives::Felt;
2222
use lazy_static::lazy_static;
2323
use serde::{Deserialize, Serialize};
@@ -47,7 +47,6 @@ pub struct ChainSpec {
4747
impl ChainSpec {
4848
pub fn block(&self) -> ExecutableBlock {
4949
let header = PartialHeader {
50-
starknet_version: CURRENT_STARKNET_VERSION,
5150
number: self.genesis.number,
5251
timestamp: self.genesis.timestamp,
5352
parent_hash: self.genesis.parent_hash,
@@ -56,6 +55,8 @@ impl ChainSpec {
5655
l2_gas_prices: GasPrices::MIN,
5756
l1_data_gas_prices: self.genesis.gas_prices.clone(),
5857
sequencer_address: self.genesis.sequencer_address,
58+
// keep at 0.13.1.1 for backward compatibility reason
59+
starknet_version: StarknetVersion::new([0, 13, 1, 1]),
5960
};
6061

6162
ExecutableBlock { header, body: Vec::new() }
@@ -270,7 +271,6 @@ mod tests {
270271
DEFAULT_LEGACY_ERC20_CLASS, DEFAULT_LEGACY_ERC20_COMPILED_CLASS_HASH,
271272
DEFAULT_LEGACY_UDC_CLASS, DEFAULT_LEGACY_UDC_COMPILED_CLASS_HASH,
272273
};
273-
use katana_primitives::version::CURRENT_STARKNET_VERSION;
274274
use starknet::macros::felt;
275275

276276
use super::*;
@@ -356,7 +356,7 @@ mod tests {
356356
l1_gas_prices: chain_spec.genesis.gas_prices.clone(),
357357
l1_data_gas_prices: chain_spec.genesis.gas_prices.clone(),
358358
l1_da_mode: L1DataAvailabilityMode::Calldata,
359-
starknet_version: CURRENT_STARKNET_VERSION,
359+
starknet_version: StarknetVersion::new([0, 13, 1, 1]),
360360
},
361361
body: Vec::new(),
362362
};

crates/core/src/backend/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl<EF: ExecutorFactory> Backend<EF> {
117117
parent_hash,
118118
number: block_env.number,
119119
timestamp: block_env.timestamp,
120-
starknet_version: CURRENT_STARKNET_VERSION,
120+
starknet_version: block_env.starknet_version,
121121
l1_da_mode: L1DataAvailabilityMode::Calldata,
122122
sequencer_address: block_env.sequencer_address,
123123
l2_gas_prices: block_env.l2_gas_prices.clone(),
@@ -181,6 +181,7 @@ impl<EF: ExecutorFactory> Backend<EF> {
181181

182182
block_env.number += 1;
183183
block_env.timestamp = timestamp;
184+
block_env.starknet_version = CURRENT_STARKNET_VERSION;
184185

185186
// update the gas prices
186187
self.update_block_gas_prices(block_env);

crates/core/src/service/block_producer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use katana_primitives::da::L1DataAvailabilityMode;
2525
use katana_primitives::execution::TransactionExecutionInfo;
2626
use katana_primitives::receipt::Receipt;
2727
use katana_primitives::transaction::{ExecutableTxWithHash, TxHash, TxWithHash};
28-
use katana_primitives::version::CURRENT_STARKNET_VERSION;
2928
use katana_provider::error::ProviderError;
3029
use katana_provider::traits::block::{BlockHashProvider, BlockNumberProvider};
3130
use katana_provider::traits::env::BlockEnvProvider;
@@ -626,7 +625,7 @@ impl<EF: ExecutorFactory> InstantBlockProducer<EF> {
626625
parent_hash,
627626
number: block_env.number,
628627
timestamp: block_env.timestamp,
629-
starknet_version: CURRENT_STARKNET_VERSION,
628+
starknet_version: block_env.starknet_version,
630629
sequencer_address: block_env.sequencer_address,
631630
l1_da_mode: L1DataAvailabilityMode::Calldata,
632631
l2_gas_prices: block_env.l2_gas_prices.clone(),

crates/primitives/src/version.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
/// The currently supported version of the Starknet protocol.
2-
pub const CURRENT_STARKNET_VERSION: StarknetVersion = StarknetVersion::new([0, 13, 1, 1]); // version 0.13.1.1
2+
///
3+
/// ## IMPORTANT
4+
///
5+
/// This version must correspond to the minimum Cairo/Sierra version we want to support. Ideally,
6+
/// this version should be synchronized with Dojo's Cairo version.
7+
///
8+
/// As of Cairo v2.10.0, contracts written with that version are only deployable on Starknet
9+
/// >=0.13.4. Check out the [release notes] for more info.
10+
///
11+
/// [release notes]: https://community.starknet.io/t/cairo-v2-10-0-is-out/115362
12+
pub const CURRENT_STARKNET_VERSION: StarknetVersion = StarknetVersion::new([0, 13, 4, 0]);
313

414
/// Starknet protocol version.
515
#[derive(Debug, Copy, Clone, PartialEq, Eq)]

crates/sync/stage/src/blocks.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ mod tests {
273273
use crate::{Stage, StageExecutionInput};
274274

275275
#[tokio::test]
276+
#[ignore = "require external network"]
276277
async fn fetch_blocks() {
277278
let from_block = 308919;
278279
let to_block = from_block + 2;

0 commit comments

Comments
 (0)