Skip to content

Update EIP-8024 decoding to new spec#10710

Merged
LukaszRozmej merged 9 commits into
bal-devnet-3from
feature/eip-8024-new-decoding
Mar 4, 2026
Merged

Update EIP-8024 decoding to new spec#10710
LukaszRozmej merged 9 commits into
bal-devnet-3from
feature/eip-8024-new-decoding

Conversation

@LukaszRozmej
Copy link
Copy Markdown
Member

@LukaszRozmej LukaszRozmej commented Mar 3, 2026

Summary

  • Update EIP-8024 immediate decoding to match the latest spec change
  • Single operand (DUPN/SWAPN): branchless n = (x + 145) % 256 (was branched x+17 / x-20)
  • Pair operand (EXCHANGE): branchless k = x ^ 143 (was branched x / x-48), invalid range narrowed from 80-127 to 82-127 (immediates 0x50, 0x51 now valid, encoding new pairs (14,16) and (14,15))
  • Refactored tests: 34 methods → 7 using TestCaseSource with byte[] bytecode parameters, covering same 33 unique scenarios

Changes

  • EvmInstructions.Stack.cs: Updated TryDecodeSingle and TryDecodePair decoding formulas and disallowed range check
  • Eip8024Tests.cs: Refactored with TestCaseSource generators, extracted helpers, removed duplicate test

Test plan

  • All 33 EIP-8024 tests pass (dotnet test --filter Eip8024)
  • Ethereum Foundation reference tests (when available)

🤖 Generated with Claude Code

@LukaszRozmej LukaszRozmej requested review from Marchhill and flcl42 March 3, 2026 14:35
Copy link
Copy Markdown
Contributor

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

Updates Nethermind’s legacy (non-EOF) EIP-8024 immediate decoding for DUPN/SWAPN/EXCHANGE to match the latest spec changes, and refactors the associated NUnit test suite to use shared TestCaseSource generators.

Changes:

  • Update DUPN/SWAPN immediate decoding to depth = (imm + 145) mod 256 and keep the disallowed immediate window 0x5B..0x7F.
  • Update EXCHANGE immediate decoding to k = imm ^ 0x8F and narrow the disallowed window to 0x52..0x7F (making 0x50/0x51 valid).
  • Refactor EIP-8024 tests into a smaller set of parameterized tests with shared bytecode builders and generators.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/Nethermind/Nethermind.Evm/Instructions/EvmInstructions.Stack.cs Adjusts EIP-8024 immediate decoding formulas and updates the invalid-immediate range for EXCHANGE.
src/Nethermind/Nethermind.Evm.Test/Eip8024Tests.cs Reworks tests into TestCaseSource-based suites and updates vectors/immediates to the new decoding rules.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Nethermind/Nethermind.Evm.Test/Eip8024Tests.cs Outdated
Comment thread src/Nethermind/Nethermind.Evm.Test/Eip8024Tests.cs Outdated
Comment thread src/Nethermind/Nethermind.Evm.Test/Eip8024Tests.cs Outdated
Comment thread src/Nethermind/Nethermind.Evm.Test/Eip8024Tests.cs Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 3, 2026

EVM Opcode Benchmark Diff

Aggregated runs: base=1, pr=1

No significant regressions or improvements detected.

Copy link
Copy Markdown
Contributor

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Nethermind/Nethermind.Evm/ByteCodeBuilder.cs
Comment thread src/Nethermind/Nethermind.Evm.Test/Eip8024Tests.cs Outdated
@LukaszRozmej LukaszRozmej added the amsterdam Amsterdam hard fork label Mar 3, 2026
@LukaszRozmej LukaszRozmej merged commit 0f8aeb1 into bal-devnet-3 Mar 4, 2026
103 checks passed
@LukaszRozmej LukaszRozmej deleted the feature/eip-8024-new-decoding branch March 4, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

amsterdam Amsterdam hard fork eip evm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants