Skip to content

!fix(opchild): port #192 into main#194

Merged
traviolus merged 2 commits intomainfrom
fix/opchild-ibc-migration-base-denom-path-main
May 6, 2026
Merged

!fix(opchild): port #192 into main#194
traviolus merged 2 commits intomainfrom
fix/opchild-ibc-migration-base-denom-path-main

Conversation

@traviolus
Copy link
Copy Markdown
Contributor

@traviolus traviolus commented May 6, 2026

Description

Porting #192 into main

Closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • New Features

    • Added support for BaseIbcDenomPath in migration information
    • New API to remove IBC-to-L2 denom mappings
  • Improvements

    • Enhanced IBC denomination handling and validation logic
    • Support for overwriting legacy IBC base denom mappings during migration registration
  • Tests

    • Added coverage for migration info registration with IBC base denom scenarios

@traviolus traviolus requested a review from a team as a code owner May 6, 2026 09:21
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Walkthrough

The PR adds support for a BaseIbcDenomPath field to the MigrationInfo message and refactors IBC denomination derivation logic. It centralizes denom computation into an ibcDenom helper function, updates proto dependencies from IBC v8 to v10, wires the new field through validation and storage layers, and adds tests for base IBC denom path scenarios.

Changes

IBC Base Denom Path Support

Layer / File(s) Summary
Proto Definition & Version
proto/opinit/opchild/v1/types.proto, scripts/protocgen-pulsar.sh
New base_ibc_denom_path field (tag 4) added to MigrationInfo message. IBC proto dependency bumped from v8 to v10 in generation script.
Generated Reflection & Marshaling
api/opinit/opchild/v1/types.pulsar.go
Auto-generated getter GetBaseIbcDenomPath() and fastReflection methods (Has/Get/Set/NewField/ProtoMethods) wired for new field. Size calculation and descriptor initialization updated.
Core Denom Derivation Logic
x/opchild/keeper/migration.go
New ibcDenom() helper (signature: (migrationInfo, baseDenom) (string, error)) replaces inline denom extraction. Handles base IBC denom paths and validates path format. Added legacyIBCDenom() and canOverwriteMigrationInfo() helpers for legacy support. New public method RemoveIBCToL2DenomMap() for cleanup. Updated MigrateToken() to use ibcDenom helper with error handling.
Validation
x/opchild/types/migration_info.go
New validation block in MigrationInfo.Validate() to extract and validate BaseIbcDenomPath when set, ensuring the denom trace is valid and non-native.
Integration & Wiring
x/opchild/keeper/msg_server.go, x/opchild/keeper/querier.go, x/opchild/keeper/genesis.go
RegisterMigrationInfo refactored to check for existing entries, support overwriting with canOverwriteMigrationInfo logic, remove legacy IBC mappings when needed, and compute denom via ibcDenom(). MigrationInfo RPC query and genesis init updated to use ibcDenom() helper instead of direct transfertypes extraction. Removed direct transfertypes usage in favor of centralized helper.
Tests
x/opchild/keeper/migration_test.go
Added Test_RegisterMigrationInfo_WithIBCBaseDenom to validate registration with missing then present base path. Added Test_RegisterMigrationInfo_OverwriteLegacyIBCBaseDenom to validate overwriting legacy IBC base denom mappings and cleaning up old entries.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐰 A denom path decoded with care,
IBC traces flow through the air,
From proto to keeper they dance,
Legacy mappings get a new chance—
Base paths now guide the way there!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'fix(opchild): port #192 into main' is vague and does not clearly convey the actual changes in the PR. While it mentions the issue number, the word 'port' is non-descriptive and does not explain what is being fixed or what the main change is. Replace with a more descriptive title such as 'fix(opchild): handle ibc migration base denom path' to clearly communicate the primary change and purpose of this PR.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/opchild-ibc-migration-base-denom-path-main

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

The latest Buf updates on your PR. Results from workflow Protobuf / buf-build (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMay 6, 2026, 9:22 AM

@traviolus traviolus changed the title fix(opchild): handle ibc migration base denom path !fix(opchild): port #192 into main May 6, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

❌ Patch coverage is 39.39394% with 40 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.33%. Comparing base (7df13df) to head (557f1a6).

Files with missing lines Patch % Lines
x/opchild/keeper/migration.go 50.00% 13 Missing and 4 partials ⚠️
x/opchild/keeper/msg_server.go 40.00% 5 Missing and 4 partials ⚠️
x/opchild/types/migration_info.go 0.00% 8 Missing ⚠️
x/opchild/keeper/genesis.go 25.00% 1 Missing and 2 partials ⚠️
x/opchild/keeper/querier.go 40.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #194      +/-   ##
==========================================
- Coverage   43.39%   43.33%   -0.07%     
==========================================
  Files          74       74              
  Lines        7369     7424      +55     
==========================================
+ Hits         3198     3217      +19     
- Misses       3586     3614      +28     
- Partials      585      593       +8     
Files with missing lines Coverage Δ
x/opchild/keeper/genesis.go 42.10% <25.00%> (-0.76%) ⬇️
x/opchild/keeper/querier.go 45.45% <40.00%> (-1.85%) ⬇️
x/opchild/types/migration_info.go 0.00% <0.00%> (ø)
x/opchild/keeper/msg_server.go 62.33% <40.00%> (-0.37%) ⬇️
x/opchild/keeper/migration.go 57.66% <50.00%> (-2.64%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
x/opchild/keeper/querier.go (1)

110-118: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Guard the request before dereferencing it.

req.Denom is read before any nil check, so a nil call into this RPC will panic instead of returning InvalidArgument. It would also be worth rejecting an empty denom here for consistency with the other query handlers.

Proposed fix
 func (q Querier) MigrationInfo(ctx context.Context, req *types.QueryMigrationInfoRequest) (*types.QueryMigrationInfoResponse, error) {
+	if req == nil {
+		return nil, status.Error(codes.InvalidArgument, "empty request")
+	}
+	if req.Denom == "" {
+		return nil, status.Error(codes.InvalidArgument, "denom cannot be empty")
+	}
+
 	migrationInfo, err := q.GetMigrationInfo(ctx, req.Denom)
 	if err != nil && errors.Is(err, collections.ErrNotFound) {
 		return nil, status.Error(codes.NotFound, err.Error())
 	} else if err != nil {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@x/opchild/keeper/querier.go` around lines 110 - 118, The MigrationInfo
handler currently dereferences req.Denom before validating req; add a guard at
the start of Querier.MigrationInfo to check if req is nil or req.Denom is empty
and return status.Error(codes.InvalidArgument, "...") accordingly, then proceed
to call q.GetMigrationInfo and q.GetBaseDenom; ensure the nil/empty check
happens before any access to req.Denom to prevent panics and to match other
query handlers' validation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@x/opchild/keeper/genesis.go`:
- Around line 109-113: Genesis hydration panics because ibcDenom(migrationInfo,
baseDenom) hard-fails for legacy ibc/... base denoms when BaseIbcDenomPath is
empty; to preserve round-trip compatibility, change the genesis import logic
around ibcDenom in the migration hydration path to detect legacy-shaped
MigrationInfos (or base denoms that start with "ibc/") and fall back to the
legacy decoder (call legacyIBCDenom(...) or equivalent) when BaseIbcDenomPath is
unset, then continue to call k.SetIBCToL2DenomMap(ctx, migrationIBCDenom,
migrationInfo.Denom); alternatively, before export/import ensure ExportGenesis
backfills BaseIbcDenomPath for stored MigrationInfos — reference ibcDenom,
legacyIBCDenom, MigrationInfos, ExportGenesis, and SetIBCToL2DenomMap to locate
the change.

In `@x/opchild/keeper/migration.go`:
- Around line 261-262: canOverwriteMigrationInfo currently checks only that the
stored record has an empty BaseIbcDenomPath and the baseDenom looks like an IBC
denom, which allows callers (e.g., RegisterMigrationInfo) to replace routing
fields; change the predicate to compare the incoming MigrationInfo with the
stored one and allow overwrite only when the stored.BaseIbcDenomPath == "" and
the incoming.BaseIbcDenomPath is non-empty AND all route-identifying fields are
identical (e.g., IbcPortId and IbcChannelId must match between the stored
migrationInfo and the incoming migrationInfo). Update RegisterMigrationInfo to
pass both the existing record and the new request into this check (or call
canOverwriteMigrationInfo with both versions) so only backfilling of
BaseIbcDenomPath is permitted, not replacement of routing fields.

In `@x/opchild/keeper/querier.go`:
- Around line 125-129: The query currently returns an Internal error because
ibcDenom(migrationInfo, baseDenom) fails when MigrationInfo.BaseIbcDenomPath is
empty (new field), so add a legacy fallback or perform a store migration: in the
QueryMigrationInfo handler, if ibcDenom returns an error and
migrationInfo.BaseIbcDenomPath == "" (or error indicates missing path), compute
the IBC denom using the old/legacy logic (reproduce the pre-upgrade derivation
used prior to adding BaseIbcDenomPath or call a helper legacyIbcDenom function),
or trigger a one-time MigrateStore routine that backfills BaseIbcDenomPath for
existing MigrationInfo rows; ensure you return a successful
QueryMigrationInfoResponse with MigrationInfo and the derived IbcDenom instead
of returning status.Error(codes.Internal,...). Reference symbols: ibcDenom,
MigrationInfo, BaseIbcDenomPath, QueryMigrationInfoResponse, migration.go.

---

Outside diff comments:
In `@x/opchild/keeper/querier.go`:
- Around line 110-118: The MigrationInfo handler currently dereferences
req.Denom before validating req; add a guard at the start of
Querier.MigrationInfo to check if req is nil or req.Denom is empty and return
status.Error(codes.InvalidArgument, "...") accordingly, then proceed to call
q.GetMigrationInfo and q.GetBaseDenom; ensure the nil/empty check happens before
any access to req.Denom to prevent panics and to match other query handlers'
validation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 74ed6a87-ad2e-4c93-ae5a-72b01114e747

📥 Commits

Reviewing files that changed from the base of the PR and between 7df13df and 557f1a6.

⛔ Files ignored due to path filters (1)
  • x/opchild/types/types.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (9)
  • api/opinit/opchild/v1/types.pulsar.go
  • proto/opinit/opchild/v1/types.proto
  • scripts/protocgen-pulsar.sh
  • x/opchild/keeper/genesis.go
  • x/opchild/keeper/migration.go
  • x/opchild/keeper/migration_test.go
  • x/opchild/keeper/msg_server.go
  • x/opchild/keeper/querier.go
  • x/opchild/types/migration_info.go

Comment thread x/opchild/keeper/genesis.go
Comment thread x/opchild/keeper/migration.go
Comment thread x/opchild/keeper/querier.go
Copy link
Copy Markdown
Member

@beer-1 beer-1 left a comment

Choose a reason for hiding this comment

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

LGTM

@traviolus traviolus merged commit e310410 into main May 6, 2026
11 of 12 checks passed
@traviolus traviolus deleted the fix/opchild-ibc-migration-base-denom-path-main branch May 6, 2026 10:08
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