fix(opchild): validate attestor packet origin#196
Conversation
WalkthroughThe PR adds packet origin validation to the OPchild IBC module for attestor set updates. It introduces a new validation method that verifies channel state, connection openness, and client ID matching; constrains channel handshakes to single-hop connections; integrates validation into the receive packet flow; and provides comprehensive tests covering validation logic and integration scenarios. ChangesPacket Origin Validation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
x/opchild/ibc_module_test.go (1)
43-100: ⚡ Quick winAdd regression cases for the new handshake guard branches.
OnChanOpenInitandOnChanOpenTrynow enforce single connection hop and counterparty port matching, but these new failure paths are not asserted here. Adding explicit negative test cases for both guards in both methods will prevent silent regressions.Also applies to: 102-144
🤖 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/ibc_module_test.go` around lines 43 - 100, Add negative regression tests that exercise the new handshake guard branches in the IBC module: for ibcModule.OnChanOpenInit add explicit cases that (1) pass multiple connection hops (e.g., []string{"conn-0", "conn-1"}) and assert an error mentioning single-hop requirement and (2) pass a Counterparty with a mismatched PortID (e.g., channeltypes.NewCounterparty("wrong-port", "chan-x")) and assert an error about counterparty port mismatch; do the same for ibcModule.OnChanOpenTry (create tests calling OnChanOpenTry with multiple connection hops and with a counterparty port that does not equal opchildtypes.PortID) and assert the appropriate errors so these new guards are covered and cannot regress.
🤖 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.
Nitpick comments:
In `@x/opchild/ibc_module_test.go`:
- Around line 43-100: Add negative regression tests that exercise the new
handshake guard branches in the IBC module: for ibcModule.OnChanOpenInit add
explicit cases that (1) pass multiple connection hops (e.g., []string{"conn-0",
"conn-1"}) and assert an error mentioning single-hop requirement and (2) pass a
Counterparty with a mismatched PortID (e.g.,
channeltypes.NewCounterparty("wrong-port", "chan-x")) and assert an error about
counterparty port mismatch; do the same for ibcModule.OnChanOpenTry (create
tests calling OnChanOpenTry with multiple connection hops and with a
counterparty port that does not equal opchildtypes.PortID) and assert the
appropriate errors so these new guards are covered and cannot regress.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f4472b41-bfa6-46fb-a0c9-fa0546ebcc7b
📒 Files selected for processing (5)
x/opchild/ibc_module.gox/opchild/ibc_module_test.gox/opchild/keeper/attestor.gox/opchild/keeper/attestor_test.gox/opchild/types/errors.go
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #196 +/- ##
==========================================
+ Coverage 43.33% 43.51% +0.18%
==========================================
Files 74 74
Lines 7424 7485 +61
==========================================
+ Hits 3217 3257 +40
- Misses 3614 3628 +14
- Partials 593 600 +7
🚀 New features to boost your workflow:
|
Description
Closes: N/A
This PR binds
opchildattestor-set update packets to the configured canonical IBC origin before applying validator updates.Changes:
opinitport.Why:
opchild.OnRecvPacketforwarded only packet data into the attestor update path. The handler verifiedbridge_id, but did not bind the packet to the configured L1 client/channel origin.Validation:
GOTOOLCHAIN=go1.24.13 go test ./x/opchild/... -count=1Breaking change: No.
Author Checklist
I have...
!in the type prefix if API or client breaking change: N/A, not breakingReviewers 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
Release Notes