Skip to content

Commit

Permalink
refactor: change target param from string reference to string slice
Browse files Browse the repository at this point in the history
  • Loading branch information
iankressin committed Dec 10, 2023
1 parent 0633c2e commit ecb59fe
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
8 changes: 0 additions & 8 deletions common/src/ether/selectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pub async fn get_resolved_selectors(
disassembled_bytecode: &str,
skip_resolving: &bool,
evm: &VM,
shortened_target: &str,
) -> Result<
(HashMap<String, u128>, HashMap<String, Vec<ResolvedFunction>>),
Box<dyn std::error::Error>,
Expand All @@ -33,13 +32,6 @@ pub async fn get_resolved_selectors(
resolved_selectors =
resolve_selectors::<ResolvedFunction>(selectors.keys().cloned().collect()).await;

// if resolved selectors are empty, we can't perform symbolic execution
if resolved_selectors.is_empty() {
debug_max!(&format!(
"failed to resolve any function selectors from '{shortened_target}' .",
));
}

debug_max!(&format!(
"resolved {} possible functions from {} detected selectors.",
resolved_selectors.len(),
Expand Down
4 changes: 2 additions & 2 deletions common/src/utils/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ pub fn classify_token(token: &str) -> TokenType {
/// let long_target = "0".repeat(80);
/// let shortened_target = get_shortned_target(&long_target);
/// ```
pub fn get_shortned_target(target: &String) -> String {
let mut shortened_target = target.clone();
pub fn get_shortned_target(target: &str) -> String {
let mut shortened_target = target.to_string();

if shortened_target.len() > 66 {
shortened_target = shortened_target.chars().take(66).collect::<String>() +
Expand Down
9 changes: 2 additions & 7 deletions core/src/snapshot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,8 @@ pub async fn snapshot(args: SnapshotArgs) -> Result<SnapshotResult, Box<dyn std:
})
.await?;

let (selectors, resolved_selectors) = get_resolved_selectors(
&disassembled_bytecode,
&args.skip_resolving,
&evm,
&shortened_target,
)
.await?;
let (selectors, resolved_selectors) =
get_resolved_selectors(&disassembled_bytecode, &args.skip_resolving, &evm).await?;

let (snapshots, all_resolved_errors, all_resolved_events) = get_snapshots(
selectors,
Expand Down

0 comments on commit ecb59fe

Please sign in to comment.