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

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
edg-l committed Jan 26, 2024
1 parent 3adaefe commit 70edcf2
Show file tree
Hide file tree
Showing 49 changed files with 1,914 additions and 220 deletions.
411 changes: 206 additions & 205 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ metrics = []
# Disclaimer: This feature enables state modifications being applied on reverted and failings txs, and also disables address availability check when deploying contracts.
# Only use for benchmarking using the replay binary
replay_benchmark = []
cairo-native = ["dep:ipc-channel", "dep:tracing-appender", "dep:cairo-native", "dep:uuid"]

[workspace]
members = [
Expand Down Expand Up @@ -43,8 +44,10 @@ cairo-lang-runner = { 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 = "5e003699e53003c03b848e3001f1d4ec0d7007ed", optional = true }

cairo-native = { git = "https://github.com/lambdaclass/cairo_native", rev = "a2e6d118af9a54295ef1ca4d693b98e54ffc3b0f", features = ["with-serde"], optional = true }
ipc-channel = { version = "0.18.0", features = ["memfd"], optional = true }
tracing-appender = { version = "0.2.3", optional = true}
uuid = { version = "1.6.1", features = ["serde", "v4"], optional = true }

cairo-vm = { workspace = true }
flate2 = "1.0.25"
Expand All @@ -70,6 +73,7 @@ starknet_api = { workspace = true }
starknet-crypto = "0.6.1"
thiserror = { workspace = true }
tracing = "0.1.37"
tracing-subscriber = "0.3.17"

[dev-dependencies]
assert_matches = "1.5.0"
Expand All @@ -88,6 +92,11 @@ path = "src/bin/native_bench.rs"
name = "cairo_native"
required-features = ["cairo-native"]

[[bin]]
path = "src/bin/native_executor.rs"
name = "cairo_native_executor"
required-features = ["cairo-native"]

[[bench]]
path = "bench/yas.rs"
name = "yas"
Expand Down
10 changes: 10 additions & 0 deletions bench/internals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ pub fn deploy_account(
block_context,
#[cfg(feature = "cairo-native")]
Some(program_cache.clone()),
#[cfg(feature = "cairo-native")]
None,
)
})
.unwrap();
Expand Down Expand Up @@ -158,6 +160,8 @@ pub fn declare(
block_context,
#[cfg(feature = "cairo-native")]
Some(program_cache.clone()),
#[cfg(feature = "cairo-native")]
None,
)
})
.unwrap();
Expand Down Expand Up @@ -207,6 +211,8 @@ pub fn deploy(
block_context,
#[cfg(feature = "cairo-native")]
Some(program_cache.clone()),
#[cfg(feature = "cairo-native")]
None,
)
})
.unwrap();
Expand Down Expand Up @@ -254,6 +260,8 @@ pub fn invoke(
block_context,
#[cfg(feature = "cairo-native")]
Some(program_cache.clone()),
#[cfg(feature = "cairo-native")]
None,
)
.unwrap();

Expand Down Expand Up @@ -282,6 +290,8 @@ pub fn invoke(
2_000_000,
#[cfg(feature = "cairo-native")]
Some(program_cache.clone()),
#[cfg(feature = "cairo-native")]
None,
)
})
.unwrap();
Expand Down
26 changes: 26 additions & 0 deletions bench/yas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ where
&BlockContext::default(),
#[cfg(feature = "cairo-native")]
Some(program_cache),
#[cfg(feature = "cairo-native")]
None,
)?;

// Ensure the execution was successful.
Expand Down Expand Up @@ -426,6 +428,8 @@ where
&BlockContext::default(),
#[cfg(feature = "cairo-native")]
Some(program_cache),
#[cfg(feature = "cairo-native")]
None,
)?;

// Ensure the execution was successful.
Expand Down Expand Up @@ -467,6 +471,8 @@ where
&BlockContext::default(),
#[cfg(feature = "cairo-native")]
Some(program_cache),
#[cfg(feature = "cairo-native")]
None,
)?;

// Ensure the execution was successful.
Expand Down Expand Up @@ -508,6 +514,8 @@ where
&BlockContext::default(),
#[cfg(feature = "cairo-native")]
Some(program_cache),
#[cfg(feature = "cairo-native")]
None,
)?;

// Ensure the execution was successful.
Expand Down Expand Up @@ -560,6 +568,8 @@ where
u64::MAX.into(),
#[cfg(feature = "cairo-native")]
Some(program_cache),
#[cfg(feature = "cairo-native")]
None,
)?;

// Ensure the execution was successful.
Expand Down Expand Up @@ -607,6 +617,8 @@ where
u64::MAX.into(),
#[cfg(feature = "cairo-native")]
Some(program_cache),
#[cfg(feature = "cairo-native")]
None,
)?;

// Ensure the execution was successful.
Expand Down Expand Up @@ -646,6 +658,8 @@ where
u64::MAX.into(),
#[cfg(feature = "cairo-native")]
Some(program_cache),
#[cfg(feature = "cairo-native")]
None,
)?;

// Ensure the execution was successful.
Expand Down Expand Up @@ -701,6 +715,8 @@ where
u64::MAX.into(),
#[cfg(feature = "cairo-native")]
Some(program_cache),
#[cfg(feature = "cairo-native")]
None,
)?;

// Ensure the execution was successful.
Expand Down Expand Up @@ -752,6 +768,8 @@ where
u64::MAX.into(),
#[cfg(feature = "cairo-native")]
Some(program_cache),
#[cfg(feature = "cairo-native")]
None,
)?;

// Ensure the execution was successful.
Expand Down Expand Up @@ -801,6 +819,8 @@ where
u64::MAX.into(),
#[cfg(feature = "cairo-native")]
Some(program_cache),
#[cfg(feature = "cairo-native")]
None,
)?;

// Ensure the execution was successful.
Expand Down Expand Up @@ -859,6 +879,8 @@ where
u64::MAX.into(),
#[cfg(feature = "cairo-native")]
Some(program_cache),
#[cfg(feature = "cairo-native")]
None,
)?;

// Ensure the execution was successful.
Expand Down Expand Up @@ -919,6 +941,8 @@ where
u64::MAX.into(),
#[cfg(feature = "cairo-native")]
Some(program_cache),
#[cfg(feature = "cairo-native")]
None,
)?;

// Ensure the execution was successful.
Expand Down Expand Up @@ -967,6 +991,8 @@ where
u64::MAX.into(),
#[cfg(feature = "cairo-native")]
Some(program_cache),
#[cfg(feature = "cairo-native")]
None,
)?;

// Ensure the execution was successful.
Expand Down
4 changes: 4 additions & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ fn invoke_parser(
0,
#[cfg(feature = "cairo-native")]
None,
#[cfg(feature = "cairo-native")]
None,
)?;
cached_state.apply_state_update(&StateDiff::from_cached_state(transactional_state.cache())?)?;

Expand Down Expand Up @@ -274,6 +276,8 @@ fn call_parser(
block_context.invoke_tx_max_n_steps(),
#[cfg(feature = "cairo-native")]
None,
#[cfg(feature = "cairo-native")]
None,
)?;

let call_info = call_info.ok_or(TransactionError::CallInfoIsNone)?;
Expand Down
8 changes: 8 additions & 0 deletions examples/contract_execution/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ fn test_contract(
&block_context,
#[cfg(feature = "cairo-native")]
None,
#[cfg(feature = "cairo-native")]
None,
)
.expect("Account Deploy Failed")
.call_info
Expand Down Expand Up @@ -179,6 +181,8 @@ fn test_contract(
&block_context,
#[cfg(feature = "cairo-native")]
None,
#[cfg(feature = "cairo-native")]
None,
)
.expect("could not declare the contract class");

Expand All @@ -205,6 +209,8 @@ fn test_contract(
0,
#[cfg(feature = "cairo-native")]
None,
#[cfg(feature = "cairo-native")]
None,
)
.expect("could not deploy contract")
.call_info
Expand Down Expand Up @@ -254,6 +260,8 @@ fn test_contract(
0,
#[cfg(feature = "cairo-native")]
None,
#[cfg(feature = "cairo-native")]
None,
)
.unwrap();

Expand Down
6 changes: 6 additions & 0 deletions examples/lru_cache/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ fn run_contract(
&block_context,
#[cfg(feature = "cairo-native")]
None,
#[cfg(feature = "cairo-native")]
None,
)
.unwrap();

Expand All @@ -88,6 +90,8 @@ fn run_contract(
&block_context,
#[cfg(feature = "cairo-native")]
None,
#[cfg(feature = "cairo-native")]
None,
)
.unwrap();

Expand All @@ -113,6 +117,8 @@ fn run_contract(
0,
#[cfg(feature = "cairo-native")]
None,
#[cfg(feature = "cairo-native")]
None,
)
.unwrap();

Expand Down
2 changes: 2 additions & 0 deletions fuzzer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ fn main() {
block_context.invoke_tx_max_n_steps(),
#[cfg(feature = "cairo-native")]
None,
#[cfg(feature = "cairo-native")]
None,
)
.unwrap();
assert_eq!(call_info.unwrap(), expected_call_info);
Expand Down
2 changes: 1 addition & 1 deletion rpc_state_reader/src/sir_state_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ pub fn execute_tx_configurable_with_state(
#[cfg(not(feature = "cairo-native"))]
let sir_execution = tx.execute(state, &block_context, u128::MAX)?;
#[cfg(feature = "cairo-native")]
let sir_execution = tx.execute(state, &block_context, u128::MAX, None)?;
let sir_execution = tx.execute(state, &block_context, u128::MAX, None, None)?;

Ok(sir_execution)
}
Expand Down
2 changes: 2 additions & 0 deletions src/bin/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ fn main() {
0,
#[cfg(feature = "cairo-native")]
None,
#[cfg(feature = "cairo-native")]
None,
)
.unwrap();
}
Expand Down
6 changes: 6 additions & 0 deletions src/bin/deploy_invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ fn main() {
0,
#[cfg(feature = "cairo-native")]
None,
#[cfg(feature = "cairo-native")]
None,
)
.unwrap();

Expand Down Expand Up @@ -112,6 +114,8 @@ fn main() {
0,
#[cfg(feature = "cairo-native")]
None,
#[cfg(feature = "cairo-native")]
None,
)
.unwrap();

Expand All @@ -135,6 +139,8 @@ fn main() {
0,
#[cfg(feature = "cairo-native")]
None,
#[cfg(feature = "cairo-native")]
None,
)
.unwrap();

Expand Down
2 changes: 2 additions & 0 deletions src/bin/fibonacci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ fn main() {
block_context.invoke_tx_max_n_steps(),
#[cfg(feature = "cairo-native")]
None,
#[cfg(feature = "cairo-native")]
None,
)
.unwrap();

Expand Down
4 changes: 4 additions & 0 deletions src/bin/invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ fn main() {
0,
#[cfg(feature = "cairo-native")]
None,
#[cfg(feature = "cairo-native")]
None,
)
.unwrap();

Expand All @@ -117,6 +119,8 @@ fn main() {
0,
#[cfg(feature = "cairo-native")]
None,
#[cfg(feature = "cairo-native")]
None,
)
.unwrap();

Expand Down
4 changes: 4 additions & 0 deletions src/bin/invoke_with_cachedstate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ fn main() {
0,
#[cfg(feature = "cairo-native")]
None,
#[cfg(feature = "cairo-native")]
None,
)
.unwrap();

Expand All @@ -91,6 +93,8 @@ fn main() {
0,
#[cfg(feature = "cairo-native")]
None,
#[cfg(feature = "cairo-native")]
None,
)
.unwrap();

Expand Down
Loading

0 comments on commit 70edcf2

Please sign in to comment.