From 09f482400c474ab02c29b93462b8df905dfefd1c Mon Sep 17 00:00:00 2001 From: brock elmore Date: Wed, 10 Jul 2024 16:41:13 -0700 Subject: [PATCH] tiny fixes --- crates/graph/src/nodes/context/variables.rs | 8 -- crates/solc-expressions/src/variable.rs | 1 - mini.sol | 130 -------------------- 3 files changed, 139 deletions(-) delete mode 100644 mini.sol diff --git a/crates/graph/src/nodes/context/variables.rs b/crates/graph/src/nodes/context/variables.rs index 8a68882e..ff27c40f 100644 --- a/crates/graph/src/nodes/context/variables.rs +++ b/crates/graph/src/nodes/context/variables.rs @@ -135,7 +135,6 @@ impl ContextNode { return Ok(None); }; - println!("name: {full_name}"); // maybe move var into this context let member = self.maybe_move_var(member, loc, analyzer)?; let global_first = member.global_first_version(analyzer); @@ -144,7 +143,6 @@ impl ContextNode { let mut field = None; // recursively search for the field by looking at all major versions of the member (i.e. first version // of the variable in a context) - println!("getting field {field_name}"); while field.is_none() && curr != global_first { field = curr.field_of_struct(field_name, analyzer)?; if let Some(prev) = curr.previous_or_inherited_version(analyzer) { @@ -155,13 +153,7 @@ impl ContextNode { } if let Some(field) = field { - println!("found field"); if let Some(ctx) = curr.maybe_ctx(analyzer) { - println!( - "had context: {}, self: {}", - ctx.path(analyzer), - self.path(analyzer) - ); if ctx != *self { tracing::trace!( "moving field access {} from {} to {}", diff --git a/crates/solc-expressions/src/variable.rs b/crates/solc-expressions/src/variable.rs index e7ce1b37..59bf4972 100644 --- a/crates/solc-expressions/src/variable.rs +++ b/crates/solc-expressions/src/variable.rs @@ -114,7 +114,6 @@ pub trait Variable: AnalyzerBackend + Size } else { None }; - println!("{:?} const var: {const_var:?}", self.node(idx)); let var = if let Some(con) = const_var { con diff --git a/mini.sol b/mini.sol deleted file mode 100644 index f10dff26..00000000 --- a/mini.sol +++ /dev/null @@ -1,130 +0,0 @@ -contract ComptrollerErrorReporter { - enum Error { - NO_ERROR, - UNAUTHORIZED, - COMPTROLLER_MISMATCH, - INSUFFICIENT_SHORTFALL, - INSUFFICIENT_LIQUIDITY, - INVALID_CLOSE_FACTOR, - INVALID_COLLATERAL_FACTOR, - INVALID_LIQUIDATION_INCENTIVE, - MARKET_NOT_ENTERED, // no longer possible - MARKET_NOT_LISTED, - MARKET_ALREADY_LISTED, - MATH_ERROR, - NONZERO_BORROW_BALANCE, - PRICE_ERROR, - REJECTION, - SNAPSHOT_ERROR, - TOO_MANY_ASSETS, - TOO_MUCH_REPAY - } - - enum FailureInfo { - ACCEPT_ADMIN_PENDING_ADMIN_CHECK, - ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK, - EXIT_MARKET_BALANCE_OWED, - EXIT_MARKET_REJECTION, - SET_CLOSE_FACTOR_OWNER_CHECK, - SET_CLOSE_FACTOR_VALIDATION, - SET_COLLATERAL_FACTOR_OWNER_CHECK, - SET_COLLATERAL_FACTOR_NO_EXISTS, - SET_COLLATERAL_FACTOR_VALIDATION, - SET_COLLATERAL_FACTOR_WITHOUT_PRICE, - SET_IMPLEMENTATION_OWNER_CHECK, - SET_LIQUIDATION_INCENTIVE_OWNER_CHECK, - SET_LIQUIDATION_INCENTIVE_VALIDATION, - SET_MAX_ASSETS_OWNER_CHECK, - SET_PENDING_ADMIN_OWNER_CHECK, - SET_PENDING_IMPLEMENTATION_OWNER_CHECK, - SET_PRICE_ORACLE_OWNER_CHECK, - SUPPORT_MARKET_EXISTS, - SUPPORT_MARKET_OWNER_CHECK, - SET_PAUSE_GUARDIAN_OWNER_CHECK - } - - function fail(Error err, FailureInfo info) internal returns (uint256) { - emit Failure(uint256(err), uint256(info), 0); - - return uint256(err); - } -} - -contract CTokenStorage { - address payable public admin; -} - -contract ExponentialNoError { - struct Exp { - uint256 mantissa; - } - - function lessThanExp(Exp memory left, Exp memory right) internal pure returns (bool) { - return left.mantissa < right.mantissa; - } -} - -abstract contract CToken is ExponentialNoError {} - -contract UnitrollerAdminStorage { - address public admin; -} - -contract ComptrollerV1Storage is UnitrollerAdminStorage {} - -contract ComptrollerV2Storage is ComptrollerV1Storage { - struct Market { - // Whether or not this market is listed - bool isListed; - // Multiplier representing the most one can borrow against their collateral in this market. - // For instance, 0.9 to allow borrowing 90% of collateral value. - // Must be between 0 and 1, and stored as a mantissa. - uint256 collateralFactorMantissa; - // Per-market mapping of "accounts in this asset" - mapping(address => bool) accountMembership; - // Whether or not this market receives COMP - bool isComped; - } - - mapping(address => Market) public markets; -} - -contract ComptrollerV3Storage is ComptrollerV2Storage {} - -contract ComptrollerV4Storage is ComptrollerV3Storage {} - -contract ComptrollerV5Storage is ComptrollerV4Storage {} - -contract ComptrollerV6Storage is ComptrollerV5Storage {} - -contract ComptrollerV7Storage is ComptrollerV6Storage {} - -contract Comptroller is ComptrollerV7Storage, ComptrollerErrorReporter, ExponentialNoError { - uint256 internal constant collateralFactorMaxMantissa = 0.9e18; - - function _setCollateralFactor(CToken cToken, uint256 newCollateralFactorMantissa) external returns (uint256) { - // Check caller is admin - // if (msg.sender != admin) { - // return fail(Error.UNAUTHORIZED, FailureInfo.SET_COLLATERAL_FACTOR_OWNER_CHECK); - // } - - // // Verify market is listed - // Market storage market = markets[address(cToken)]; - // if (!market.isListed) { - // return fail(Error.MARKET_NOT_LISTED, FailureInfo.SET_COLLATERAL_FACTOR_NO_EXISTS); - // } - - Exp memory newCollateralFactorExp = Exp({mantissa: newCollateralFactorMantissa}); - - // Check collateral factor <= 0.9 - Exp memory highLimit = Exp({mantissa: collateralFactorMaxMantissa}); - bool t = lessThanExp(highLimit, newCollateralFactorExp); - if (t) { - return 1; - // return fail(Error.INVALID_COLLATERAL_FACTOR, FailureInfo.SET_COLLATERAL_FACTOR_VALIDATION); - } else { - return 0; - } - - } -}