Module storage_access

Module storage_access 

Source
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:

  1. Identifies Entry Points: It uses ReachabilityAnalyzer to find all functions marked as public or external that are not part of an interface definition. These serve as the starting points for the analysis.

  2. Call Graph Traversal: For each identified entry point, it traverses the call graph using a Depth-First Search (DFS) approach, following Call edges.

  3. 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 or StorageWrite and target a StorageVariable node, the ID of the storage variable is recorded.

  4. Aggregation: The read and write accesses are aggregated into a StorageAccessSummary for each entry point. This summary contains two HashSets: 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 NodeIds 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.

Structs§

StorageAccessSummary

Functions§

analyze_storage_access