Skip to content

Commit

Permalink
sierra emu
Browse files Browse the repository at this point in the history
  • Loading branch information
edg-l committed Sep 17, 2024
1 parent 92b2fa9 commit dcae0b9
Show file tree
Hide file tree
Showing 7 changed files with 933 additions and 10 deletions.
30 changes: 30 additions & 0 deletions Cargo.lock

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

13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ byteorder = "1.4.3"
bytes = "1"
cached = "0.44.0"
cairo-felt = "0.9.1"
cairo-lang-casm = "2.8.0"
cairo-lang-runner = "2.8.0"
cairo-lang-sierra = "2.8.0"
cairo-lang-sierra-to-casm = "2.7.1"
cairo-lang-starknet-classes = "2.8.0"
cairo-lang-utils = "2.7.1"
cairo-lang-casm = "2.8.2"
cairo-lang-runner = "2.8.2"
cairo-lang-sierra = "2.8.2"
cairo-lang-sierra-to-casm = "2.8.2"
cairo-lang-starknet-classes = "2.8.2"
cairo-lang-utils = "2.8.2"
# This is a temporary dependency, will be removed once the new version of cairo-native is released to main.
cairo-native = { git = "https://github.com/lambdaclass/cairo_native" }
sierra-emu = { git = "https://github.com/lambdaclass/sierra-emu.git" }
cairo-vm = "1.0.1"
camelpaste = "0.1.0"
chrono = "0.4.26"
Expand Down
2 changes: 2 additions & 0 deletions crates/blockifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ workspace = true
concurrency = []
jemalloc = ["dep:tikv-jemallocator"]
testing = ["rand", "rstest"]
use-sierra-emu = []


# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -30,6 +31,7 @@ cairo-lang-sierra.workspace = true
cairo-lang-starknet-classes.workspace = true
cairo-lang-utils.workspace = true
cairo-native.workspace = true
sierra-emu.workspace = true
cairo-vm.workspace = true
derive_more.workspace = true
indexmap.workspace = true
Expand Down
9 changes: 8 additions & 1 deletion crates/blockifier/src/execution/contract_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,15 +644,21 @@ impl NativeContractClassV1 {
}
}

#[derive(Debug)]
pub struct NativeContractClassV1Inner {
pub executor: Arc<AotNativeExecutor>,
entry_points_by_type: NativeContractEntryPoints,
// Storing the raw sierra program and entry points to be able to fallback to the vm
sierra_program_raw: Vec<BigUintAsHex>,
program: cairo_lang_sierra::program::Program, // for sierra emu
fallback_entry_points_by_type: SierraContractEntryPoints,
}

impl std::fmt::Debug for NativeContractClassV1Inner {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "NativeContractClassV1Inner")
}
}

impl NativeContractClassV1Inner {
/// See [NativeContractClassV1::new]
fn new(
Expand Down Expand Up @@ -682,6 +688,7 @@ impl NativeContractClassV1Inner {
&sierra_contract_class.entry_points_by_type,
)?,
sierra_program_raw: sierra_contract_class.sierra_program,
program: sierra_program.clone(),
fallback_entry_points_by_type: sierra_contract_class.entry_points_by_type,
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ pub fn execute_entry_point_call(
tracing::info!("native contract execution started");

let pre_execution_instant = Instant::now();
let result = run_native_executor(&contract_class.executor, function_id, call, syscall_handler);

let result = if cfg!(feature = "use-sierra-emu") {
todo!()
} else {
run_native_executor(&contract_class.executor, function_id, call, syscall_handler)
};
let execution_time = pre_execution_instant.elapsed().as_millis();

tracing::info!(time = execution_time, "native contract execution finished");
Expand Down
Loading

0 comments on commit dcae0b9

Please sign in to comment.