Skip to content

feat(feynman): cherry-pick EIP-7823 and EIP-7883 from upstream#1211

Closed
Thegaram wants to merge 4 commits intodevelopfrom
feat-feynman-modexp-changes
Closed

feat(feynman): cherry-pick EIP-7823 and EIP-7883 from upstream#1211
Thegaram wants to merge 4 commits intodevelopfrom
feat-feynman-modexp-changes

Conversation

@Thegaram
Copy link
Copy Markdown

@Thegaram Thegaram commented Jun 23, 2025

1. Purpose or design rationale of this PR

Enable https://eips.ethereum.org/EIPS/eip-7823 and https://eips.ethereum.org/EIPS/eip-7883 in Feynman. Disable our previous length check at the same time.

Relevant previous changes:

Upstream PRs:

2. PR title

Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:

  • feat: A new feature

3. Deployment tag versioning

Has the version in params/version.go been updated?

  • This PR doesn't involve a new deployment, git tag, docker image tag, and it doesn't affect traces
  • Yes

4. Breaking change label

Does this PR have the breaking-change label?

  • This PR is not a breaking change
  • Yes

Summary by CodeRabbit

  • New Features
    • Added support for EIP-7883 in modular exponentiation precompile with updated gas calculation and input validation.
  • Bug Fixes
    • Enhanced error messages for input length violations in modular exponentiation.
  • Tests
    • Added tests and benchmarks for the EIP-7883 modular exponentiation variant.
    • Included extensive test data covering multiple modular exponentiation scenarios under EIP-7883.

@Thegaram Thegaram requested review from colinlyguo and georgehao June 23, 2025 15:35
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jun 23, 2025

Walkthrough

The changes introduce support for EIP-7883 and EIP-7823 in the modular exponentiation (bigModExp) precompile by adding new boolean flags to its struct and updating gas calculation and input validation logic accordingly. Test coverage and benchmarks are extended for the new EIP-7883 variant, including new test vectors in a dedicated JSON file.

Changes

File(s) Change Summary
core/vm/contracts.go Added eip7823 and eip7883 flags to bigModExp, updated gas calculation and input checks for EIP-7823/7883, and imported fmt.
core/vm/contracts_test.go Added EIP-7883 variant to precompile map, new tests and benchmarks for EIP-7883.
core/vm/testdata/precompiles/modexp_eip7883.json New test data file with EIP-7883 modular exponentiation test cases and expected results.

Sequence Diagram(s)

sequenceDiagram
    participant TestRunner
    participant PrecompileMap
    participant BigModExp
    participant GasCalculator

    TestRunner->>PrecompileMap: Lookup address (e.g., 0xf6)
    PrecompileMap->>BigModExp: Instantiate with eip2565/eip7883 flags
    TestRunner->>BigModExp: Run(input)
    BigModExp->>GasCalculator: RequiredGas(input, flags)
    GasCalculator-->>BigModExp: Calculated gas
    BigModExp->>BigModExp: Validate input lengths (per EIP flags)
    BigModExp->>BigModExp: Perform modular exponentiation
    BigModExp-->>TestRunner: Return result or error
Loading

Suggested reviewers

  • colinlyguo
  • jonastheis

Poem

In a warren of code, the rabbits convene,
To add new flags and make modexp keen.
With EIP-7883, gas math grows bold,
And tests hop in with vectors untold.
Now exponent bunnies leap with delight—
More precompiles, more power,
All through the night!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d7e9819 and 505a1e3.

📒 Files selected for processing (1)
  • core/vm/contracts.go (12 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • core/vm/contracts.go
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: test
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (go)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 02b33db and d7e9819.

📒 Files selected for processing (3)
  • core/vm/contracts.go (12 hunks)
  • core/vm/contracts_test.go (2 hunks)
  • core/vm/testdata/precompiles/modexp_eip7883.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: test
  • GitHub Check: check
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (go)
🔇 Additional comments (11)
core/vm/contracts_test.go (2)

53-55: LGTM! Comprehensive test infrastructure update.

The changes properly extend the test infrastructure by:

  • Explicitly setting eip7883: false for existing precompile variants to maintain clarity
  • Adding a new variant at address 0xf6 with both eip2565 and eip7883 enabled
  • Following the established pattern for precompile configuration

248-250: Test coverage appropriately extended for EIP-7883.

The new test and benchmark functions follow established naming conventions and correctly reference the new test data file (modexp_eip7883) and precompile address (f6).

core/vm/testdata/precompiles/modexp_eip7883.json (1)

1-107: Comprehensive test data for EIP-7883 modular exponentiation.

The test vectors provide excellent coverage:

  • Variety: Includes squaring, cubing, and power operations with exponent 0x10001
  • Scale: Covers input sizes from 0x40 to 0x400 bytes (64 to 1024 bytes)
  • Gas progression: Appropriate gas cost increases with input complexity (500 → 43690 → 174762)
  • Standard vectors: Uses well-established "nagydani" test series for compatibility

The JSON structure is consistent and includes all necessary fields for comprehensive testing.

core/vm/contracts.go (8)

23-23: Import addition necessary for enhanced error formatting.

The fmt import is correctly added to support the new formatted error message in the EIP-7823 validation logic.


68-68: Consistent precompile configuration across releases.

The explicit initialization of eip7823: false, eip7883: false for existing releases maintains backward compatibility while clearly documenting the flag states for each version.

Also applies to: 81-81, 95-95, 109-109, 123-123, 137-137


152-152: Feynman release correctly enables all EIP flags.

The Feynman precompile configuration appropriately enables eip2565: true, eip7823: true, eip7883: true to support the new EIP implementations.


353-355: Struct extension follows established pattern.

The addition of eip7823 and eip7883 boolean flags to the bigModExp struct follows the existing pattern established by eip2565.


443-449: Gas calculation logic reorganization.

The refactored gas calculation now uses max(baseLen, modLen) instead of separate variables, which simplifies the logic. The introduction of maxLenOver32 flag for subsequent conditional logic is well-structured.


507-513: Input validation logic correctly preserves backward compatibility.

The 32-byte length limit is only enforced when neither eip7823 nor eip7883 are enabled, maintaining backward compatibility while allowing larger inputs for newer EIP versions.


524-526: EIP-7823 size limit enforcement.

The 1024-byte limit for EIP-7823 with a clear error message using fmt.Errorf provides appropriate bounds checking. The error message is descriptive and helpful for debugging.


435-439: Review the bit shifting logic for EIP-7883.

The gas calculation introduces different bit shifting based on EIP-7883:

  • EIP-7883: 4-bit left shift (16x multiplier)
  • Non-EIP-7883: 3-bit left shift (8x multiplier)

This represents a significant change in gas calculation that should be thoroughly validated against the EIP specification.

Please verify that the 4-bit vs 3-bit shift difference aligns with the EIP-7883 specification requirements.

#!/bin/bash
# Search for any documentation or comments explaining the bit shift logic
rg -A 5 -B 5 "Lsh.*4|shift.*4|EIP-7883.*shift" --type go

Comment thread core/vm/contracts.go
@Thegaram
Copy link
Copy Markdown
Author

Spec is not final yet, so this is not included in Feynman.

@Thegaram Thegaram closed this Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants