Skip to content

Commit

Permalink
Add the only_cairo_vm feature (#33)
Browse files Browse the repository at this point in the history
* Update blockifier version

* Update blockifier version

* Add only_casm feature in state reader

* Add only_cairo_vm feature in replay

* Add doc

---------

Co-authored-by: Pedro Fontana <peter@Pedros-MacBook-Pro.local>
  • Loading branch information
pefontana and Pedro Fontana authored Jul 18, 2024
1 parent 7b60add commit f64a2a6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ resolver = "2"
[workspace.dependencies]
thiserror = "1.0.32"
starknet_api = "=0.12.0-dev.1"
blockifier = { git = "https://github.com/lambdaclass/blockifier", rev = "d458a8d64b6d31da49c447576894ce013af862c2" }
blockifier = { git = "https://github.com/lambdaclass/blockifier", rev = "8eab209eabee1359bec1cc0e9d0a34542a8b65a5" }
tracing = "0.1"
2 changes: 2 additions & 0 deletions replay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ edition = "2021"

[features]
benchmark = []
# The only_cairo_vm feature is designed to avoid executing transitions with cairo_native and instead use cairo_vm exclusively
only_cairo_vm = ["rpc-state-reader/only_casm"]

[dependencies]
# starknet specific crates
Expand Down
5 changes: 5 additions & 0 deletions rpc-state-reader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name = "rpc-state-reader"
version = "0.1.0"
edition = "2021"

[features]
# The only_casm feature compiles all the Sierra fetched contracts to CASM.
# We use this feature to avoid using cairo_native in the Replay crate.
only_casm = []

[dependencies]
ureq = { version = "2.7.1", features = ["json"] }
serde = { version = "1.0", features = ["derive"] }
Expand Down
9 changes: 8 additions & 1 deletion rpc-state-reader/src/blockifier_state_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,14 @@ impl StateReader for RpcStateReader {
sierra_program_debug_info: None,
abi: None,
};
ContractClass::V1Sierra(sierra_cc.try_into().unwrap())

if cfg!(feature = "only_casm") {
let casm_cc =
cairo_lang_starknet_classes::casm_contract_class::CasmContractClass::from_contract_class(sierra_cc, false, usize::MAX).unwrap();
ContractClass::V1(casm_cc.try_into().unwrap())
} else {
ContractClass::V1Sierra(sierra_cc.try_into().unwrap())
}
}
None => {
return Err(StateError::UndeclaredClassHash(
Expand Down

0 comments on commit f64a2a6

Please sign in to comment.