-
Notifications
You must be signed in to change notification settings - Fork 724
imp(transfer,rate-limiting,pfm)!: use AddressCodec instead of Bech32 #8573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #8573 +/- ##
==========================================
+ Coverage 58.02% 58.31% +0.28%
==========================================
Files 319 319
Lines 22804 22821 +17
==========================================
+ Hits 13232 13307 +75
+ Misses 8967 8907 -60
- Partials 605 607 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors address handling across multiple modules by replacing direct Bech32 parsing with a generic AddressCodec, updating keeper constructors, message validation, server handlers, and tests to use the new interface.
- Inject
addressCodec
into allNewKeeper
constructors and keeper initialization in simapp. - Replace
sdk.AccAddressFromBech32
/.String()
calls withaddressCodec.StringToBytes
/.BytesToString
. - Simplify
ValidateBasic
to only check non-empty signers and move format validation to message server and keeper layers; update tests accordingly.
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
testing/simapp/app.go | pass AddressCodec into Transfer, RateLimit, and PFM Keeper constructors |
simapp/app.go | pass AddressCodec into Transfer, PFM, and RateLimit Keeper constructors |
modules/light-clients/08-wasm/testing/simapp/app.go | inject AddressCodec into transfer keeper |
modules/apps/transfer/v2/ibc_module.go | replace Bech32 parsing with addressCodec.StringToBytes & use bytes.Equal |
modules/apps/transfer/types/msgs_test.go | remove invalid-bech32 test for MsgUpdateParams |
modules/apps/transfer/types/msgs.go | simplify ValidateBasic to non-empty checks for Signer /Receiver |
modules/apps/transfer/keeper/relay_test.go | add TestAddressCodec stub supporting hex & Bech32 decoding |
modules/apps/transfer/keeper/relay.go | replace Bech32 parse with addressCodec.StringToBytes in OnRecvPacket & refundPacketTokens |
modules/apps/transfer/keeper/msg_server_test.go | add zero-amount failure test |
modules/apps/transfer/keeper/msg_server.go | use addressCodec for sender decoding and update transferV1Packet signature |
modules/apps/transfer/keeper/keeper_test.go | include AccountKeeper.AddressCodec in NewKeeper tests |
modules/apps/transfer/keeper/keeper.go | add addressCodec field, getter, and constructor parameter |
modules/apps/transfer/keeper/export_test.go | add SetAddressCodec setter for testing |
modules/apps/rate-limiting/types/msgs_test.go | rename test names & add empty-signer case |
modules/apps/rate-limiting/types/msgs.go | simplify ValidateBasic to non-empty signer check |
modules/apps/rate-limiting/keeper/msg_server_test.go | add sdkerrors import & test invalid-format signer |
modules/apps/rate-limiting/keeper/msg_server.go | validate signer format with addressCodec.StringToBytes before authority check |
modules/apps/rate-limiting/keeper/keeper_test.go | include AccountKeeper.AddressCodec in NewKeeper tests |
modules/apps/rate-limiting/keeper/keeper.go | add addressCodec field and constructor parameter |
modules/apps/packet-forward-middleware/keeper/keeper_test.go | pass AddressCodec to PFM keeper in tests |
modules/apps/packet-forward-middleware/keeper/keeper.go | add addressCodec field & use it in userRecoverableAccount |
modules/apps/callbacks/testing/simapp/app.go | pass AddressCodec into transfer keeper |
Comments suppressed due to low confidence (4)
modules/apps/transfer/types/msgs.go:38
- The ValidateBasic implementation only checks for a non-empty signer string and omits verification of address format. Consider invoking addressCodec.StringToBytes here to validate the address encoding during message validation.
if strings.TrimSpace(msg.Signer) == "" {
modules/apps/transfer/types/msgs.go:122
- MsgTransfer.ValidateBasic only checks for an empty sender string and does not verify address format. Incorporating addressCodec.StringToBytes would catch invalid senders earlier in validation.
if strings.TrimSpace(msg.Sender) == "" {
modules/apps/rate-limiting/types/msgs.go:38
- MsgAddRateLimit.ValidateBasic currently only checks for a non-empty signer and skips address format validation. Use addressCodec.StringToBytes to ensure the signer is correctly encoded.
if strings.TrimSpace(msg.Signer) == "" {
modules/apps/rate-limiting/types/msgs_test.go:76
- The test case name indicates success but expPass is false. Rename it to "failure: empty authority" to accurately reflect the expected outcome.
name: "success: empty authority",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! 🙌
A few things I want to see resolved:
- Please link the Linear issue
- Some level of testing that confirms the core use case from the issue is solved and working as expected.
- Add a changelog entry
- Update the migration guide
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this PR. A couple of PR comments in the files.
One question, with this change, we can no longer check for address validity in ValidateBasic
functions. What are we getting in return for this inconvenience?
Also minor nitpick,
If we have a code pattern like
_, err := something()
if err != nil {...}
Almost always limting the scope of the err variable is the desired pattern.
if _, err := somethin(); err != nil {
....
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me! If you agree, I would also move the testing address codec into testing/
.
…osmos#8573) * imp: added address codec to transfer * imp: address codec used in transfer * fix: tests * imp: test passing * imp: added addressCodec to PFM * imp: added receiver test * test: transfer cov * test: added cases * test: more cov * test: more cov * style: single line func def * test: new test works * imp: add basic test * imp: added migration guide * doc: added changelog * refactor: address codec moved
) * imp: added address codec to transfer * imp: address codec used in transfer * fix: tests * imp: test passing * imp: added addressCodec to PFM * imp: added receiver test * test: transfer cov * test: added cases * test: more cov * test: more cov * style: single line func def * test: new test works * imp: add basic test * imp: added migration guide * doc: added changelog * refactor: address codec moved
) * imp: added address codec to transfer * imp: address codec used in transfer * fix: tests * imp: test passing * imp: added addressCodec to PFM * imp: added receiver test * test: transfer cov * test: added cases * test: more cov * test: more cov * style: single line func def * test: new test works * imp: add basic test * imp: added migration guide * doc: added changelog * refactor: address codec moved
Description
closes: IBCGO-2345
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) if anything is changed.godoc
comments if relevant.Files changed
in the GitHub PR explorer.