Module utils

Module utils 

Source
Expand description

Utility functions and helpers for the EDB engine.

This module provides a collection of utility functions and helper modules that support various aspects of the EDB debugging engine. These utilities handle common tasks across contract analysis, compilation, source code processing, and external service integration.

§Core Utility Modules

§Contract and Artifact Management

  • [artifact] - Contract artifact handling and metadata management
  • [compilation] - Solidity compilation utilities and configuration
  • [abi] - ABI processing and type conversion utilities

§Source Code Processing

  • [source] - Source code analysis and manipulation utilities
  • [ast_prune] - AST pruning and optimization for instrumentation

§Bytecode Analysis

  • disasm - EVM bytecode disassembly and analysis utilities

§External Service Integration

  • [etherscan] - Etherscan API integration and data fetching utilities

§Design Philosophy

The utilities in this module are designed to be:

  • Reusable: Common functionality shared across multiple engine components
  • Efficient: Optimized for performance in debugging scenarios
  • Reliable: Robust error handling and edge case management
  • Modular: Independent modules that can be used separately

Each utility module focuses on a specific domain while providing clean interfaces for integration with the broader EDB engine ecosystem.

Re-exports§

pub use disasm::*;

Modules§

disasm
EVM bytecode disassembly utilities

Macros§

etherscan_rate_limit_guard
Automaticall pause the request if the rate limit is reached and resume it after the rate limit is reset.

Structs§

ASTPruner
We prune the AST to remove or refine nodes that are not strongly related to analysis. We do this because the Solidity compiler has changed the AST structure over time, but we want to maintain a consistently parsable AST structure for debugging purposes.
Artifact
Compiled contract artifact with comprehensive metadata and compilation data.
OnchainCompiler
Onchain compiler.

Functions§

abi_encode_available
Check if the abi.encode function (which is available since solidity 0.4.24) is available in the given version requirement.
compile_contract_source_to_source_unit
Compile a string as Solidity source code to a SourceUnit
contains_function_type
Check recursively if the type name contains a function type.
contains_mapping_type
Check recursively if the type name contains a mapping type.
contains_user_defined_type
Check recursively if the type name contains a user defined type or a function type.
encode_function_call
Encode a text-form function call to bytes using the provided function ABI
find_index_of_first_statement_in_block
Find the index of the first statement in the Block.
find_index_of_first_statement_in_block_or_statement
Find the index of the first statement in the BlockOrStatement.
find_next_index_of_block_or_statement
Find the index of the next character immediately after the BlockOrStatement.
find_next_index_of_last_statement_in_block
Find the index of the next character immediately after the last statement in the Block.
find_next_index_of_source_location
Find the index of the next character immediately after the source location.
find_next_index_of_statement
Find the index of the next character immediately after the Statement.
find_next_semicolon_after_source_location
Find the next semicolon after the source location.
get_compilation_input_from_metadata
Prepare the input for solc using metadate downloaded from Etherscan.
mutability_to_str
Convert the mutability to a string.
next_etherscan_api_key
Returns the next Etherscan API key to use from the rotation pool.
slice_source_location
Slice the source location.
source_string_at_location
Get the source string at the given location.
source_string_at_location_unchecked
Get the source string at the given location.
visibility_to_str
Convert the visibility to a string.