Skip to content

Commit

Permalink
Merge branch 'main' into damian/2674-ics27-race-condition
Browse files Browse the repository at this point in the history
  • Loading branch information
damiannolan authored Nov 7, 2022
2 parents 694fe99 + b1f494c commit faa6312
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (modules/core/keeper) [\#1728](https://github.com/cosmos/ibc-go/pull/2399) Updated channel callback errors to include portID & channelID for better identification of errors.
* [\#2434](https://github.com/cosmos/ibc-go/pull/2478) Removed all `TypeMsg` constants
* (modules/core/exported) [#1689] (https://github.com/cosmos/ibc-go/pull/2539) Removing `GetVersions` from `ConnectionI` interface.
* (testing) [\#2657](https://github.com/cosmos/ibc-go/pull/2657) Carry `ProposerAddress` through commited blocks. Allow `DefaultGenTxGas` to be modified.

### Features

Expand All @@ -121,6 +122,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (light-clients/07-tendermint) [\#1674](https://github.com/cosmos/ibc-go/pull/1674) Submitted ClientState is zeroed out before checking the proof in order to prevent the proposal from containing information governance is not actually voting on.
* (modules/core/02-client)[\#1676](https://github.com/cosmos/ibc-go/pull/1676) ClientState must be zeroed out for `UpgradeProposals` to pass validation. This prevents a proposal containing information governance is not actually voting on.
* (modules/core/keeper) [\#2403](https://github.com/cosmos/ibc-go/pull/2403) Added a function in keeper to cater for blank pointers.
* (apps/transfer) [\#2672](https://github.com/cosmos/ibc-go/pull/2672) Check `x/bank` send enabled.

## [v5.0.1](https://github.com/cosmos/ibc-go/releases/tag/v5.0.1) - 2022-10-27

Expand Down
4 changes: 4 additions & 0 deletions modules/apps/transfer/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types.
return nil, err
}

if !k.bankKeeper.IsSendEnabledCoin(ctx, msg.Token) {
return nil, sdkerrors.Wrapf(types.ErrSendDisabled, "%s transfers are currently disabled", msg.Token.Denom)
}

if k.bankKeeper.BlockedAddr(sender) {
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to send funds", sender)
}
Expand Down
23 changes: 23 additions & 0 deletions modules/apps/transfer/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper_test

import (
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

"github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
)
Expand All @@ -19,6 +20,17 @@ func (suite *KeeperTestSuite) TestMsgTransfer() {
func() {},
true,
},
{
"bank send enabled for denom",
func() {
suite.chainA.GetSimApp().BankKeeper.SetParams(suite.chainA.GetContext(),
banktypes.Params{
SendEnabled: []*banktypes.SendEnabled{{Denom: sdk.DefaultBondDenom, Enabled: true}},
},
)
},
true,
},
{
"send transfers disabled",
func() {
Expand All @@ -44,6 +56,17 @@ func (suite *KeeperTestSuite) TestMsgTransfer() {
},
false,
},
{
"bank send disabled for denom",
func() {
suite.chainA.GetSimApp().BankKeeper.SetParams(suite.chainA.GetContext(),
banktypes.Params{
SendEnabled: []*banktypes.SendEnabled{{Denom: sdk.DefaultBondDenom, Enabled: false}},
},
)
},
false,
},
{
"channel does not exist",
func() {
Expand Down
1 change: 1 addition & 0 deletions modules/apps/transfer/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type BankKeeper interface {
SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
BlockedAddr(addr sdk.AccAddress) bool
IsSendEnabledCoin(ctx sdk.Context, coin sdk.Coin) bool
}

// ChannelKeeper defines the expected IBC channel keeper
Expand Down
1 change: 1 addition & 0 deletions testing/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ func (chain *TestChain) NextBlock() {
Time: chain.CurrentHeader.Time,
ValidatorsHash: chain.Vals.Hash(),
NextValidatorsHash: chain.NextVals.Hash(),
ProposerAddress: chain.CurrentHeader.ProposerAddress,
}

chain.App.BeginBlock(abci.RequestBeginBlock{Header: chain.CurrentHeader})
Expand Down
8 changes: 4 additions & 4 deletions testing/simapp/helpers/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
authsign "github.com/cosmos/cosmos-sdk/x/auth/signing"
)

// DefaultGenTxGas default gas for tx simulation
var DefaultGenTxGas = uint64(1000000)

// SimAppChainID hardcoded chainID for simulation
const (
DefaultGenTxGas = 1000000
SimAppChainID = "simulation-app"
)
const SimAppChainID = "simulation-app"

// GenTx generates a signed mock transaction.
func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey) (sdk.Tx, error) {
Expand Down

0 comments on commit faa6312

Please sign in to comment.