Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion crates/movy-fuzz/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ where
}

let db = CachedStore::new(&self.executor.db);
self.oracles.pre_execution(&db, state, &input.sequence())?;
self.oracles.pre_execution(&db, state, input.sequence())?;

trace!("Executing input: {}", input.sequence());

Expand Down
34 changes: 14 additions & 20 deletions crates/movy-fuzz/src/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use movy_replay::{
meta::Metadata,
};
use movy_sui::database::cache::ObjectSuiStoreCommit;
use movy_types::{abi::MoveAbiSignatureToken, input::MoveStructTag};
use movy_types::abi::MoveAbiSignatureToken;
use movy_types::{
abi::{
MoveAbility, MoveFunctionAbi, MoveFunctionVisibility, MoveModuleAbi, MoveModuleId,
Expand Down Expand Up @@ -309,36 +309,30 @@ fn apply_function_filters(
.filter(|func| {
let pkg = func.0.module_address;
let module_id = &func.0;
if let Some(set) = &include_pkgs {
if !set.contains(&pkg) {
if let Some(set) = &include_pkgs
&& !set.contains(&pkg) {
return false;
}
}
if let Some(set) = &exclude_pkgs {
if set.contains(&pkg) {
if let Some(set) = &exclude_pkgs
&& set.contains(&pkg) {
return false;
}
}
if let Some(set) = &include_funcs {
if !set.contains(func) {
if let Some(set) = &include_funcs
&& !set.contains(func) {
return false;
}
}
if let Some(set) = &exclude_funcs {
if set.contains(func) {
if let Some(set) = &exclude_funcs
&& set.contains(func) {
return false;
}
}
if let Some(set) = &include_modules {
if !set.contains(module_id) {
if let Some(set) = &include_modules
&& !set.contains(module_id) {
return false;
}
}
if let Some(set) = &exclude_modules {
if set.contains(module_id) {
if let Some(set) = &exclude_modules
&& set.contains(module_id) {
return false;
}
}
true
})
.collect()
Expand Down Expand Up @@ -531,7 +525,7 @@ impl FuzzMetadata {
checkpoint: u64,
epoch: u64,
epoch_ms: u64,
mut filters: TargetFilters,
filters: TargetFilters,
) -> Result<Self, MovyError>
where
T: ObjectStoreCachedStore
Expand Down
2 changes: 1 addition & 1 deletion crates/movy-fuzz/src/mutators/arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ where
&movecall.module_name,
&movecall.function,
);
let origin_module_id = {
let _origin_module_id = {
let meta = state.fuzz_state();
meta.get_package_metadata(&target_function.0.module_address)
.unwrap()
Expand Down
29 changes: 13 additions & 16 deletions crates/movy-fuzz/src/mutators/sequence/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,13 @@ fn append_hook_call<S>(

let mut fixed_args: BTreeMap<u16, (SequenceArgument, MoveTypeTag)> = BTreeMap::new();
let mut fixed_ty_args: BTreeMap<u16, MoveTypeTag> = BTreeMap::new();
if let Some(ctx) = ctx_arg {
if let Some(param_ty) = hook_abi
.parameters
.get(0)
if let Some(ctx) = ctx_arg
&& let Some(param_ty) = hook_abi
.parameters.first()
.and_then(|p| p.subst(&BTreeMap::new()))
{
fixed_args.insert(0, (ctx, param_ty));
}
}
if let Some((target_call, target_abi, maybe_idx)) = target {
let ty_args_map = target_call
.type_arguments
Expand All @@ -129,7 +127,7 @@ fn append_hook_call<S>(
.arguments
.iter()
.zip(target_abi.parameters.iter())
.filter_map(|(arg, param)| param.subst(&ty_args_map).map(|ty| (ty, arg.clone())))
.filter_map(|(arg, param)| param.subst(&ty_args_map).map(|ty| (ty, *arg)))
.collect();
if let Some(target_idx) = maybe_idx {
let ret_args = if target_abi.return_paramters.len() == 1 {
Expand Down Expand Up @@ -163,13 +161,13 @@ fn append_hook_call<S>(
.enumerate()
.find(|(i, (ty, _))| !used[*i] && *ty == param_ty)
{
fixed_args.insert(idx as u16, (arg.clone(), param_ty.clone()));
fixed_args.insert(idx as u16, (*arg, param_ty.clone()));
used[cand_idx] = true;
}
}
}

let used_arguments = fixed_args.values().map(|(arg, _)| arg.clone()).collect();
let used_arguments = fixed_args.values().map(|(arg, _)| *arg).collect();
if append_function(
state,
ptb,
Expand Down Expand Up @@ -240,7 +238,7 @@ where

// Sequence-level pre hooks use the global context if available.
for hook in sequence_hooks.pre_hooks.iter() {
append_hook_call(state, &mut ptb, hook, None, global_ctx.clone());
append_hook_call(state, &mut ptb, hook, None, global_ctx);
}

for cmd in base.commands.iter() {
Expand All @@ -263,8 +261,8 @@ where
&movecall.function,
)
.cloned();
if let Some(target_abi) = target_abi {
if let Some(hooks) = function_hooks.get(&func_ident) {
if let Some(target_abi) = target_abi
&& let Some(hooks) = function_hooks.get(&func_ident) {
let mut hook_ctx: Option<SequenceArgument> = None;
if let Some((create_ctx, _)) = context_idents.as_ref() {
if let Some((_, rets)) = append_function(
Expand All @@ -291,7 +289,7 @@ where
&mut ptb,
hook,
Some((&remapped_call, &target_abi, None)),
hook_ctx.clone(),
hook_ctx,
);
}
let main_idx = ptb.commands.len() as u16;
Expand All @@ -304,7 +302,7 @@ where
&mut ptb,
hook,
Some((&remapped_call, &target_abi, Some(main_idx))),
hook_ctx.clone(),
hook_ctx,
);
}
if let (Some(ctx_arg), Some((_, destroy_ctx)), Some(param_ty)) =
Expand All @@ -325,7 +323,6 @@ where
}
continue;
}
}
let new_idx = ptb.commands.len() as u16;
ptb.commands.push(MoveSequenceCall::Call(remapped_call));
index_map.push(new_idx);
Expand All @@ -339,11 +336,11 @@ where
}

for hook in sequence_hooks.post_hooks.iter() {
append_hook_call(state, &mut ptb, hook, None, global_ctx.clone());
append_hook_call(state, &mut ptb, hook, None, global_ctx);
}

if let Some((_, destroy_ctx)) = context_idents.as_ref() {
if let (Some(ctx_arg), Some(param_ty)) = (global_ctx.clone(), destroy_param_ty.clone()) {
if let (Some(ctx_arg), Some(param_ty)) = (global_ctx, destroy_param_ty.clone()) {
let mut fixed_args = BTreeMap::new();
fixed_args.insert(0u16, (ctx_arg, param_ty));
let _ = append_function(
Expand Down
4 changes: 2 additions & 2 deletions crates/movy-fuzz/src/mutators/sequence/remap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn remap_arg_with_map(arg: &SequenceArgument, mapping: &[Option<u16>]) -> Option
SequenceArgument::NestedResult(i, j) => mapping
.get(*i as usize)
.and_then(|new| new.map(|n| SequenceArgument::NestedResult(n, *j))),
_ => Some(arg.clone()),
_ => Some(*arg),
}
}

Expand All @@ -25,7 +25,7 @@ pub fn remap_arg(arg: &SequenceArgument, mapping: &[u16]) -> SequenceArgument {
}),
*j,
),
_ => arg.clone(),
_ => *arg,
}
}

Expand Down
4 changes: 1 addition & 3 deletions crates/movy-fuzz/src/operations/sui_replay.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use libafl::{
Evaluator, HasMetadata, NopFuzzer, StdFuzzer,
Evaluator, HasMetadata, StdFuzzer,
corpus::{Corpus, InMemoryCorpus},
events::SimpleEventManager,
executors::Executor,
feedback_and_fast,
feedbacks::{CrashFeedback, ExitKindFeedback, MaxMapPow2Feedback},
monitors::SimpleMonitor,
Expand All @@ -19,7 +18,6 @@ use movy_replay::{
use movy_sui::database::cache::ObjectSuiStoreCommit;
use movy_types::error::MovyError;
use sui_types::{
base_types::ObjectID,
effects::TransactionEffectsAPI,
storage::{BackingPackageStore, BackingStore, ObjectStore},
};
Expand Down
4 changes: 2 additions & 2 deletions crates/movy-fuzz/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,14 @@ impl<S: HasTestcase<I>, I, T> HasTestcase<I> for SuperState<S, T> {
fn testcase(
&self,
id: libafl::corpus::CorpusId,
) -> Result<std::cell::Ref<libafl::corpus::Testcase<I>>, libafl::Error> {
) -> Result<std::cell::Ref<'_, libafl::corpus::Testcase<I>>, libafl::Error> {
self.state.testcase(id)
}

fn testcase_mut(
&self,
id: libafl::corpus::CorpusId,
) -> Result<std::cell::RefMut<libafl::corpus::Testcase<I>>, libafl::Error> {
) -> Result<std::cell::RefMut<'_, libafl::corpus::Testcase<I>>, libafl::Error> {
self.state.testcase_mut(id)
}
}
Expand Down
5 changes: 2 additions & 3 deletions crates/movy-replay/src/env.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use std::{
collections::{BTreeMap, BTreeSet},
io::Write,
path::{Path, PathBuf},
path::Path,
str::FromStr,
};

use color_eyre::eyre::eyre;
use itertools::Itertools;
use movy_sui::{
compile::{SuiCompiledPackage, build_package_resolved},
compile::SuiCompiledPackage,
database::cache::ObjectSuiStoreCommit,
rpc::graphql::{GraphQlClient, OwnerKind},
};
Expand Down
3 changes: 1 addition & 2 deletions crates/movy-replay/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use move_core_types::account_address::AccountAddress;
use move_trace_format::{format::MoveTraceBuilder, interface::Tracer};
use movy_sui::{compile::SuiCompiledPackage, database::cache::ObjectSuiStoreCommit};
use movy_types::{error::MovyError, object::MoveOwner};
use serde::{Deserialize, Serialize};
use sui_types::{
TypeTag,
base_types::{ObjectID, SuiAddress},
Expand Down Expand Up @@ -175,7 +174,7 @@ where
None
};
trace!("Tx digest is {}", tx_data.digest());
let (store, gas_status, effects, timing, result) =
let (store, gas_status, effects, _timing, result) =
self.executor.execute_transaction_to_effects(
&self.db,
&self.protocol_config,
Expand Down
16 changes: 8 additions & 8 deletions crates/movy-replay/src/tracer/concolic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ impl ConcolicState {
let bit_width = value_bitwidth(true_lhs);
let (true_l, true_r) = (value_to_u256(true_lhs), value_to_u256(true_rhs));
match (lhs, rhs) {
(SymbolValue::Value(l), SymbolValue::Value(r)) => {
(SymbolValue::Value(_l), SymbolValue::Value(_r)) => {
self.stack.push(SymbolValue::Unknown);
}
(SymbolValue::Value(l), SymbolValue::Unknown) => {
Expand All @@ -571,7 +571,7 @@ impl ConcolicState {
let bit_width = value_bitwidth(true_lhs);
let (true_l, true_r) = (value_to_u256(true_lhs), value_to_u256(true_rhs));
match (lhs, rhs) {
(SymbolValue::Value(l), SymbolValue::Value(r)) => {
(SymbolValue::Value(_l), SymbolValue::Value(_r)) => {
self.stack.push(SymbolValue::Unknown);
}
(SymbolValue::Value(l), SymbolValue::Unknown) => {
Expand All @@ -596,7 +596,7 @@ impl ConcolicState {
let bit_width = value_bitwidth(true_lhs);
let (true_l, true_r) = (value_to_u256(true_lhs), value_to_u256(true_rhs));
match (lhs, rhs) {
(SymbolValue::Value(l), SymbolValue::Value(r)) => {
(SymbolValue::Value(_l), SymbolValue::Value(_r)) => {
self.stack.push(SymbolValue::Unknown);
}
(SymbolValue::Value(l), SymbolValue::Unknown) => {
Expand All @@ -621,7 +621,7 @@ impl ConcolicState {
let true_r = value_to_u256(true_rhs).unchecked_as_u32();
let threshold = Self::max_u_bits(bit_width);
match (lhs, rhs) {
(SymbolValue::Value(l), SymbolValue::Value(r)) => {
(SymbolValue::Value(_l), SymbolValue::Value(_r)) => {
self.stack.push(SymbolValue::Unknown);
}
(SymbolValue::Value(l), SymbolValue::Unknown) => {
Expand All @@ -630,7 +630,7 @@ impl ConcolicState {
self.stack.push(SymbolValue::Value(shl_mod));
return Some(shl.gt(&threshold)); // cause overflow
}
(SymbolValue::Unknown, SymbolValue::Value(r)) => {
(SymbolValue::Unknown, SymbolValue::Value(_r)) => {
self.stack.push(SymbolValue::Unknown);
}
(SymbolValue::Unknown, SymbolValue::Unknown) => {
Expand All @@ -641,19 +641,19 @@ impl ConcolicState {
Bytecode::Shr => {
let (rhs, lhs) = (self.stack.pop().unwrap(), self.stack.pop().unwrap());
let mut stack_iter = stack.unwrap().last_n(2).unwrap();
let true_lhs = stack_iter.next().unwrap();
let _true_lhs = stack_iter.next().unwrap();
let true_rhs = stack_iter.next().unwrap();

let true_r = value_to_u256(true_rhs).unchecked_as_u32();
match (lhs, rhs) {
(SymbolValue::Value(l), SymbolValue::Value(r)) => {
(SymbolValue::Value(_l), SymbolValue::Value(_r)) => {
self.stack.push(SymbolValue::Unknown);
}
(SymbolValue::Value(l), SymbolValue::Unknown) => {
let shr = l / int_two_pow(true_r);
self.stack.push(SymbolValue::Value(shr));
}
(SymbolValue::Unknown, SymbolValue::Value(r)) => {
(SymbolValue::Unknown, SymbolValue::Value(_r)) => {
self.stack.push(SymbolValue::Unknown);
}
(SymbolValue::Unknown, SymbolValue::Unknown) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/movy-replay/src/tracer/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ where
fn notify(
&mut self,
event: &TraceEvent,
writer: &mut move_trace_format::interface::Writer<'_>,
_writer: &mut move_trace_format::interface::Writer<'_>,
stack: Option<&move_vm_stack::Stack>,
) {
if let Err(e) = self.notify_event(event, stack) {
Expand Down
2 changes: 1 addition & 1 deletion crates/movy-replay/src/tracer/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use move_trace_format::format::TraceEvent;
use move_vm_stack::Stack;
use movy_types::{
error::MovyError,
input::{FunctionIdent, InputArgument, MoveSequence},
input::{FunctionIdent, MoveSequence},
oracle::OracleFinding,
};
use sui_types::effects::TransactionEffects;
Expand Down
6 changes: 3 additions & 3 deletions crates/movy-replay/src/tracer/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl Tracer for TreeTracer {
let inner = &mut self.inner;
inner.evs.push(event.clone());
match event {
TraceEvent::OpenFrame { frame, gas_left } => {
TraceEvent::OpenFrame { frame, gas_left: _ } => {
let current = inner.current_calls();
let idx_len = current.len();
current.push(FrameTraced {
Expand All @@ -149,9 +149,9 @@ impl Tracer for TreeTracer {
inner.call_idxs.push(idx_len);
}
TraceEvent::CloseFrame {
frame_id,
frame_id: _,
return_,
gas_left,
gas_left: _,
} => {
let current = inner.current_frame();
if current.is_none() {
Expand Down
Loading
Loading