Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Update Cairo lang versions to 2.5.3 (#1217)
Browse files Browse the repository at this point in the history
* Update cairo-vm commit and cairo-lang- versions to 2.5.3

* fix build errors

* Update Cargo.lock

* Update cairo-lang version in Makefile

* Fix cairo programs

* Fix bench contracts

* Update cairo-native, cairo-vm and blockifier commits

* Replace biguint_to_felt

* Update starknet-api version

* Restore cairo 2 compiler version

* Restore Makefile

* Fix native keccak syscall

* cargo fmt

* Fix nextest version

* Fix merge conflicts

* Fix imports

* bump cairo-vm and cairo_native commits

* Update cairo_native commit

---------

Co-authored-by: Pedro Fontana <[email protected]>
  • Loading branch information
pefontana and Pedro Fontana authored Feb 15, 2024
1 parent 2e7bcc1 commit e7bfee9
Show file tree
Hide file tree
Showing 16 changed files with 366 additions and 216 deletions.
451 changes: 305 additions & 146 deletions Cargo.lock

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ members = [
]

[workspace.dependencies]
cairo-lang-casm = "=2.4.2"
cairo-lang-sierra = "=2.4.2"
cairo-lang-starknet = "=2.4.2"
cairo-lang-utils = "=2.4.2"
cairo-vm = { git = "https://github.com/lambdaclass/cairo-vm", rev = "7af00641014f295d820cbc6417714d6470823440", features = ["cairo-1-hints"] }
cairo-lang-casm = "=2.5.3"
cairo-lang-sierra = "=2.5.3"
cairo-lang-starknet = "=2.5.3"
cairo-lang-utils = "=2.5.3"
cairo-vm = { git = "https://github.com/lambdaclass/cairo-vm", rev = "1f98feff566dd2da016e439f5e8db912c6e39872", features = ["cairo-1-hints"] }
num-traits = "0.2.15"
starknet = "0.5.0"
starknet_api = "0.6.0"
starknet_api = {version = "0.7.0-dev.0"}
thiserror = "1.0.32"

[dependencies]
Expand All @@ -40,7 +40,7 @@ cairo-lang-casm = { workspace = true }
cairo-lang-sierra = { workspace = true }
cairo-lang-starknet = { workspace = true }
cairo-lang-utils = { workspace = true }
cairo-native = { git = "https://github.com/lambdaclass/cairo_native", rev = "66d16af0db37ba6769d4576a49e12a40af14f565", optional = true }
cairo-native = { git = "https://github.com/lambdaclass/cairo_native", rev = "96ea3a37180a194ba14c3b21788b09e76bb634fd", optional = true }
k256 = "0.13.3"
p256 = "0.13.2"
sec1 = "0.7.3"
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ deps: check-python-version build-cairo-2-compiler build-cairo-1-compiler
-pyenv && pyenv install -s 3.9.15
python3.9 -m venv starknet-venv
. starknet-venv/bin/activate && $(MAKE) deps-venv
cargo install cargo-nextest --version 0.9.49
cargo install --version 0.9.49 cargo-nextest --locked

deps-macos: check-python-version build-cairo-2-compiler-macos build-cairo-1-compiler-macos
cargo install flamegraph --version 0.6.2
Expand All @@ -175,7 +175,7 @@ deps-macos: check-python-version build-cairo-2-compiler-macos build-cairo-1-comp
-pyenv install -s 3.9.15
python3.9 -m venv starknet-venv
. starknet-venv/bin/activate && $(MAKE) deps-venv
cargo install cargo-nextest
cargo install --version 0.9.49 cargo-nextest --locked

clean:
-rm -rf starknet-venv/
Expand Down
6 changes: 3 additions & 3 deletions rpc_state_reader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ serde_json = { version = "1.0", features = [
"arbitrary_precision",
"raw_value",
] }
starknet_api = "0.6.0"
starknet_api = "0.7.0-dev.0"
cairo-lang-starknet = { workspace = true }
cairo-lang-utils = { workspace = true }
starknet = { workspace = true }
Expand All @@ -24,8 +24,8 @@ flate2 = "1.0.25"
serde_with = "3.0.0"
dotenv = "0.15.0"
cairo-vm = { workspace = true }
cairo-vm-blockifier = { package = "cairo-vm", version = "0.8.2" }
blockifier = "=0.4.0"
cairo-vm-blockifier = { package = "cairo-vm", version = "0.9.1" }
blockifier = "=0.5.0-dev.0"
starknet_in_rust = { path = "../", version = "0.4.0" }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion rpc_state_reader/tests/blockifier_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub struct RpcStateReader(RpcState);
impl StateReader for RpcStateReader {
fn get_storage_at(
&mut self,
contract_address: ContractAddress,
contract_address: starknet_api::core::ContractAddress,
key: StorageKey,
) -> StateResult<StarkFelt> {
Ok(self.0.get_storage_at(&contract_address, &key))
Expand Down
5 changes: 2 additions & 3 deletions src/bin/native_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use cairo_native::cache::AotProgramCache;
use cairo_native::cache::JitProgramCache;
use cairo_native::cache::ProgramCache;
use cairo_native::context::NativeContext;
use cairo_vm::utils::biguint_to_felt;
use cairo_vm::Felt252;
use lazy_static::lazy_static;
use starknet_in_rust::definitions::block_context::BlockContext;
Expand Down Expand Up @@ -349,7 +348,7 @@ fn bench_erc20(executions: usize, bench_type: BenchType) {
let exec_entry_point = ExecutionEntryPoint::new(
DEPLOYER_ADDRESS.clone(),
ERC20_DEPLOYER_CALLDATA.to_vec(),
biguint_to_felt(deploy_entrypoint_selector).unwrap(),
Felt252::from(deploy_entrypoint_selector),
ERC20_DEPLOYMENT_CALLER_ADDRESS.clone(),
EntryPointType::External,
Some(CallType::Delegate),
Expand Down Expand Up @@ -430,7 +429,7 @@ fn bench_erc20(executions: usize, bench_type: BenchType) {
let exec_entry_point = ExecutionEntryPoint::new(
DEPLOYER_ADDRESS.clone(),
ERC20_DEPLOYER_CALLDATA.to_vec(),
biguint_to_felt(deploy_entrypoint_selector).unwrap(),
Felt252::from(deploy_entrypoint_selector),
ERC20_DEPLOYMENT_CALLER_ADDRESS.clone(),
EntryPointType::External,
Some(CallType::Delegate),
Expand Down
5 changes: 2 additions & 3 deletions src/execution/execution_entry_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use cairo_vm::{
program::Program,
relocatable::{MaybeRelocatable, Relocatable},
},
utils::felt_to_biguint,
vm::{
errors::runner_errors::RunnerError,
runners::cairo_runner::{CairoArg, CairoRunner, ExecutionResources, RunResources},
Expand Down Expand Up @@ -290,11 +289,11 @@ impl ExecutionEntryPoint {
let entry_point = entry_points
.iter()
.filter(|x| {
if x.selector == felt_to_biguint(*DEFAULT_ENTRY_POINT_SELECTOR) {
if x.selector == DEFAULT_ENTRY_POINT_SELECTOR.to_biguint() {
default_entry_point = Some(*x);
}

x.selector == felt_to_biguint(self.entry_point_selector)
x.selector == self.entry_point_selector.to_biguint()
})
.try_fold(None, |acc, x| match acc {
None => Ok(Some(x)),
Expand Down
8 changes: 3 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ mod test {
casm_contract_class::CasmContractClass,
contract_class::ContractClass as SierraContractClass,
};
use cairo_vm::{utils::biguint_to_felt, Felt252};
use cairo_vm::Felt252;
use lazy_static::lazy_static;

use pretty_assertions_sorted::assert_eq;
Expand Down Expand Up @@ -353,8 +353,7 @@ mod test {

let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap();
let entrypoints = contract_class.clone().entry_points_by_type;
let entrypoint_selector =
biguint_to_felt(&entrypoints.external.get(0).unwrap().selector).unwrap();
let entrypoint_selector = Felt252::from(&entrypoints.external.get(0).unwrap().selector);

let contract_class_cache = PermanentContractClassCache::default();

Expand Down Expand Up @@ -461,8 +460,7 @@ mod test {
let program_data = include_bytes!("../starknet_programs/cairo1/fibonacci.casm");
let contract_class: CasmContractClass = serde_json::from_slice(program_data).unwrap();
let entrypoints = contract_class.clone().entry_points_by_type;
let entrypoint_selector =
biguint_to_felt(&entrypoints.external.get(0).unwrap().selector).unwrap();
let entrypoint_selector = Felt252::from(&entrypoints.external.get(0).unwrap().selector);

let contract_class_cache = PermanentContractClassCache::default();

Expand Down
2 changes: 1 addition & 1 deletion src/syscalls/native_syscall_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl<'a, 'cache, S: StateReader, C: ContractClassCache> StarkNetSyscallHandler
&mut self,
block_number: u64,
gas: &mut u128,
) -> SyscallResult<cairo_vm::Felt252> {
) -> Result<Felt252, Vec<Felt252>> {
tracing::debug!("Called `get_block_hash({block_number})` from Cairo Native");
self.handle_syscall_request(gas, "get_block_hash")?;

Expand Down
3 changes: 1 addition & 2 deletions src/syscalls/syscall_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use cairo_lang_casm::{
hints::{Hint, StarknetHint},
operand::{CellRef, DerefOrImmediate, Register, ResOperand},
};
use cairo_vm::utils::bigint_to_felt;
use cairo_vm::vm::runners::cairo_runner::{ResourceTracker, RunResources};
use cairo_vm::{
hint_processor::{
Expand Down Expand Up @@ -164,7 +163,7 @@ fn extract_buffer(buffer: &ResOperand) -> Result<(&CellRef, Felt252), HintError>
if let DerefOrImmediate::Immediate(val) = &bin_op.b {
// TODO
// Remove this unwrap()
(&bin_op.a, bigint_to_felt(&val.value).unwrap())
(&bin_op.a, Felt252::from(&val.value))
} else {
return Err(HintError::CustomHint("Failed to extract buffer, expected ResOperand of BinOp type to have Inmediate b value".to_owned().into_boxed_str()));
}
Expand Down
4 changes: 2 additions & 2 deletions tests/account_panic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::Arc;

use cairo_vm::{utils::biguint_to_felt, Felt252};
use cairo_vm::Felt252;
use starknet_in_rust::{
core::contract_address::compute_casm_class_hash,
definitions::{block_context::BlockContext, constants::TRANSACTION_VERSION},
Expand Down Expand Up @@ -91,7 +91,7 @@ fn account_panic() {
let calldata: Vec<_> = [
1.into(),
contract_class_hash_felt,
biguint_to_felt(selector_contract).unwrap(),
Felt252::from(selector_contract),
1.into(),
2.into(),
]
Expand Down
Loading

0 comments on commit e7bfee9

Please sign in to comment.