From 2c8e91831bd986762181aa52b5ff56fd752aca9c Mon Sep 17 00:00:00 2001 From: brock elmore Date: Mon, 22 Jul 2024 13:59:27 -0700 Subject: [PATCH] remove prints --- crates/analyzers/src/func_analyzer/mod.rs | 13 --- crates/cli/src/main.rs | 12 --- crates/graph/src/nodes/context/solving.rs | 6 +- crates/graph/src/nodes/context/variables.rs | 1 - .../graph/src/nodes/debug_reconstruction.rs | 4 - .../graph/src/range/elem/elem_enum/arena.rs | 5 - crates/graph/src/range/elem/expr/collapse.rs | 3 - crates/graph/src/range/elem/mod.rs | 1 - crates/graph/src/solvers/atoms.rs | 15 +-- crates/graph/src/solvers/brute.rs | 100 ------------------ crates/pyrometer/src/analyzer.rs | 2 - crates/pyrometer/src/analyzer_backend.rs | 14 --- crates/pyrometer/src/graph_backend.rs | 23 +--- crates/solc-expressions/src/assign.rs | 6 -- crates/solc-expressions/src/literal.rs | 1 - .../src/member_access/builtin_access.rs | 9 -- .../src/member_access/library_access.rs | 1 - crates/solc-expressions/src/variable.rs | 11 +- 18 files changed, 10 insertions(+), 217 deletions(-) diff --git a/crates/analyzers/src/func_analyzer/mod.rs b/crates/analyzers/src/func_analyzer/mod.rs index 6a86b4f7..77830421 100644 --- a/crates/analyzers/src/func_analyzer/mod.rs +++ b/crates/analyzers/src/func_analyzer/mod.rs @@ -61,19 +61,6 @@ impl<'a> FunctionVarsBoundAnalysis { .iter() .map(|var| (var.as_controllable_name(analyzer, arena).unwrap(), var)) .collect::>(); - // create the bound strings - // let atoms = ctx.dep_atoms(analyzer).unwrap(); - // println!("had {} atoms", atoms.len()); - // let mut handled_atom = vec![]; - // let mut bounds_string: Vec = vec![]; - // atoms.iter().enumerate().for_each(|(i, atom)| { - // let atom_str = atom.to_range_string(true, analyzer, arena).s; - // if !handled_atom.contains(&atom_str) { - // handled_atom.push(atom_str.clone()); - // bounds_string.push(format!("{}. {}", i + 1, atom_str)) - // } - // }); - // let bounds_string = bounds_string.into_iter().collect::>().join("\n"); let bounds_string = deps .iter() diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 12de880d..4be132b9 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -304,7 +304,6 @@ fn main() { println!("DONE ANALYZING IN: {parse_time}ms. Writing to cli..."); - // println!("Arena: {:#?}", analyzer.range_arena); if unsafe { USE_DEBUG_SITE } { use pyrometer::graph_backend::mermaid_str; use pyrometer::graph_backend::post_to_site_arena; @@ -328,7 +327,6 @@ fn main() { if args.stats { println!("{}", analyzer.stats(t_end, arena)); } - // println!("Arena: {:#?}", analyzer.range_arena); // use self.sources to fill a BTreeMap with the file_no and SourcePath.path_to_solidity_file let mut file_mapping: BTreeMap = BTreeMap::new(); @@ -370,20 +368,10 @@ fn main() { analyzer.open_mermaid(arena); } - // println!("{}", analyzer.range_arena.ranges.iter().map(|i| { - // let j = i.borrow(); - // let (min_cached, max_cached) = j.is_min_max_cached(&analyzer); - // format!("\t{j}, is cached: {min_cached}, {max_cached}\n") - // }).collect::>().join("")); - // println!("{}", analyzer.range_arena.map.iter().map(|(k, v)| { - // format!("\t{}: {}\n", k, v) - // }).collect::>().join("")); - if args.debug { return; } - // println!("getting contracts"); let all_contracts = analyzer .search_children(entry, &Edge::Contract) .into_iter() diff --git a/crates/graph/src/nodes/context/solving.rs b/crates/graph/src/nodes/context/solving.rs index fc74dae9..45500d3e 100644 --- a/crates/graph/src/nodes/context/solving.rs +++ b/crates/graph/src/nodes/context/solving.rs @@ -22,17 +22,13 @@ impl ContextNode { analyzer: &mut impl GraphBackend, arena: &mut RangeArena>, ) -> Result { - // println!("checking unreachable: {}", self.path(analyzer)); let mut solver = self.dl_solver(analyzer)?.clone(); match solver.solve_partial(analyzer, arena)? { SolveStatus::Unsat => { tracing::trace!("{} is unreachable via UNSAT", self.path(analyzer)); Ok(true) } - _e => { - // println!("other: {e:?}"); - Ok(false) - } + _e => Ok(false), } } diff --git a/crates/graph/src/nodes/context/variables.rs b/crates/graph/src/nodes/context/variables.rs index a126e0f0..aa019d3e 100644 --- a/crates/graph/src/nodes/context/variables.rs +++ b/crates/graph/src/nodes/context/variables.rs @@ -212,7 +212,6 @@ impl ContextNode { } pub fn contract_vars_referenced_global(&self, analyzer: &impl AnalyzerBackend) -> Vec { - println!("getting storage vars for: {}", self.path(analyzer)); let mut reffed_storage = self.contract_vars_referenced(analyzer); analyzer .graph() diff --git a/crates/graph/src/nodes/debug_reconstruction.rs b/crates/graph/src/nodes/debug_reconstruction.rs index 166b6c41..f286397d 100644 --- a/crates/graph/src/nodes/debug_reconstruction.rs +++ b/crates/graph/src/nodes/debug_reconstruction.rs @@ -502,10 +502,6 @@ impl FunctionNode { &self, analyzer: &mut impl AnalyzerBackend, ) -> FuncReconstructionReqs { - println!( - "reconstruction requirements for: {}", - self.name(analyzer).unwrap() - ); FuncReconstructionReqs { storage: self.maybe_used_storage(analyzer).unwrap_or_default(), usertypes: self.maybe_used_usertypes(analyzer).unwrap_or_default(), diff --git a/crates/graph/src/range/elem/elem_enum/arena.rs b/crates/graph/src/range/elem/elem_enum/arena.rs index be98e938..4fba11d3 100644 --- a/crates/graph/src/range/elem/elem_enum/arena.rs +++ b/crates/graph/src/range/elem/elem_enum/arena.rs @@ -124,11 +124,6 @@ impl RangeArenaLike> for RangeArena> { self.map.insert(Elem::Null, 0); } - // println!( - // "{}\nhad cycle:\n{:?}", - // self.debug_str(analyzer), - // petgraph::dot::Dot::new(&self.to_graph(analyzer).unwrap()) // petgraph::algo::toposort(&self.to_graph(analyzer).unwrap(), None).is_err() - // ); match elem { Elem::Arena(idx) => return idx, Elem::Null => return 0, diff --git a/crates/graph/src/range/elem/expr/collapse.rs b/crates/graph/src/range/elem/expr/collapse.rs index d4242831..83587bc9 100644 --- a/crates/graph/src/range/elem/expr/collapse.rs +++ b/crates/graph/src/range/elem/expr/collapse.rs @@ -60,7 +60,6 @@ pub fn collapse( tracing::trace!("collapsing: {l} {op} {r}"); let l = if let Elem::Expr(e) = l { - //println!("collapsing lhs"); match collapse(*e.lhs, e.op, *e.rhs, arena) { MaybeCollapsed::Not(l, op, r) => Elem::Expr(RangeExpr::new(l, op, r)), MaybeCollapsed::Concretes(l, op, r) => Elem::Expr(RangeExpr::new(l, op, r)), @@ -71,7 +70,6 @@ pub fn collapse( }; let r = if let Elem::Expr(e) = r { - //println!("collapsing rhs"); match collapse(*e.lhs, e.op, *e.rhs, arena) { MaybeCollapsed::Not(l, op, r) => Elem::Expr(RangeExpr::new(l, op, r)), MaybeCollapsed::Concretes(l, op, r) => Elem::Expr(RangeExpr::new(l, op, r)), @@ -193,7 +191,6 @@ pub fn collapse( if (ords.x_eq_z() || ords.y_eq_z()) || z.range_eq(&Elem::from(Concrete::from(true)), arena) { - println!("collapsed == true"); MaybeCollapsed::Collapsed(Elem::Expr(expr)) } else { MaybeCollapsed::Not(Elem::Expr(expr), op, z) diff --git a/crates/graph/src/range/elem/mod.rs b/crates/graph/src/range/elem/mod.rs index e18640c6..1ae8a707 100644 --- a/crates/graph/src/range/elem/mod.rs +++ b/crates/graph/src/range/elem/mod.rs @@ -244,7 +244,6 @@ impl RangeOp { Gt => Lt, Lt => Gt, other => { - println!("other:{other:?}"); return None; } }; diff --git a/crates/graph/src/solvers/atoms.rs b/crates/graph/src/solvers/atoms.rs index f3d52ae0..b9b7cdfb 100644 --- a/crates/graph/src/solvers/atoms.rs +++ b/crates/graph/src/solvers/atoms.rs @@ -326,7 +326,6 @@ impl Atomize for Elem { expr.rhs.atoms_or_part(Some(self), analyzer, arena), ) { (ref lp @ AtomOrPart::Part(ref l), ref rp @ AtomOrPart::Part(ref r)) => { - // println!("part part"); match (l, r) { (_, Elem::Arena(_)) => todo!(), (Elem::Arena(_), _) => todo!(), @@ -385,16 +384,12 @@ impl Atomize for Elem { } } (AtomOrPart::Atom(l_atom), r @ AtomOrPart::Part(_)) => { - // println!("atom part"); - AtomOrPart::Atom(l_atom.add_rhs(expr.op, r)) } (l @ AtomOrPart::Part(_), AtomOrPart::Atom(r_atom)) => { - // println!("part atom"); AtomOrPart::Atom(r_atom.add_lhs(expr.op, l)) } (AtomOrPart::Atom(l_atoms), AtomOrPart::Atom(r_atoms)) => { - // println!("atom atom"); AtomOrPart::Atom(r_atoms.add_lhs(expr.op, AtomOrPart::Atom(l_atoms))) } } @@ -412,14 +407,12 @@ impl Atomize for Elem { use Elem::*; tracing::trace!("atomize: {}", self); match self { - Reference(_) => None, //{ println!("was dyn"); None}, - Null => None, //{ println!("was null"); None}, - Concrete(_c) => None, //{ println!("was conc: {}", _c.val.as_human_string()); None }, - ConcreteDyn(_) => None, //{ println!("was concDyn"); None}, + Reference(_) => None, + Null => None, + Concrete(_c) => None, + ConcreteDyn(_) => None, Expr(_) => { - // println!("atomized: was expr"); let AtomOrPart::Atom(mut a) = self.atoms_or_part(None, analyzer, arena) else { - // println!("returning none"); return None; }; a.update_max_ty(); diff --git a/crates/graph/src/solvers/brute.rs b/crates/graph/src/solvers/brute.rs index 7bdb130a..3947e7f6 100644 --- a/crates/graph/src/solvers/brute.rs +++ b/crates/graph/src/solvers/brute.rs @@ -112,13 +112,6 @@ impl BruteBinSearchSolver { // Sometimes a storage variable will be split due to a context fork. We recombine them here atomic_idxs.sort(); atomic_idxs.dedup(); - // atomic_idxs.iter().for_each(|dep| { - // println!( - // "atomic dep: {} - {}", - // dep.display_name(analyzer).unwrap(), - // dep.0 - // ) - // }); // let atomics = atomic_idxs; let mut storage_atomics: BTreeMap> = BTreeMap::default(); let mut calldata_atomics = vec![]; @@ -199,7 +192,6 @@ impl BruteBinSearchSolver { let range = &self.atomic_ranges[atomic]; let mut min = range.evaled_range_min(analyzer, arena).unwrap(); min.cache_minimize(analyzer, arena).unwrap(); - // println!("min: {}", min.minimize(analyzer).unwrap().to_range_string(false, analyzer, arena).s); let mut max = range.evaled_range_max(analyzer, arena).unwrap(); max.cache_maximize(analyzer, arena).unwrap(); let mut mid = (min.clone() + max.clone()) / Elem::from(Concrete::from(U256::from(2))); @@ -265,7 +257,6 @@ impl BruteBinSearchSolver { analyzer: &mut impl GraphBackend, arena: &mut RangeArena>, ) -> bool { - // println!("lowering mid"); // move the high to high + mid / 2 // reset the mid let mut curr_lmr = self.lmrs[i].clone(); @@ -321,9 +312,6 @@ impl SolcSolver for BruteBinSearchSolver { .ranges .iter() .filter_map(|(_dep, range)| { - // println!("dep: {}", dep.display_name(analyzer).unwrap()); - - // println!("atom: {atom:#?}"); if let Some(atom) = range.min.atomize(analyzer, arena) { Some(atom) } else { @@ -397,7 +385,6 @@ impl SolcSolver for BruteBinSearchSolver { .collect() } } - // println!("solved for: {:#?}", atomic_solves); if atomic_solves.len() == self.atomics.len() { return Ok(AtomicSolveStatus::Sat(atomic_solves)); @@ -459,13 +446,11 @@ impl SolcSolver for BruteBinSearchSolver { }); }); new_range.cache_eval(analyzer, arena).unwrap(); - // println!("{}, original range: [{}, {}], new range: [{}, {}]", dep.display_name(analyzer).unwrap(), range.min, range.max, new_range.min_cached.clone().unwrap(), new_range.max_cached.clone().unwrap()); new_range.sat(analyzer, arena) }); if all_good { Ok(AtomicSolveStatus::Sat(mapping)) } else { - // println!("thought we solved but we didnt"); Ok(AtomicSolveStatus::Indeterminate) } } else { @@ -483,7 +468,6 @@ impl SolcSolver for BruteBinSearchSolver { analyzer: &mut impl AnalyzerBackend, arena: &mut RangeArena>, ) -> Result { - // println!("recurse check for: {}", self.atomics[i].idxs[0].display_name(analyzer).unwrap()); if i >= self.lmrs.len() { return Ok(false); } @@ -653,7 +637,6 @@ impl SolcSolver for BruteBinSearchSolver { analyzer: &mut impl GraphBackend, arena: &mut RangeArena>, ) -> Result<(bool, Option), GraphError> { - // println!("checking: {}, conc: {}, {}", this.atomics[solved_for_idx].idxs[0].display_name(analyzer).unwrap(), conc.maximize(analyzer, arena)?.to_range_string(true, analyzer, arena).s, conc.minimize(analyzer)?.to_range_string(false, analyzer, arena).s); solved_atomics.push(solved_for_idx); let mut new_ranges = BTreeMap::default(); this.intermediate_atomic_ranges.insert( @@ -686,7 +669,6 @@ impl SolcSolver for BruteBinSearchSolver { match dl_solver.solve_partial(analyzer, arena)? { SolveStatus::Unsat => { - // println!("TRUE UNSAT"); return Ok((false, None)); } SolveStatus::Sat { @@ -762,50 +744,18 @@ impl SolcSolver for BruteBinSearchSolver { SolcRange::new(val.clone().into(), val.into(), vec![]), ); }); - // println!("new solves: {atomic_solves:#?}"); for dep in this.deps.iter() { let range = this .intermediate_ranges .get(dep) .expect("No range for dep?"); - // if dep.display_name(analyzer).unwrap() == "(p2 < (61 * p3)) == true" { - // println!("range: {:#?}\n{:#?}", range.min, range.max); - // println!("simplified range: {:#?}\n{:#?}", range.min.simplify_minimize(&mut vec![], analyzer), range.max.simplify_maximize(&mut vec![], analyzer)); - // } - // println!("atomizing dep: {}", dep.display_name(analyzer).unwrap()); - // println!("min atomized: {:#?}, max atomized: {:#?}", range.min.simplify_minimize(&mut vec![], analyzer)?.atomize(), range.max.simplify_maximize(&mut vec![], analyzer)?.atomize()); if solved_dep.idxs.contains(dep) { - // println!("FOR SOLVED DEP"); continue; } // check that the concrete value doesn't break any let mut new_range = range.clone(); - // check if const now - // if let Some((Some(idx), const_ineq)) = new_range.min.maybe_const_inequality() { - // println!("min const ineq: {} for {}", const_ineq.maybe_concrete().unwrap().val.as_human_string(), ContextVarNode::from(idx).display_name(analyzer).unwrap()); - - // if let Some(position) = this.atomics.iter().position(|atomic| atomic.idxs.contains(&ContextVarNode::from(idx))) { - // // check and return) - // if !solved_atomics.contains(&position) { - // println!("inner min const ineq"); - // return check_for_lmr(this, position, &this.atomics[position].clone(), const_ineq, solved_atomics, analyzer); - // } - // } - - // } - // if let Some((Some(idx), const_ineq)) = new_range.max.maybe_const_inequality() { - // println!("max const ineq: {} for {} ({}), {:#?}", const_ineq.maybe_concrete().unwrap().val.as_human_string(), ContextVarNode::from(idx).display_name(analyzer).unwrap(), idx.index(), this.atomics); - // if let Some(position) = this.atomics.iter().position(|atomic| atomic.idxs.contains(&ContextVarNode::from(idx))) { - // // check and return - // if !solved_atomics.contains(&position) { - // println!("inner max const ineq"); - // return check_for_lmr(this, position, &this.atomics[position].clone(), const_ineq, solved_atomics, analyzer); - // } - // } - // } - // check if the new range is dependent on the solved variable let is_dependent_on_solved = new_range .dependent_on(analyzer, arena) @@ -818,17 +768,6 @@ impl SolcSolver for BruteBinSearchSolver { continue; } - // println!("new range for {} dependent_on: {:?}, replacing {:?}, is dependent on solved: {is_dependent_on_solved}", dep.display_name(analyzer).unwrap(), new_range.dependent_on(), solved_dep.idxs); - // println!("dep {}:\n\tinitial range: [{}, {}],\n\tcurr range: [{}, {}]", - // dep.display_name(analyzer).unwrap(), - // dep.evaled_range_min(analyzer, arena)?.unwrap().to_range_string(false, analyzer, arena).s, - // dep.evaled_range_max(analyzer, arena)?.unwrap().to_range_string(true, analyzer, arena).s, - // new_range.evaled_range_min(analyzer, arena)?.to_range_string(false, analyzer, arena).s, - // new_range.evaled_range_max(analyzer, arena)?.to_range_string(true, analyzer, arena).s, - // // new_range.range_min() - // ); - - // println!("dep {} range: {:#?} {:#?}", dep.display_name(analyzer).unwrap(), new_range.min, new_range.max); if new_range.unsat(analyzer, arena) { return Ok((false, None)); // panic!("initial range unsat???") @@ -842,43 +781,14 @@ impl SolcSolver for BruteBinSearchSolver { }); new_range.cache_eval(analyzer, arena)?; - // println!("new range: [{}, {}], [{}, {}]", - // new_range.evaled_range_min(analyzer, arena)?.to_range_string(false, analyzer, arena).s, - // new_range.evaled_range_max(analyzer, arena)?.to_range_string(true, analyzer, arena).s, - // new_range.min.to_range_string(false, analyzer, arena).s, - // new_range.max.to_range_string(true, analyzer, arena).s, - // ); if new_range.unsat(analyzer, arena) { // figure out *where* we need to increase or decrease // work on the unreplace range for now let min_is_dependent = !range.min.dependent_on(analyzer, arena).is_empty(); let max_is_dependent = !range.max.dependent_on(analyzer, arena).is_empty(); - match (min_is_dependent, max_is_dependent) { - (true, true) => { - // both sides dependent - // println!("both"); - } - (false, true) => { - // just max is dependent - // println!("just max"); - } - (true, false) => { - // just min is dependent - // println!("just min"); - } - (false, false) => { - // panic!("this shouldnt happen"); - } - } - - // println!("new unsat range: [{}, {}]", - // new_range.evaled_range_min(analyzer, arena)?.to_range_string(false, analyzer, arena).s, - // new_range.evaled_range_max(analyzer, arena)?.to_range_string(true, analyzer, arena).s, - // ); // compare new range to prev range to see if they moved down or up - // panic!("here"); let min_change = new_range .evaled_range_min(analyzer, arena)? .range_ord(&range.evaled_range_min(analyzer, arena)?, arena); @@ -891,28 +801,18 @@ impl SolcSolver for BruteBinSearchSolver { } (Some(std::cmp::Ordering::Greater), Some(std::cmp::Ordering::Less)) => { // we shrank our range, dont give a hint - // println!("None, dep isnt sat: {}, dep initial range: {}", dep.display_name(analyzer).unwrap(), dep.range_string(analyzer).unwrap().unwrap()); return Ok((false, None)); } (Some(std::cmp::Ordering::Greater), _) => { // both grew, try lowering - // println!("Lower, dep isnt sat: {}, dep initial range: {}", dep.display_name(analyzer).unwrap(), dep.range_string(analyzer).unwrap().unwrap()); return Ok((false, Some(HintOrRanges::Lower))); } (Some(std::cmp::Ordering::Less), _) => { // both grew, try lowering - // println!("Higher, dep isnt sat: {}, dep initial range: {}", dep.display_name(analyzer).unwrap(), dep.range_string(analyzer).unwrap().unwrap()); return Ok((false, Some(HintOrRanges::Higher))); } - // (Some(std::cmp::Ordering::Equal), _) => { - // panic!("here"); - // } - // (_, Some(std::cmp::Ordering::Equal)) => { - // panic!("here"); - // } _ => { - // println!("None empty, dep isnt sat: {}, dep initial range: {}", dep.display_name(analyzer).unwrap(), dep.range_string(analyzer).unwrap().unwrap()); return Ok((false, None)); } } diff --git a/crates/pyrometer/src/analyzer.rs b/crates/pyrometer/src/analyzer.rs index 34fa1c33..82665d06 100644 --- a/crates/pyrometer/src/analyzer.rs +++ b/crates/pyrometer/src/analyzer.rs @@ -1148,7 +1148,6 @@ impl Analyzer { }) .copied() .collect(); - println!("relevant_funcs: {relevant_funcs:#?}"); if matches!(self.node(scope_node), Node::Contract(_)) { self.add_edge( scope_node, @@ -1158,7 +1157,6 @@ impl Analyzer { } relevant_funcs.iter().for_each(|func| { - println!("connecting: {:#?}, {:#?}", self.node(ty_idx), func); self.add_edge(ty_idx, *func, Edge::LibraryFunction(scope_node)); }); break; diff --git a/crates/pyrometer/src/analyzer_backend.rs b/crates/pyrometer/src/analyzer_backend.rs index 6ed9b309..7249e37a 100644 --- a/crates/pyrometer/src/analyzer_backend.rs +++ b/crates/pyrometer/src/analyzer_backend.rs @@ -82,14 +82,6 @@ impl AnalyzerLike for Analyzer { needed_functions.sort_by(|a, b| a.0.cmp(&b.0)); needed_functions.dedup(); - println!( - "needed functions: {:#?}", - needed_functions - .iter() - .map(|i| i.name(self).unwrap()) - .collect::>() - ); - fn recurse_find( contract: ContractNode, target_contract: ContractNode, @@ -123,7 +115,6 @@ impl AnalyzerLike for Analyzer { let mut structs = vec![]; let mut errs = vec![]; needed_functions.into_iter().for_each(|func| { - println!("iterating with func: {}", func.name(self).unwrap()); let maybe_func_contract = func.maybe_associated_contract(self); let reqs = func.reconstruction_requirements(self); reqs.usertypes.iter().for_each(|var| { @@ -174,8 +165,6 @@ impl AnalyzerLike for Analyzer { entry.push((func, reqs)); }); - // println!("{:#?}", contract_to_funcs); - let contracts = contract_to_funcs.keys().collect::>(); let contract_str = contracts .iter() @@ -251,7 +240,6 @@ impl AnalyzerLike for Analyzer { Node::Context(context) if context.killed.is_some() => { match context.killed.unwrap() { (_, KilledKind::ParseError) => { - // println!("found context: {}", context.path); let edges = graph::nodes::ContextNode::from(node) .all_edges(self) .unwrap(); @@ -272,7 +260,6 @@ impl AnalyzerLike for Analyzer { .unwrap(); let min_str = self.minimize_err(reconstruction_edge); - // println!("reconstructed source:\n{} placed in {}", min_str, path); let mut file = std::fs::OpenOptions::new() .write(true) @@ -356,7 +343,6 @@ impl AnalyzerLike for Analyzer { } } Variable(ident) => { - // println!("variable ident: {}", ident.name); if let Some(idxs) = self.user_types.get(&ident.name) { if idxs.len() == 1 { idxs[0] diff --git a/crates/pyrometer/src/graph_backend.rs b/crates/pyrometer/src/graph_backend.rs index af02c016..d9e79fa1 100644 --- a/crates/pyrometer/src/graph_backend.rs +++ b/crates/pyrometer/src/graph_backend.rs @@ -169,7 +169,6 @@ impl TryFrom<&RangeArena>> for Elems { for elem in &arena.ranges { // Get the map value if let Some(map_value) = arena.map.get(elem).copied() { - // println!("Adding idx {} to elems {}", map_value, elem); inner.push((map_value, elem.clone())); } else { // println!("NONE REF elem: {:?}", elem); @@ -211,11 +210,6 @@ impl TryFrom<&RangeArena>> for Elems { // dedup is needed as there are duplicate indices in the inner vec. TODO @brock is this a bug? arena has duplicate elems inner.dedup(); - // Print out elems - // for (idx, elem) in inner.iter() { - // println!("elem {}: {}", idx, elem); - // } - Ok(Elems { inner }) } } @@ -304,7 +298,6 @@ impl Elems { let lhs_arena = match *range_expr.lhs.clone() { Elem::Arena(lhs) => Some(lhs), Elem::Reference(_lhs) => { - // println!("LHS is a reference: {}", range_expr.lhs); // attempt to add in the ContextVar node that the elem is referencing let context_var_nodes = elem .dependent_on(graph_backend, arena) @@ -332,12 +325,8 @@ impl Elems { _ => None, }; let rhs_arena = match *range_expr.rhs.clone() { - Elem::Arena(rhs) => { - // println!("RHS is an arena index: {}", range_expr.rhs); - Some(rhs) - } + Elem::Arena(rhs) => Some(rhs), Elem::Reference(_rhs) => { - // println!("RHS is a reference: {}", range_expr.rhs); // attempt to add in the ContextVar node that the elem is referencing let context_var_nodes = elem .dependent_on(graph_backend, arena) @@ -398,16 +387,12 @@ impl Elems { // THIRD PASS - iterate over ContextVarNodes // iterate over the dependency map and add edges between the ContextVar nodes and the arena nodes - // println!("dependency map: {:?}", dependency_map); for (cvar_node, &node_idx) in dependency_map.iter() { - // println!("cvar node: {:?}, node idx: {:?}", cvar_node, node_idx); // Find the appropriate arena_idx for range.min and range.max using Elems.inner if let Ok(Some(range_min)) = cvar_node.range_min(graph_backend) { - // println!(" range min: {:?}", range_min); match range_min { Elem::Arena(arena_idx) => { // Make a direct edge to the arena node - // println!(" arena idx: {}", arena_idx); if let Some(&min_node_idx) = arena_idx_to_node_idx.get(&arena_idx) { graph.add_edge(node_idx, min_node_idx, ArenaEdge::MIN); } @@ -421,9 +406,7 @@ impl Elems { .map(|(idx, _)| *idx); // Add edges to the min arena indices if let Some(min_idx) = min_arena_idx { - // println!(" min idx: {:?}", min_idx); if let Some(&min_node_idx) = arena_idx_to_node_idx.get(&min_idx) { - // println!(" min node idx: {:?}", min_node_idx); graph.add_edge(node_idx, min_node_idx, ArenaEdge::MIN); } } @@ -432,11 +415,9 @@ impl Elems { } if let Ok(Some(range_max)) = cvar_node.range_max(graph_backend) { - // println!(" range max: {:?}", range_max); match range_max { Elem::Arena(arena_idx) => { // Make a direct edge to the arena node - // println!(" arena idx: {}", arena_idx); if let Some(&max_node_idx) = arena_idx_to_node_idx.get(&arena_idx) { graph.add_edge(node_idx, max_node_idx, ArenaEdge::MAX); } @@ -450,9 +431,7 @@ impl Elems { .map(|(idx, _)| *idx); // Add edges to the min arena indices if let Some(max_idx) = max_arena_idx { - // println!(" max idx: {:?}", max_idx); if let Some(&max_node_idx) = arena_idx_to_node_idx.get(&max_idx) { - // println!(" max node idx: {:?}", max_node_idx); graph.add_edge(node_idx, max_node_idx, ArenaEdge::MAX); } } diff --git a/crates/solc-expressions/src/assign.rs b/crates/solc-expressions/src/assign.rs index f3537300..98ba8dd8 100644 --- a/crates/solc-expressions/src/assign.rs +++ b/crates/solc-expressions/src/assign.rs @@ -98,12 +98,6 @@ pub trait Assign: AnalyzerBackend + Sized lhs_cvar.display_name(self).unwrap(), ); - println!( - "{:?} = {:?}", - lhs_cvar.ty(self).unwrap(), - rhs_cvar.ty(self).unwrap() - ); - if lhs_cvar.is_struct(self).into_expr_err(loc)? && rhs_cvar.is_struct(self).into_expr_err(loc)? { diff --git a/crates/solc-expressions/src/literal.rs b/crates/solc-expressions/src/literal.rs index 64e8f510..85d3f20c 100644 --- a/crates/solc-expressions/src/literal.rs +++ b/crates/solc-expressions/src/literal.rs @@ -999,7 +999,6 @@ mod tests { let cvar_node = ContextVarNode::from(stack[0].expect_single()?); assert!(cvar_node.is_const(&analyzer, arena)?); let min = cvar_node.evaled_range_min(&analyzer, arena)?.unwrap(); - println!("{min}"); let conc_value = min.maybe_concrete().unwrap().val; assert!( conc_value == expected, diff --git a/crates/solc-expressions/src/member_access/builtin_access.rs b/crates/solc-expressions/src/member_access/builtin_access.rs index 6bc7c455..fc2f175d 100644 --- a/crates/solc-expressions/src/member_access/builtin_access.rs +++ b/crates/solc-expressions/src/member_access/builtin_access.rs @@ -115,7 +115,6 @@ pub trait BuiltinAccess: num_inputs: usize, is_storage: bool, ) -> Result, GraphError> { - println!("name: {name}"); match node.underlying(self)?.clone() { Builtin::Address | Builtin::AddressPayable | Builtin::Payable => { match name { @@ -123,10 +122,8 @@ pub trait BuiltinAccess: // TODO: check if the address is known to be a certain type and the function signature is known // and call into the function let builtin_name = name.split('(').collect::>()[0]; - println!("here"); let func_node = FunctionNode::from(self.builtin_fn_or_maybe_add(builtin_name).unwrap()); - println!("func name: {}", func_node.name(self).unwrap()); Ok(Some((func_node, true))) } _ => Ok(None), @@ -333,7 +330,6 @@ pub trait BuiltinAccess: let underlying_mut = func_node.underlying_mut(self)?; let name = underlying_mut.name.as_mut().unwrap(); let full_name = format!("{}({})", name, params_strs.join(", ")); - println!("full name: {full_name}"); name.name.clone_from(&full_name); self.add_edge(func_node, self.entry(), Edge::Func); @@ -352,7 +348,6 @@ pub trait BuiltinAccess: is_storage: bool, loc: Loc, ) -> Result<(ExprRet, bool), ExprErr> { - println!("name: {name}"); match node.underlying(self).into_expr_err(loc)?.clone() { Builtin::Address | Builtin::AddressPayable | Builtin::Payable => { match name { @@ -361,10 +356,6 @@ pub trait BuiltinAccess: // and call into the function let builtin_name = name.split('(').collect::>()[0]; let func_node = self.builtin_fn_or_maybe_add(builtin_name).unwrap(); - println!( - "added address lib func: {}", - FunctionNode::from(func_node).name(self).unwrap() - ); Ok((ExprRet::Single(func_node), true)) } "codehash" => { diff --git a/crates/solc-expressions/src/member_access/library_access.rs b/crates/solc-expressions/src/member_access/library_access.rs index c74c1703..69039b7e 100644 --- a/crates/solc-expressions/src/member_access/library_access.rs +++ b/crates/solc-expressions/src/member_access/library_access.rs @@ -23,7 +23,6 @@ pub trait LibraryAccess: AnalyzerBackend + self.possible_library_funcs(ctx, ty) .iter() .filter_map(|func| { - println!("func: {:?}", func.name(self).unwrap()); if let Ok(name) = func.name(self) { Some((name, func)) } else { diff --git a/crates/solc-expressions/src/variable.rs b/crates/solc-expressions/src/variable.rs index e187f882..7564a86f 100644 --- a/crates/solc-expressions/src/variable.rs +++ b/crates/solc-expressions/src/variable.rs @@ -472,13 +472,10 @@ pub trait Variable: AnalyzerBackend + Size .all(|e| *e)) } } - (e, f) => { - println!("{e:?}, {f:?}"); - Err(ExprErr::Todo( - loc, - "Unhandled ExprRet combination in `match_var_def`".to_string(), - )) - } + (e, f) => Err(ExprErr::Todo( + loc, + "Unhandled ExprRet combination in `match_var_def`".to_string(), + )), } }