Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(levm): disable arithmetic shifts for forks before Constantinople #1948

Merged
merged 2 commits into from
Feb 13, 2025

Conversation

LeanSerra
Copy link
Contributor

Motivation

Forks before Constantinople had opcodes SHL,SHR,SAR

Description
This PR modifies the functions SHL,SHR,SAR to return VmError::InvalidOpcode for forks < Fork::Constantinople

Closes #1947

@LeanSerra LeanSerra added the levm Lambda EVM implementation label Feb 13, 2025
@LeanSerra LeanSerra self-assigned this Feb 13, 2025
@LeanSerra LeanSerra requested a review from a team as a code owner February 13, 2025 20:50
Copy link

| File                                                                                     | Lines | Diff |
+------------------------------------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/vm/levm/src/opcode_handlers/bitwise_comparison.rs | 288   | +9   |
+------------------------------------------------------------------------------------------+-------+------+

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

Copy link

github-actions bot commented Feb 13, 2025

EF Tests Comparison

Test Name MAIN PR DIFF
Summary: 14807/16775 (88.27%) 14995/16775 (89.39%) ⬆️ 188
Prague: 2373/2373 (100.00%) 2373/2373 (100.00%) ➖️
Cancun: 3579/3579 (100.00%) 3579/3579 (100.00%) ➖️
Shanghai: 221/221 (100.00%) 221/221 (100.00%) ➖️
Paris: 62/62 (100.00%) 62/62 (100.00%) ➖️
London: 39/39 (100.00%) 39/39 (100.00%) ➖️
Berlin: 35/35 (100.00%) 35/35 (100.00%) ➖️
Istanbul: 34/35 (97.14%) 34/35 (97.14%) ➖️
Constantinople: 1780/2406 (73.98%) 1780/2406 (73.98%) ➖️
Petersburg: 2345/2400 (97.71%) 2345/2400 (97.71%) ➖️
Byzantium: 2244/2330 (96.31%) 2284/2330 (98.03%) ⬆️ 40
Homestead: 868/1324 (65.56%) 905/1324 (68.35%) ⬆️ 37
Frontier: 335/742 (45.15%) 372/742 (50.13%) ⬆️ 37
SpuriousDragon: 484/579 (83.59%) 521/579 (89.98%) ⬆️ 37
Tangerine: 408/650 (62.77%) 445/650 (68.46%) ⬆️ 37

Copy link

github-actions bot commented Feb 13, 2025

Benchmark Results Comparison

PR Results

Benchmark Results: Factorial

Command Mean [ms] Min [ms] Max [ms] Relative
revm_Factorial 239.2 ± 1.0 238.1 241.8 1.00
levm_Factorial 916.1 ± 7.5 900.5 925.3 3.83 ± 0.04

Benchmark Results: Factorial - Recursive

Command Mean [s] Min [s] Max [s] Relative
revm_FactorialRecursive 1.520 ± 0.081 1.376 1.605 1.00
levm_FactorialRecursive 15.735 ± 0.036 15.689 15.806 10.35 ± 0.55

Benchmark Results: Fibonacci

Command Mean [ms] Min [ms] Max [ms] Relative
revm_Fibonacci 210.2 ± 0.4 209.5 210.9 1.00
levm_Fibonacci 911.2 ± 11.4 895.9 930.0 4.33 ± 0.05

Benchmark Results: ManyHashes

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ManyHashes 8.6 ± 0.1 8.5 8.8 1.00
levm_ManyHashes 18.2 ± 0.2 18.1 18.8 2.11 ± 0.03

Benchmark Results: BubbleSort

Command Mean [s] Min [s] Max [s] Relative
revm_BubbleSort 3.229 ± 0.025 3.206 3.296 1.00
levm_BubbleSort 6.151 ± 0.054 6.095 6.254 1.91 ± 0.02

Benchmark Results: ERC20 - Transfer

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ERC20Transfer 248.0 ± 1.5 246.3 251.3 1.00
levm_ERC20Transfer 544.4 ± 2.4 540.5 547.6 2.20 ± 0.02

Benchmark Results: ERC20 - Mint

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ERC20Mint 141.6 ± 0.9 140.3 143.3 1.00
levm_ERC20Mint 357.2 ± 2.1 354.0 360.7 2.52 ± 0.02

Benchmark Results: ERC20 - Approval

Command Mean [s] Min [s] Max [s] Relative
revm_ERC20Approval 1.042 ± 0.008 1.033 1.057 1.00
levm_ERC20Approval 2.037 ± 0.012 2.025 2.059 1.95 ± 0.02

Main Results

Benchmark Results: Factorial

Command Mean [ms] Min [ms] Max [ms] Relative
revm_Factorial 242.4 ± 15.7 236.3 286.9 1.00
levm_Factorial 910.9 ± 13.9 898.9 937.0 3.76 ± 0.25

Benchmark Results: Factorial - Recursive

Command Mean [s] Min [s] Max [s] Relative
revm_FactorialRecursive 1.446 ± 0.075 1.355 1.550 1.00
levm_FactorialRecursive 15.645 ± 0.041 15.585 15.702 10.82 ± 0.56

Benchmark Results: Fibonacci

Command Mean [ms] Min [ms] Max [ms] Relative
revm_Fibonacci 210.0 ± 0.5 209.4 210.9 1.00
levm_Fibonacci 914.0 ± 20.2 894.7 961.8 4.35 ± 0.10

Benchmark Results: ManyHashes

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ManyHashes 8.7 ± 0.1 8.6 8.9 1.00
levm_ManyHashes 18.1 ± 0.1 18.0 18.3 2.09 ± 0.02

Benchmark Results: BubbleSort

Command Mean [s] Min [s] Max [s] Relative
revm_BubbleSort 3.257 ± 0.020 3.233 3.305 1.00
levm_BubbleSort 6.155 ± 0.136 6.077 6.529 1.89 ± 0.04

Benchmark Results: ERC20 - Transfer

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ERC20Transfer 248.9 ± 2.1 243.9 251.2 1.00
levm_ERC20Transfer 543.4 ± 12.5 533.0 569.4 2.18 ± 0.05

Benchmark Results: ERC20 - Mint

Command Mean [ms] Min [ms] Max [ms] Relative
revm_ERC20Mint 141.4 ± 0.7 139.7 142.3 1.00
levm_ERC20Mint 351.8 ± 4.5 341.1 356.6 2.49 ± 0.03

Benchmark Results: ERC20 - Approval

Command Mean [s] Min [s] Max [s] Relative
revm_ERC20Approval 1.041 ± 0.007 1.028 1.052 1.00
levm_ERC20Approval 2.024 ± 0.011 2.007 2.041 1.94 ± 0.02

Copy link
Contributor

@fborello-lambda fborello-lambda left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@tomip01 tomip01 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@JereSalo JereSalo left a comment

Choose a reason for hiding this comment

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

👍

@fborello-lambda fborello-lambda added this pull request to the merge queue Feb 13, 2025
Merged via the queue into main with commit eb2a5f3 Feb 13, 2025
27 checks passed
@fborello-lambda fborello-lambda deleted the levm/disable_arithmetic_shifts_old_forks branch February 13, 2025 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
levm Lambda EVM implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LEVM: Add support for the stShift test suite
4 participants