Skip to content

Conversation

@thomas-nguy
Copy link
Collaborator

@thomas-nguy thomas-nguy commented Oct 3, 2025

👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻

PR Checklist:

  • Have you read the CONTRIBUTING.md?
  • Does your PR follow the C4 patch requirements?
  • Have you rebased your work on top of the latest master?
  • Have you checked your code compiles? (make)
  • Have you included tests for any non-trivial functionality?
  • Have you checked your code passes the unit tests? (make test)
  • Have you checked your code formatting is correct? (go fmt)
  • Have you checked your basic code style is fine? (golangci-lint run)
  • If you added any dependencies, have you checked they do not contain any known vulnerabilities? (go list -json -m all | nancy sleuth)
  • If your changes affect the client infrastructure, have you run the integration test?
  • If your changes affect public APIs, does your PR follow the C4 evolution of public contracts?
  • If your code changes public APIs, have you incremented the crate version numbers and documented your changes in the CHANGELOG.md?
  • If you are contributing for the first time, please read the agreement in CONTRIBUTING.md now and add a comment to this pull request stating that your PR is in accordance with the Developer's Certificate of Origin.

Thank you for your code, it's appreciated! :)

Summary by CodeRabbit

  • New Features
    • Added a configurable history serve window to support EIP-2935 behavior.
  • Tests
    • Added integration tests validating EIP-2935 preinstall registration and runtime blockhash behavior.
    • Added a supporting test contract and test configuration for blockhash verification.
  • Documentation
    • Updated changelog with EIP-2935 and preinstall entries.
  • Chores
    • Updated several dependency versions and module mappings.

@thomas-nguy thomas-nguy requested a review from a team as a code owner October 3, 2025 16:09
@thomas-nguy thomas-nguy requested review from calvinaco and songgaoye and removed request for a team October 3, 2025 16:09
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 3, 2025

Walkthrough

Adds EIP‑2935 support and tests: bumps a few Go module versions, adds a proto field for history serving, introduces a HistoryStorage preinstall integration test and helper Solidity contract, extends test utils and config, and updates the changelog.

Changes

Cohort / File(s) Summary
Changelog
CHANGELOG.md
Update UNRELEASED notes: reword tracer/preinstalls entries and add entry referencing EIP‑2935 support (PR #1882).
Go module updates
go.mod, gomod2nix.toml
Bump google.golang.org/protobuf v1.36.9→v1.36.10, indirect github.com/tidwall/pretty v1.2.0→v1.2.1, and update pseudo-version/hash for the ethermint replacement entry in both files. No code changes.
Proto: EVM params
third_party/proto/ethermint/evm/v1/params.proto
Add uint64 history_serve_window = 8 to Params (EIP‑2935 related).
Integration tests & contracts
integration_tests/contracts/.../TestEip2935.sol, integration_tests/test_eip2935.py, integration_tests/utils.py, integration_tests/configs/eip2935.jsonnet
Add TestEip2935.sol exposing a blockhashOpcode(uint256) helper; new integration test test_eip2935.py to register HistoryStorage as a preinstall via governance and validate blockhash behavior across blocks; register contract in test utils; add test environment config for EIP‑2935.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Tester
  participant Gov as Gov Module
  participant Registry as Preinstall Registry
  participant EVM as EVM Runtime
  participant HS as HistoryStorage (address)
  participant C as TestEip2935

  rect rgba(230,240,255,0.35)
    Tester->>Gov: Submit preinstall registration proposal (HistoryStorage)
    Gov-->>Registry: On approval, register preinstall code at HS address
    Registry-->>EVM: Update preinstall mapping
  end

  rect rgba(240,255,230,0.35)
    Tester->>EVM: Deploy/Test C
    Tester->>C: call blockhashOpcode(n)
    C->>EVM: execute BLOCKHASH opcode
    EVM->>HS: Query history storage / serve window
    HS-->>EVM: Return stored block hash
    EVM-->>C: Deliver bytes32 result
    C-->>Tester: Return and verify hash
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

cronos

Suggested reviewers

  • calvinaco
  • songgaoye
  • JayT106

Poem

I hop through code and tally hops,
A preinstall tucked in ledger shops.
Blockhashs stored and tests take flight,
Governance nods — the rabbit's right. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “feat: support eip2935” succinctly describes the primary change of the pull request, namely adding support for EIP-2935, and is concise, clear, and directly aligned with the scope of the code and test updates in the changeset.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 50092fe and d233314.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (2)
  • go.mod (3 hunks)
  • gomod2nix.toml (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: build
  • GitHub Check: Socket Security: Pull Request Alerts
  • GitHub Check: Run golangci-lint
  • GitHub Check: integration_tests (slow)
  • GitHub Check: integration_tests (ibc_timeout)
  • GitHub Check: integration_tests (gas)
  • GitHub Check: integration_tests (gov)
  • GitHub Check: integration_tests (upgrade)
  • GitHub Check: integration_tests (ibc_update_client)
  • GitHub Check: integration_tests (ica)
  • GitHub Check: integration_tests (ibc)
  • GitHub Check: integration_tests (unmarked)
  • GitHub Check: integration_tests (ibc_rly_gas)
  • GitHub Check: integration_tests (ibc_rly_evm)
  • GitHub Check: unittest
  • GitHub Check: gomod2nix
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (macos-14)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@socket-security
Copy link

socket-security bot commented Oct 3, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedgolang/​github.com/​crypto-org-chain/​ethermint@​v0.22.1-0.20251002045626-63f3de0a10b2 ⏵ v0.22.1-0.20251007011737-164da0caf70375 +110010010070
Updatedgolang/​google.golang.org/​protobuf@​v1.36.9 ⏵ v1.36.1075 +1100100100100

View full report

@codecov
Copy link

codecov bot commented Oct 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 35.79%. Comparing base (a3c2f70) to head (d233314).
⚠️ Report is 113 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #1882       +/-   ##
===========================================
+ Coverage   16.87%   35.79%   +18.91%     
===========================================
  Files          72      127       +55     
  Lines        6163    11812     +5649     
===========================================
+ Hits         1040     4228     +3188     
- Misses       5000     7161     +2161     
- Partials      123      423      +300     

see 81 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@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: 0

🧹 Nitpick comments (6)
CHANGELOG.md (1)

8-8: Clarify scope of EIP‑2935 changes in changelog

Consider expanding this entry to mention the HistoryStorage preinstall registration and the new history_serve_window param (plus the ethermint replace), for easier auditability.

go.mod (1)

309-309: Ethermint replace points to a personal fork; verify provenance and pinning

Using github.com/thomas-nguy/ethermint is risky for supply‑chain and long‑term maintenance. Prefer:

  • A branch/tag under your org (e.g., crypto-org-chain/ethermint) or a specific commit SHA, and
  • A tracking issue to upstream/backport.

Verify that gomod2nix is in sync and CI reproducible builds pass with this replace.

gomod2nix.toml (1)

318-321: Keep gomod2nix in lockstep with go.mod replace

The module mapping now targets the ethermint fork. Ensure:

  • gomod2nix was regenerated from this PR branch,
  • Nix builds work end‑to‑end in CI.

If you plan to move the fork under the org, remember to update this block accordingly.

integration_tests/test_eip2935.py (3)

1-11: Fix import order to satisfy isort

Group third‑party and local imports, and keep them sorted.

-from hexbytes import HexBytes
-
-from .cosmoscli import module_address
-from .network import Cronos
-from .utils import (
-    CONTRACTS,
-    deploy_contract,
-    submit_gov_proposal,
-    w3_wait_for_block,
-)
+from hexbytes import HexBytes
+
+from .cosmoscli import module_address
+from .network import Cronos
+from .utils import CONTRACTS, deploy_contract, submit_gov_proposal, w3_wait_for_block

22-25: Wrap long hex string to pass line length limits

Break the literal across more lines to satisfy E501.

-    expected_history_storage_code = (
-        "0x3373fffffffffffffffffffffffffffffffffffffffe14604657602036036042575f3560014303811160"
-        "4257611fff81430311604257611fff9006545f5260205ff35b5f5ffd5b5f35611fff60014303065500"
-    )
+    expected_history_storage_code = (
+        "0x3373fffffffffffffffffffffffffffffffffffffffe14604657602036036042575f3560014303811160"
+        "4257611fff81430311604257611fff9006545f5260205ff35b5f5ffd5b"
+        "5f35611fff60014303065500"
+    )

57-60: Use the loop index; fix unused variable and strengthen the check

Currently i is unused and start + 0 is constant. Compare multiple consecutive blocks.

-    for i in range(0, 9):
-        block = w3.eth.get_block(start + 0)
-        stored = contract.caller.blockhashOpcode(start + 0)
+    for i in range(0, 9):
+        block = w3.eth.get_block(start + i)
+        stored = contract.caller.blockhashOpcode(start + i)
         assert stored == block.hash
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aff01b5 and 70f4edf.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (7)
  • CHANGELOG.md (1 hunks)
  • go.mod (1 hunks)
  • gomod2nix.toml (1 hunks)
  • integration_tests/contracts/contracts/TestEip2935.sol (1 hunks)
  • integration_tests/test_eip2935.py (1 hunks)
  • integration_tests/utils.py (1 hunks)
  • third_party/proto/ethermint/evm/v1/params.proto (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
integration_tests/test_eip2935.py (2)
integration_tests/utils.py (4)
  • module_address (746-748)
  • deploy_contract (421-441)
  • submit_gov_proposal (224-236)
  • w3_wait_for_block (267-279)
integration_tests/network.py (2)
  • Cronos (16-69)
  • w3 (39-42)
🪛 GitHub Check: Lint python
integration_tests/test_eip2935.py

[failure] 24-24:
./integration_tests/test_eip2935.py:24:89: E501 line too long (92 > 88 characters)


[failure] 23-23:
./integration_tests/test_eip2935.py:23:89: E501 line too long (96 > 88 characters)


[failure] 11-11:
./integration_tests/test_eip2935.py:11:1: I005 isort found an unexpected missing import


[failure] 10-10:
./integration_tests/test_eip2935.py:10:1: I001 isort found an import in the wrong position


[failure] 9-9:
./integration_tests/test_eip2935.py:9:1: I001 isort found an import in the wrong position


[failure] 8-8:
./integration_tests/test_eip2935.py:8:1: I001 isort found an import in the wrong position


[failure] 7-7:
./integration_tests/test_eip2935.py:7:1: I001 isort found an import in the wrong position


[failure] 6-6:
./integration_tests/test_eip2935.py:6:1: I001 isort found an import in the wrong position


[failure] 5-5:
./integration_tests/test_eip2935.py:5:1: I001 isort found an import in the wrong position

🪛 Ruff (0.13.2)
integration_tests/test_eip2935.py

57-57: Loop control variable i not used within loop body

Rename unused i to _i

(B007)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (17)
  • GitHub Check: Run golangci-lint
  • GitHub Check: unittest
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (macos-14)
  • GitHub Check: gomod2nix
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: integration_tests (upgrade)
  • GitHub Check: integration_tests (gas)
  • GitHub Check: integration_tests (ibc_rly_gas)
  • GitHub Check: integration_tests (slow)
  • GitHub Check: integration_tests (ibc_rly_evm)
  • GitHub Check: integration_tests (ibc_timeout)
  • GitHub Check: integration_tests (ibc)
  • GitHub Check: integration_tests (unmarked)
  • GitHub Check: integration_tests (ibc_update_client)
  • GitHub Check: integration_tests (gov)
  • GitHub Check: integration_tests (ica)
🔇 Additional comments (4)
integration_tests/utils.py (1)

72-73: LGTM: contract artifact mapping added

The new TestEip2935 artifact entry integrates cleanly with existing deployment helpers.

integration_tests/contracts/contracts/TestEip2935.sol (1)

1-9: LGTM: minimal helper for blockhash

Contract is concise and suitable for the test purpose.

integration_tests/test_eip2935.py (1)

32-44: Request: confirm preinstall msg type and authority

Ensure /ethermint.evm.v1.MsgRegisterPreinstalls is routed/authorized in the app and that module_address("gov") matches the expected authority on your ethermint fork, otherwise the proposal will fail at runtime.

third_party/proto/ethermint/evm/v1/params.proto (1)

27-28: Integrate new history_serve_window param

  • Regenerate protobufs (e.g. run your proto‐gen script) and commit updated .pb.go for third_party/proto/ethermint/evm/v1/params.proto.
  • Add history_serve_window to DefaultParams() and include validation in Params.Validate().
  • Confirm field number 8 isn’t used upstream in Ethermint to avoid wire‐incompatibility.

Copy link
Contributor

@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

🧹 Nitpick comments (2)
integration_tests/test_eip2935.py (2)

29-39: Clarify why only 4 blocks are checked instead of 5.

The comment on line 29 states "we persist only the latest 5 block hashes," and line 30 says "Check that there is no history if query < current_block_number - 5." However, the loop at line 37 checks range(0, 4), which validates only 4 blocks (start+0 through start+3).

Since header_hash_num is 5, consider checking 5 blocks to fully validate the boundary condition, or add a comment explaining why 4 blocks suffice (e.g., to avoid edge cases at the exact boundary).


74-77: Simplify redundant block waiting.

Lines 75-77 introduce potentially redundant waiting:

  • Line 75: Wait for current block + 10
  • Line 76: Capture new current block as start
  • Line 77: Wait for start + 10 (another 10 blocks)

This results in waiting for approximately 20 blocks total. If the intent is to accumulate sufficient history after deploying the preinstall, consider consolidating or adding a comment explaining the two-phase wait.

Apply this diff to simplify:

-    # Check that history < current_block_number - 5 is available
-    w3_wait_for_block(w3, w3.eth.block_number + 10, timeout=30)
-    start = w3.eth.block_number
-    w3_wait_for_block(w3, start + 10, timeout=30)
+    # Wait for sufficient blocks to accumulate history after preinstall
+    start = w3.eth.block_number + 10
+    w3_wait_for_block(w3, start + 10, timeout=30)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 70f4edf and 73a7aeb.

📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • integration_tests/configs/eip2935.jsonnet (1 hunks)
  • integration_tests/test_eip2935.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md
🧰 Additional context used
🧬 Code graph analysis (1)
integration_tests/test_eip2935.py (2)
integration_tests/utils.py (4)
  • module_address (746-748)
  • deploy_contract (421-441)
  • submit_gov_proposal (224-236)
  • w3_wait_for_block (267-279)
integration_tests/network.py (3)
  • Cronos (16-69)
  • setup_custom_cronos (155-197)
  • w3 (39-42)
🪛 Gitleaks (8.28.0)
integration_tests/configs/eip2935.jsonnet

[high] 122-122: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
  • GitHub Check: integration_tests (gov)
  • GitHub Check: integration_tests (ica)
  • GitHub Check: integration_tests (slow)
  • GitHub Check: integration_tests (gas)
  • GitHub Check: integration_tests (ibc_timeout)
  • GitHub Check: integration_tests (ibc_update_client)
  • GitHub Check: integration_tests (ibc_rly_gas)
  • GitHub Check: integration_tests (upgrade)
  • GitHub Check: integration_tests (ibc)
  • GitHub Check: integration_tests (ibc_rly_evm)
  • GitHub Check: integration_tests (unmarked)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: unittest
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (macos-14)
  • GitHub Check: gomod2nix
  • GitHub Check: Run golangci-lint
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (3)
integration_tests/configs/eip2935.jsonnet (1)

119-123: False positive: Test encryption key, not a secret.

The gitleaks warning flags this as a potential API key, but this is an age encryption public key used for testing the e2ee (end-to-end encryption) module. Test fixtures commonly include hardcoded keys for reproducibility.

integration_tests/test_eip2935.py (2)

78-81: LGTM! Block hash validation logic is correct.

The test correctly validates that after deploying the HistoryStorage preinstall, the blockhashOpcode method returns actual block hashes (not zero bytes) for historical blocks beyond the initial 5-block window. The assertion stored == block.hash confirms the contract retrieves the correct on-chain hash.


42-42: HistoryStorage address verified
The hardcoded address matches the canonical EIP-2935 HISTORY_STORAGE address.

Copy link
Contributor

@JayT106 JayT106 left a comment

Choose a reason for hiding this comment

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

LGTM

@thomas-nguy thomas-nguy enabled auto-merge October 7, 2025 01:20
@thomas-nguy thomas-nguy added this pull request to the merge queue Oct 7, 2025
Merged via the queue into crypto-org-chain:main with commit 9ed1402 Oct 7, 2025
50 checks passed
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