Repository navigation
fix: return error when transfer memo has no provider field - #2704
Open
amalsaidov wants to merge 2 commits into
Open
amalsaidov wants to merge 2 commits into
amalsaidov wants to merge 2 commits into
Conversation
GetRewardMemoFromTransferMemo returned a nil error when the parsed transfer memo did not contain a "provider" field, so callers could not tell a missing reward memo apart from a valid one. The provider IBC middleware branches on this error to fall back to identifying the consumer from the IBC packet, and that fallback was skipped whenever the memo was valid JSON without a provider field. Return a descriptive error in that case and add unit tests covering the present, absent, malformed, and empty memo cases.
|
This PR does not match any of the 1 configured review trigger rule. |
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
GetRewardMemoFromTransferMemoinx/ccv/types/wire.gois meant to return the reward memo embedded under theproviderfield of an ICS reward transfer memo, or an error when the memo is not a reward transfer memo.When the parsed memo did not contain a
providerfield, the function returnedRewardMemo{}, errwhereerrwas alreadynil(the precedingjson.Unmarshalhad succeeded). It therefore reported success with an emptyRewardMemoinstead of signaling that no reward memo was present.The provider IBC middleware (
x/ccv/provider/ibc_middleware.go) relies on this error to decide whether to fall back to identifying the consumer from the IBC packet:Because the function returned a nil error for a valid JSON memo without a
providerfield, the middleware took theelsebranch with an emptyconsumerIdand skipped the packet-based fallback entirely for those transfers.This change returns a descriptive error when the
providerfield is absent, which restores the intended fallback behavior. The middleware already handles a non-nil error, so no change is needed there.Note: this is a behavior change on the provider for transfers to the consumer rewards pool whose memo is valid JSON without a
providerfield, so it is flagged as a bug fix in the changelog. Legitimate ICS reward transfers built byCreateTransferMemoalways include theproviderfield and are unaffected.Testing
Added
TestGetRewardMemoFromTransferMemoinx/ccv/types/wire_test.gocovering a valid provider memo, a valid JSON object without aproviderfield, an empty JSON object, a non-JSON memo, an empty memo, and aproviderfield that is not a reward-memo object. The absent and empty-object cases fail before the fix and pass after it.AI-assisted; directed, reviewed and tested by the author (amalsaidov).
Author Checklist
I have...
!to the type prefix if the change is state-machine breakingmain)CHANGELOG.md