Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
brockelmore committed Dec 9, 2023
1 parent 486b3dc commit 450dc5b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
6 changes: 5 additions & 1 deletion crates/graph/src/nodes/context/solving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ impl ContextNode {
dep: ContextVarNode,
analyzer: &mut (impl GraphBackend + AnalyzerBackend),
) -> Result<(), GraphError> {
tracing::trace!("Adding ctx dependency: {}, is_controllable: {}", dep.display_name(analyzer)?, dep.is_controllable(analyzer)?);
tracing::trace!(
"Adding ctx dependency: {}, is_controllable: {}",
dep.display_name(analyzer)?,
dep.is_controllable(analyzer)?
);
if dep.is_controllable(analyzer)? {
let range = dep.ref_range(analyzer)?.unwrap();
let r = range.into_flattened_range(analyzer)?;
Expand Down
22 changes: 11 additions & 11 deletions crates/graph/src/nodes/context/var/typing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ impl ContextVarNode {
Ok(global_first.is_storage(analyzer)? || global_first.is_calldata_input(analyzer))
}

pub fn is_fundamental(
&self,
analyzer: &impl GraphBackend,
) -> Result<bool, GraphError> {
pub fn is_fundamental(&self, analyzer: &impl GraphBackend) -> Result<bool, GraphError> {
let global_first = self.global_first_version(analyzer);
let is_independent = self.is_independent(analyzer)?;

Expand All @@ -86,13 +83,16 @@ impl ContextVarNode {
}

pub fn is_controllable(&self, analyzer: &impl GraphBackend) -> Result<bool, GraphError> {
Ok(self.dependent_on(analyzer, true)?.iter().any(|dependent_on| {
if let Ok(t) = dependent_on.is_fundamental(analyzer) {
t
} else {
false
}
}))
Ok(self
.dependent_on(analyzer, true)?
.iter()
.any(|dependent_on| {
if let Ok(t) = dependent_on.is_fundamental(analyzer) {
t
} else {
false
}
}))
}

pub fn is_calldata_input(&self, analyzer: &impl GraphBackend) -> bool {
Expand Down
22 changes: 11 additions & 11 deletions crates/graph/src/range/exec/exec_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,17 @@ impl ExecOp<Concrete> for RangeExpr<Concrete> {
// contains the rhs, we can add zero. Futher more, if
// the lhs contains rhs - 1, we can add max as it
// would overflow to uint256.max
// zero min max uint256.max
// zero min max uint256.max
// lhs: | - - |----------------------------| - - |
// rhs: | - - |--| - - - - - - - - - - - - - - - |
// rhs: | - - |--| - - - - - - - - - - - - - - - |
match lhs_max.range_ord(&rhs_min) {
Some(std::cmp::Ordering::Less) => {
// We are going to overflow, zero not possible
}
Some(std::cmp::Ordering::Equal) => {
// We are going to at least be zero,
// we may overflow. check if rhs is const, otherwise
// add uint256.max as a candidate
// add uint256.max as a candidate
candidates.push(Some(zero.clone()));
if !consts.1 {
candidates.push(zero.range_wrapping_sub(&one));
Expand All @@ -254,21 +254,21 @@ impl ExecOp<Concrete> for RangeExpr<Concrete> {
Some(std::cmp::Ordering::Equal) => {
// We are going to at least be zero,
// we may overflow. check if rhs is const, otherwise
// add uint256.max as a candidate
// add uint256.max as a candidate
candidates.push(Some(zero.clone()));
if !consts.1 {
candidates.push(zero.range_wrapping_sub(&one));
}
}
Some(std::cmp::Ordering::Greater) => {
// current info:
// zero min max uint256.max
// zero min max uint256.max
// lhs: | - - |----------------------------| - - |
// rhs: | - |----? - - - - - - - - - - - - - - - |
// figure out where rhs max is
match lhs_min.range_ord(&rhs_max) {
Some(std::cmp::Ordering::Less) => {
// zero min
// zero min
// lhs: | - - |---?
// rhs: | - |----|
// min max
Expand All @@ -277,21 +277,21 @@ impl ExecOp<Concrete> for RangeExpr<Concrete> {
candidates.push(zero.range_wrapping_sub(&one));
}
Some(std::cmp::Ordering::Equal) => {
// zero min
// zero min
// lhs: | - - |---?
// rhs: | |---|
// min max
// Add zero
candidates.push(Some(zero.clone()));
candidates.push(Some(zero.clone()));
}
Some(std::cmp::Ordering::Greater) => {
// zero min
// zero min
// lhs: | - - |---?
// rhs: |-----|
// min max
// Add nothing
}
_ => {}
}
_ => {}
}
}
_ => {}
Expand Down
3 changes: 2 additions & 1 deletion crates/solc-expressions/src/context_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,8 @@ pub trait ContextBuilder:
);

let new_lhs = self.advance_var_in_ctx(lhs_cvar.latest_version(self), loc, ctx)?;
new_lhs.underlying_mut(self).into_expr_err(loc)?.tmp_of = rhs_cvar.tmp_of(self).into_expr_err(loc)?;
new_lhs.underlying_mut(self).into_expr_err(loc)?.tmp_of =
rhs_cvar.tmp_of(self).into_expr_err(loc)?;
if lhs_cvar.is_storage(self).into_expr_err(loc)? {
self.add_edge(new_lhs, rhs_cvar, Edge::Context(ContextEdge::StorageWrite));
}
Expand Down

0 comments on commit 450dc5b

Please sign in to comment.