Expand description
§Storage Access Analysis Module
This module provides functionality to analyze a CallGraph
and determine
which storage variables are read or written by each public or external
entry point function within the analyzed contracts.
§Core Functionality
The main entry point is the analyze_storage_access
function. It performs
the following steps:
-
Identifies Entry Points: It uses
ReachabilityAnalyzer
to find all functions marked aspublic
orexternal
that are not part of an interface definition. These serve as the starting points for the analysis. -
Call Graph Traversal: For each identified entry point, it traverses the call graph using a Depth-First Search (DFS) approach, following
Call
edges. -
Storage Interaction Processing: When a function, modifier, or constructor node is visited during the DFS traversal, this module inspects its direct outgoing edges. If these edges are of type
StorageRead
orStorageWrite
and target aStorageVariable
node, the ID of the storage variable is recorded. -
Aggregation: The read and write accesses are aggregated into a
StorageAccessSummary
for each entry point. This summary contains twoHashSet
s: one for the NodeIds of storage variables read, and one for those written.
§Output
The analyze_storage_access
function returns a HashMap
where the keys are
the NodeId
s of the entry point functions, and the values are their
corresponding StorageAccessSummary
objects.
This information is crucial for understanding the storage footprint and side effects of different functions in a smart contract system.