-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Background
Morph-Reth currently supports custom L2 engine RPCs (engine_assembleL2Block, engine_validateL2Block, engine_newL2Block, engine_newSafeL2Block).
Historically, the implementation used a custom API-layer import/commit path instead of reth's engine pipeline (newPayload + forkchoiceUpdated + engine tree).
This increases maintenance complexity, duplicates validation/import logic, and makes behavior diverge from reth engine pipeline semantics.
Functional Description
Refactor custom L2 engine API implementation to reuse reth engine pipeline while keeping external Morph engine RPC interfaces compatible.
Key goals:
- Keep Morph custom engine RPC method signatures and behavior compatible.
- Route block validation/import through reth engine tree (
newPayload + FCU) instead of manual DB append path. - Preserve Morph-specific semantics (pre-/post-
MPTForkstate_root handling,withdraw_trie_rootvalidation, custom header fields). - Reduce duplicated API-layer caching/state tracking logic.
Scope
- Refactor
morph-engine-apito reuse reth engine pipeline for:engine_validateL2Blockengine_newL2Blockengine_newSafeL2Block
- Add/maintain deterministic
ExecutableL2Data -> MorphExecutionDataconversion for engine submission - Move Morph-specific validation into engine validator path:
- pre-/post-
MPTForkstate_root behavior withdraw_trie_rootpost-execution validation
- pre-/post-
- Replace legacy API-layer import/canonical management path
- Add engine-state tracking for head/forkchoice reads used by custom engine API
- Remove obsolete compatibility code and redundant API-layer caches
- Update tests/docs accordingly
Acceptance Criteria
-
engine_validateL2Blockandengine_newL2Blockwork through reth engine pipeline (newPayload + FCU) - Morph custom engine RPC interfaces remain compatible for existing callers
- pre-
MPTForkand post-MPTForkstate_root behavior is preserved -
withdraw_trie_rootvalidation is preserved in engine validator path - Legacy manual API-layer append/canonical path is removed from main flow
-
cargo check --workspacepasses - Related tests pass
Operational Note
Current sync/import performance is highly sensitive to engine state-root algorithm selection on Morph workloads.
In practice, --engine.legacy-state-root may be required for acceptable throughput in this engine-API-driven sync mode.
(Performance tuning is tracked separately from this refactor task.)