Fix validation blocking async tasks & upgrade mega-evm dependency - #51
Merged
Conversation
yilongli
approved these changes
Dec 8, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves the stateless validator's performance by introducing a thread pool for CPU-intensive validation tasks and upgrades the
mega-evmdependency with refactored hardfork implementations.Purpose
To address two issues encountered in testnet v2:
validate_one, resulting in thousands of blocks being validated without the reporter providing any updates. At the time, the server was running both the witness generator and the validator simultaneously; the generator was using 200% CPU, and the validator, with 32 workers, was using 800% CPU.Changes
1. Use thread pool for validation to avoid blocking async tasks
validate_block()call intask::spawn_blocking()to run CPU-intensive validation in a dedicated thread poolArc<ChainSpec>for thread-safe sharing2. Optimize release build profile
lto = "fat"for better link-time optimizationstrip = trueto reduce binary sizepanic = "abort"for smaller binary and faster panic handling3. Upgrade mega-evm & refactor chainspec hardfork implementation
mega-evmto commit3b28c205c8c2f89730a4dd88abe47e1831c6fac9MegaethHardforkandMegaethHardforksdefinitions withMegaHardforkandMegaHardforksfrommega-evmchain_spec.rsby removing 43 lines of redundant hardfork codeMegaHardforkstrait forChainSpecFiles Changed
Cargo.toml- Updated dependencies and release profileCargo.lock- Updated lockfilebin/stateless-validator/src/main.rs- Added spawn_blocking for validationvalidator-core/src/chain_spec.rs- Refactored hardfork implementation