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

Use perfect hashing instead of string matching in SyscallHintProcessor::execute_syscall_hint #969

Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
94d1dc6
add phf_map problem with the HintProcessorData string
Aug 31, 2023
342b8f4
add phf_map problem with the HintProcessorData string
Aug 31, 2023
ee28c82
wip
Aug 31, 2023
73cffb2
wip
Sep 5, 2023
5fabd70
wip
Sep 5, 2023
55db822
Merge branch 'main' into use-perfect-hashing-instead-of-string-matchi…
Sep 5, 2023
c4bfe78
created perfect hashing mapping intead of strings
Sep 7, 2023
1550b82
Merge branch 'main' into use-perfect-hashing-instead-of-string-matchi…
Sep 7, 2023
efee61e
Removed hint_code.rs
Sep 7, 2023
9bc956a
remove hint_code from mod.rs
Sep 7, 2023
5b7cfe9
wip
Sep 11, 2023
e04efca
wip
Sep 14, 2023
6b7d9ed
merge main
Sep 14, 2023
3c9bdbe
wip
Sep 14, 2023
39e1e8c
added benchmarking
Sep 15, 2023
6171235
format
Sep 18, 2023
69676ae
wip
Sep 21, 2023
ed9d731
Merge branch 'main' into use-perfect-hashing-instead-of-string-matchi…
Sep 21, 2023
8ff4c3f
wip
Sep 21, 2023
a361785
wip
Sep 21, 2023
2c0427d
fix format
Sep 22, 2023
bfc8106
Merge branch 'main' into use-perfect-hashing-instead-of-string-matchi…
Sep 22, 2023
8d7b23a
use hint_code in hint_code_map
Sep 28, 2023
b611e4e
use hint_code in hint_code_map
Sep 28, 2023
3035bf4
corrected duplicated Cargo.toml
Sep 28, 2023
12b29ef
Added Makefile line to regerate hint_map if necessary
Sep 28, 2023
b5a6d4a
Modifile Makefile line to be regenerate map-hints
Sep 28, 2023
0b1a9fa
test without the #[allow(dead_code)]
Sep 29, 2023
7f08a2c
resolve dead code
Sep 29, 2023
40813da
wip
Oct 2, 2023
e54d5e8
wip
Oct 2, 2023
66e1a82
remove unsued dependencies awc , actix-web and clap
Oct 3, 2023
836e94f
Merge branch 'main' into use-perfect-hashing-instead-of-string-matchi…
Oct 3, 2023
5862f4b
resolve merge conflict
Nov 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ starknet = { workspace = true }
base64 = { version = "0.21.0", default-features = false, features = ["alloc"] }
flate2 = "1.0.25"
serde_json_pythonic = { git = "https://github.com/xJonathanLEI/serde_json_pythonic", tag = "v0.1.2"}
phf = "0.11"
phf_macros = "0.11"

[dev-dependencies]
assert_matches = "1.5.0"
Expand All @@ -65,3 +67,6 @@ coverage-helper = "0.1.0"
path = "bench/internals.rs"
name = "internals"
harness = false

[build-dependencies]
phf_codegen = "0.11"
fguthmann marked this conversation as resolved.
Show resolved Hide resolved
12 changes: 6 additions & 6 deletions rpc_state_reader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ impl RpcState {
"params": [self.block.to_value()],
"id": 1
});

let block_info: serde_json::Value = self.rpc_call(&get_block_info_params).unwrap();

starknet_in_rust::state::BlockInfo {
Expand Down Expand Up @@ -584,12 +583,9 @@ mod tests {
RpcChain::TestNet2,
BlockValue::Number(serde_json::to_value(838683).unwrap()),
);

let tx_hash_str = "19feb888a2d53ffddb7a1750264640afab8e9c23119e648b5259f1b5e7d51bc";
let tx_hash = felt_str!(format!("{}", tx_hash_str), 16);

let tx_trace = state_reader.get_transaction_trace(tx_hash);

assert_eq!(
tx_trace.signature,
vec![
Expand Down Expand Up @@ -630,6 +626,7 @@ mod tests {
felt_str!("38bd34c31a0a5c", 16),
]
);

assert_eq!(tx_trace.validate_invocation.retdata, vec![]);
assert_eq!(
tx_trace.validate_invocation.execution_resources,
Expand Down Expand Up @@ -671,6 +668,7 @@ mod tests {
felt_str!("38bd34c31a0a5c", 16),
]
);

assert_eq!(tx_trace.function_invocation.retdata, vec![0.into()]);
assert_eq!(
tx_trace.function_invocation.execution_resources,
Expand All @@ -683,6 +681,7 @@ mod tests {
]),
}
);

assert_eq!(tx_trace.function_invocation.internal_calls.len(), 1);
assert_eq!(
tx_trace.function_invocation.internal_calls[0]
Expand All @@ -708,6 +707,7 @@ mod tests {
felt_str!("0", 16),
]
);

assert_eq!(tx_trace.fee_transfer_invocation.retdata, vec![1.into()]);
assert_eq!(
tx_trace.fee_transfer_invocation.execution_resources,
Expand Down Expand Up @@ -753,7 +753,9 @@ mod transaction_tests {

// Instantiate the RPC StateReader and the CachedState
let block = BlockValue::Number(serde_json::to_value(block_number).unwrap());

let rpc_state = Arc::new(RpcState::new(network, block));

let mut state = CachedState::new(rpc_state.clone(), HashMap::new());

let fee_token_address = Address(felt_str!(
Expand Down Expand Up @@ -843,7 +845,6 @@ mod transaction_tests {
838683,
2917470325,
);

dbg!(&result.actual_resources);
dbg!(&result.actual_fee); // test=7252831227950, explorer=7207614784695, diff=45216443255 (0.06%)
dbg!(&result.call_info.clone().unwrap().execution_resources); // Ok with explorer
Expand Down Expand Up @@ -907,7 +908,6 @@ mod transaction_tests {
155054,
33977120598,
);

dbg!(&result.actual_resources);
dbg!(&result.actual_fee); // test=6361070805216, explorer=47292465953700, diff=5888146145679 (0.13%)
dbg!(&result.call_info.clone().unwrap().execution_resources); // Ok with explorer
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use utils::Address;
#[cfg(test)]
#[macro_use]
extern crate assert_matches;
extern crate phf_macros;

// Re-exports
pub use crate::services::api::contract_classes::deprecated_contract_class::{
Expand Down
Loading