paradigmxyz / reth

Modular, contributor-friendly and blazing-fast implementation of the Ethereum protocol, in Rust
https://reth.rs/
Apache License 2.0
3.99k stars 1.21k forks source link

refactor: unify code paths for trie unwind #12741

Closed klkvr closed 12 hours ago

klkvr commented 15 hours ago

take_block_and_execution_range and remove_block_and_execution_range share the exact the same logic for unwinding trie state from database which this PR unifies into a single unwind_trie_state_range

The primary motivation however is to reuse unwind_trie_state_range in reth debug execution command. I'm preparing changes to make remove_block_and_execution_range to also prune static files which is inappropriate for debug utilities which expect the database to only be changed during commits.

When simulating unwinds, reth debug execution will now only call unwind_trie_state_range which will verify state root consistency during unwind which I believe is the purpose of this uncommited unwind per https://github.com/paradigmxyz/reth/pull/2619