Skip to main content Module reentrancy Copy item path Source use super::ReentrancyEth ; π use crate::linter::LateLintPass ; π use crate::linter::LintContext ; π use crate::sol::Severity ; π use crate::sol::SolLint ; π use crate::sol::analysis::DEFAULT_HELPER_ANALYSIS_CACHE_LIMIT ; π use crate::sol::analysis::HelperAnalysisCache ; π use crate::sol::analysis::arg_for_param ; π use crate::sol::analysis::branch_always_exits ; π use crate::sol::analysis::cast_type ; π use crate::sol::analysis::count_placeholders ; π use crate::sol::analysis::expr_is_address ; π use crate::sol::analysis::for_each_child ; π use crate::sol::analysis::for_each_lhs_var ; π use crate::sol::analysis::is_address_cast ; π use crate::sol::analysis::is_builtin ; π use crate::sol::analysis::is_require_or_assert ; π use crate::sol::analysis::lhs_local_var ; π use crate::sol::analysis::loop_update ; π use crate::sol::analysis::state_lhs_vars ; π use crate::sol::analysis::stmts_before_placeholder ; π use crate::sol::analysis::tuple_elems ; π use alloy_primitives::U256; π use solar::ast::BinOpKind; π use solar::ast::FunctionKind; π use solar::ast::LitKind; π use solar::ast::StateMutability; π use solar::ast::UnOpKind; π use solar::ast::Visibility; π use solar::interface::Span; π use solar::interface::Symbol; π use solar::interface::data_structures::Never; π use solar::interface::kw; π use solar::interface::sym; π use solar::sema::Gcx; π use solar::sema::builtins::Builtin; π use solar::sema::hir; π use solar::sema::hir::CallArgs; π use solar::sema::hir::CallOptions; π use solar::sema::hir::Expr; π use solar::sema::hir::ExprKind; π use solar::sema::hir::FunctionId; π use solar::sema::hir::ItemId; π use solar::sema::hir::LoopSource; π use solar::sema::hir::Stmt; π use solar::sema::hir::StmtKind; π use solar::sema::hir::VariableId; π use solar::sema::hir::Visit; π use solar::sema::ty::TyFnKind; π use solar::sema::ty::TyKind; π use std::collections::BTreeMap ; π use std::collections::BTreeSet ; π use std::collections::HashMap ; π use std::collections::HashSet ; π use std::ops::ControlFlow ; π Analyzer π BalanceForm π A supported additive source pattern on one path. An empty term list is balance-independent.
At most two balance terms are retained: a stale/current comparison needs one of each. More
terms are rejected rather than cancelled, since Solidity arithmetic may wrap or revert. BalanceTerm π One signed balance read, retaining the calls across which it was cached. BalanceValue π Balance-related facts about a value flowing into a local, parameter or return slot. CallCollector π Collects the internal functions and modifiers a function invokes directly. FlowState π Facts that hold along one execution path. InlineCallKey π Operand π A local variable or constant appearing in a predicate or lock expression. PathPredicate π ReentrantCallKind π REENTRANCY_GAS_STIPEND π Gas stipend forwarded by transfer/send; a call capped at or below it cannot reenter. REENTRANCY_BALANCE REENTRANCY_ETH REENTRANCY_NO_ETH balance_reentry_lock π The reentrancy-guard lock, if any, that protects every entry point of every deployable
contract exposing entry. branch_stops_current_path π break/continue or anything that exits the function, so the current path stops here.call_option π call_options_allow_reentrancy π True unless a gas: option provably leaves the callee too little gas to reenter. call_sends_eth π call_uses_delegate_context π delegatecall/callcode, which run the callee in the callerβs storage context.callee_can_reenter π An external call that hands control to another contract: a low-level call/callcode/
delegatecall on an address, or a state-changing external function call. cast_args π Arguments of a plain type conversion such as uint256(x) or address(x). collect_internal_calls π common_path_predicates π const_value π Constant-folds expr over literals, constant variables, casts, ! and ==/!=; lock
supplies the value of the lock variable. constrain_boolean_outcome π Records in state that expr evaluated to outcome; returns false if that is impossible. constrain_paths π Keeps the paths compatible with active, extended by the active predicates. forget_path_predicates π Drops every path fact that mentions the (re)assigned local var_id. guard_activation π The lock and value set by the last of stmts (directly or via an argument-less helper), if
an earlier statement rejects that value. guard_locks π Locks of the standard reentrancy guards among functionβs modifiers. guard_restoration π The lock and value restored by stmt (directly or via a single-statement helper). is_entry_point π Non-view functions an external caller can invoke: public/external functions, fallback and
receive. is_uncapped_value_call π .call{value: v}(...) with a non-zero value and no gas cap other than gasleft().is_view_or_pure π is_zero_value π join_branches π Replaces state with the union of the reachable branches, keeping only the path predicates
all of them agree on. Returns whether any branch was reachable. merge_maps π owned_by π The variables of func_id. path_predicate π The boolean fact expr establishes when it evaluates to true: a local flag, its negation,
or an ==/!= between locals and literals. paths_compatible π predicate_operand π reaches_balance_read π Whether entry, or a modifier or internal function it can reach, reads a .balance. remap_return_paths π Rewrites the callee-local predicates in the returned values into the callerβs terms. simple_internal_call π f(); naming exactly one function.standard_reentrancy_guard_lock π The lock state variable of a standard reentrancy guard modifier: it rejects re-entry, sets
the lock, runs _ exactly once and restores the lock right after. state_lock_assignment π lock = <constant>; on a state variable.static_internal_callee π Internal function statically named by callee: a bare identifier or super.f. stmt_rejects_lock_value π True if stmt reverts whenever lock_var holds entered. take_inert_locals π Takes out the balance forms and dependencies that are balance-independent and belong to locals
of functions other than func_id, whose paths do not mention func_idβs locals. ModifierContinuation π What to analyse when a modifierβs _ is reached: the remaining modifiers, the function body
and the reentrancy-guard lock the current modifier holds. PathAlternatives π PathPredicates π