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

Commit

Permalink
fix: merge conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Dori Medini <[email protected]>
  • Loading branch information
dorimedini-starkware committed Jul 1, 2024
1 parent a499916 commit d5cf944
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 101 deletions.
42 changes: 19 additions & 23 deletions Cargo.lock

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

23 changes: 0 additions & 23 deletions crates/blockifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@ workspace = true

[features]
concurrency = []
<<<<<<< HEAD
testing = ["rand", "rstest"]
||||||| 73c3821e
=======
jemalloc = ["dep:tikv-jemallocator"]
testing = ["rand", "rstest"]
>>>>>>> origin/main

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down Expand Up @@ -49,15 +44,8 @@ rstest = { workspace = true, optional = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true, features = ["arbitrary_precision"] }
sha2.workspace = true
<<<<<<< HEAD
sha3.workspace = true
starknet-types-core.workspace = true
||||||| 73c3821e
starknet-crypto.workspace = true
=======
sha3.workspace = true
starknet-crypto.workspace = true
>>>>>>> origin/main
starknet_api = { workspace = true, features = ["testing"] }
strum.workspace = true
strum_macros.workspace = true
Expand All @@ -76,16 +64,5 @@ test-case.workspace = true

[[bench]]
harness = false
<<<<<<< HEAD
name = "blockifier_bench"
path = "bench/blockifier_bench.rs"
required-features = ["testing"]

[[test]]
name = "feature_contracts_compatibility_test"
required-features = ["testing"]
||||||| 73c3821e
=======
name = "blockifier_bench"
path = "bench/blockifier_bench.rs"
>>>>>>> origin/main
54 changes: 2 additions & 52 deletions crates/blockifier/src/execution/call_info.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use std::collections::{HashMap, HashSet};
use std::collections::HashSet;
use std::iter::Sum;
use std::ops::Add;

use cairo_vm::types::builtin_name::BuiltinName;
use cairo_vm::vm::runners::cairo_runner::ExecutionResources;
use serde::{Deserialize, Serialize};
use serde::Serialize;
use starknet_api::core::{ClassHash, ContractAddress, EthAddress, PatriciaKey};
use starknet_api::state::StorageKey;
use starknet_api::transaction::{EventContent, L2ToL1Payload};
Expand Down Expand Up @@ -84,54 +83,6 @@ pub struct CallExecution {
pub gas_consumed: u64,
}

// TODO(Dori, 1/1/2025): If and when cairo_vm::types::builtin_name::serde_generic_map_impl is
// public, remove this inline-module and use the cairo_vm's implementation.
pub(crate) mod serialize_builtin_map {
use std::collections::HashMap;

use cairo_vm::types::builtin_name::BuiltinName;
use serde::de::Error;
use serde::ser::SerializeMap;
use serde::{Deserialize, Deserializer, Serialize, Serializer};

pub fn serialize<S, V>(
values: &HashMap<BuiltinName, V>,
serializer: S,
) -> Result<S::Ok, S::Error>
where
S: Serializer,
V: Serialize,
{
let mut map_serializer = serializer.serialize_map(Some(values.len()))?;
for (key, val) in values {
map_serializer.serialize_entry(key.to_str_with_suffix(), val)?
}
map_serializer.end()
}

pub fn deserialize<'de, D: Deserializer<'de>, V: Deserialize<'de>>(
d: D,
) -> Result<HashMap<BuiltinName, V>, D::Error> {
// First deserialize keys into String
let map = HashMap::<String, V>::deserialize(d)?;
// Then match keys to BuiltinName and handle invalid names
map.into_iter()
.map(|(k, v)| BuiltinName::from_str_with_suffix(&k).map(|k| (k, v)))
.collect::<Option<HashMap<_, _>>>()
.ok_or(D::Error::custom("Invalid builtin name"))
}
}

// This struct is used to implement `serde` functionality in a remote `ExecutionResources` Struct.
#[derive(Debug, Default, Deserialize, derive_more::From, Eq, PartialEq, Serialize)]
#[serde(remote = "ExecutionResources")]
struct ExecutionResourcesDef {
n_steps: usize,
n_memory_holes: usize,
#[serde(with = "serialize_builtin_map")]
builtin_instance_counter: HashMap<BuiltinName, usize>,
}

#[derive(Default)]
pub struct ExecutionSummary {
pub executed_class_hashes: HashSet<ClassHash>,
Expand Down Expand Up @@ -215,7 +166,6 @@ impl TestExecutionSummary {
pub struct CallInfo {
pub call: CallEntryPoint,
pub execution: CallExecution,
#[serde(with = "ExecutionResourcesDef")]
pub resources: ExecutionResources,
pub inner_calls: Vec<CallInfo>,

Expand Down
4 changes: 1 addition & 3 deletions crates/blockifier/src/execution/entry_point_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,7 @@ fn test_syscall_execution_security_failures() {
run_security_test(
state,
security_contract,
"Requested contract address ContractAddress(PatriciaKey(Felt(FieldElement { value: \
UnsignedInteger { limbs: [576460752303410992, 18446744073709551615, \
18446744073709551615, 18446744073709550881] } }))) is not deployed",
"Requested contract address 0x17 is not deployed",
"test_bad_call_address",
calldata![],
);
Expand Down

0 comments on commit d5cf944

Please sign in to comment.