This project implements an Ethereum Virtual Machine (EVM) command executor, leveraging Rust's powerful concurrency features. The executor processes blocks from a blockchain, performing transactions in parallel using multiple threads to maximize efficiency.
- Executes EVM commands within a defined block range.
- Employs a multi-threaded approach to enhance execution speed.
- Supports dynamic task distribution and load balancing across threads.
- Offers real-time monitoring of execution progress.
The project relies on several external crates:
clapfor command-line argument parsing.eyrefor error handling.tracingfor logging.reth_*crates for blockchain-related functionalities.num_cpusto determine the number of CPU cores.
- Ensure you have Rust installed. If not, install it from rustup.rs.
- Clone the repository:
git clone <repository-url> cd <repository-directory>
- Build the project:
cargo build --release
The main functionality is provided by the EvmCommand struct, which is configured and executed through the command line.
--beginor-b: Begin block number (required).--endor-e: End block number (required).--stepor-s: Step size for loop, default is 100.
To execute the EVM command for blocks from 1000 to 2000 with a step size of 50, run:
cargo run --release -- -b 1000 -e 2000 -s 50The core functionality is implemented in the EvmCommand struct. The execute method performs the following steps:
- Sets up the environment and consensus mechanism.
- Configures the blockchain tree and provider.
- Validates the specified block range.
- Creates a task queue and splits the block range into individual tasks.
- Launches multiple threads to process these tasks concurrently.
- Monitors and logs execution progress in real time.
- Waits for threads to complete and manages any errors that arise during execution.
Each thread fetches tasks from a shared task queue, processes blocks within the specified range, and updates shared counters for gas usage, block count, and transaction count. The execution results are logged for monitoring.
A separate thread periodically records runtime metrics, such as the number of blocks and transactions processed, along with the current gas throughput.
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature). - Commit your changes (
git commit -am 'Add your feature'). - Push to the branch (
git push origin feature/your-feature). - Create a new Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to the authors of the
rethcrates for providing essential blockchain components. - We are deeply grateful to the Rust community for their invaluable support and resources.