Skip to content
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

ics29: fix: add check for blocked addr for forward relayer distribution #1231

Merged
merged 2 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/apps/29-fee/ibc_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() {
}.Acknowledgement()

expectedRelayerBalance = packetFee.Fee.AckFee
expectedBalance = expectedBalance.Add(packetFee.Fee.RecvFee[0])
},
true,
},
Expand Down Expand Up @@ -693,7 +694,6 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() {
expectedRelayerBalance,
relayerBalance,
)

})
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/29-fee/keeper/escrow.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (k Keeper) DistributePacketFees(ctx sdk.Context, forwardRelayer string, rev
}

// distribute fee to valid forward relayer address otherwise refund the fee
if !forwardAddr.Empty() {
if !forwardAddr.Empty() && !k.bankKeeper.BlockedAddr(forwardAddr) {
// distribute fee for forward relaying
k.distributeFee(ctx, forwardAddr, packetFee.Fee.RecvFee)
} else {
Expand Down
6 changes: 6 additions & 0 deletions modules/apps/29-fee/keeper/escrow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/tendermint/tendermint/crypto/secp256k1"

"github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"
transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
ibctesting "github.com/cosmos/ibc-go/v3/testing"
)
Expand Down Expand Up @@ -141,6 +142,11 @@ func (suite *KeeperTestSuite) TestDistributeFee() {
forwardRelayer = "invalid address"
}, false,
},
{
"invalid forward address: blocked address", func() {
forwardRelayer = suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress().String()
}, false,
},
}

for _, tc := range testCases {
Expand Down
1 change: 1 addition & 0 deletions modules/apps/29-fee/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ type BankKeeper interface {
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error
BlockedAddr(sdk.AccAddress) bool
}