diff --git a/CHANGELOG.md b/CHANGELOG.md index 67f7aa7cf8..08e4b840ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -92,6 +92,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (simapp) [\#679](https://github.com/line/lbm-sdk/pull/679) fix the bug not setting `iavl-cache-size` value of `app.toml` * (x/foundation) [\#687](https://github.com/line/lbm-sdk/pull/687) fix bugs on aborting x/foundation proposals * (global) [\#694](https://github.com/line/lbm-sdk/pull/694) replace deprecated functions since go 1.16 or 1.17 +* (x/bankplus) [\#705](https://github.com/line/lbm-sdk/pull/705) add missing blockedAddr checking in bankplus ### Breaking Changes * (proto) [\#564](https://github.com/line/lbm-sdk/pull/564) change gRPC path to original cosmos path diff --git a/x/bank/keeper/genesis_test.go b/x/bank/keeper/genesis_test.go index 798a7e3a93..9d35e6cb5d 100644 --- a/x/bank/keeper/genesis_test.go +++ b/x/bank/keeper/genesis_test.go @@ -39,7 +39,7 @@ func (suite *IntegrationTestSuite) TestExportGenesis() { func (suite *IntegrationTestSuite) getTestBalancesAndSupply() ([]types.Balance, sdk.Coins) { addr2, _ := sdk.AccAddressFromBech32("link1f9xjhxm0plzrh9cskf4qee4pc2xwp0n0p662v8") - addr1, _ := sdk.AccAddressFromBech32("link1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3q4fdzl") + addr1, _ := sdk.AccAddressFromBech32("link1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8j3y7jh") // distribution module address addr1Balance := sdk.Coins{sdk.NewInt64Coin("testcoin3", 10)} addr2Balance := sdk.Coins{sdk.NewInt64Coin("testcoin1", 32), sdk.NewInt64Coin("testcoin2", 34)} diff --git a/x/bankplus/keeper/keeper.go b/x/bankplus/keeper/keeper.go index 5a2f84d179..2261c319e4 100644 --- a/x/bankplus/keeper/keeper.go +++ b/x/bankplus/keeper/keeper.go @@ -57,6 +57,10 @@ func (keeper BaseKeeper) SendCoinsFromModuleToAccount( panic(sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "module account %s does not exist", senderModule)) } + if keeper.BlockedAddr(recipientAddr) { + return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive funds", recipientAddr) + } + return keeper.SendCoins(ctx, senderAddr, recipientAddr, amt) } diff --git a/x/bankplus/keeper/keeper_test.go b/x/bankplus/keeper/keeper_test.go index aa4bc2a59d..0fbb290567 100644 --- a/x/bankplus/keeper/keeper_test.go +++ b/x/bankplus/keeper/keeper_test.go @@ -204,6 +204,33 @@ func (suite *IntegrationTestSuite) TestInitializeBankPlus() { } } +func (suite *IntegrationTestSuite) TestSendCoinsFromModuleToAccount_Blacklist() { + app := simapp.Setup(false) + ctx := app.BaseApp.NewContext(false, ocproto.Header{Height: 1}) + appCodec := app.AppCodec() + + // add module accounts to supply keeper + maccPerms := simapp.GetMaccPerms() + maccPerms[holder] = nil + maccPerms[authtypes.Burner] = []string{authtypes.Burner} + maccPerms[authtypes.Minter] = []string{authtypes.Minter} + + addr1 := sdk.AccAddress([]byte("addr1_______________")) + + authKeeper := authkeeper.NewAccountKeeper( + appCodec, app.GetKey(types.StoreKey), app.GetSubspace(types.ModuleName), + authtypes.ProtoBaseAccount, maccPerms, + ) + keeper := bankpluskeeper.NewBaseKeeper( + appCodec, app.GetKey(types.StoreKey), authKeeper, + app.GetSubspace(types.ModuleName), map[string]bool{addr1.String(): true}) + + suite.Require().NoError(keeper.MintCoins(ctx, minttypes.ModuleName, initCoins)) + suite.Require().Error(keeper.SendCoinsFromModuleToAccount( + ctx, minttypes.ModuleName, addr1, initCoins, + )) +} + func TestKeeperTestSuite(t *testing.T) { suite.Run(t, new(IntegrationTestSuite)) } diff --git a/x/ibc/applications/transfer/keeper/relay_test.go b/x/ibc/applications/transfer/keeper/relay_test.go index 8109a609f2..adf511a72c 100644 --- a/x/ibc/applications/transfer/keeper/relay_test.go +++ b/x/ibc/applications/transfer/keeper/relay_test.go @@ -169,11 +169,9 @@ func (suite *KeeperTestSuite) TestOnRecvPacket() { }, true, false}, // - coin being sent to module address on chainA - // Change the original test (https://github.com/cosmos/ibc-go/blob/v3.0.0/modules/apps/transfer/keeper/relay_test.go#L171-L174) - // because the bankplus module SendCoinsFromModuleToAccount function does not have a blacklist check {"failure: receive on module account", func() { receiver = suite.chainA.GetSimApp().AccountKeeper.GetModuleAddress(types.ModuleName).String() - }, false, true}, + }, false, false}, // - coin being sent back to original chain (chainB) to module address {"failure: receive on module account on source chain", func() {