Skip to content

Conversation

JereSalo
Copy link
Contributor

@JereSalo JereSalo commented Oct 9, 2025

Motivation

  • Start using the AccountStatus enum that we created some time ago in order to know the state of an account at a given moment.

Description

  • We now don't need the hashmap of destroyed_accounts in the GeneralizedDatabase because each account will keep track of their state.
  • Improved documentation for cases in which an account storage has to be removed but not the account. We had in our mind just one case but we weren't contemplating the case in which an account is destroyed but then sent value (without being created again). In this scenario the account won't be removed because it's not empty, that's why it falls into the DestroyedModified category.
  • Keep track of accounts that have been modified so that we can skip processing unmodified accounts when getting state transitions.

Closes #3948 (issue related to the destroyed_accounts part)

@JereSalo JereSalo self-assigned this Oct 9, 2025
@github-actions github-actions bot added the levm Lambda EVM implementation label Oct 9, 2025
Copy link

github-actions bot commented Oct 9, 2025

Lines of code report

Total lines added: 9
Total lines removed: 0
Total lines changed: 9

Detailed view
+----------------------------------------+-------+------+
| File                                   | Lines | Diff |
+----------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/account.rs   | 77    | +7   |
+----------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/db/gen_db.rs | 338   | +2   |
+----------------------------------------+-------+------+

Copy link

github-actions bot commented Oct 9, 2025

Benchmark Results Comparison

No significant difference was registered for any benchmark run.

Detailed Results

Benchmark Results: BubbleSort

Command Mean [s] Min [s] Max [s] Relative
main_revm_BubbleSort 4.712 ± 0.013 4.694 4.743 1.01 ± 0.00
main_levm_BubbleSort 4.685 ± 0.019 4.648 4.723 1.00 ± 0.00
pr_revm_BubbleSort 4.728 ± 0.014 4.712 4.759 1.01 ± 0.00
pr_levm_BubbleSort 4.677 ± 0.013 4.662 4.705 1.00

Benchmark Results: ERC20Approval

Command Mean [s] Min [s] Max [s] Relative
main_revm_ERC20Approval 1.556 ± 0.033 1.530 1.638 1.01 ± 0.02
main_levm_ERC20Approval 1.647 ± 0.005 1.640 1.654 1.07 ± 0.01
pr_revm_ERC20Approval 1.536 ± 0.008 1.527 1.552 1.00
pr_levm_ERC20Approval 1.649 ± 0.004 1.643 1.658 1.07 ± 0.01

Benchmark Results: ERC20Mint

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Mint 185.9 ± 1.4 184.0 189.3 1.01 ± 0.01
main_levm_ERC20Mint 200.2 ± 1.0 199.4 202.8 1.09 ± 0.01
pr_revm_ERC20Mint 184.0 ± 0.7 183.4 185.8 1.00
pr_levm_ERC20Mint 199.1 ± 2.1 197.4 204.7 1.08 ± 0.01

Benchmark Results: ERC20Transfer

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Transfer 350.6 ± 5.4 348.2 365.7 1.01 ± 0.02
main_levm_ERC20Transfer 387.1 ± 1.3 384.8 389.0 1.11 ± 0.01
pr_revm_ERC20Transfer 348.8 ± 1.4 347.7 351.1 1.00
pr_levm_ERC20Transfer 387.2 ± 1.0 385.4 388.6 1.11 ± 0.01

Benchmark Results: Factorial

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Factorial 240.3 ± 14.8 234.3 282.2 1.02 ± 0.06
main_levm_Factorial 282.0 ± 0.9 280.8 283.1 1.19 ± 0.01
pr_revm_Factorial 236.0 ± 0.8 235.4 238.1 1.00
pr_levm_Factorial 287.7 ± 1.6 285.4 290.1 1.22 ± 0.01

Benchmark Results: FactorialRecursive

Command Mean [s] Min [s] Max [s] Relative
main_revm_FactorialRecursive 1.656 ± 0.024 1.613 1.687 1.02 ± 0.03
main_levm_FactorialRecursive 8.842 ± 0.110 8.675 8.997 5.42 ± 0.14
pr_revm_FactorialRecursive 1.631 ± 0.038 1.595 1.696 1.00
pr_levm_FactorialRecursive 8.845 ± 0.100 8.700 8.981 5.42 ± 0.14

Benchmark Results: Fibonacci

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Fibonacci 211.6 ± 8.9 207.7 236.7 1.01 ± 0.04
main_levm_Fibonacci 261.9 ± 4.3 258.2 269.0 1.25 ± 0.02
pr_revm_Fibonacci 210.1 ± 0.7 208.8 211.2 1.00
pr_levm_Fibonacci 259.1 ± 1.0 257.4 261.0 1.23 ± 0.01

Benchmark Results: FibonacciRecursive

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_FibonacciRecursive 867.6 ± 15.6 845.9 899.9 1.00 ± 0.02
main_levm_FibonacciRecursive 1058.4 ± 5.1 1051.9 1064.8 1.23 ± 0.01
pr_revm_FibonacciRecursive 863.5 ± 4.3 857.4 872.7 1.00
pr_levm_FibonacciRecursive 1062.6 ± 4.8 1055.7 1070.3 1.23 ± 0.01

Benchmark Results: ManyHashes

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ManyHashes 12.4 ± 0.0 12.3 12.5 1.00
main_levm_ManyHashes 14.1 ± 0.2 13.8 14.6 1.13 ± 0.02
pr_revm_ManyHashes 12.5 ± 0.1 12.4 12.7 1.01 ± 0.01
pr_levm_ManyHashes 14.0 ± 0.2 13.9 14.4 1.13 ± 0.01

Benchmark Results: MstoreBench

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_MstoreBench 266.8 ± 6.6 262.0 279.6 1.00 ± 0.03
main_levm_MstoreBench 760.7 ± 5.5 754.9 772.9 2.86 ± 0.05
pr_revm_MstoreBench 266.2 ± 3.8 263.0 274.2 1.00
pr_levm_MstoreBench 760.0 ± 5.2 755.3 769.9 2.85 ± 0.05

Benchmark Results: Push

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Push 296.9 ± 1.4 295.3 299.7 1.00 ± 0.01
main_levm_Push 845.1 ± 3.4 841.3 852.1 2.85 ± 0.02
pr_revm_Push 296.6 ± 1.2 295.2 299.1 1.00
pr_levm_Push 849.4 ± 4.9 844.5 861.7 2.86 ± 0.02

Benchmark Results: SstoreBench_no_opt

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_SstoreBench_no_opt 219.5 ± 2.6 217.4 226.7 2.39 ± 0.05
main_levm_SstoreBench_no_opt 91.8 ± 1.5 90.1 93.5 1.00
pr_revm_SstoreBench_no_opt 220.1 ± 3.4 217.5 228.7 2.40 ± 0.05
pr_levm_SstoreBench_no_opt 91.9 ± 1.3 90.2 93.3 1.00 ± 0.02

@JereSalo JereSalo moved this to In Progress in ethrex_l1 Oct 9, 2025
@JereSalo JereSalo marked this pull request as ready for review October 13, 2025 13:57
@JereSalo JereSalo requested a review from a team as a code owner October 13, 2025 13:57
@Copilot Copilot AI review requested due to automatic review settings October 13, 2025 13:57
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the LEVM to use the AccountStatus enum for managing account states instead of maintaining a separate destroyed_accounts HashMap. The changes improve account state tracking by consolidating status management into individual accounts and optimizing state transition processing.

  • Remove the destroyed_accounts HashSet from GeneralizedDatabase and use AccountStatus enum instead
  • Add methods to mark accounts as destroyed or modified with proper status transitions
  • Optimize state transition processing by skipping unmodified accounts

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
crates/vm/levm/src/hooks/default_hook.rs Replace destroyed_accounts HashMap usage with account.mark_destroyed() method
crates/vm/levm/src/db/gen_db.rs Remove destroyed_accounts field and logic, add account modification tracking, update state transition processing
crates/vm/levm/src/account.rs Add mark_destroyed() and mark_modified() methods, update AccountStatus enum with better documentation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@SDartayet SDartayet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@github-project-automation github-project-automation bot moved this from In Progress to In Review in ethrex_l1 Oct 15, 2025
@JereSalo JereSalo added this pull request to the merge queue Oct 15, 2025
Merged via the queue into main with commit 462ab79 Oct 15, 2025
59 checks passed
@JereSalo JereSalo deleted the levm/use_account_status branch October 15, 2025 18:02
@github-project-automation github-project-automation bot moved this from In Review to Done in ethrex_l1 Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

levm Lambda EVM implementation

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

LEVM: Remove destroyed_accounts from GeneralizedDatabase and use AccountStatus instead

3 participants