Skip to content

Commit

Permalink
Merge branch 'main' into replace_get_libwasm_version
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtGinn authored Feb 2, 2025
2 parents d6bddb7 + 98d7e75 commit ae01600
Show file tree
Hide file tree
Showing 39 changed files with 419 additions and 348 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
images: ${{ env.REGISTRY }}/cosmos/${{ env.IMAGE_NAME }}

- name: Build Docker image
uses: docker/build-push-action@67a2d409c0a876cbe6b11854e3e25193efe4e62d
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991
with:
context: .
tags: ${{ steps.meta.outputs.tags }}
Expand All @@ -46,7 +46,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push Docker image
uses: docker/build-push-action@67a2d409c0a876cbe6b11854e3e25193efe4e62d
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991
with:
context: .
push: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e-test-workflow-call.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:

- name: Build and push Docker image
if: ${{ inputs.build-and-push-docker-image }}
uses: docker/build-push-action@67a2d409c0a876cbe6b11854e3e25193efe4e62d
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991
with:
context: .
push: true
Expand Down Expand Up @@ -155,7 +155,7 @@ jobs:

- name: Build and push Docker image
if: ${{ inputs.build-and-push-docker-image-wasm }}
uses: docker/build-push-action@67a2d409c0a876cbe6b11854e3e25193efe4e62d
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991
with:
context: .
push: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
images: ${{ env.REGISTRY }}/cosmos/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@67a2d409c0a876cbe6b11854e3e25193efe4e62d
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991
with:
context: .
push: true
Expand Down
30 changes: 23 additions & 7 deletions e2e/testsuite/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
sdk "github.com/cosmos/cosmos-sdk/types"

abci "github.com/cometbft/cometbft/api/cometbft/abci/v1"
Expand Down Expand Up @@ -153,14 +154,13 @@ func (s *E2ETestSuite) ExecuteAndPassGovV1Proposal(ctx context.Context, msg sdk.
// ExecuteGovV1Proposal submits a v1 governance proposal using the provided user and message and uses all validators
// to vote yes on the proposal.
func (s *E2ETestSuite) ExecuteGovV1Proposal(ctx context.Context, msg sdk.Msg, chain ibc.Chain, user ibc.Wallet) error {
sender := s.ConvertToAccAddress(chain, user.FormattedAddress())

cosmosChain, ok := chain.(*cosmos.CosmosChain)
if !ok {
panic("ExecuteAndPassGovV1Proposal must be passed a cosmos.CosmosChain")
panic("ExecuteGovV1Proposal must be passed a cosmos.CosmosChain")
}

sender, err := sdk.AccAddressFromBech32(user.FormattedAddress())
s.Require().NoError(err)

proposalID := s.proposalIDs[cosmosChain.Config().ChainID]
defer func() {
s.proposalIDs[cosmosChain.Config().ChainID] = proposalID + 1
Expand Down Expand Up @@ -189,6 +189,19 @@ func (s *E2ETestSuite) ExecuteGovV1Proposal(ctx context.Context, msg sdk.Msg, ch
return s.waitForGovV1ProposalToPass(ctx, cosmosChain, proposalID)
}

func (s *E2ETestSuite) ConvertToAccAddress(chain ibc.Chain, formattedAddress string) sdk.AccAddress {
cosmosChain, ok := chain.(*cosmos.CosmosChain)
if !ok {
panic("ConvertToAccAddress must be passed a cosmos.CosmosChain")
}

addrCdc := addresscodec.NewBech32Codec(cosmosChain.Config().Bech32Prefix)
senderBytes, err := addrCdc.StringToBytes(formattedAddress)
s.Require().NoError(err)

return sdk.AccAddress(senderBytes)
}

// waitForGovV1ProposalToPass polls for the entire voting period to see if the proposal has passed.
// if the proposal has not passed within the duration of the voting period, an error is returned.
func (s *E2ETestSuite) waitForGovV1ProposalToPass(ctx context.Context, chain ibc.Chain, proposalID uint64) error {
Expand Down Expand Up @@ -276,10 +289,13 @@ func (*E2ETestSuite) waitForGovV1Beta1ProposalToPass(ctx context.Context, chain

// ExecuteGovV1Beta1Proposal submits a v1beta1 governance proposal using the provided content.
func (s *E2ETestSuite) ExecuteGovV1Beta1Proposal(ctx context.Context, chain ibc.Chain, user ibc.Wallet, content govtypesv1beta1.Content) sdk.TxResponse {
sender, err := sdk.AccAddressFromBech32(user.FormattedAddress())
s.Require().NoError(err)
sender := s.ConvertToAccAddress(chain, user.FormattedAddress())

msgSubmitProposal, err := govtypesv1beta1.NewMsgSubmitProposal(content, sdk.NewCoins(sdk.NewCoin(chain.Config().Denom, govtypesv1beta1.DefaultMinDepositTokens)), sender.String())
msgSubmitProposal, err := govtypesv1beta1.NewMsgSubmitProposal(
content,
sdk.NewCoins(sdk.NewCoin(chain.Config().Denom, govtypesv1beta1.DefaultMinDepositTokens)),
sender.String(),
)
s.Require().NoError(err)

return s.BroadcastMessages(ctx, chain, user, msgSubmitProposal)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

banktypes "cosmossdk.io/x/bank/types"

addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
"github.com/cosmos/cosmos-sdk/codec/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
Expand Down Expand Up @@ -108,7 +109,10 @@ func TestMsgRegisterInterchainAccountValidateBasic(t *testing.T) {
}

func TestMsgRegisterInterchainAccountGetSigners(t *testing.T) {
expSigner, err := sdk.AccAddressFromBech32(ibctesting.TestAccAddress)
addrCdc := addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix())
expSigerBytes, err := addrCdc.StringToBytes(ibctesting.TestAccAddress)
expSigner := sdk.AccAddress(expSigerBytes)

require.NoError(t, err)

msg := types.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, ibctesting.TestAccAddress, "", channeltypes.ORDERED)
Expand Down
4 changes: 2 additions & 2 deletions modules/apps/29-fee/ibc_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func (im IBCMiddleware) OnAcknowledgementPacket(
payee = relayer.String()
}

payeeAddr, err := sdk.AccAddressFromBech32(payee)
payeeAddr, err := im.keeper.AddrCodec.StringToBytes(payee)
if err != nil {
return errorsmod.Wrapf(err, "failed to create sdk.Address from payee: %s", payee)
}
Expand Down Expand Up @@ -329,7 +329,7 @@ func (im IBCMiddleware) OnTimeoutPacket(
payee = relayer.String()
}

payeeAddr, err := sdk.AccAddressFromBech32(payee)
payeeAddr, err := im.keeper.AddrCodec.StringToBytes(payee)
if err != nil {
return errorsmod.Wrapf(err, "failed to create sdk.Address from payee: %s", payee)
}
Expand Down
10 changes: 5 additions & 5 deletions modules/apps/29-fee/keeper/escrow.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
// escrowPacketFee sends the packet fee to the 29-fee module account to hold in escrow
func (k Keeper) escrowPacketFee(ctx context.Context, packetID channeltypes.PacketId, packetFee types.PacketFee) error {
// check if the refund address is valid
refundAddr, err := sdk.AccAddressFromBech32(packetFee.RefundAddress)
refundAddr, err := k.AddrCodec.StringToBytes(packetFee.RefundAddress)
if err != nil {
return err
}
Expand Down Expand Up @@ -52,7 +52,7 @@ func (k Keeper) DistributePacketFeesOnAcknowledgement(ctx context.Context, forwa
// if the escrow account has insufficient balance then we want to avoid partially distributing fees
if err := k.BranchService.Execute(ctx, func(ctx context.Context) error {
// forward relayer address will be empty if conversion fails
forwardAddr, _ := sdk.AccAddressFromBech32(forwardRelayer)
forwardAddr, _ := k.AddrCodec.StringToBytes(forwardRelayer)

for _, packetFee := range packetFees {
if !k.EscrowAccountHasBalance(ctx, packetFee.Fee.Total()) {
Expand All @@ -61,7 +61,7 @@ func (k Keeper) DistributePacketFeesOnAcknowledgement(ctx context.Context, forwa
}

// check if refundAcc address works
refundAddr, err := sdk.AccAddressFromBech32(packetFee.RefundAddress)
refundAddr, err := k.AddrCodec.StringToBytes(packetFee.RefundAddress)
if err != nil {
panic(fmt.Errorf("could not parse refundAcc %s to sdk.AccAddress", packetFee.RefundAddress))
}
Expand Down Expand Up @@ -117,7 +117,7 @@ func (k Keeper) DistributePacketFeesOnTimeout(ctx context.Context, timeoutRelaye
}

// check if refundAcc address works
refundAddr, err := sdk.AccAddressFromBech32(packetFee.RefundAddress)
refundAddr, err := k.AddrCodec.StringToBytes(packetFee.RefundAddress)
if err != nil {
panic(fmt.Errorf("could not parse refundAcc %s to sdk.AccAddress", packetFee.RefundAddress))
}
Expand Down Expand Up @@ -206,7 +206,7 @@ func (k Keeper) RefundFeesOnChannelClosure(ctx context.Context, portID, channelI
return ibcerrors.ErrInsufficientFunds
}

refundAddr, err := sdk.AccAddressFromBech32(packetFee.RefundAddress)
refundAddr, err := k.AddrCodec.StringToBytes(packetFee.RefundAddress)
if err != nil {
unRefundedFees = append(unRefundedFees, packetFee)
continue
Expand Down
19 changes: 11 additions & 8 deletions modules/apps/29-fee/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"context"

"cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
storetypes "cosmossdk.io/store/types"

Expand All @@ -24,7 +25,8 @@ var _ types.ChannelKeeper = (*Keeper)(nil)
type Keeper struct {
appmodule.Environment

cdc codec.BinaryCodec
cdc codec.BinaryCodec
AddrCodec address.Codec

authKeeper types.AuthKeeper
ics4Wrapper porttypes.ICS4Wrapper
Expand All @@ -34,12 +36,13 @@ type Keeper struct {

// NewKeeper creates a new 29-fee Keeper instance
func NewKeeper(
cdc codec.BinaryCodec, env appmodule.Environment,
cdc codec.BinaryCodec, addrCdc address.Codec, env appmodule.Environment,
ics4Wrapper porttypes.ICS4Wrapper, channelKeeper types.ChannelKeeper,
authKeeper types.AuthKeeper, bankKeeper types.BankKeeper,
) Keeper {
return Keeper{
cdc: cdc,
AddrCodec: addrCdc,
Environment: env,
ics4Wrapper: ics4Wrapper,
channelKeeper: channelKeeper,
Expand Down Expand Up @@ -220,17 +223,17 @@ func (k Keeper) GetAllPayees(ctx context.Context) []types.RegisteredPayee {

// SetCounterpartyPayeeAddress maps the destination chain counterparty payee address to the source relayer address
// The receiving chain must store the mapping from: address -> counterpartyPayeeAddress for the given channel
func (k Keeper) SetCounterpartyPayeeAddress(ctx context.Context, address, counterpartyAddress, channelID string) {
func (k Keeper) SetCounterpartyPayeeAddress(ctx context.Context, addr, counterpartyAddress, channelID string) {
store := k.KVStoreService.OpenKVStore(ctx)
if err := store.Set(types.KeyCounterpartyPayee(address, channelID), []byte(counterpartyAddress)); err != nil {
if err := store.Set(types.KeyCounterpartyPayee(addr, channelID), []byte(counterpartyAddress)); err != nil {
panic(err)
}
}

// GetCounterpartyPayeeAddress gets the counterparty payee address given a destination relayer address
func (k Keeper) GetCounterpartyPayeeAddress(ctx context.Context, address, channelID string) (string, bool) {
func (k Keeper) GetCounterpartyPayeeAddress(ctx context.Context, relayerAddr, channelID string) (string, bool) {
store := k.KVStoreService.OpenKVStore(ctx)
key := types.KeyCounterpartyPayee(address, channelID)
key := types.KeyCounterpartyPayee(relayerAddr, channelID)

addr, err := store.Get(key)
if err != nil {
Expand Down Expand Up @@ -269,9 +272,9 @@ func (k Keeper) GetAllCounterpartyPayees(ctx context.Context) []types.Registered
}

// SetRelayerAddressForAsyncAck sets the forward relayer address during OnRecvPacket in case of async acknowledgement
func (k Keeper) SetRelayerAddressForAsyncAck(ctx context.Context, packetID channeltypes.PacketId, address string) {
func (k Keeper) SetRelayerAddressForAsyncAck(ctx context.Context, packetID channeltypes.PacketId, addr string) {
store := k.KVStoreService.OpenKVStore(ctx)
if err := store.Set(types.KeyRelayerAddressForAsyncAck(packetID), []byte(address)); err != nil {
if err := store.Set(types.KeyRelayerAddressForAsyncAck(packetID), []byte(addr)); err != nil {
panic(err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/29-fee/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (m Migrator) Migrate1to2(ctx context.Context) error {
for _, packetFee := range feesInEscrow.PacketFees {
refundCoins := legacyTotal(packetFee.Fee).Sub(packetFee.Fee.Total()...)

refundAddr, err := sdk.AccAddressFromBech32(packetFee.RefundAddress)
refundAddr, err := m.keeper.AddrCodec.StringToBytes(packetFee.RefundAddress)
if err != nil {
return err
}
Expand Down
8 changes: 3 additions & 5 deletions modules/apps/29-fee/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (

errorsmod "cosmossdk.io/errors"

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/cosmos/ibc-go/v9/modules/apps/29-fee/types"
channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types"
ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors"
Expand All @@ -20,7 +18,7 @@ var _ types.MsgServer = (*Keeper)(nil)
// the source chain from which packets originate as this is where fee distribution takes place. This function may be
// called more than once by a relayer, in which case, the latest payee is always used.
func (k Keeper) RegisterPayee(ctx context.Context, msg *types.MsgRegisterPayee) (*types.MsgRegisterPayeeResponse, error) {
payee, err := sdk.AccAddressFromBech32(msg.Payee)
payee, err := k.AddrCodec.StringToBytes(msg.Payee)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -87,7 +85,7 @@ func (k Keeper) PayPacketFee(ctx context.Context, msg *types.MsgPayPacketFee) (*
return nil, types.ErrFeeModuleLocked
}

refundAcc, err := sdk.AccAddressFromBech32(msg.Signer)
refundAcc, err := k.AddrCodec.StringToBytes(msg.Signer)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -130,7 +128,7 @@ func (k Keeper) PayPacketFeeAsync(ctx context.Context, msg *types.MsgPayPacketFe
return nil, types.ErrFeeModuleLocked
}

refundAcc, err := sdk.AccAddressFromBech32(msg.PacketFee.RefundAddress)
refundAcc, err := k.AddrCodec.StringToBytes(msg.PacketFee.RefundAddress)
if err != nil {
return nil, err
}
Expand Down
50 changes: 27 additions & 23 deletions modules/apps/callbacks/testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/spf13/cast"

coreaddress "cosmossdk.io/core/address"
appmodule "cosmossdk.io/core/appmodule"
"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"
"cosmossdk.io/x/accounts"
Expand Down Expand Up @@ -405,6 +406,7 @@ func NewSimApp(

app.IBCKeeper = ibckeeper.NewKeeper(
appCodec,
signingCtx.AddressCodec(),
runtime.NewEnvironment(runtime.NewKVStoreService(keys[ibcexported.StoreKey]), logger.With(log.ModuleKey, "x/ibc")),
app.GetSubspace(ibcexported.ModuleName),
app.UpgradeKeeper,
Expand All @@ -431,6 +433,7 @@ func NewSimApp(
// IBC Fee Module keeper
app.IBCFeeKeeper = ibcfeekeeper.NewKeeper(
appCodec,
signingCtx.AddressCodec(),
runtime.NewEnvironment(runtime.NewKVStoreService(keys[ibcfeetypes.StoreKey]), logger.With(log.ModuleKey, fmt.Sprintf("x/%s-%s", ibcexported.ModuleName, ibcfeetypes.ModuleName))),
app.IBCKeeper.ChannelKeeper, // may be replaced with IBC middleware
app.IBCKeeper.ChannelKeeper,
Expand Down Expand Up @@ -469,6 +472,7 @@ func NewSimApp(
// NOTE: the Transfer Keeper's ICS4Wrapper can later be replaced.
app.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec,
signingCtx.AddressCodec(),
runtime.NewEnvironment(runtime.NewKVStoreService(keys[ibctransfertypes.StoreKey]), logger.With(log.ModuleKey, fmt.Sprintf("x/%s-%s", ibcexported.ModuleName, ibctransfertypes.ModuleName))),
app.GetSubspace(ibctransfertypes.ModuleName),
app.IBCFeeKeeper, // ISC4 Wrapper: fee IBC middleware
Expand Down Expand Up @@ -584,33 +588,33 @@ func NewSimApp(

// NOTE: Any module instantiated in the module manager that is later modified
// must be passed by reference here.
app.ModuleManager = module.NewManager(
genutil.NewAppModule(appCodec, app.AuthKeeper, app.StakingKeeper, app, txConfig, genutiltypes.DefaultMessageValidator),
accounts.NewAppModule(appCodec, app.AccountsKeeper),
auth.NewAppModule(appCodec, app.AuthKeeper, app.AccountsKeeper, authsims.RandomGenesisAccounts, nil),
vesting.NewAppModule(app.AuthKeeper, app.BankKeeper),
bank.NewAppModule(appCodec, app.BankKeeper, app.AuthKeeper),
feegrantmodule.NewAppModule(appCodec, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, &app.GovKeeper, app.AuthKeeper, app.BankKeeper, app.PoolKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AuthKeeper),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.interfaceRegistry, cometService),
distr.NewAppModule(appCodec, app.DistrKeeper, app.StakingKeeper),
staking.NewAppModule(appCodec, app.StakingKeeper),
upgrade.NewAppModule(app.UpgradeKeeper),
params.NewAppModule(app.ParamsKeeper),
consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),
app.ModuleManager = module.NewManagerFromMap(map[string]appmodule.AppModule{
genutiltypes.ModuleName: genutil.NewAppModule(appCodec, app.AuthKeeper, app.StakingKeeper, app, txConfig, genutiltypes.DefaultMessageValidator),
accounts.ModuleName: accounts.NewAppModule(appCodec, app.AccountsKeeper),
authtypes.ModuleName: auth.NewAppModule(appCodec, app.AuthKeeper, app.AccountsKeeper, authsims.RandomGenesisAccounts, nil),
vestingtypes.ModuleName: vesting.NewAppModule(app.AuthKeeper, app.BankKeeper),
banktypes.ModuleName: bank.NewAppModule(appCodec, app.BankKeeper, app.AuthKeeper),
feegrant.ModuleName: feegrantmodule.NewAppModule(appCodec, app.FeeGrantKeeper, app.interfaceRegistry),
govtypes.ModuleName: gov.NewAppModule(appCodec, &app.GovKeeper, app.AuthKeeper, app.BankKeeper, app.PoolKeeper),
minttypes.ModuleName: mint.NewAppModule(appCodec, app.MintKeeper, app.AuthKeeper),
slashingtypes.ModuleName: slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.interfaceRegistry, cometService),
distrtypes.ModuleName: distr.NewAppModule(appCodec, app.DistrKeeper, app.StakingKeeper),
stakingtypes.ModuleName: staking.NewAppModule(appCodec, app.StakingKeeper),
upgradetypes.ModuleName: upgrade.NewAppModule(app.UpgradeKeeper),
paramstypes.ModuleName: params.NewAppModule(app.ParamsKeeper),
consensusparamtypes.ModuleName: consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper),

// IBC modules
ibc.NewAppModule(appCodec, app.IBCKeeper),
transfer.NewAppModule(appCodec, app.TransferKeeper),
ibcfee.NewAppModule(appCodec, app.IBCFeeKeeper),
ica.NewAppModule(appCodec, &app.ICAControllerKeeper, &app.ICAHostKeeper),
mockModule,
ibcexported.ModuleName: ibc.NewAppModule(appCodec, app.IBCKeeper),
ibctransfertypes.ModuleName: transfer.NewAppModule(appCodec, app.TransferKeeper),
ibcfeetypes.ModuleName: ibcfee.NewAppModule(appCodec, app.IBCFeeKeeper),
icatypes.ModuleName: ica.NewAppModule(appCodec, &app.ICAControllerKeeper, &app.ICAHostKeeper),
mockModule.Name(): mockModule,

// IBC light clients
ibctm.NewAppModule(tmLightClientModule),
solomachine.NewAppModule(smLightClientModule),
)
ibctm.ModuleName: ibctm.NewAppModule(tmLightClientModule),
solomachine.ModuleName: solomachine.NewAppModule(smLightClientModule),
})

app.ModuleManager.RegisterLegacyAminoCodec(legacyAmino)
app.ModuleManager.RegisterInterfaces(interfaceRegistry)
Expand Down
Loading

0 comments on commit ae01600

Please sign in to comment.