Conversation
WalkthroughThe PR adds support for a ChangesIBC Base Denom Path Support
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
The latest Buf updates on your PR. Results from workflow Protobuf / buf-build (pull_request).
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ 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
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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 winGuard the request before dereferencing it.
req.Denomis read before any nil check, so a nil call into this RPC will panic instead of returningInvalidArgument. 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
⛔ Files ignored due to path filters (1)
x/opchild/types/types.pb.gois excluded by!**/*.pb.go
📒 Files selected for processing (9)
api/opinit/opchild/v1/types.pulsar.goproto/opinit/opchild/v1/types.protoscripts/protocgen-pulsar.shx/opchild/keeper/genesis.gox/opchild/keeper/migration.gox/opchild/keeper/migration_test.gox/opchild/keeper/msg_server.gox/opchild/keeper/querier.gox/opchild/types/migration_info.go
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...
!in the type prefix if API or client breaking changeReviewers 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...
Summary by CodeRabbit
New Features
Improvements
Tests