Expand description
Contract bytecode modification for debugging through creation transaction replay.
This module provides the CodeTweaker utility for modifying deployed contract bytecode
by replaying their creation transactions with replacement init code. This enables debugging
with instrumented or modified contracts without requiring redeployment to the network.
§Core Functionality
§Contract Bytecode Replacement
The CodeTweaker handles the complete process of:
- Creation Transaction Discovery: Finding the original deployment transaction
- Transaction Replay: Re-executing the creation with modified init code
- Bytecode Extraction: Capturing the resulting runtime bytecode
- State Update: Replacing the deployed bytecode in the debugging database
§Etherscan Integration
- Creation Data Caching: Local caching of contract creation transaction data
- API Key Management: Automatic API key rotation for rate limit handling
- Chain Support: Multi-chain support through configurable Etherscan endpoints
§Workflow Integration
The code tweaking process is typically used in the debugging workflow to:
- Replace original contracts with instrumented versions for hook-based debugging
- Substitute contracts with modified versions for testing different scenarios
- Enable debugging of contracts that weren’t originally compiled with debug information
§Usage Example
ⓘ
let mut tweaker = CodeTweaker::new(&mut edb_context, rpc_url, etherscan_api_key);
tweaker.tweak(&contract_address, &original_artifact, &instrumented_artifact, false).await?;This replaces the deployed bytecode at contract_address with the instrumented version,
enabling advanced debugging features on the modified contract.
Structs§
- Code
Tweaker - Utility for modifying deployed contract bytecode through creation transaction replay.