Skip to content

Commit

Permalink
add check for blocked addr for forward relayer distribution (#1231)
Browse files Browse the repository at this point in the history
  • Loading branch information
seantking authored Apr 7, 2022
1 parent 76e0c24 commit 35427da
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
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
}

0 comments on commit 35427da

Please sign in to comment.