How risechain/pevm works
Project Type and Purpose
• This is a Rust-based blockchain execution engine focused on parallelizing EVM (Ethereum Virtual Machine) block execution.
• Its purpose is to leverage parallel execution (through techniques like Block-STM, a collaborative scheduler, and multi-version data structures) to improve throughput and enable new dApp designs.
• The design aims to deliver deterministic yet highly concurrent transaction execution with special handling for gas payment and transfers.
Analyzing the File Structure
• The project is organized as a Cargo workspace with distinct sections:
• The “crates” directory holds the core logic under the “pevm” crate. This includes modules for chain handling (for Ethereum and Optimism), memory management (mv_memory), scheduling, storage implementations (in_memory and rpc), and the main VM logic.
• The “bins” directory contains at least one CLI tool (“fetch”) for grabbing real block data, which feeds into the testing and benchmarking workflows.
• The “data” directory stores block and pre-state JSON files used for validations, tests, and benchmarking.
• There are directories for benchmarks (“benches”) and extensive tests (including unit tests and integration tests for multiple scenarios such as raw transfers, ERC-20, and uniswap contracts).
• Configuration files (like Cargo.toml, GitHub workflows, and cmake dependency notes for snmalloc) hint at performance and deployment considerations.
Insights from the README
• The README outlines both the problem and solution areas. It explains that RISE pevm is purposely built to optimize EVM execution through parallelism, using techniques like:
• Lazy updates for beneficiary and transfer scenarios.
• A collaborative scheduler that aggressively finds tasks to minimize overhead.
• Multi-version concurrency control for maintaining deterministic state execution.
• The README also highlights testing groups (Ethereum state tests, mocked block tests, and mainnet block tests) and a dedicated CLI tool for fetching blocks.
a. Main Components to Include:
• Core Execution Engine ("pevm" Crate):
• VM Module
• Scheduler module (collaborative scheduling)
• Chain handlers (modules: ethereum.rs, optimism.rs under chain)
• Lazy Update Mechanisms (for beneficiary and token transfers)
• Multi-version storage system (with in_memory and rpc submodules)
• Memory management module (mv_memory)
• CLI and Fetch Module:
• bins/fetch as the command-line tool to fetch real block data from various networks.
• Testing, Benchmarks, and Data:
• Benchmarking modules (in benches)
• Test suites for ethereum, raw transfers, ERC-20, uniswap, etc.
• Data ingestion from the “data” directory containing block & pre_state JSON files.
• External Dependencies and Integrations:
• Integration with Ethereum mainnet and potential integration with Ethereum clients like Reth.
• Use of external libraries (e.g., snmalloc for memory allocation, cmake for builds).
b. Relationships and Interactions:
• The core execution engine processes EVM block transactions in parallel using its scheduler and the multi-version memory storage.
• Lazy update mechanisms allow safe parallel modifications (representing dependencies like beneficiary updates) while ensuring output consistency.
• The CLI tool interacts with external Ethereum nodes via RPC to fetch blocks, then deposits data to the “data” directory for subsequent execution by the engine.
• Testing modules feed various scenarios into the core engine to validate correctness and performance, indicating tight integration between unit/integration tests and the engine’s key modules.
c. Architectural Patterns and Design Principles:
• Separation of concerns:
– The execution logic (VM, scheduler, storage) is decoupled from I/O and block fetching.
– Modular design with separate components for chain-specific handling.
• Use of optimistic concurrency via multi-version data structures and the lazy update techniques.
• Acknowledge the importance of determinism in blockchain execution, underlining error handling and conflict resolution.
d. Relevant Technologies, Frameworks, or Libraries:
• Programming Language: Rust.
• Build and Package Management: Cargo.
• Memory Allocation: snmalloc (via cmake).
• Testing and Benchmarking frameworks integrated with Cargo.
• GitHub workflows for continuous integration that might affect build/deployment aspects.