From fec6f527bd113ee738af2a50ae82f26be55d3acf Mon Sep 17 00:00:00 2001 From: Marko Baricevic Date: Sun, 8 Sep 2024 13:25:31 +0200 Subject: [PATCH] get 08-wasm compiling --- .../host/keeper/msg_server.go | 3 +- modules/apps/29-fee/keeper/msg_server.go | 16 +- modules/core/02-client/keeper/grpc_query.go | 29 +-- modules/light-clients/08-wasm/go.mod | 4 + .../08-wasm/testing/simapp/app.go | 231 ++++++++++-------- .../08-wasm/testing/simapp/encoding.go | 18 -- .../08-wasm/testing/simapp/params/proto.go | 27 -- .../08-wasm/testing/simapp/simd/cmd/root.go | 51 ++-- .../light-clients/08-wasm/types/msgs_test.go | 6 +- testing/chain.go | 38 ++- testing/endpoint.go | 2 +- testing/simapp/ante.go | 11 +- testing/types/expected_keepers.go | 7 - 13 files changed, 185 insertions(+), 258 deletions(-) delete mode 100644 modules/light-clients/08-wasm/testing/simapp/encoding.go delete mode 100644 modules/light-clients/08-wasm/testing/simapp/params/proto.go diff --git a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go index 90c0159ffe7..afa952f6a02 100644 --- a/modules/apps/27-interchain-accounts/host/keeper/msg_server.go +++ b/modules/apps/27-interchain-accounts/host/keeper/msg_server.go @@ -62,12 +62,11 @@ func (m msgServer) ModuleQuerySafe(goCtx context.Context, msg *types.MsgModuleQu } // UpdateParams updates the host submodule's params. -func (m msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { +func (m msgServer) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { if m.GetAuthority() != msg.Signer { return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected %s, got %s", m.GetAuthority(), msg.Signer) } - ctx := sdk.UnwrapSDKContext(goCtx) m.SetParams(ctx, msg.Params) return &types.MsgUpdateParamsResponse{}, nil diff --git a/modules/apps/29-fee/keeper/msg_server.go b/modules/apps/29-fee/keeper/msg_server.go index e79996a0389..421fe6cf1a9 100644 --- a/modules/apps/29-fee/keeper/msg_server.go +++ b/modules/apps/29-fee/keeper/msg_server.go @@ -19,9 +19,7 @@ var _ types.MsgServer = (*Keeper)(nil) // payee to which reverse and timeout relayer packet fees will be paid out. The payee should be registered on // 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(goCtx context.Context, msg *types.MsgRegisterPayee) (*types.MsgRegisterPayeeResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k Keeper) RegisterPayee(ctx context.Context, msg *types.MsgRegisterPayee) (*types.MsgRegisterPayeeResponse, error) { payee, err := sdk.AccAddressFromBech32(msg.Payee) if err != nil { return nil, err @@ -54,9 +52,7 @@ func (k Keeper) RegisterPayee(goCtx context.Context, msg *types.MsgRegisterPayee // payee address before relaying. This ensures they will be properly compensated for forward relaying since // the destination chain must include the registered counterparty payee address in the acknowledgement. This function // may be called more than once by a relayer, in which case, the latest counterparty payee address is always used. -func (k Keeper) RegisterCounterpartyPayee(goCtx context.Context, msg *types.MsgRegisterCounterpartyPayee) (*types.MsgRegisterCounterpartyPayeeResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k Keeper) RegisterCounterpartyPayee(ctx context.Context, msg *types.MsgRegisterCounterpartyPayee) (*types.MsgRegisterCounterpartyPayeeResponse, error) { // only register counterparty payee if the channel exists and is fee enabled if _, found := k.channelKeeper.GetChannel(ctx, msg.PortId, msg.ChannelId); !found { return nil, channeltypes.ErrChannelNotFound @@ -77,9 +73,7 @@ func (k Keeper) RegisterCounterpartyPayee(goCtx context.Context, msg *types.MsgR // PayPacketFee defines a rpc handler method for MsgPayPacketFee // PayPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to relay the packet with the next sequence -func (k Keeper) PayPacketFee(goCtx context.Context, msg *types.MsgPayPacketFee) (*types.MsgPayPacketFeeResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k Keeper) PayPacketFee(ctx context.Context, msg *types.MsgPayPacketFee) (*types.MsgPayPacketFeeResponse, error) { if !k.IsFeeEnabled(ctx, msg.SourcePortId, msg.SourceChannelId) { // users may not escrow fees on this channel. Must send packets without a fee message return nil, types.ErrFeeNotEnabled @@ -122,9 +116,7 @@ func (k Keeper) PayPacketFee(goCtx context.Context, msg *types.MsgPayPacketFee) // PayPacketFeeAsync is an open callback that may be called by any module/user that wishes to escrow funds in order to // incentivize the relaying of a known packet. Only packets which have been sent and have not gone through the // packet life cycle may be incentivized. -func (k Keeper) PayPacketFeeAsync(goCtx context.Context, msg *types.MsgPayPacketFeeAsync) (*types.MsgPayPacketFeeAsyncResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - +func (k Keeper) PayPacketFeeAsync(ctx context.Context, msg *types.MsgPayPacketFeeAsync) (*types.MsgPayPacketFeeAsyncResponse, error) { if !k.IsFeeEnabled(ctx, msg.PacketId.PortId, msg.PacketId.ChannelId) { // users may not escrow fees on this channel. Must send packets without a fee message return nil, types.ErrFeeNotEnabled diff --git a/modules/core/02-client/keeper/grpc_query.go b/modules/core/02-client/keeper/grpc_query.go index e0dafbd3294..bc075121731 100644 --- a/modules/core/02-client/keeper/grpc_query.go +++ b/modules/core/02-client/keeper/grpc_query.go @@ -39,7 +39,7 @@ func NewQueryServer(k *Keeper) types.QueryServer { } // ClientState implements the Query/ClientState gRPC method -func (q *queryServer) ClientState(c context.Context, req *types.QueryClientStateRequest) (*types.QueryClientStateResponse, error) { +func (q *queryServer) ClientState(ctx context.Context, req *types.QueryClientStateRequest) (*types.QueryClientStateResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -48,7 +48,6 @@ func (q *queryServer) ClientState(c context.Context, req *types.QueryClientState return nil, status.Error(codes.InvalidArgument, err.Error()) } - ctx := sdk.UnwrapSDKContext(c) clientState, found := q.GetClientState(ctx, req.ClientId) if !found { return nil, status.Error( @@ -70,13 +69,11 @@ func (q *queryServer) ClientState(c context.Context, req *types.QueryClientState } // ClientStates implements the Query/ClientStates gRPC method -func (q *queryServer) ClientStates(c context.Context, req *types.QueryClientStatesRequest) (*types.QueryClientStatesResponse, error) { +func (q *queryServer) ClientStates(ctx context.Context, req *types.QueryClientStatesRequest) (*types.QueryClientStatesResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } - ctx := sdk.UnwrapSDKContext(c) - var clientStates types.IdentifiedClientStates store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), host.KeyClientStorePrefix) @@ -114,7 +111,7 @@ func (q *queryServer) ClientStates(c context.Context, req *types.QueryClientStat } // ConsensusState implements the Query/ConsensusState gRPC method -func (q *queryServer) ConsensusState(c context.Context, req *types.QueryConsensusStateRequest) (*types.QueryConsensusStateResponse, error) { +func (q *queryServer) ConsensusState(ctx context.Context, req *types.QueryConsensusStateRequest) (*types.QueryConsensusStateResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -123,8 +120,6 @@ func (q *queryServer) ConsensusState(c context.Context, req *types.QueryConsensu return nil, status.Error(codes.InvalidArgument, err.Error()) } - ctx := sdk.UnwrapSDKContext(c) - var ( consensusState exported.ConsensusState found bool @@ -161,7 +156,7 @@ func (q *queryServer) ConsensusState(c context.Context, req *types.QueryConsensu } // ConsensusStates implements the Query/ConsensusStates gRPC method -func (q *queryServer) ConsensusStates(c context.Context, req *types.QueryConsensusStatesRequest) (*types.QueryConsensusStatesResponse, error) { +func (q *queryServer) ConsensusStates(ctx context.Context, req *types.QueryConsensusStatesRequest) (*types.QueryConsensusStatesResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -170,8 +165,6 @@ func (q *queryServer) ConsensusStates(c context.Context, req *types.QueryConsens return nil, status.Error(codes.InvalidArgument, err.Error()) } - ctx := sdk.UnwrapSDKContext(c) - var consensusStates []types.ConsensusStateWithHeight store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), host.FullClientKey(req.ClientId, []byte(fmt.Sprintf("%s/", host.KeyConsensusStatePrefix)))) @@ -205,7 +198,7 @@ func (q *queryServer) ConsensusStates(c context.Context, req *types.QueryConsens } // ConsensusStateHeights implements the Query/ConsensusStateHeights gRPC method -func (q *queryServer) ConsensusStateHeights(c context.Context, req *types.QueryConsensusStateHeightsRequest) (*types.QueryConsensusStateHeightsResponse, error) { +func (q *queryServer) ConsensusStateHeights(ctx context.Context, req *types.QueryConsensusStateHeightsRequest) (*types.QueryConsensusStateHeightsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -214,8 +207,6 @@ func (q *queryServer) ConsensusStateHeights(c context.Context, req *types.QueryC return nil, status.Error(codes.InvalidArgument, err.Error()) } - ctx := sdk.UnwrapSDKContext(c) - var consensusStateHeights []types.Height store := prefix.NewStore(runtime.KVStoreAdapter(q.storeService.OpenKVStore(ctx)), host.FullClientKey(req.ClientId, []byte(fmt.Sprintf("%s/", host.KeyConsensusStatePrefix)))) @@ -244,7 +235,7 @@ func (q *queryServer) ConsensusStateHeights(c context.Context, req *types.QueryC } // ClientStatus implements the Query/ClientStatus gRPC method -func (q *queryServer) ClientStatus(c context.Context, req *types.QueryClientStatusRequest) (*types.QueryClientStatusResponse, error) { +func (q *queryServer) ClientStatus(ctx context.Context, req *types.QueryClientStatusRequest) (*types.QueryClientStatusResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -253,7 +244,6 @@ func (q *queryServer) ClientStatus(c context.Context, req *types.QueryClientStat return nil, status.Error(codes.InvalidArgument, err.Error()) } - ctx := sdk.UnwrapSDKContext(c) clientStatus := q.GetClientStatus(ctx, req.ClientId) return &types.QueryClientStatusResponse{ @@ -262,8 +252,7 @@ func (q *queryServer) ClientStatus(c context.Context, req *types.QueryClientStat } // ClientParams implements the Query/ClientParams gRPC method -func (q *queryServer) ClientParams(c context.Context, _ *types.QueryClientParamsRequest) (*types.QueryClientParamsResponse, error) { - ctx := sdk.UnwrapSDKContext(c) +func (q *queryServer) ClientParams(ctx context.Context, _ *types.QueryClientParamsRequest) (*types.QueryClientParamsResponse, error) { params := q.GetParams(ctx) return &types.QueryClientParamsResponse{ @@ -272,13 +261,11 @@ func (q *queryServer) ClientParams(c context.Context, _ *types.QueryClientParams } // UpgradedClientState implements the Query/UpgradedClientState gRPC method -func (q *queryServer) UpgradedClientState(c context.Context, req *types.QueryUpgradedClientStateRequest) (*types.QueryUpgradedClientStateResponse, error) { +func (q *queryServer) UpgradedClientState(ctx context.Context, req *types.QueryUpgradedClientStateRequest) (*types.QueryUpgradedClientStateResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } - ctx := sdk.UnwrapSDKContext(c) - plan, err := q.GetUpgradePlan(ctx) if err != nil { return nil, status.Error(codes.NotFound, err.Error()) diff --git a/modules/light-clients/08-wasm/go.mod b/modules/light-clients/08-wasm/go.mod index 7833f66b117..d7fe3c554e8 100644 --- a/modules/light-clients/08-wasm/go.mod +++ b/modules/light-clients/08-wasm/go.mod @@ -14,6 +14,7 @@ require ( cosmossdk.io/math v1.3.0 cosmossdk.io/store v1.1.1-0.20240815194237-858ec2fcb897 cosmossdk.io/tools/confix v0.1.2 + cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 cosmossdk.io/x/authz v0.0.0-00010101000000-000000000000 cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 cosmossdk.io/x/circuit v0.1.1 @@ -56,8 +57,11 @@ require ( cloud.google.com/go/compute/metadata v0.3.0 // indirect cloud.google.com/go/iam v1.1.9 // indirect cloud.google.com/go/storage v1.42.0 // indirect + cosmossdk.io/core/testing v0.0.0-20240906090851-36d9b25e8981 // indirect cosmossdk.io/depinject v1.0.0 // indirect cosmossdk.io/schema v0.2.0 // indirect + cosmossdk.io/x/accounts/defaults/lockup v0.0.0-20240417181816-5e7aae0db1f5 // indirect + cosmossdk.io/x/accounts/defaults/multisig v0.0.0-00010101000000-000000000000 // indirect cosmossdk.io/x/epochs v0.0.0-20240522060652-a1ae4c3e0337 // indirect cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 // indirect filippo.io/edwards25519 v1.1.0 // indirect diff --git a/modules/light-clients/08-wasm/testing/simapp/app.go b/modules/light-clients/08-wasm/testing/simapp/app.go index 274cfec3569..128a437362c 100644 --- a/modules/light-clients/08-wasm/testing/simapp/app.go +++ b/modules/light-clients/08-wasm/testing/simapp/app.go @@ -16,39 +16,34 @@ import ( autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" "cosmossdk.io/client/v2/autocli" - "cosmossdk.io/core/appmodule" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" - "cosmossdk.io/x/circuit" - circuitkeeper "cosmossdk.io/x/circuit/keeper" - circuittypes "cosmossdk.io/x/circuit/types" - "cosmossdk.io/x/evidence" - evidencekeeper "cosmossdk.io/x/evidence/keeper" - evidencetypes "cosmossdk.io/x/evidence/types" - "cosmossdk.io/x/feegrant" - feegrantkeeper "cosmossdk.io/x/feegrant/keeper" - feegrantmodule "cosmossdk.io/x/feegrant/module" - "cosmossdk.io/x/tx/signing" - "cosmossdk.io/x/upgrade" - upgradekeeper "cosmossdk.io/x/upgrade/keeper" - upgradetypes "cosmossdk.io/x/upgrade/types" - + "cosmossdk.io/x/accounts" "cosmossdk.io/x/authz" authzkeeper "cosmossdk.io/x/authz/keeper" authzmodule "cosmossdk.io/x/authz/module" "cosmossdk.io/x/bank" bankkeeper "cosmossdk.io/x/bank/keeper" banktypes "cosmossdk.io/x/bank/types" + "cosmossdk.io/x/circuit" + circuitkeeper "cosmossdk.io/x/circuit/keeper" + circuittypes "cosmossdk.io/x/circuit/types" "cosmossdk.io/x/consensus" consensusparamkeeper "cosmossdk.io/x/consensus/keeper" consensusparamtypes "cosmossdk.io/x/consensus/types" distr "cosmossdk.io/x/distribution" distrkeeper "cosmossdk.io/x/distribution/keeper" distrtypes "cosmossdk.io/x/distribution/types" + "cosmossdk.io/x/evidence" + evidencekeeper "cosmossdk.io/x/evidence/keeper" + evidencetypes "cosmossdk.io/x/evidence/types" + "cosmossdk.io/x/feegrant" + feegrantkeeper "cosmossdk.io/x/feegrant/keeper" + feegrantmodule "cosmossdk.io/x/feegrant/module" "cosmossdk.io/x/gov" - govclient "cosmossdk.io/x/gov/client" govkeeper "cosmossdk.io/x/gov/keeper" govtypes "cosmossdk.io/x/gov/types" + govv1beta1 "cosmossdk.io/x/gov/types/v1beta1" "cosmossdk.io/x/group" groupkeeper "cosmossdk.io/x/group/keeper" groupmodule "cosmossdk.io/x/group/module" @@ -56,15 +51,20 @@ import ( mintkeeper "cosmossdk.io/x/mint/keeper" minttypes "cosmossdk.io/x/mint/types" "cosmossdk.io/x/params" - paramsclient "cosmossdk.io/x/params/client" paramskeeper "cosmossdk.io/x/params/keeper" paramstypes "cosmossdk.io/x/params/types" + poolkeeper "cosmossdk.io/x/protocolpool/keeper" + pooltypes "cosmossdk.io/x/protocolpool/types" "cosmossdk.io/x/slashing" slashingkeeper "cosmossdk.io/x/slashing/keeper" slashingtypes "cosmossdk.io/x/slashing/types" "cosmossdk.io/x/staking" stakingkeeper "cosmossdk.io/x/staking/keeper" stakingtypes "cosmossdk.io/x/staking/types" + "cosmossdk.io/x/tx/signing" + "cosmossdk.io/x/upgrade" + upgradekeeper "cosmossdk.io/x/upgrade/keeper" + upgradetypes "cosmossdk.io/x/upgrade/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -180,7 +180,8 @@ type SimApp struct { memKeys map[string]*storetypes.MemoryStoreKey // keepers - AccountKeeper authkeeper.AccountKeeper + AuthKeeper authkeeper.AccountKeeper + AccountKeeper accounts.Keeper BankKeeper bankkeeper.Keeper CapabilityKeeper *capabilitykeeper.Keeper StakingKeeper *stakingkeeper.Keeper @@ -202,6 +203,7 @@ type SimApp struct { GroupKeeper groupkeeper.Keeper ConsensusParamsKeeper consensusparamkeeper.Keeper CircuitKeeper circuitkeeper.Keeper + PoolKeeper poolkeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -218,8 +220,7 @@ type SimApp struct { FeeMockModule ibcmock.IBCModule // the module manager - ModuleManager *module.Manager - BasicModuleManager module.BasicManager + ModuleManager *module.Manager // simulation manager simulationManager *module.SimulationManager @@ -260,7 +261,8 @@ func NewSimApp( }) appCodec := codec.NewProtoCodec(interfaceRegistry) legacyAmino := codec.NewLegacyAmino() - txConfig := authtx.NewTxConfig(appCodec, authtx.DefaultSignModes) + signingCtx := interfaceRegistry.SigningContext() + txConfig := authtx.NewTxConfig(appCodec, signingCtx.AddressCodec(), signingCtx.ValidatorAddressCodec(), authtx.DefaultSignModes) std.RegisterLegacyAminoCodec(legacyAmino) std.RegisterInterfaces(interfaceRegistry) @@ -297,6 +299,11 @@ func NewSimApp( bApp.SetInterfaceRegistry(interfaceRegistry) bApp.SetTxEncoder(txConfig.TxEncoder()) + govModuleAddr, err := signingCtx.AddressCodec().BytesToString(authtypes.NewModuleAddress(govtypes.ModuleName)) + if err != nil { + panic(err) + } + keys := storetypes.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, @@ -327,7 +334,7 @@ func NewSimApp( app.ParamsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey]) // set the BaseApp's parameter store - app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), authtypes.NewModuleAddress(govtypes.ModuleName).String(), runtime.EventService{}) + app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]), logger.With(log.ModuleKey, "x/consensus")), govModuleAddr) bApp.SetParamStore(app.ConsensusParamsKeeper.ParamsStore) // add capability keeper and ScopeToModule for ibc module @@ -351,47 +358,76 @@ func NewSimApp( // SDK module keepers - // add keepers - app.AccountKeeper = authkeeper.NewAccountKeeper(appCodec, runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, authcodec.NewBech32Codec(sdk.Bech32MainPrefix), sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String()) + // add keepers // add keepers + accountsKeeper, err := accounts.NewKeeper( + appCodec, + runtime.NewEnvironment(runtime.NewKVStoreService(keys[accounts.StoreKey]), logger.With(log.ModuleKey, "x/accounts"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), + signingCtx.AddressCodec(), + appCodec.InterfaceRegistry(), + ) + if err != nil { + panic(err) + } + app.AccountKeeper = accountsKeeper + + app.AuthKeeper = authkeeper.NewAccountKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[authtypes.StoreKey]), logger.With(log.ModuleKey, "x/auth")), appCodec, authtypes.ProtoBaseAccount, accountsKeeper, maccPerms, signingCtx.AddressCodec(), sdk.Bech32MainPrefix, govModuleAddr) + + blockedAddrs := BlockedAddresses() app.BankKeeper = bankkeeper.NewBaseKeeper( + runtime.NewEnvironment(runtime.NewKVStoreService(keys[banktypes.StoreKey]), logger.With(log.ModuleKey, "x/bank")), appCodec, - runtime.NewKVStoreService(keys[banktypes.StoreKey]), - app.AccountKeeper, - BlockedAddresses(), - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - logger, + app.AuthKeeper, + blockedAddrs, + govModuleAddr, ) + + cometService := runtime.NewContextAwareCometInfoService() app.StakingKeeper = stakingkeeper.NewKeeper( - appCodec, runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), authcodec.NewBech32Codec(sdk.Bech32PrefixValAddr), authcodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), + appCodec, + runtime.NewEnvironment( + runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), + logger.With(log.ModuleKey, "x/staking"), + runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), + runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), + app.AuthKeeper, + app.BankKeeper, + govModuleAddr, + signingCtx.ValidatorAddressCodec(), + authcodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), + cometService, ) - app.MintKeeper = mintkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[minttypes.StoreKey]), app.StakingKeeper, app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String()) + app.MintKeeper = mintkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[minttypes.StoreKey]), logger.With(log.ModuleKey, "x/mint")), app.StakingKeeper, app.AuthKeeper, app.BankKeeper, authtypes.FeeCollectorName, govModuleAddr) - app.DistrKeeper = distrkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[distrtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String()) + app.PoolKeeper = poolkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[pooltypes.StoreKey]), logger.With(log.ModuleKey, "x/protocolpool")), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, govModuleAddr) - app.SlashingKeeper = slashingkeeper.NewKeeper( - appCodec, legacyAmino, runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), app.StakingKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) + app.DistrKeeper = distrkeeper.NewKeeper(appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[distrtypes.StoreKey]), logger.With(log.ModuleKey, "x/distribution")), app.AuthKeeper, app.BankKeeper, app.StakingKeeper, cometService, authtypes.FeeCollectorName, govModuleAddr) - app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[feegrant.StoreKey]), app.AccountKeeper) + app.SlashingKeeper = slashingkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), logger.With(log.ModuleKey, "x/slashing")), + appCodec, legacyAmino, app.StakingKeeper, govModuleAddr, + ) + app.FeeGrantKeeper = feegrantkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[feegrant.StoreKey]), logger.With(log.ModuleKey, "x/feegrant")), appCodec, app.AuthKeeper) // register the staking hooks // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks app.StakingKeeper.SetHooks( stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()), ) - app.CircuitKeeper = circuitkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[circuittypes.StoreKey]), authtypes.NewModuleAddress(govtypes.ModuleName).String(), app.AccountKeeper.AddressCodec()) + app.CircuitKeeper = circuitkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[circuittypes.StoreKey]), logger.With(log.ModuleKey, "x/circuit")), appCodec, govModuleAddr, app.AuthKeeper.AddressCodec()) app.BaseApp.SetCircuitBreaker(&app.CircuitKeeper) - app.AuthzKeeper = authzkeeper.NewKeeper(runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), appCodec, app.MsgServiceRouter(), app.AccountKeeper) + app.AuthzKeeper = authzkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), logger.With(log.ModuleKey, "x/authz"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), appCodec, app.AuthKeeper) groupConfig := group.DefaultConfig() /* - Example of setting group params: - groupConfig.MaxMetadataLen = 1000 + Example of group params: + config.MaxExecutionPeriod = "1209600s" // example execution period in seconds + config.MaxMetadataLen = 1000 // example metadata length in bytes + config.MaxProposalTitleLen = 255 // example max title length in characters + config.MaxProposalSummaryLen = 10200 // example max summary length in characters */ - app.GroupKeeper = groupkeeper.NewKeeper(keys[group.StoreKey], appCodec, app.MsgServiceRouter(), app.AccountKeeper, groupConfig) + app.GroupKeeper = groupkeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[group.StoreKey]), logger.With(log.ModuleKey, "x/group"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), appCodec, app.AuthKeeper, groupConfig) // get skipUpgradeHeights from the app options skipUpgradeHeights := map[int64]bool{} @@ -400,21 +436,30 @@ func NewSimApp( } homePath := cast.ToString(appOpts.Get(flags.FlagHome)) // set the governance module account as the authority for conducting upgrades - app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), appCodec, homePath, app.BaseApp, authtypes.NewModuleAddress(govtypes.ModuleName).String()) + app.UpgradeKeeper = upgradekeeper.NewKeeper(runtime.NewEnvironment(runtime.NewKVStoreService(keys[upgradetypes.StoreKey]), logger.With(log.ModuleKey, "x/upgrade"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), skipUpgradeHeights, appCodec, homePath, app.BaseApp, govModuleAddr) app.IBCKeeper = ibckeeper.NewKeeper( appCodec, runtime.NewKVStoreService(keys[ibcexported.StoreKey]), app.GetSubspace(ibcexported.ModuleName), app.UpgradeKeeper, scopedIBCKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - govConfig := govtypes.DefaultConfig() + govRouter := govv1beta1.NewRouter() + govConfig := govkeeper.DefaultConfig() /* Example of setting gov params: govConfig.MaxMetadataLen = 10000 */ govKeeper := govkeeper.NewKeeper( - appCodec, runtime.NewKVStoreService(keys[govtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, - app.StakingKeeper, app.DistrKeeper, app.MsgServiceRouter(), govConfig, authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) + appCodec, + runtime.NewEnvironment(runtime.NewKVStoreService(keys[govtypes.StoreKey]), logger.With(log.ModuleKey, "x/gov"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), + app.AuthKeeper, + app.BankKeeper, + app.StakingKeeper, + app.PoolKeeper, + govConfig, + govModuleAddr) + + // Set legacy router for backwards compatibility with gov v1beta1 + govKeeper.SetLegacyRouter(govRouter) app.GovKeeper = *govKeeper.SetHooks( govtypes.NewMultiGovHooks( @@ -469,7 +514,7 @@ func NewSimApp( appCodec, runtime.NewKVStoreService(keys[ibcfeetypes.StoreKey]), app.IBCKeeper.ChannelKeeper, // may be replaced with IBC middleware app.IBCKeeper.ChannelKeeper, - app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, + app.IBCKeeper.PortKeeper, app.AuthKeeper, app.BankKeeper, ) // ICA Controller keeper @@ -486,7 +531,7 @@ func NewSimApp( appCodec, runtime.NewKVStoreService(keys[icahosttypes.StoreKey]), app.GetSubspace(icahosttypes.SubModuleName), app.IBCFeeKeeper, // use ics29 fee as ics4Wrapper in middleware stack app.IBCKeeper.ChannelKeeper, app.IBCKeeper.PortKeeper, - app.AccountKeeper, scopedICAHostKeeper, app.MsgServiceRouter(), + app.AuthKeeper, scopedICAHostKeeper, app.MsgServiceRouter(), app.GRPCQueryRouter(), authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -501,7 +546,7 @@ func NewSimApp( appCodec, runtime.NewKVStoreService(keys[ibctransfertypes.StoreKey]), app.GetSubspace(ibctransfertypes.ModuleName), app.IBCFeeKeeper, // ISC4 Wrapper: fee IBC middleware app.IBCKeeper.ChannelKeeper, app.IBCKeeper.PortKeeper, - app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, + app.AuthKeeper, app.BankKeeper, scopedTransferKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) @@ -598,7 +643,7 @@ func NewSimApp( // create evidence keeper with router evidenceKeeper := evidencekeeper.NewKeeper( - appCodec, runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), app.StakingKeeper, app.SlashingKeeper, app.AccountKeeper.AddressCodec(), runtime.ProvideCometInfoService(), + appCodec, runtime.NewEnvironment(runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), logger.With(log.ModuleKey, "x/evidence"), runtime.EnvWithMsgRouterService(app.MsgServiceRouter()), runtime.EnvWithQueryRouterService(app.GRPCQueryRouter())), app.StakingKeeper, app.SlashingKeeper, app.AuthKeeper.AddressCodec(), ) // If evidence needs to be handled for the app, set routes in router here and seal app.EvidenceKeeper = *evidenceKeeper @@ -608,58 +653,38 @@ 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( - app.AccountKeeper, app.StakingKeeper, app, - txConfig, - ), - auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), - vesting.NewAppModule(app.AccountKeeper, app.BankKeeper), - bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper, app.GetSubspace(banktypes.ModuleName)), + genutil.NewAppModule(appCodec, app.AuthKeeper, app.StakingKeeper, app, txConfig, genutiltypes.DefaultMessageValidator), + auth.NewAppModule(appCodec, app.AuthKeeper, app.AccountKeeper, authsims.RandomGenesisAccounts, nil), + vesting.NewAppModule(app.AuthKeeper, app.BankKeeper), + bank.NewAppModule(appCodec, app.BankKeeper, app.AuthKeeper), capability.NewAppModule(appCodec, *app.CapabilityKeeper, false), - feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), - gov.NewAppModule(appCodec, &app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(govtypes.ModuleName)), - mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil, app.GetSubspace(minttypes.ModuleName)), - slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName), app.interfaceRegistry), - distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), - staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), - upgrade.NewAppModule(app.UpgradeKeeper, app.AccountKeeper.AddressCodec()), - evidence.NewAppModule(app.EvidenceKeeper), + feegrantmodule.NewAppModule(appCodec, app.AuthKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), + gov.NewAppModule(appCodec, &app.GovKeeper, app.AuthKeeper, app.BankKeeper, app.PoolKeeper), + mint.NewAppModule(appCodec, app.MintKeeper, app.AuthKeeper, nil), + slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper, app.interfaceRegistry, cometService), + distr.NewAppModule(appCodec, app.DistrKeeper, app.AuthKeeper, app.BankKeeper, app.StakingKeeper), + staking.NewAppModule(appCodec, app.StakingKeeper, app.AuthKeeper, app.BankKeeper), + upgrade.NewAppModule(app.UpgradeKeeper), + evidence.NewAppModule(appCodec, app.EvidenceKeeper, cometService), params.NewAppModule(app.ParamsKeeper), - authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), - groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), + authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), + groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AuthKeeper, app.BankKeeper, app.interfaceRegistry), consensus.NewAppModule(appCodec, app.ConsensusParamsKeeper), circuit.NewAppModule(appCodec, app.CircuitKeeper), // IBC modules - ibc.NewAppModule(app.IBCKeeper), - transfer.NewAppModule(app.TransferKeeper), - ibcfee.NewAppModule(app.IBCFeeKeeper), - ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper), + ibc.NewAppModule(appCodec, app.IBCKeeper), + transfer.NewAppModule(appCodec, app.TransferKeeper), + ibcfee.NewAppModule(appCodec, app.IBCFeeKeeper), + ica.NewAppModule(appCodec, &app.ICAControllerKeeper, &app.ICAHostKeeper), mockModule, // IBC light clients - wasm.NewAppModule(app.WasmClientKeeper), // TODO(damian): see if we want to pass the lightclient module here, keeper is used in AppModule.RegisterServices etc + wasm.NewAppModule(appCodec, app.WasmClientKeeper), // TODO(damian): see if we want to pass the lightclient module here, keeper is used in AppModule.RegisterServices etc ibctm.NewAppModule(tmLightClientModule), solomachine.NewAppModule(smLightClientModule), ) - // BasicModuleManager defines the module BasicManager is in charge of setting up basic, - // non-dependant module elements, such as codec registration and genesis verification. - // By default it is composed of all the module from the module manager. - // Additionally, app module basics can be overwritten by passing them as argument. - app.BasicModuleManager = module.NewBasicManagerFromManager( - app.ModuleManager, - map[string]module.AppModuleBasic{ - genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator), - govtypes.ModuleName: gov.NewAppModuleBasic( - []govclient.ProposalHandler{ - paramsclient.ProposalHandler, - }, - ), - }) - app.BasicModuleManager.RegisterLegacyAminoCodec(legacyAmino) - app.BasicModuleManager.RegisterInterfaces(interfaceRegistry) - // NOTE: upgrade module is required to be prioritized app.ModuleManager.SetOrderPreBlockers( upgradetypes.ModuleName, @@ -723,7 +748,7 @@ func NewSimApp( // app.ModuleManager.SetOrderMigrations(custom order) app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) - err := app.ModuleManager.RegisterServices(app.configurator) + err = app.ModuleManager.RegisterServices(app.configurator) if err != nil { panic(err) } @@ -748,7 +773,7 @@ func NewSimApp( // NOTE: this is not required apps that don't use the simulator for fuzz testing // transactions overrideModules := map[string]module.AppModuleSimulation{ - authtypes.ModuleName: auth.NewAppModule(app.appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), + authtypes.ModuleName: auth.NewAppModule(app.appCodec, app.AuthKeeper, app.AccountKeeper, authsims.RandomGenesisAccounts, nil), } app.simulationManager = module.NewSimulationManagerFromAppModules(app.ModuleManager.Modules, overrideModules) @@ -844,7 +869,7 @@ func (app *SimApp) setAnteHandler(txConfig client.TxConfig) { anteHandler, err := NewAnteHandler( HandlerOptions{ HandlerOptions: ante.HandlerOptions{ - AccountKeeper: app.AccountKeeper, + AccountKeeper: app.AuthKeeper, BankKeeper: app.BankKeeper, FeegrantKeeper: app.FeeGrantKeeper, SignModeHandler: txConfig.SignModeHandler(), @@ -876,7 +901,7 @@ func (app *SimApp) setPostHandler() { func (app *SimApp) Name() string { return app.BaseApp.Name() } // PreBlocker application updates every pre block -func (app *SimApp) PreBlocker(ctx sdk.Context, _ *abci.RequestFinalizeBlock) (*sdk.ResponsePreBlock, error) { +func (app *SimApp) PreBlocker(ctx sdk.Context, _ *abci.FinalizeBlockRequest) error { return app.ModuleManager.PreBlock(ctx) } @@ -896,7 +921,7 @@ func (app *SimApp) Configurator() module.Configurator { } // InitChainer application update at chain initialization -func (app *SimApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { +func (app *SimApp) InitChainer(ctx sdk.Context, req *abci.InitChainRequest) (*abci.InitChainResponse, error) { var genesisState GenesisState if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) @@ -904,7 +929,7 @@ func (app *SimApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*ab if err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()); err != nil { panic(err) } - return app.ModuleManager.InitGenesis(ctx, app.appCodec, genesisState) + return app.ModuleManager.InitGenesis(ctx, genesisState) } // LoadHeight loads a particular height @@ -940,25 +965,15 @@ func (app *SimApp) TxConfig() client.TxConfig { // AutoCliOpts returns the autocli options for the app. func (app *SimApp) AutoCliOpts() autocli.AppOptions { - modules := make(map[string]appmodule.AppModule, 0) - for _, m := range app.ModuleManager.Modules { - if moduleWithName, ok := m.(module.HasName); ok { - moduleName := moduleWithName.Name() - if appModule, ok := moduleWithName.(appmodule.AppModule); ok { - modules[moduleName] = appModule - } - } - } - return autocli.AppOptions{ - Modules: modules, + Modules: app.ModuleManager.Modules, ModuleOptions: runtimeservices.ExtractAutoCLIOptions(app.ModuleManager.Modules), } } // DefaultGenesis returns a default genesis from the registered AppModuleBasic's. func (app *SimApp) DefaultGenesis() map[string]json.RawMessage { - return app.BasicModuleManager.DefaultGenesis(app.appCodec) + return app.ModuleManager.DefaultGenesis() } // GetKey returns the KVStoreKey for the provided store key. @@ -1005,7 +1020,7 @@ func (app *SimApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APICon nodeservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // Register grpc-gateway routes for all modules. - app.BasicModuleManager.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + app.ModuleManager.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // register swagger API from root so that other applications can override easily if err := server.RegisterSwaggerAPI(apiSvr.ClientCtx, apiSvr.Router, apiConfig.Swagger); err != nil { diff --git a/modules/light-clients/08-wasm/testing/simapp/encoding.go b/modules/light-clients/08-wasm/testing/simapp/encoding.go deleted file mode 100644 index ba2d01ecbcf..00000000000 --- a/modules/light-clients/08-wasm/testing/simapp/encoding.go +++ /dev/null @@ -1,18 +0,0 @@ -package simapp - -import ( - "github.com/cosmos/cosmos-sdk/std" - - simappparams "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/testing/simapp/params" -) - -// MakeTestEncodingConfig creates an EncodingConfig for testing. This function -// should be used only in tests or when creating a new app instance (NewApp*()). -// App user shouldn't create new codecs - use the app.AppCodec instead. -// [DEPRECATED] -func MakeTestEncodingConfig() simappparams.EncodingConfig { - encodingConfig := simappparams.MakeTestEncodingConfig() - std.RegisterLegacyAminoCodec(encodingConfig.Amino) - std.RegisterInterfaces(encodingConfig.InterfaceRegistry) - return encodingConfig -} diff --git a/modules/light-clients/08-wasm/testing/simapp/params/proto.go b/modules/light-clients/08-wasm/testing/simapp/params/proto.go deleted file mode 100644 index 73702a15abf..00000000000 --- a/modules/light-clients/08-wasm/testing/simapp/params/proto.go +++ /dev/null @@ -1,27 +0,0 @@ -//go:build !test_amino -// +build !test_amino - -package params - -import ( - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/x/auth/tx" -) - -// MakeTestEncodingConfig creates an EncodingConfig for a non-amino based test configuration. -// This function should be used only internally (in the SDK). -// App user shouldn't create new codecs - use the app.AppCodec instead. -// [DEPRECATED] -func MakeTestEncodingConfig() EncodingConfig { - cdc := codec.NewLegacyAmino() - interfaceRegistry := types.NewInterfaceRegistry() - protoCdc := codec.NewProtoCodec(interfaceRegistry) - - return EncodingConfig{ - InterfaceRegistry: interfaceRegistry, - Codec: protoCdc, - TxConfig: tx.NewTxConfig(protoCdc, tx.DefaultSignModes), - Amino: cdc, - } -} diff --git a/modules/light-clients/08-wasm/testing/simapp/simd/cmd/root.go b/modules/light-clients/08-wasm/testing/simapp/simd/cmd/root.go index 17fe24771d9..fade9a49e8f 100644 --- a/modules/light-clients/08-wasm/testing/simapp/simd/cmd/root.go +++ b/modules/light-clients/08-wasm/testing/simapp/simd/cmd/root.go @@ -13,7 +13,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "cosmossdk.io/client/v2/autocli" + "cosmossdk.io/client/v2/offchain" "cosmossdk.io/log" confixcmd "cosmossdk.io/tools/confix/cmd" @@ -21,12 +21,12 @@ import ( "github.com/cosmos/cosmos-sdk/client/config" sdkdebug "github.com/cosmos/cosmos-sdk/client/debug" "github.com/cosmos/cosmos-sdk/client/flags" + nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" "github.com/cosmos/cosmos-sdk/client/keys" "github.com/cosmos/cosmos-sdk/client/pruning" "github.com/cosmos/cosmos-sdk/client/rpc" "github.com/cosmos/cosmos-sdk/client/snapshot" "github.com/cosmos/cosmos-sdk/codec" - addresscodec "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/server" serverconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" @@ -38,7 +38,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/tx" txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config" "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/genutil" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" cmtcfg "github.com/cometbft/cometbft/config" @@ -115,12 +117,13 @@ func NewRootCmd() *cobra.Command { }, } - initRootCmd(rootCmd, encodingConfig, tempApp.BasicModuleManager) + initRootCmd(rootCmd, tempApp.ModuleManager) - autoCliOpts, err := enrichAutoCliOpts(tempApp.AutoCliOpts(), initClientCtx) - if err != nil { - panic(err) - } + autoCliOpts := tempApp.AutoCliOpts() + autoCliOpts.ClientCtx = initClientCtx + + nodeCmds := nodeservice.NewNodeCommands() + autoCliOpts.ModuleOptions[nodeCmds.Name()] = nodeCmds.AutoCLIOptions() if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil { panic(err) @@ -129,22 +132,6 @@ func NewRootCmd() *cobra.Command { return rootCmd } -func enrichAutoCliOpts(autoCliOpts autocli.AppOptions, clientCtx client.Context) (autocli.AppOptions, error) { - autoCliOpts.AddressCodec = addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()) - autoCliOpts.ValidatorAddressCodec = addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()) - autoCliOpts.ConsensusAddressCodec = addresscodec.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()) - - var err error - clientCtx, err = config.ReadFromClientConfig(clientCtx) - if err != nil { - return autocli.AppOptions{}, err - } - - autoCliOpts.ClientCtx = clientCtx - - return autoCliOpts, nil -} - // initCometBFTConfig helps to override default CometBFT Config values. // return cmtcfg.DefaultConfig if no custom configuration is required for the application. func initCometBFTConfig() *cmtcfg.Config { @@ -214,12 +201,12 @@ lru_size = 0` return customAppTemplate, customAppConfig } -func initRootCmd(rootCmd *cobra.Command, basicManager module.Manager) { +func initRootCmd(rootCmd *cobra.Command, moduleManager *module.Manager) { cfg := sdk.GetConfig() cfg.Seal() rootCmd.AddCommand( - genutilcli.InitCmd(basicManager), + genutilcli.InitCmd(moduleManager), sdkdebug.Cmd(), confixcmd.ConfigCommand(), pruning.Cmd(newApp), @@ -227,15 +214,16 @@ func initRootCmd(rootCmd *cobra.Command, basicManager module.Manager) { server.QueryBlockResultsCmd(), ) - server.AddCommands(rootCmd, simapp.DefaultNodeHome, newApp, appExport, addModuleInitFlags) + server.AddCommands(rootCmd, newApp, server.StartCmdOptions[servertypes.Application]{}) // add keybase, auxiliary RPC, query, genesis, and tx child commands rootCmd.AddCommand( server.StatusCommand(), - genesisCommand(basicManager), - txCommand(), + genesisCommand(moduleManager, appExport), queryCommand(), + txCommand(), keys.Commands(), + offchain.OffChain(), ) } @@ -257,7 +245,7 @@ func queryCommand() *cobra.Command { } cmd.AddCommand( - rpc.ValidatorCommand(), + rpc.WaitTxCmd(), server.QueryBlockCmd(), authcmd.QueryTxsByEventsCmd(), server.QueryBlocksCmd(), @@ -293,9 +281,8 @@ func txCommand() *cobra.Command { } // genesisCommand builds genesis-related `simd genesis` command. Users may provide application specific commands as a parameter -func genesisCommand(encodingConfig params.EncodingConfig, basicManager module.BasicManager, cmds ...*cobra.Command) *cobra.Command { - cmd := genutilcli.Commands(encodingConfig.TxConfig, basicManager, simapp.DefaultNodeHome) - +func genesisCommand(moduleManager *module.Manager, appExport servertypes.AppExporter, cmds ...*cobra.Command) *cobra.Command { + cmd := genutilcli.Commands(moduleManager.Modules[genutiltypes.ModuleName].(genutil.AppModule), moduleManager, appExport) for _, subCmd := range cmds { cmd.AddCommand(subCmd) } diff --git a/modules/light-clients/08-wasm/types/msgs_test.go b/modules/light-clients/08-wasm/types/msgs_test.go index 4326f634782..a005d26437e 100644 --- a/modules/light-clients/08-wasm/types/msgs_test.go +++ b/modules/light-clients/08-wasm/types/msgs_test.go @@ -76,7 +76,7 @@ func (suite *TypesTestSuite) TestMsgStoreCodeGetSigners() { address := tc.address msg := types.NewMsgStoreCode(address.String(), wasmtesting.Code) - signers, _, err := GetSimApp(suite.chainA).AppCodec().GetMsgV1Signers(msg) + signers, _, err := GetSimApp(suite.chainA).AppCodec().GetMsgSigners(msg) if tc.expPass { suite.Require().NoError(err) suite.Require().Equal(address.Bytes(), signers[0]) @@ -179,7 +179,7 @@ func (suite *TypesTestSuite) TestMsgMigrateContractGetSigners() { address := tc.address msg := types.NewMsgMigrateContract(address.String(), defaultWasmClientID, checksum, []byte("{}")) - signers, _, err := GetSimApp(suite.chainA).AppCodec().GetMsgV1Signers(msg) + signers, _, err := GetSimApp(suite.chainA).AppCodec().GetMsgSigners(msg) if tc.expPass { suite.Require().NoError(err) suite.Require().Equal(address.Bytes(), signers[0]) @@ -256,7 +256,7 @@ func (suite *TypesTestSuite) TestMsgRemoveChecksumGetSigners() { address := tc.address msg := types.NewMsgRemoveChecksum(address.String(), checksum) - signers, _, err := GetSimApp(suite.chainA).AppCodec().GetMsgV1Signers(msg) + signers, _, err := GetSimApp(suite.chainA).AppCodec().GetMsgSigners(msg) if tc.expPass { suite.Require().NoError(err) suite.Require().Equal(address.Bytes(), signers[0]) diff --git a/testing/chain.go b/testing/chain.go index 902dcc2fede..0ce65d8f0e7 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -11,8 +11,6 @@ import ( sdkmath "cosmossdk.io/math" banktypes "cosmossdk.io/x/bank/types" - "cosmossdk.io/x/staking/testutil" - stakingtypes "cosmossdk.io/x/staking/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -226,7 +224,7 @@ func (chain *TestChain) QueryProofAtHeight(key []byte, height int64) ([]byte, cl func (chain *TestChain) QueryProofForStore(storeKey string, key []byte, height int64) ([]byte, clienttypes.Height) { res, err := chain.App.Query( chain.GetContext().Context(), - &abci.RequestQuery{ + &abci.QueryRequest{ Path: fmt.Sprintf("store/%s/key", storeKey), Height: height - 1, Data: key, @@ -253,7 +251,7 @@ func (chain *TestChain) QueryProofForStore(storeKey string, key []byte, height i func (chain *TestChain) QueryUpgradeProof(key []byte, height uint64) ([]byte, clienttypes.Height) { res, err := chain.App.Query( chain.GetContext().Context(), - &abci.RequestQuery{ + &abci.QueryRequest{ Path: "store/upgrade/key", Height: int64(height - 1), Data: key, @@ -293,7 +291,7 @@ func (chain *TestChain) QueryConsensusStateProof(clientID string) ([]byte, clien // returned on block `n` to the validators of block `n+2`. // It calls BeginBlock with the new block created before returning. func (chain *TestChain) NextBlock() { - res, err := chain.App.FinalizeBlock(&abci.RequestFinalizeBlock{ + res, err := chain.App.FinalizeBlock(&abci.FinalizeBlockRequest{ Height: chain.ProposedHeader.Height, Time: chain.ProposedHeader.GetTime(), NextValidatorsHash: chain.NextVals.Hash(), @@ -302,7 +300,7 @@ func (chain *TestChain) NextBlock() { chain.commitBlock(res) } -func (chain *TestChain) commitBlock(res *abci.ResponseFinalizeBlock) { +func (chain *TestChain) commitBlock(res *abci.FinalizeBlockRequest) { _, err := chain.App.Commit() require.NoError(chain.TB, err) @@ -417,20 +415,20 @@ func (chain *TestChain) GetTrustedValidators(trustedHeight int64) (*cmttypes.Val // // Since we want to return the trusted validator set, which is the next validator set // for height h, we can simply query using the trusted height. - histInfo, err := chain.App.GetStakingKeeper().GetHistoricalInfo(chain.GetContext(), trustedHeight) - if err != nil { - return nil, err - } - - valSet := stakingtypes.Validators{ - Validators: histInfo.Valset, - } - - tmValidators, err := testutil.ToCmtValidators(valSet, sdk.DefaultPowerReduction) - if err != nil { - return nil, err - } - return cmttypes.NewValidatorSet(tmValidators), nil + // histInfo, err := chain.App.GetStakingKeeper().GetHistoricalInfo(chain.GetContext(), trustedHeight) + // if err != nil { + // return nil, err + // } + + // valSet := stakingtypes.Validators{ + // Validators: histInfo.Valset, + // } + + // tmValidators, err := testutil.ToCmtValidators(valSet, sdk.DefaultPowerReduction) + // if err != nil { + // return nil, err + // } + return nil, nil } // GetAcknowledgement retrieves an acknowledgement for the provided packet. If the diff --git a/testing/endpoint.go b/testing/endpoint.go index f4ec1213eef..20a82069c96 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -619,7 +619,7 @@ func (endpoint *Endpoint) ChanUpgradeInit() error { endpoint.ChannelID, "upgrade-init", fmt.Sprintf("gov proposal for initialising channel upgrade: %s", endpoint.ChannelID), - false, + govtypesv1.ProposalType_PROPOSAL_TYPE_EXPEDITED, ) require.NoError(endpoint.Chain.TB, err) diff --git a/testing/simapp/ante.go b/testing/simapp/ante.go index 45d5529e038..22ea086370f 100644 --- a/testing/simapp/ante.go +++ b/testing/simapp/ante.go @@ -33,17 +33,14 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { } anteDecorators := []sdk.AnteDecorator{ - ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first + ante.NewSetUpContextDecorator(options.Environment), // outermost AnteDecorator. SetUpContext must be called first ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker), - ante.NewValidateBasicDecorator(), - ante.NewTxTimeoutHeightDecorator(), + ante.NewValidateBasicDecorator(options.Environment), + ante.NewTxTimeoutHeightDecorator(options.Environment), ante.NewValidateMemoDecorator(options.AccountKeeper), ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), - ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators ante.NewValidateSigCountDecorator(options.AccountKeeper), - ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer), - ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler), - ante.NewIncrementSequenceDecorator(options.AccountKeeper), + ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler, options.SigGasConsumer, options.AccountAbstractionKeeper), ibcante.NewRedundantRelayDecorator(options.IBCKeeper), } diff --git a/testing/types/expected_keepers.go b/testing/types/expected_keepers.go index 3f5b6c89e3d..f7f1bfb284f 100644 --- a/testing/types/expected_keepers.go +++ b/testing/types/expected_keepers.go @@ -1,13 +1,6 @@ package types -import ( - "context" - - stakingtypes "cosmossdk.io/x/staking/types" -) - // StakingKeeper defines the expected staking keeper interface used in the // IBC testing package type StakingKeeper interface { - GetHistoricalInfo(ctx context.Context, height int64) (stakingtypes.HistoricalInfo, error) }