Skip to content

Conversation

srdtrk
Copy link
Member

@srdtrk srdtrk commented Jul 4, 2025

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.

  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Include changelog entry when appropriate (e.g. chores should be omitted from changelog).
  • Wrote unit and integration tests if relevant.
  • Updated documentation (docs/) if anything is changed.
  • Added godoc comments if relevant.
  • Self-reviewed Files changed in the GitHub PR explorer.
  • Provide a conventional commit message to follow the repository standards.

Copy link

codecov bot commented Jul 4, 2025

Codecov Report

❌ Patch coverage is 88.67925% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.31%. Comparing base (bc8d007) to head (a3fd4af).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
modules/apps/callbacks/testing/simapp/app.go 0.00% 3 Missing ⚠️
...es/apps/packet-forward-middleware/keeper/keeper.go 80.00% 1 Missing ⚠️
modules/apps/transfer/keeper/relay.go 66.66% 1 Missing ⚠️
modules/apps/transfer/v2/ibc_module.go 66.66% 0 Missing and 1 partial ⚠️
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     
Flag Coverage Δ
08-wasm 65.99% <ø> (ø)
e2e 1.14% <ø> (ø)
ibc-go 63.74% <88.67%> (+0.31%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@srdtrk srdtrk changed the title imp: use AddressCodec instead of Bech32 imp(transfer,rate-limiting,pfm): use AddressCodec instead of Bech32 Jul 9, 2025
@srdtrk srdtrk marked this pull request as ready for review July 9, 2025 14:56
@gjermundgaraba gjermundgaraba requested a review from Copilot July 14, 2025 15:33
Copy link

@Copilot Copilot AI left a 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 all NewKeeper constructors and keeper initialization in simapp.
  • Replace sdk.AccAddressFromBech32/.String() calls with addressCodec.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",

Copy link
Contributor

@gjermundgaraba gjermundgaraba left a 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

Copy link

linear bot commented Jul 20, 2025

Copy link
Contributor

@DeshErBojhaa DeshErBojhaa left a 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 {
....
}

@gjermundgaraba gjermundgaraba linked an issue Aug 15, 2025 that may be closed by this pull request
@srdtrk srdtrk requested a review from womensrights as a code owner August 20, 2025 17:51
@srdtrk srdtrk changed the title imp(transfer,rate-limiting,pfm): use AddressCodec instead of Bech32 imp(transfer,rate-limiting,pfm)!: use AddressCodec instead of Bech32 Aug 20, 2025
@srdtrk srdtrk requested a review from gjermundgaraba August 21, 2025 07:48
Copy link
Contributor

@gjermundgaraba gjermundgaraba left a 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/.

@srdtrk srdtrk merged commit 24b29e5 into main Aug 21, 2025
87 of 88 checks passed
@srdtrk srdtrk deleted the serdar/2345-addr-bench32 branch August 21, 2025 15:23
mmsqe pushed a commit to mmsqe/ibc-go that referenced this pull request Aug 27, 2025
…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
yihuang pushed a commit to yihuang/ibc-go that referenced this pull request Aug 28, 2025
)

* 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
yihuang added a commit to yihuang/ibc-go that referenced this pull request Aug 28, 2025
)

* 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
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.

Handle restriction that receiver must be bech32 address
3 participants