Add SHL, SHR and SAR shift operations for EVM v2#10154
Merged
ahamlat merged 13 commits intobesu-eth:mainfrom Apr 7, 2026
Merged
Add SHL, SHR and SAR shift operations for EVM v2#10154ahamlat merged 13 commits intobesu-eth:mainfrom
ahamlat merged 13 commits intobesu-eth:mainfrom
Conversation
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
siladu
reviewed
Apr 2, 2026
Contributor
siladu
left a comment
There was a problem hiding this comment.
Should we compare benchmarks to stack_long_array as well?
evm/src/main/java/org/hyperledger/besu/evm/v2/operation/AddOperationV2.java
Show resolved
Hide resolved
...jmh/java/org/hyperledger/besu/ethereum/vm/operations/v2/AbstractSarOperationBenchmarkV2.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
0f1d4e6 to
45f61e5
Compare
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
siladu
reviewed
Apr 2, 2026
Contributor
There was a problem hiding this comment.
nit: I would append V2 to the end of the filename so to keep a consistent pattern for this project, i.e. ShiftOperationsPropertyBasedTestV2.java
| .isTrue(); | ||
| } | ||
|
|
||
| private static UInt256 getV2StackItem(final MessageFrame frame, final int offset) { |
Contributor
There was a problem hiding this comment.
nit: I would append V2 to the end of the filename so to keep a consistent pattern for this project, i.e. getStackItemV2. Though since this is already in a V2 class, maybe could just be getStackItem here?
Contributor
There was a problem hiding this comment.
Suggested change
| private static UInt256 getV2StackItem(final MessageFrame frame, final int offset) { | |
| private static UInt256 getStackItem(final MessageFrame frame, final int offset) { |
evm/src/test/java/org/hyperledger/besu/evm/v2/operation/SarOperationV2Test.java
Show resolved
Hide resolved
evm/src/main/java/org/hyperledger/besu/evm/v2/StackArithmetic.java
Outdated
Show resolved
Hide resolved
evm/src/main/java/org/hyperledger/besu/evm/v2/StackArithmetic.java
Outdated
Show resolved
Hide resolved
evm/src/main/java/org/hyperledger/besu/evm/v2/StackArithmetic.java
Outdated
Show resolved
Hide resolved
evm/src/main/java/org/hyperledger/besu/evm/v2/StackArithmetic.java
Outdated
Show resolved
Hide resolved
This was referenced Apr 3, 2026
Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net>
siladu
approved these changes
Apr 7, 2026
Contributor
There was a problem hiding this comment.
Just the V2 method name should change ideally. #10154 (comment)
daniellehrner
added a commit
that referenced
this pull request
Apr 8, 2026
* Add SHL, SHR and SAR shift operations for EVM v2 (#10154) * Add SHL, SHR and SAR implementations and benchmarks for EVM v2 Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> * Upgrade RocksDB version from 9.7.3 to 10.6.2 (#9767) * Upgrade RocksDB version from 9.7.3 to 10.6.2 * Fix JNI SIGSEGV crashes Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> * Add missing verification metadata (#10198) Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Stream debug_traceBlock* responses directly to avoid OOM on large blocks (#9848) * stream block traces on op code level Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * correctly parse default setting for memory tracing Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * fix initcode capture for failed create op codes Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * created separate streaming debug tracer, for batch request fall back to accumulation in memory, adddress pr comments Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * execute tests from genesis and verify full trace Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * addressed pr comments Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * spotless Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * optimize trace streaming and struct log handling Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> * spotless Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> * Fix remaining issues and add unit tests Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> * added back pressure when writing to the socket and reduced the buffer size to work better with netty's default buffer size Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * improve error handling by deferring to send the header only when data is available, allows to send the proper error codes during setup Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * compactHex candidate comparison Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * wire in more performant hex writer Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * introduce separate timeout for streaming calls, defaults to 10 minutes Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * spotless Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * Fix streamin/accumulating output parity, added missing refund field, corrected error format, reason encoding, returnValue prefix, and precompile gasCost, with equivalence tests between both Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * revert accidental removal of 0x prefix Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * pad memory bytes to 32 bytes Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> --------- Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> Co-authored-by: Ameziane H. <ameziane.hamlat@consensys.net> --------- Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> Co-authored-by: ahamlat <ameziane.hamlat@consensys.net> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net>
daniellehrner
added a commit
that referenced
this pull request
Apr 9, 2026
* Add SHL, SHR and SAR shift operations for EVM v2 (#10154) * Add SHL, SHR and SAR implementations and benchmarks for EVM v2 Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> * Upgrade RocksDB version from 9.7.3 to 10.6.2 (#9767) * Upgrade RocksDB version from 9.7.3 to 10.6.2 * Fix JNI SIGSEGV crashes Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> * Add missing verification metadata (#10198) Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Stream debug_traceBlock* responses directly to avoid OOM on large blocks (#9848) * stream block traces on op code level Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * correctly parse default setting for memory tracing Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * fix initcode capture for failed create op codes Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * created separate streaming debug tracer, for batch request fall back to accumulation in memory, adddress pr comments Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * execute tests from genesis and verify full trace Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * addressed pr comments Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * spotless Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * optimize trace streaming and struct log handling Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> * spotless Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> * Fix remaining issues and add unit tests Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> * added back pressure when writing to the socket and reduced the buffer size to work better with netty's default buffer size Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * improve error handling by deferring to send the header only when data is available, allows to send the proper error codes during setup Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * compactHex candidate comparison Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * wire in more performant hex writer Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * introduce separate timeout for streaming calls, defaults to 10 minutes Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * spotless Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * Fix streamin/accumulating output parity, added missing refund field, corrected error format, reason encoding, returnValue prefix, and precompile gasCost, with equivalence tests between both Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * revert accidental removal of 0x prefix Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> * pad memory bytes to 32 bytes Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> --------- Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> Co-authored-by: Ameziane H. <ameziane.hamlat@consensys.net> * Optimize performance and reduce memory when creating Quantity from scalar (#10134) * Optimize performance and reduce memory when creating Quantity from scalar Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Benchmark other implementations Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> --------- Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * snap sync - apply BALs before flat db heal (#10151) Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com> * Remove dryRunDetector workaround methods from unit tests (#10201) * Remove dryRunDetector workaround methods from unit tests The dryRunDetector methods were added as a workaround for a Gradle issue that prevented @ParameterizedTest classes from being selected when running with --dry-run. Since the issue is fixed and --dry-run is no longer used, these methods are no longer needed. Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * Remove dryRunDetector workaround from acceptance tests too The Gradle issue is confirmed fixed, so the workaround is no longer needed anywhere, including acceptance tests. Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> --------- Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> * preserve state gas reservoir for the top level frame in case of OOG (#10205) Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> --------- Signed-off-by: Ameziane H. <ameziane.hamlat@consensys.net> Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> Signed-off-by: daniellehrner <daniel.lehrner@consensys.net> Signed-off-by: Miroslav Kovar <miroslavkovar@protonmail.com> Co-authored-by: ahamlat <ameziane.hamlat@consensys.net> Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com> Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net> Co-authored-by: Miroslav Kovář <miroslavkovar@protonmail.com>
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.
Description
Continues the EVM v2 implementation started in #10105.
This PR adds the
SHL(0x1b),SHR(0x1c), andSAR(0x1d) shift opcodes to the EVM v2long[]-based stack.Changes
SHL(0x1b),SHR(0x1c), andSAR(0x1d) shift opcodes for the EVM v2long[]-based stack, with zero heap allocation on the hot pathStackArithmetic— a dedicated utility class for 256-bit binary and arithmetic operations operating directly on the flatlong[]operand stackShlOperationV2,ShrOperationV2,SarOperationV2operation classes wired into the EVM v2switchdispatch (with Constantinople gate)evm.v2.operationpackageBenchmarks
With current main
With this PR
Thanks for sending a pull request! Have you done the following?
doc-change-requiredlabel to this PR if updates are required.Locally, you can run these tests to catch failures early:
./gradlew spotlessApply./gradlew build./gradlew acceptanceTest./gradlew integrationTest./gradlew ethereum:referenceTests:referenceTests