Parallel Execution Framework
Last updated
Last updated
Pharos Execution is the engine powering the Pharos network, designed for exceptional performance, scalability, and efficiency. The architecture comprises two key components: the scheduler and the executor. The scheduler is a core component for parallel scheduling and executing transactions, utilizing optimized algorithms for maximum parallelism and minimal conflicts. The executor features dual virtual machine (EVM and WASM) engines for fast and flexible smart contract execution. The EVM engine ensures compatibility with solidity contracts, while the WASM engine provides high-performance execution for a wider set of smart contract languages.
Pharos adopts a parallel approach to transaction execution, focusing on:
Optimal Grouping: Near-optimal parallel transaction groups with high concurrency.
Extreme Performance: Fast transaction execution with integrity and correctness. Efficient transaction validation, deterministic finality, and conflict handling.
Pharos ensures parallel execution efficiency and deterministic finality through:
Parallel Hint Generation: Leveraging static analysis and speculative execution of smart contracts, Pharos generates accurate read-write set hints to minimize conflicts and enhance parallelism. This is achieved through a robust compilation framework and a fine-grained analysis algorithm, providing comprehensive control and data flow insights to reduce runtime overhead.
Transaction Dependency Analysis: Pharos analyzes transaction dependencies using read-write sets and generates parallelizable transaction groups with the union-find algorithm. These groups are aligned with the number of execution workers, and all state objects for each group are preloaded in a single batched I/O operation, significantly reducing execution time.
Optimistic Execution & Pipeline Finality: Pharos utilizes optimistic execution alongside a "Pipeline Finality" algorithm, allowing quick convergence of execution results and determining the final state efficiently.
Pharos is continuously improving its parallelism by:
Efficient Resource Management: Validators balance tasks such as speculative execution, fully utilizing multi-core CPUs and I/O resources while allowing executors to take on scheduling work, optimizing overall resource use.
Global Data Optimization: Parallel and storage optimization of global data with read-write set conflicts, such as global counters, further enhances performance.
Conflict Detection & Minimal Re-execution: Through fine-grained control, Pharos achieves faster conflict detection and minimal-cost re-execution, delivering optimal parallel performance.
In Full Life Cycle Async Pipelining,we divide the finality of transactions into the following three categories::
Ordering Finality: Ensures permanent transaction sequencing.
Transaction Finality: Provides deterministic execution results.
Block Finality: Allows immediate access to finalized blocks.
In the Pharos Parallel Execution Framework, Transaction Finality is prioritized to ensure a seamless Web3 user experience, while we aim to minimize the delay in Block Finality. This is crucial as infrastructure components like oracles and indexers rely on this information. To optimize block finality, Pharos employs the following techniques:
Setting a maximum finality time for each block (e.g., n blocks, where n = 10).
Faster BlockHeader Generation: Performance-optimized validators or RPC nodes may generate block headers faster, broadcasting them to other nodes that perform verification and application without full computation (via state sync).
The Pharos Parallel Execution Framework operates through the following seven steps:
Consensus the latest block batch and synchronize parallel execution hints across the network.
Split execution groups using dependency graphs based on the parallel hints.
Sequentially process transactions within each group in the executor.
Load merklized state data in parallel to optimize performance.
Identify and resolve execution conflicts between concurrent groups.
Redo some transactions in the groups and generate the finality status.
Write the updated state using asynchronous I/O.
Our algorithm is designed to minimize Transaction Finality time, while Pharos Store assists by preloading merklized state data (e.g., MPT, JMT nodes), accelerating block header generation and block finality consensus.