Skip to content

Conversation

@thomas-nguy
Copy link
Collaborator

@thomas-nguy thomas-nguy commented Dec 16, 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
    • Adds preinstalled EVM contracts to provide historical block-hash access (EIP-2935); testnet also includes additional preinstalls for Create2 and Permit2.
  • Chores
    • Project version advanced to v1.7.0 and upgrade handlers extended to support the v1.7 upgrade path.
  • Tests
    • Integration tests expanded to perform the v1.7 upgrade and verify preinstalled contract code.
  • Documentation
    • UNRELEASED changelog entry added for the preinstall in the upgrade handler.

✏️ Tip: You can customize this high-level summary in your review settings.

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

coderabbitai bot commented Dec 16, 2025

Walkthrough

Adds v1.7 upgrade handlers (mainnet and testnet) that register EVM preinstall contracts, bumps version references to v1.7.0, updates changelog and test flakes, and extends integration tests to verify preinstalled contract bytecode after upgrade.

Changes

Cohort / File(s) Summary
Changelog & version
CHANGELOG.md, default.nix
Adds UNRELEASED changelog entry "Add preinstall in upgrade handler"; bumps version string from v1.6.0 to v1.7.0.
Upgrade handler logic
app/upgrades.go
Adds v1.7 and v1.7-testnet upgrade handlers; after migrations unwraps sdk.Context and registers EVM preinstalls (EIP‑2935 on mainnet; EIP‑2935, Create2, Permit2 on testnet); imports Ethereum/Ethermint types.
Integration test infra
integration_tests/configs/upgrade-test-package.nix
Adds released1_6 flake reference for v1.6.1 and updates linkFarm entries to include v1.7 (current) and point v1.6 to the released flake.
Integration tests
integration_tests/test_upgrade.py
Adds HexBytes import; extends allowed upgrade plan names to include v1.7; after v1.7 upgrade verifies preinstall contract bytecode via get_code and HexBytes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Inspect app/upgrades.go for correct preinstall addresses, code bytes, and safe unwrapping of sdk.Context.
  • Verify the integration test get_code assertion and expected HexBytes values.
  • Confirm flake references and linkFarm updates in integration_tests/configs/upgrade-test-package.nix.

Possibly related PRs

Suggested labels

cronos

Suggested reviewers

  • songgaoye
  • calvinaco
  • JayT106

Poem

🐇 I hopped through code, a tiny patch in paw,

Planted preinstalls where the old blocks saw,
EIP‑2935 hums a bright new tune,
Create2 and Permit2 wink under moon,
V1.7 — crunchy carrot, hop and la‑la‑la.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding preinstall functionality in the upgrade handler across multiple upgrade versions (v1.7 and v1.7-testnet).
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 899acd0 and 6d46474.

📒 Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md
⏰ 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: Run golangci-lint
  • GitHub Check: integration_tests (evm)
  • GitHub Check: integration_tests (ica)
  • GitHub Check: integration_tests (ibc_rly_gas)
  • GitHub Check: integration_tests (unmarked)
  • GitHub Check: integration_tests (ibc_timeout)
  • GitHub Check: integration_tests (gov)
  • GitHub Check: integration_tests (ibc)
  • GitHub Check: integration_tests (mint)
  • GitHub Check: integration_tests (slow)
  • GitHub Check: integration_tests (upgrade)
  • GitHub Check: integration_tests (ibc_update_client)
  • GitHub Check: integration_tests (gas)
  • GitHub Check: integration_tests (ibc_rly_evm)
  • GitHub Check: build (macos-14)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: unittest
  • GitHub Check: Analyze (go)

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.

@github-actions github-actions bot added the nix label Dec 16, 2025
@github-actions

This comment has been minimized.

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: 3

🧹 Nitpick comments (1)
app/upgrades.go (1)

24-35: Consider extracting common preinstall definitions.

The EIP-2935 preinstall is duplicated between the mainnet (v1.7) and testnet (v1.7-testnet) handlers. Consider extracting it to a package-level variable or helper to reduce duplication.

// At package level or as a helper
var eip2935Preinstall = evmtypes.Preinstall{
    Name:    "EIP-2935 - Serve historical block hashes from state",
    Address: params.HistoryStorageAddress.String(),
    Code:    common.Bytes2Hex(params.HistoryStorageCode),
}

Then reuse in both handlers.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 63b6a38 and c1ed71c.

📒 Files selected for processing (5)
  • CHANGELOG.md (1 hunks)
  • app/upgrades.go (1 hunks)
  • default.nix (1 hunks)
  • integration_tests/configs/upgrade-test-package.nix (2 hunks)
  • integration_tests/test_upgrade.py (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
integration_tests/test_upgrade.py (2)
integration_tests/cosmoscli.py (1)
  • block_height (177-178)
integration_tests/network.py (1)
  • w3 (39-42)
app/upgrades.go (2)
app/app.go (2)
  • App (273-338)
  • Name (167-167)
x/cronos/types/interfaces.go (1)
  • EvmKeeper (59-69)
🪛 GitHub Check: Lint python
integration_tests/test_upgrade.py

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


[failure] 357-357:
./integration_tests/test_upgrade.py:357:89: E501 line too long (102 > 88 characters)

⏰ 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: Run golangci-lint
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (macos-14)
  • GitHub Check: unittest
  • GitHub Check: integration_tests (evm)
  • GitHub Check: integration_tests (slow)
  • GitHub Check: integration_tests (mint)
  • GitHub Check: integration_tests (unmarked)
  • GitHub Check: integration_tests (ibc_rly_gas)
  • GitHub Check: integration_tests (gov)
  • GitHub Check: integration_tests (ibc_rly_evm)
  • GitHub Check: integration_tests (ibc_timeout)
  • GitHub Check: integration_tests (ibc_update_client)
  • GitHub Check: integration_tests (ica)
  • GitHub Check: integration_tests (ibc)
  • GitHub Check: integration_tests (upgrade)
  • GitHub Check: integration_tests (gas)
  • GitHub Check: Analyze (go)
🔇 Additional comments (9)
CHANGELOG.md (1)

10-11: LGTM!

The changelog entry follows the existing format and is correctly placed under the UNRELEASED section.

default.nix (1)

14-14: LGTM!

Version bump to v1.7.0 correctly aligns with the new v1.7 upgrade handlers.

integration_tests/test_upgrade.py (2)

347-362: Preinstall verification test logic looks correct.

The test correctly verifies that the EIP-2935 historical storage contract is deployed at the expected address with the expected bytecode after the v1.7 upgrade.


172-172: LGTM!

Adding v1.7 to the allowed upgrade plan names enables the governance proposal submission path for the new version.

integration_tests/configs/upgrade-test-package.nix (2)

30-32: LGTM!

The released1_6 binding correctly references the v1.6.1 release commit, following the established pattern for previous releases.


61-67: LGTM!

The v1.6 entry now correctly points to the released version, and v1.7 points to the current development code, enabling proper upgrade path testing.

app/upgrades.go (3)

17-38: Mainnet v1.7 upgrade handler structure looks correct.

The handler properly runs migrations first, then applies preinstalls. Error handling is appropriate, returning errors from both RunMigrations and AddPreinstalls.


40-71: Testnet v1.7-testnet upgrade handler structure looks correct.

The handler correctly registers additional testnet-specific preinstalls (Create2 and Permit2) alongside the standard EIP-2935 preinstall.


48-58: Hardcoded preinstall addresses are canonical deployments

Both addresses are confirmed as canonical:

  • Create2 deployer (0x4e59b44847b379578588920ca78fbf26c0b4956c) is the most widely used CREATE2 factory contract out there, deployed to this address on many chains
  • Permit2 (0x000000000022D473030F116dDEE9F6B43aC78BA3) is the canonical Permit2 contract referred to in Uniswap's documentation and integration guides as the one blessed address that everyone should use

Both bytecodes correspond to the verified contracts on Ethereum and are deployed identically across multiple chains.

@codecov
Copy link

codecov bot commented Dec 16, 2025

Codecov Report

❌ Patch coverage is 5.71429% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 25.51%. Comparing base (a3c2f70) to head (6d46474).
⚠️ Report is 131 commits behind head on main.

Files with missing lines Patch % Lines
app/upgrades.go 5.71% 32 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1939      +/-   ##
==========================================
+ Coverage   16.87%   25.51%   +8.63%     
==========================================
  Files          72       78       +6     
  Lines        6163     5150    -1013     
==========================================
+ Hits         1040     1314     +274     
+ Misses       5000     3673    -1327     
- Partials      123      163      +40     
Files with missing lines Coverage Δ
app/upgrades.go 10.52% <5.71%> (+5.19%) ⬆️

... and 72 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

♻️ Duplicate comments (1)
app/upgrades.go (1)

50-66: Prefix inconsistency—normalize the Code field format.

Create2 and Permit2 preinstalls use explicit 0x prefixes (lines 54, 59), while EIP-2935 uses common.Bytes2Hex() which does not include the 0x prefix (line 64). This inconsistency could cause issues depending on how AddPreinstalls parses the Code field.

Either add the 0x prefix to the Bytes2Hex output or use Bytes2Hex for all Code fields to maintain consistency.

#!/bin/bash
# Verify how AddPreinstalls handles the Code field and whether it expects 0x prefix
ast-grep --pattern $'func ($_ $_) AddPreinstalls($_, $_) $_ {
  $$$
}'
# Also search for hex decoding logic
rg -n "Code" --type go -A 3 -B 3 | grep -i "hex\|decode"
🧹 Nitpick comments (1)
app/upgrades.go (1)

27-37: Consider extracting EIP-2935 preinstall to reduce duplication.

The EIP-2935 preinstall definition is identical in both the mainnet (lines 27-33) and testnet (lines 61-65) handlers. Extract this to a shared variable or helper function.

+var eip2935Preinstall = evmtypes.Preinstall{
+	Name:    "EIP-2935 - Serve historical block hashes from state",
+	Address: params.HistoryStorageAddress.String(),
+	Code:    common.Bytes2Hex(params.HistoryStorageCode),
+}
+
 func (app *App) RegisterUpgradeHandlers(cdc codec.BinaryCodec, maxVersion int64) bool {
 	planName := "v1.7"
 	app.UpgradeKeeper.SetUpgradeHandler(planName, func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
 		// ...
 		{
-			preinstall := []evmtypes.Preinstall{
-				{
-					Name:    "EIP-2935 - Serve historical block hashes from state",
-					Address: params.HistoryStorageAddress.String(),
-					Code:    common.Bytes2Hex(params.HistoryStorageCode),
-				},
-			}
+			preinstall := []evmtypes.Preinstall{eip2935Preinstall}

Also applies to: 61-66

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fa33642 and 960177f.

📒 Files selected for processing (2)
  • app/upgrades.go (1 hunks)
  • integration_tests/test_upgrade.py (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
integration_tests/test_upgrade.py (2)
integration_tests/cosmoscli.py (1)
  • block_height (177-178)
integration_tests/network.py (1)
  • w3 (39-42)
⏰ 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: build (ubuntu-latest)
  • GitHub Check: build (macos-latest)
  • GitHub Check: unittest
  • GitHub Check: build (macos-14)
  • GitHub Check: integration_tests (upgrade)
  • GitHub Check: Run golangci-lint
  • GitHub Check: integration_tests (slow)
  • GitHub Check: integration_tests (ibc_rly_evm)
  • GitHub Check: integration_tests (ibc)
  • GitHub Check: integration_tests (ica)
  • GitHub Check: integration_tests (unmarked)
  • GitHub Check: integration_tests (mint)
  • GitHub Check: integration_tests (gas)
  • GitHub Check: integration_tests (ibc_timeout)
  • GitHub Check: integration_tests (evm)
  • GitHub Check: integration_tests (gov)
  • GitHub Check: integration_tests (ibc_rly_gas)
  • GitHub Check: Analyze (go)
  • GitHub Check: integration_tests (ibc_update_client)
🔇 Additional comments (4)
app/upgrades.go (1)

27-37: LGTM for the mainnet upgrade handler structure.

The error handling for migrations and the preinstall registration pattern look correct. The use of sdk.UnwrapSDKContext is appropriate for interfacing with the EVM keeper.

integration_tests/test_upgrade.py (3)

12-15: Import order appears correct now.

The HexBytes import at line 12 is properly positioned alphabetically among third-party imports (hexbytes before pystarport and web3).


172-172: LGTM for adding v1.7 to the upgrade flow.

The v1.7 plan name is correctly added to the conditional that uses the new governance proposal format.


347-363: The review comment's concern is valid in principle: hardcoded test values should be kept synchronized with upstream constants to prevent test failures. However, I cannot complete the verification without repository access to confirm the specific claims about app/upgrades.go using params.HistoryStorageAddress and params.HistoryStorageCode. The test values do match the current go-ethereum params constants, but further investigation into the local codebase is needed to fully assess the synchronization risk.

@thomas-nguy thomas-nguy force-pushed the thomas/create2preinstall branch from 960177f to 899acd0 Compare December 18, 2025 07:30
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

♻️ Duplicate comments (2)
integration_tests/test_upgrade.py (2)

12-12: Import order issue already flagged.

The static analysis tool flagged an import order violation on this line in a previous review. Please address the linting issue by moving the HexBytes import to the correct position.


355-359: Line length issue already flagged.

The line length violation on line 357 has been flagged in a previous review. Please break the string literal into multiple lines to satisfy the linter.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 960177f and 899acd0.

📒 Files selected for processing (5)
  • CHANGELOG.md (1 hunks)
  • app/upgrades.go (1 hunks)
  • default.nix (1 hunks)
  • integration_tests/configs/upgrade-test-package.nix (2 hunks)
  • integration_tests/test_upgrade.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • default.nix
  • CHANGELOG.md
🧰 Additional context used
🧬 Code graph analysis (2)
app/upgrades.go (2)
app/app.go (1)
  • App (273-338)
x/cronos/types/interfaces.go (1)
  • EvmKeeper (59-69)
integration_tests/test_upgrade.py (2)
integration_tests/cosmoscli.py (1)
  • block_height (177-178)
integration_tests/network.py (1)
  • w3 (39-42)
⏰ 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: build (macos-14)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: unittest
  • GitHub Check: integration_tests (gas)
  • GitHub Check: integration_tests (evm)
  • GitHub Check: integration_tests (slow)
  • GitHub Check: integration_tests (mint)
  • GitHub Check: integration_tests (ibc_update_client)
  • GitHub Check: integration_tests (ica)
  • GitHub Check: integration_tests (unmarked)
  • GitHub Check: integration_tests (ibc_timeout)
  • GitHub Check: integration_tests (ibc_rly_evm)
  • GitHub Check: integration_tests (ibc)
  • GitHub Check: integration_tests (upgrade)
  • GitHub Check: integration_tests (gov)
  • GitHub Check: Run golangci-lint
  • GitHub Check: integration_tests (ibc_rly_gas)
  • GitHub Check: Analyze (go)
🔇 Additional comments (8)
integration_tests/test_upgrade.py (2)

172-172: LGTM!

The addition of "v1.7" to the allowed upgrade plan names correctly enables the new upgrade path.


347-363: The hardcoded bytecode in the test correctly matches the EIP-2935 specification and aligns with go-ethereum's params.HistoryStorageCode implementation.

Verification confirms the test bytecode matches the EIP-2935 specification and is consistent with the go-ethereum v1.15.11 dependency used in the codebase.

app/upgrades.go (4)

6-13: LGTM!

The added imports are necessary for preinstall handling and are used appropriately in the upgrade handlers.


19-40: LGTM, but note the Code field format inconsistency.

The v1.7 mainnet upgrade handler correctly:

  • Runs migrations before adding preinstalls
  • Unwraps the context for SDK operations
  • Handles errors appropriately
  • Adds the EIP-2935 preinstall

However, a past review comment already flagged that the Code field uses common.Bytes2Hex() which returns hex without the 0x prefix, while the testnet handler uses explicit 0x prefixes for Create2 and Permit2. Please address the format inconsistency noted in the previous review.


51-55: Appropriate separation of mainnet and testnet preinstalls.

The Create2 preinstall is correctly included only in the testnet handler, addressing the concern raised in previous comments about the existing Create2 deployment on mainnet.


56-60: LGTM!

The Permit2 preinstall is appropriately included in the testnet handler alongside Create2, as discussed in previous comments.

integration_tests/configs/upgrade-test-package.nix (2)

60-67: LGTM!

The linkFarm entries correctly transition v1.6 to use the released version and add v1.7 as the new current version, following the established pattern.


30-32: v1.6.1 is not a recognized release in cronos repository.

The released1_6 binding references a non-existent release tag. The latest available version is v1.5.0, with stable releases only up to v1.4.10. Verify whether this should target an existing release (v1.4.x or v1.5.0) or if this configuration is intended for a future release that hasn't been published yet. The commit hash 05e102ef83b9ab0d5b55d46fb90f5fee53a295d2 should also be validated against an actual release tag.

@thomas-nguy thomas-nguy added this pull request to the merge queue Dec 18, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 18, 2025
@thomas-nguy thomas-nguy added this pull request to the merge queue Dec 19, 2025
Merged via the queue into crypto-org-chain:main with commit 6dac283 Dec 19, 2025
46 of 48 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jan 13, 2026
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants