Skip to content

fix: edit upgrade to include v7.0 for mainnet#284

Merged
Thaleszh merged 6 commits into
mainfrom
upgrade/v7.1-mainnet
Mar 13, 2026
Merged

fix: edit upgrade to include v7.0 for mainnet#284
Thaleszh merged 6 commits into
mainfrom
upgrade/v7.1-mainnet

Conversation

@Thaleszh

Copy link
Copy Markdown
Contributor

Description

Makes a special upgrade path for mainnet

Type of change

  • Bug fix (non-breaking change which fixes an issue)

@Thaleszh Thaleszh requested a review from jhelison as a code owner March 13, 2026 00:23
@coderabbitai

coderabbitai Bot commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This pull request introduces a mainnet-specific upgrade handler for v7.1.0. The changes wire a new v7_1_mainnet upgrade implementation into the application, add accessor methods for the module manager and configurator in KiichainApp, and implement EVM upgrade logic that initializes token metadata, extends EVM parameters with denom options, manages static precompiles (removing wasmd, adding ICS20), and executes module migrations. Supporting tests validate the EVM upgrade flow and precompile management. A changelog entry documents the merge of v7.0.0 and v7.1.0 into a single mainnet upgrade.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: creating a special v7.1-mainnet upgrade implementation that merges v7.0 and v7.1 for mainnet, as evidenced by the new v7_1_mainnet module, updated CHANGELOG, and Upgrades wiring changes.
Description check ✅ Passed The description is related to the changeset, stating that the PR makes a special upgrade path for mainnet, which aligns with the addition of the v7_1_mainnet upgrade module and the CHANGELOG entry documenting the v7.0 and v7.1 merge.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch upgrade/v7.1-mainnet
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@codecov

codecov Bot commented Mar 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/upgrades/v7_1/upgrade.go`:
- Around line 89-107: The code unconditionally calls BankKeeper.SetDenomMetaData
in EVMUpgrade, which can overwrite existing metadata; change it to first call
BankKeeper.GetDenomMetaData with params.BaseDenom (and/or params.DisplayDenom)
and only call SetDenomMetaData if GetDenomMetaData returns not-ok, mirroring the
defensive pattern used in x/oracle/keeper (check GetDenomMetaData before
SetDenomMetaData) so the function truly "adds missing" metadata without
overwriting existing entries.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d665976f-e393-499a-beca-3a6c3016b35e

📥 Commits

Reviewing files that changed from the base of the PR and between d3221f0 and b76cd02.

📒 Files selected for processing (1)
  • app/upgrades/v7_1/upgrade.go

Comment thread app/upgrades/v7_1/upgrade.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

48-91: Consider adding a test case where ICS20 already exists.

The test covers the scenario where ICS20 is absent and should be added. However, the production code in CreateUpgradeHandler (lines 49-60 in upgrade.go) has logic to skip adding ICS20 if it already exists (icsExists check). Adding a complementary test case would ensure the idempotency logic is verified.

💡 Suggested additional test case
// TestCreateUpgradeHandler_Precompiles_ICS20AlreadyPresent verifies that when ICS20
// is already in the precompile list, it is not duplicated after the upgrade.
//
// Initial state: [otherPrecompile, ics20Precompile, wasmdPrecompile]
// Expected state: [otherPrecompile, ics20Precompile]
func TestCreateUpgradeHandler_Precompiles_ICS20AlreadyPresent(t *testing.T) {
	app, ctx := kiihelpers.SetupWithContext(t)

	// Set up initial active precompiles: ICS20 already present
	evmParams := app.EVMKeeper.GetParams(ctx)
	evmParams.ActiveStaticPrecompiles = []string{otherPrecompileAddress, ics20PrecompileAddress, wasmdPrecompileAddress}
	err := app.EVMKeeper.SetParams(ctx, evmParams)
	require.NoError(t, err)

	// Run the upgrade handler
	mm := app.GetModuleManager()
	handler := v710.CreateUpgradeHandler(mm, app.GetConfigurator(), &app.AppKeepers)
	vm, err := handler(ctx, upgradetypes.Plan{Name: v710.UpgradeName}, mm.GetVersionMap())
	require.NoError(t, err)
	require.NotNil(t, vm)

	resultParams := app.EVMKeeper.GetParams(ctx)
	result := resultParams.ActiveStaticPrecompiles

	// ICS20 must appear exactly once (not duplicated)
	count := 0
	for _, p := range result {
		if p == ics20PrecompileAddress {
			count++
		}
	}
	require.Equal(t, 1, count, "ICS20 precompile should appear exactly once, not be duplicated")
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/upgrades/v7_1/upgrade_test.go` around lines 48 - 91, Add a complementary
test to confirm idempotency when ICS20 already exists: create
TestCreateUpgradeHandler_Precompiles_ICS20AlreadyPresent that sets
evmParams.ActiveStaticPrecompiles to include otherPrecompileAddress,
ics20PrecompileAddress, and wasmdPrecompileAddress, call the handler created by
v710.CreateUpgradeHandler (same way as TestCreateUpgradeHandler_Precompiles),
then assert wasmdPrecompileAddress is removed, otherPrecompileAddress is
retained, and that ics20PrecompileAddress appears exactly once (count == 1) to
ensure the icsExists branch in CreateUpgradeHandler (upgrade.go) does not
duplicate ICS20; use app.EVMKeeper.GetParams/SetParams and the same require
checks as the existing test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@app/upgrades/v7_1/upgrade_test.go`:
- Around line 48-91: Add a complementary test to confirm idempotency when ICS20
already exists: create TestCreateUpgradeHandler_Precompiles_ICS20AlreadyPresent
that sets evmParams.ActiveStaticPrecompiles to include otherPrecompileAddress,
ics20PrecompileAddress, and wasmdPrecompileAddress, call the handler created by
v710.CreateUpgradeHandler (same way as TestCreateUpgradeHandler_Precompiles),
then assert wasmdPrecompileAddress is removed, otherPrecompileAddress is
retained, and that ics20PrecompileAddress appears exactly once (count == 1) to
ensure the icsExists branch in CreateUpgradeHandler (upgrade.go) does not
duplicate ICS20; use app.EVMKeeper.GetParams/SetParams and the same require
checks as the existing test.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: def49351-6c3b-40d2-a456-74f76006b648

📥 Commits

Reviewing files that changed from the base of the PR and between b76cd02 and f7c2245.

📒 Files selected for processing (2)
  • app/app_helpers.go
  • app/upgrades/v7_1/upgrade_test.go

@jhelison jhelison left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lint is broken

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
app/upgrades/v7_1_mainnet/upgrade.go (1)

22-24: Centralize upgrade identifiers and align logging/comments.

There’s small drift between comments/log labels and the mainnet upgrade naming, plus an inline wasmd address literal. Consolidating these to constants will reduce maintenance mistakes.

Refactor sketch
 const (
 	ics20precompileAddress = "0x0000000000000000000000000000000000000802"
+	wasmdPrecompileAddress = "0x0000000000000000000000000000000000001001"
 )
 
-// CreateUpgradeHandler creates the upgrade handler for the v7.1.0 upgrade
-// Its only purpose is to run the module migrations
+// CreateUpgradeHandler creates the upgrade handler for the v7.1.0-mainnet upgrade.
 func CreateUpgradeHandler(
@@
-			if precompile != "0x0000000000000000000000000000000000001001" {
+			if precompile != wasmdPrecompileAddress {
 				newPrecompiles = append(newPrecompiles, precompile)
 			}
@@
-		ctx.Logger().Info("Upgrade v7.1.0 complete")
+		ctx.Logger().Info("Upgrade complete", "name", UpgradeName)
 		return vm, nil
 	}
 }

Also applies to: 49-50, 78-78

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/upgrades/v7_1_mainnet/upgrade.go` around lines 22 - 24, Define
centralized constants for the upgrade identifier and the wasmd address, and
replace all inline literals and mismatched labels/comments with those constants:
add something like UpgradeName and WasmdModuleAddress and use UpgradeName in the
CreateUpgradeHandler comment, any log.Printf/processLogger messages, and the
upgrade registration call (replace the inline "v7.1.0" or mainnet string), and
use WasmdModuleAddress wherever the literal wasmd address appears (lines
referenced around CreateUpgradeHandler, the migration registration at the 49-50
area, and the logging at ~78). Ensure comments/logs use the UpgradeName constant
so names stay consistent and avoid duplicated literals.
app/upgrades/v7_1_mainnet/upgrade_test.go (1)

53-91: Consider one more test: ICS20 already present before upgrade.

An additional case where ICS20 exists in the initial params would lock in “no duplicate ICS20” behavior across both branches.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/upgrades/v7_1_mainnet/upgrade_test.go` around lines 53 - 91, Add a new
test to cover the case where ICS20 is already present before running the
upgrade: create TestCreateUpgradeHandler_Precompiles_Ics20AlreadyPresent (or
similar) that sets evmParams.ActiveStaticPrecompiles to include
otherPrecompileAddress, wasmdPrecompileAddress, and ics20PrecompileAddress via
app.EVMKeeper.SetParams, run the upgrade handler from
v710_mainnet.CreateUpgradeHandler with v710_mainnet.UpgradeName, then assert
wasmdPrecompileAddress was removed, otherPrecompileAddress remains,
ics20PrecompileAddress is present and appears exactly once (use
app.EVMKeeper.GetParams and check the slice contents/count to prevent
duplicates).
app/app.go (1)

79-82: Consider adding a legacy upgrade-name alias in the registry.

Upgrades now registers only one name path. Adding a legacy alias mapped to the same handler can reduce rollout risk during transition windows.

Suggested compatibility pattern
 Upgrades = []upgrades.Upgrade{
 	v7_1_mainnet.Upgrade,
+	v7_1_mainnet.LegacyUpgrade,
 }
// app/upgrades/v7_1_mainnet/constants.go (additional)
const LegacyUpgradeName = "v7.1.0"

var LegacyUpgrade = upgrades.Upgrade{
	UpgradeName:          LegacyUpgradeName,
	CreateUpgradeHandler: CreateUpgradeHandler,
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/app.go` around lines 79 - 82, Add a legacy alias entry for the upgrade so
the registry contains both the current and legacy names; create a
LegacyUpgradeName constant and a LegacyUpgrade variable in the v7_1_mainnet
package (e.g., LegacyUpgradeName = "v7.1.0" and LegacyUpgrade using the same
CreateUpgradeHandler) and then include v7_1_mainnet.LegacyUpgrade alongside
v7_1_mainnet.Upgrade in the Upgrades slice (the Upgrades variable and
upgrades.Upgrade type are the targets to modify).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@app/app.go`:
- Around line 79-82: Add a legacy alias entry for the upgrade so the registry
contains both the current and legacy names; create a LegacyUpgradeName constant
and a LegacyUpgrade variable in the v7_1_mainnet package (e.g.,
LegacyUpgradeName = "v7.1.0" and LegacyUpgrade using the same
CreateUpgradeHandler) and then include v7_1_mainnet.LegacyUpgrade alongside
v7_1_mainnet.Upgrade in the Upgrades slice (the Upgrades variable and
upgrades.Upgrade type are the targets to modify).

In `@app/upgrades/v7_1_mainnet/upgrade_test.go`:
- Around line 53-91: Add a new test to cover the case where ICS20 is already
present before running the upgrade: create
TestCreateUpgradeHandler_Precompiles_Ics20AlreadyPresent (or similar) that sets
evmParams.ActiveStaticPrecompiles to include otherPrecompileAddress,
wasmdPrecompileAddress, and ics20PrecompileAddress via app.EVMKeeper.SetParams,
run the upgrade handler from v710_mainnet.CreateUpgradeHandler with
v710_mainnet.UpgradeName, then assert wasmdPrecompileAddress was removed,
otherPrecompileAddress remains, ics20PrecompileAddress is present and appears
exactly once (use app.EVMKeeper.GetParams and check the slice contents/count to
prevent duplicates).

In `@app/upgrades/v7_1_mainnet/upgrade.go`:
- Around line 22-24: Define centralized constants for the upgrade identifier and
the wasmd address, and replace all inline literals and mismatched
labels/comments with those constants: add something like UpgradeName and
WasmdModuleAddress and use UpgradeName in the CreateUpgradeHandler comment, any
log.Printf/processLogger messages, and the upgrade registration call (replace
the inline "v7.1.0" or mainnet string), and use WasmdModuleAddress wherever the
literal wasmd address appears (lines referenced around CreateUpgradeHandler, the
migration registration at the 49-50 area, and the logging at ~78). Ensure
comments/logs use the UpgradeName constant so names stay consistent and avoid
duplicated literals.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1ee5242b-64d9-41e9-8f82-cbc1b24913b4

📥 Commits

Reviewing files that changed from the base of the PR and between f7c2245 and 8549782.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • app/app.go
  • app/upgrades/v7_1_mainnet/constants.go
  • app/upgrades/v7_1_mainnet/upgrade.go
  • app/upgrades/v7_1_mainnet/upgrade_test.go
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md

@Thaleszh Thaleszh merged commit b103c1c into main Mar 13, 2026
10 checks passed
@Thaleszh Thaleszh deleted the upgrade/v7.1-mainnet branch March 13, 2026 20:26
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.

2 participants