fix: edit upgrade to include v7.0 for mainnet#284
Conversation
WalkthroughThis 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)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
app/upgrades/v7_1/upgrade.go
There was a problem hiding this comment.
🧹 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 (icsExistscheck). 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
📒 Files selected for processing (2)
app/app_helpers.goapp/upgrades/v7_1/upgrade_test.go
There was a problem hiding this comment.
🧹 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.
Upgradesnow 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
📒 Files selected for processing (5)
CHANGELOG.mdapp/app.goapp/upgrades/v7_1_mainnet/constants.goapp/upgrades/v7_1_mainnet/upgrade.goapp/upgrades/v7_1_mainnet/upgrade_test.go
✅ Files skipped from review due to trivial changes (1)
- CHANGELOG.md
Description
Makes a special upgrade path for mainnet
Type of change