Skip to content

Commit

Permalink
chore: reduce unnecessary collected fuzz state (#7306)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Mar 4, 2024
1 parent d176715 commit b8047b7
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions crates/evm/fuzz/src/strategies/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,21 @@ pub fn collect_state_from_call(
) {
let mut state = state.write();

// Insert log topics and data.
for log in logs {
for topic in log.topics() {
state.values_mut().insert(topic.0);
}
let chunks = log.data.data.chunks_exact(32);
let rem = chunks.remainder();
for chunk in chunks {
state.values_mut().insert(chunk.try_into().unwrap());
}
if !rem.is_empty() {
state.values_mut().insert(B256::right_padding_from(rem).0);
}
}

for (address, account) in state_changeset {
// Insert basic account information
state.values_mut().insert(address.into_word().into());
Expand Down Expand Up @@ -182,23 +197,6 @@ pub fn collect_state_from_call(
state.values_mut().insert(B256::from(above_value).0);
}
}
} else {
return;
}
}

// Insert log topics and data.
for log in logs {
for topic in log.topics() {
state.values_mut().insert(topic.0);
}
let chunks = log.data.data.chunks_exact(32);
let rem = chunks.remainder();
for chunk in chunks {
state.values_mut().insert(chunk.try_into().unwrap());
}
if !rem.is_empty() {
state.values_mut().insert(B256::right_padding_from(rem).0);
}
}
}
Expand Down

0 comments on commit b8047b7

Please sign in to comment.