From bac67bd64cb3bdb1c43901dcbdcb8f29a6950b8b Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 10 May 2024 17:01:46 +0200 Subject: [PATCH 01/21] initialize module --- .../zetacore/ibccrosschain/genesis.proto | 9 + .../zetacore/ibccrosschain/query.proto | 7 + .../zetachain/zetacore/ibccrosschain/tx.proto | 9 + .../zetacore/ibccrosschain/genesis_pb.d.ts | 29 ++ .../zetacore/ibccrosschain/index.d.ts | 1 + x/ibccrosschain/client/cli/query.go | 25 ++ x/ibccrosschain/client/cli/tx.go | 24 ++ x/ibccrosschain/genesis.go | 16 ++ x/ibccrosschain/keeper/grpc_query.go | 7 + x/ibccrosschain/keeper/keeper.go | 51 ++++ x/ibccrosschain/keeper/msg_server.go | 15 + x/ibccrosschain/module.go | 162 +++++++++++ x/ibccrosschain/types/client_ctx.go | 14 + x/ibccrosschain/types/codec.go | 22 ++ x/ibccrosschain/types/errors.go | 1 + x/ibccrosschain/types/genesis.go | 11 + x/ibccrosschain/types/genesis.pb.go | 267 ++++++++++++++++++ x/ibccrosschain/types/keys.go | 18 ++ x/ibccrosschain/types/query.pb.go | 83 ++++++ x/ibccrosschain/types/tx.pb.go | 85 ++++++ 20 files changed, 856 insertions(+) create mode 100644 proto/zetachain/zetacore/ibccrosschain/genesis.proto create mode 100644 proto/zetachain/zetacore/ibccrosschain/query.proto create mode 100644 proto/zetachain/zetacore/ibccrosschain/tx.proto create mode 100644 typescript/zetachain/zetacore/ibccrosschain/genesis_pb.d.ts create mode 100644 typescript/zetachain/zetacore/ibccrosschain/index.d.ts create mode 100644 x/ibccrosschain/client/cli/query.go create mode 100644 x/ibccrosschain/client/cli/tx.go create mode 100644 x/ibccrosschain/genesis.go create mode 100644 x/ibccrosschain/keeper/grpc_query.go create mode 100644 x/ibccrosschain/keeper/keeper.go create mode 100644 x/ibccrosschain/keeper/msg_server.go create mode 100644 x/ibccrosschain/module.go create mode 100644 x/ibccrosschain/types/client_ctx.go create mode 100644 x/ibccrosschain/types/codec.go create mode 100644 x/ibccrosschain/types/errors.go create mode 100644 x/ibccrosschain/types/genesis.go create mode 100644 x/ibccrosschain/types/genesis.pb.go create mode 100644 x/ibccrosschain/types/keys.go create mode 100644 x/ibccrosschain/types/query.pb.go create mode 100644 x/ibccrosschain/types/tx.pb.go diff --git a/proto/zetachain/zetacore/ibccrosschain/genesis.proto b/proto/zetachain/zetacore/ibccrosschain/genesis.proto new file mode 100644 index 0000000000..7190e7bf54 --- /dev/null +++ b/proto/zetachain/zetacore/ibccrosschain/genesis.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; +package zetachain.zetacore.ibccrosschain; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/zeta-chain/zetacore/x/ibccrosschain/types"; + +// GenesisState defines the ibccrosschain module's genesis state. +message GenesisState {} diff --git a/proto/zetachain/zetacore/ibccrosschain/query.proto b/proto/zetachain/zetacore/ibccrosschain/query.proto new file mode 100644 index 0000000000..cc2cfc577d --- /dev/null +++ b/proto/zetachain/zetacore/ibccrosschain/query.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; +package zetachain.zetacore.ibccrosschain; + +option go_package = "github.com/zeta-chain/zetacore/x/ibccrosschain/types"; + +// Query defines the gRPC querier service. +service Query {} \ No newline at end of file diff --git a/proto/zetachain/zetacore/ibccrosschain/tx.proto b/proto/zetachain/zetacore/ibccrosschain/tx.proto new file mode 100644 index 0000000000..54ea972a0c --- /dev/null +++ b/proto/zetachain/zetacore/ibccrosschain/tx.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; +package zetachain.zetacore.ibccrosschain; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/zeta-chain/zetacore/x/ibccrosschain/types"; + +// Msg defines the Msg service. +service Msg {} diff --git a/typescript/zetachain/zetacore/ibccrosschain/genesis_pb.d.ts b/typescript/zetachain/zetacore/ibccrosschain/genesis_pb.d.ts new file mode 100644 index 0000000000..ff752f14b2 --- /dev/null +++ b/typescript/zetachain/zetacore/ibccrosschain/genesis_pb.d.ts @@ -0,0 +1,29 @@ +// @generated by protoc-gen-es v1.3.0 with parameter "target=dts" +// @generated from file zetachain/zetacore/ibccrosschain/genesis.proto (package zetachain.zetacore.ibccrosschain, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; + +/** + * GenesisState defines the ibccrosschain module's genesis state. + * + * @generated from message zetachain.zetacore.ibccrosschain.GenesisState + */ +export declare class GenesisState extends Message { + constructor(data?: PartialMessage); + + static readonly runtime: typeof proto3; + static readonly typeName = "zetachain.zetacore.ibccrosschain.GenesisState"; + static readonly fields: FieldList; + + static fromBinary(bytes: Uint8Array, options?: Partial): GenesisState; + + static fromJson(jsonValue: JsonValue, options?: Partial): GenesisState; + + static fromJsonString(jsonString: string, options?: Partial): GenesisState; + + static equals(a: GenesisState | PlainMessage | undefined, b: GenesisState | PlainMessage | undefined): boolean; +} + diff --git a/typescript/zetachain/zetacore/ibccrosschain/index.d.ts b/typescript/zetachain/zetacore/ibccrosschain/index.d.ts new file mode 100644 index 0000000000..b5836d0adf --- /dev/null +++ b/typescript/zetachain/zetacore/ibccrosschain/index.d.ts @@ -0,0 +1 @@ +export * from "./genesis_pb"; diff --git a/x/ibccrosschain/client/cli/query.go b/x/ibccrosschain/client/cli/query.go new file mode 100644 index 0000000000..31cf944881 --- /dev/null +++ b/x/ibccrosschain/client/cli/query.go @@ -0,0 +1,25 @@ +package cli + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/x/ibccrosschain/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(_ string) *cobra.Command { + // Group ibccrosschain queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand() + + return cmd +} diff --git a/x/ibccrosschain/client/cli/tx.go b/x/ibccrosschain/client/cli/tx.go new file mode 100644 index 0000000000..6cc099126b --- /dev/null +++ b/x/ibccrosschain/client/cli/tx.go @@ -0,0 +1,24 @@ +package cli + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/x/ibccrosschain/types" +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand() + + return cmd +} diff --git a/x/ibccrosschain/genesis.go b/x/ibccrosschain/genesis.go new file mode 100644 index 0000000000..71f979b90a --- /dev/null +++ b/x/ibccrosschain/genesis.go @@ -0,0 +1,16 @@ +package ibccrosschain + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/zetacore/x/ibccrosschain/keeper" + "github.com/zeta-chain/zetacore/x/ibccrosschain/types" +) + +// InitGenesis initializes the ibccrosschain module's state from a provided genesis state +func InitGenesis(_ sdk.Context, _ keeper.Keeper, _ types.GenesisState) {} + +// ExportGenesis returns the ibccrosschain module's exported genesis. +func ExportGenesis(_ sdk.Context, _ keeper.Keeper) *types.GenesisState { + var genesis types.GenesisState + return &genesis +} diff --git a/x/ibccrosschain/keeper/grpc_query.go b/x/ibccrosschain/keeper/grpc_query.go new file mode 100644 index 0000000000..414ad58269 --- /dev/null +++ b/x/ibccrosschain/keeper/grpc_query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "github.com/zeta-chain/zetacore/x/ibccrosschain/types" +) + +var _ types.QueryServer = Keeper{} diff --git a/x/ibccrosschain/keeper/keeper.go b/x/ibccrosschain/keeper/keeper.go new file mode 100644 index 0000000000..013a53952f --- /dev/null +++ b/x/ibccrosschain/keeper/keeper.go @@ -0,0 +1,51 @@ +package keeper + +import ( + "fmt" + + "github.com/cometbft/cometbft/libs/log" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/zeta-chain/zetacore/x/ibccrosschain/types" +) + +// Keeper maintains the link to data storage and exposes getter/setter methods for the various parts of the state machine +type Keeper struct { + cdc codec.Codec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey +} + +// NewKeeper creates new instances of the ibccrosschain Keeper +func NewKeeper( + cdc codec.Codec, + storeKey, + memKey storetypes.StoreKey, +) *Keeper { + return &Keeper{ + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + } +} + +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +// GetStoreKey returns the key to the store for ibccrosschain +func (k Keeper) GetStoreKey() storetypes.StoreKey { + return k.storeKey +} + +// GetMemKey returns the mem key to the store for ibccrosschain +func (k Keeper) GetMemKey() storetypes.StoreKey { + return k.memKey +} + +// GetCodec returns the codec for ibccrosschain +func (k Keeper) GetCodec() codec.Codec { + return k.cdc +} diff --git a/x/ibccrosschain/keeper/msg_server.go b/x/ibccrosschain/keeper/msg_server.go new file mode 100644 index 0000000000..c74fd04024 --- /dev/null +++ b/x/ibccrosschain/keeper/msg_server.go @@ -0,0 +1,15 @@ +package keeper + +import "github.com/zeta-chain/zetacore/x/ibccrosschain/types" + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} //nolint:typecheck +} + +var _ types.MsgServer = msgServer{} //nolint:typecheck diff --git a/x/ibccrosschain/module.go b/x/ibccrosschain/module.go new file mode 100644 index 0000000000..16ce056dd1 --- /dev/null +++ b/x/ibccrosschain/module.go @@ -0,0 +1,162 @@ +package ibccrosschain + +import ( + "encoding/json" + "fmt" + + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + "github.com/zeta-chain/zetacore/x/ibccrosschain/client/cli" + "github.com/zeta-chain/zetacore/x/ibccrosschain/keeper" + "github.com/zeta-chain/zetacore/x/ibccrosschain/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the ibccrosschain module. +type AppModuleBasic struct { + cdc codec.Codec +} + +func NewAppModuleBasic(cdc codec.Codec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the ibccrosschain module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers the module's interface types +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns the ibccrosschain module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis performs genesis state validation for the ibccrosschain module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterRESTRoutes registers the ibccrosschain module's REST service handlers. +func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) { +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, _ *runtime.ServeMux) { + err := types.RegisterClientCtx(clientCtx) + if err != nil { + fmt.Println("RegisterQueryHandlerClient err: %w", err) + } + // TODO: Uncomment once query created + //err = types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + //if err != nil { + // fmt.Println("RegisterQueryHandlerClient err: %w", err) + //} +} + +// GetTxCmd returns the ibccrosschain module's root tx command. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the ibccrosschain module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface for the ibccrosschain module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// Name returns the ibccrosschain module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// RegisterServices registers a GRPC query service to respond to the +// module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the ibccrosschain module's invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the ibccrosschain module's genesis initialization It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the ibccrosschain module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock executes all ABCI BeginBlock logic respective to the ibccrosschain module. +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock executes all ABCI EndBlock logic respective to the ibccrosschain module. It +// returns no validator updates. +func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/ibccrosschain/types/client_ctx.go b/x/ibccrosschain/types/client_ctx.go new file mode 100644 index 0000000000..b4622e1a61 --- /dev/null +++ b/x/ibccrosschain/types/client_ctx.go @@ -0,0 +1,14 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/client" +) + +var ( + ClientCtx client.Context +) + +func RegisterClientCtx(clientCtx client.Context) error { + ClientCtx = clientCtx + return nil +} diff --git a/x/ibccrosschain/types/codec.go b/x/ibccrosschain/types/codec.go new file mode 100644 index 0000000000..acce7bb414 --- /dev/null +++ b/x/ibccrosschain/types/codec.go @@ -0,0 +1,22 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterCodec(_ *codec.LegacyAmino) { +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil)) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/ibccrosschain/types/errors.go b/x/ibccrosschain/types/errors.go new file mode 100644 index 0000000000..ab1254f4c2 --- /dev/null +++ b/x/ibccrosschain/types/errors.go @@ -0,0 +1 @@ +package types diff --git a/x/ibccrosschain/types/genesis.go b/x/ibccrosschain/types/genesis.go new file mode 100644 index 0000000000..f82f76c8ab --- /dev/null +++ b/x/ibccrosschain/types/genesis.go @@ -0,0 +1,11 @@ +package types + +// DefaultGenesis returns the default ibccrosschain genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{} +} + +// Validate performs basic genesis state validation returning an error upon any failure +func (gs GenesisState) Validate() error { + return nil +} diff --git a/x/ibccrosschain/types/genesis.pb.go b/x/ibccrosschain/types/genesis.pb.go new file mode 100644 index 0000000000..57b37f942e --- /dev/null +++ b/x/ibccrosschain/types/genesis.pb.go @@ -0,0 +1,267 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: zetachain/zetacore/ibccrosschain/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the ibccrosschain module's genesis state. +type GenesisState struct { +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_787966a214cc1ca3, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func init() { + proto.RegisterType((*GenesisState)(nil), "zetachain.zetacore.ibccrosschain.GenesisState") +} + +func init() { + proto.RegisterFile("zetachain/zetacore/ibccrosschain/genesis.proto", fileDescriptor_787966a214cc1ca3) +} + +var fileDescriptor_787966a214cc1ca3 = []byte{ + // 158 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xab, 0x4a, 0x2d, 0x49, + 0x4c, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x07, 0xb3, 0xf2, 0x8b, 0x52, 0xf5, 0x33, 0x93, 0x92, 0x93, + 0x8b, 0xf2, 0x8b, 0x8b, 0x21, 0xc2, 0xe9, 0xa9, 0x79, 0xa9, 0xc5, 0x99, 0xc5, 0x7a, 0x05, 0x45, + 0xf9, 0x25, 0xf9, 0x42, 0x0a, 0x70, 0xf5, 0x7a, 0x30, 0xf5, 0x7a, 0x28, 0xea, 0xa5, 0x44, 0xd2, + 0xf3, 0xd3, 0xf3, 0xc1, 0x8a, 0xf5, 0x41, 0x2c, 0x88, 0x3e, 0x25, 0x3e, 0x2e, 0x1e, 0x77, 0x88, + 0x41, 0xc1, 0x25, 0x89, 0x25, 0xa9, 0x4e, 0x7e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, + 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, + 0xc7, 0x10, 0x65, 0x92, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0x0b, 0x76, 0x92, + 0x2e, 0x9a, 0xeb, 0x2a, 0xd0, 0xdc, 0x57, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0xb6, 0xc6, + 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x7b, 0x9e, 0xb1, 0xd0, 0x00, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/ibccrosschain/types/keys.go b/x/ibccrosschain/types/keys.go new file mode 100644 index 0000000000..c5930b636c --- /dev/null +++ b/x/ibccrosschain/types/keys.go @@ -0,0 +1,18 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "ibccrosschain" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey is the message route + RouterKey = ModuleName + + // QuerierRoute defines the module's query routing key + QuerierRoute = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_" + ModuleName +) diff --git a/x/ibccrosschain/types/query.pb.go b/x/ibccrosschain/types/query.pb.go new file mode 100644 index 0000000000..b2cefa7ab1 --- /dev/null +++ b/x/ibccrosschain/types/query.pb.go @@ -0,0 +1,83 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: zetachain/zetacore/ibccrosschain/query.proto + +package types + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +func init() { + proto.RegisterFile("zetachain/zetacore/ibccrosschain/query.proto", fileDescriptor_0e06553cbe2eb6e6) +} + +var fileDescriptor_0e06553cbe2eb6e6 = []byte{ + // 138 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xa9, 0x4a, 0x2d, 0x49, + 0x4c, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x07, 0xb3, 0xf2, 0x8b, 0x52, 0xf5, 0x33, 0x93, 0x92, 0x93, + 0x8b, 0xf2, 0x8b, 0x8b, 0x21, 0xc2, 0x85, 0xa5, 0xa9, 0x45, 0x95, 0x7a, 0x05, 0x45, 0xf9, 0x25, + 0xf9, 0x42, 0x0a, 0x70, 0xd5, 0x7a, 0x30, 0xd5, 0x7a, 0x28, 0xaa, 0x8d, 0xd8, 0xb9, 0x58, 0x03, + 0x41, 0x1a, 0x9c, 0xfc, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, + 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x24, + 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x17, 0x6c, 0xa7, 0x2e, 0x9a, 0xf5, 0x15, + 0x68, 0x0e, 0x28, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0xbb, 0xc0, 0x18, 0x10, 0x00, 0x00, + 0xff, 0xff, 0x03, 0xc2, 0x92, 0x0e, 0xb1, 0x00, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +// QueryServer is the server API for Query service. +type QueryServer interface { +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "zetachain.zetacore.ibccrosschain.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "zetachain/zetacore/ibccrosschain/query.proto", +} diff --git a/x/ibccrosschain/types/tx.pb.go b/x/ibccrosschain/types/tx.pb.go new file mode 100644 index 0000000000..3f79c86c94 --- /dev/null +++ b/x/ibccrosschain/types/tx.pb.go @@ -0,0 +1,85 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: zetachain/zetacore/ibccrosschain/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +func init() { + proto.RegisterFile("zetachain/zetacore/ibccrosschain/tx.proto", fileDescriptor_3618214015c2c1fb) +} + +var fileDescriptor_3618214015c2c1fb = []byte{ + // 147 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xac, 0x4a, 0x2d, 0x49, + 0x4c, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x07, 0xb3, 0xf2, 0x8b, 0x52, 0xf5, 0x33, 0x93, 0x92, 0x93, + 0x8b, 0xf2, 0x8b, 0x8b, 0x21, 0xc2, 0x25, 0x15, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x0a, + 0x70, 0xa5, 0x7a, 0x30, 0xa5, 0x7a, 0x28, 0x4a, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x8a, + 0xf5, 0x41, 0x2c, 0x88, 0x3e, 0x23, 0x56, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0x27, 0xbf, 0x13, 0x8f, + 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, + 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x32, 0x49, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, + 0x4b, 0xce, 0xcf, 0x05, 0x3b, 0x42, 0x17, 0xcd, 0x3d, 0x15, 0xe8, 0x2e, 0xaa, 0x2c, 0x48, 0x2d, + 0x4e, 0x62, 0x03, 0x9b, 0x6e, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xf3, 0x51, 0x12, 0x34, 0xc2, + 0x00, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "zetachain.zetacore.ibccrosschain.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "zetachain/zetacore/ibccrosschain/tx.proto", +} From 576f9d0e2d06395e519149ed6df3131e08c73ea0 Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 10 May 2024 17:18:11 +0200 Subject: [PATCH 02/21] add ibc module implementation --- x/ibccrosschain/ibc_module.go | 122 ++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 x/ibccrosschain/ibc_module.go diff --git a/x/ibccrosschain/ibc_module.go b/x/ibccrosschain/ibc_module.go new file mode 100644 index 0000000000..cf11c8e3bf --- /dev/null +++ b/x/ibccrosschain/ibc_module.go @@ -0,0 +1,122 @@ +package ibccrosschain + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + "github.com/zeta-chain/zetacore/x/ibccrosschain/keeper" +) + +var ( + _ porttypes.IBCModule = IBCModule{} +) + +// IBCModule implements the ICS26 interface for transfer given the transfer keeper. +type IBCModule struct { + keeper keeper.Keeper +} + +// NewIBCModule creates a new IBCModule given the keeper +func NewIBCModule(k keeper.Keeper) IBCModule { + return IBCModule{ + keeper: k, + } +} + +// OnChanOpenInit implements the IBCModule interface +func (im IBCModule) OnChanOpenInit( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID string, + channelID string, + chanCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + version string, +) (string, error) { + return version, nil +} + +// OnChanOpenTry implements the IBCModule interface. +func (im IBCModule) OnChanOpenTry( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID, + channelID string, + chanCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + counterpartyVersion string, +) (string, error) { + return "", nil +} + +// OnChanOpenAck implements the IBCModule interface +func (im IBCModule) OnChanOpenAck( + ctx sdk.Context, + portID, + channelID string, + _ string, + counterpartyVersion string, +) error { + return nil +} + +// OnChanOpenConfirm implements the IBCModule interface +func (im IBCModule) OnChanOpenConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + return nil +} + +// OnChanCloseInit implements the IBCModule interface +func (im IBCModule) OnChanCloseInit( + ctx sdk.Context, + portID, + channelID string, +) error { + return nil +} + +// OnChanCloseConfirm implements the IBCModule interface +func (im IBCModule) OnChanCloseConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + return nil +} + +// OnRecvPacket implements the IBCModule interface. A successful acknowledgement +// is returned if the packet data is successfully decoded and the receive application +// logic returns without error. +func (im IBCModule) OnRecvPacket( + ctx sdk.Context, + packet channeltypes.Packet, + relayer sdk.AccAddress, +) ibcexported.Acknowledgement { + return nil +} + +// OnAcknowledgementPacket implements the IBCModule interface +func (im IBCModule) OnAcknowledgementPacket( + ctx sdk.Context, + packet channeltypes.Packet, + acknowledgement []byte, + relayer sdk.AccAddress, +) error { + return nil +} + +// OnTimeoutPacket implements the IBCModule interface +func (im IBCModule) OnTimeoutPacket( + ctx sdk.Context, + packet channeltypes.Packet, + relayer sdk.AccAddress, +) error { + return nil +} From 83365a4e8e7dc71a71890a8a827af6ce9646714c Mon Sep 17 00:00:00 2001 From: lumtis Date: Fri, 10 May 2024 17:41:52 +0200 Subject: [PATCH 03/21] add module to app.go --- app/app.go | 40 +++++++++++++++---- app/init_genesis.go | 2 + app/setup_handlers.go | 2 + docs/cli/zetacored/zetacored_query.md | 1 + .../zetacored_query_ibccrosschain.md | 29 ++++++++++++++ docs/cli/zetacored/zetacored_tx.md | 1 + .../zetacored/zetacored_tx_ibccrosschain.md | 29 ++++++++++++++ 7 files changed, 96 insertions(+), 8 deletions(-) create mode 100644 docs/cli/zetacored/zetacored_query_ibccrosschain.md create mode 100644 docs/cli/zetacored/zetacored_tx_ibccrosschain.md diff --git a/app/app.go b/app/app.go index 195dd14cf5..3ec57073b0 100644 --- a/app/app.go +++ b/app/app.go @@ -131,6 +131,10 @@ import ( observermodule "github.com/zeta-chain/zetacore/x/observer" observerkeeper "github.com/zeta-chain/zetacore/x/observer/keeper" observertypes "github.com/zeta-chain/zetacore/x/observer/types" + + "github.com/zeta-chain/zetacore/x/ibccrosschain" + ibccrosschainkeeper "github.com/zeta-chain/zetacore/x/ibccrosschain/keeper" + ibccrosschaintypes "github.com/zeta-chain/zetacore/x/ibccrosschain/types" ) const Name = "zetacore" @@ -207,6 +211,7 @@ var ( authoritymodule.AppModuleBasic{}, lightclientmodule.AppModuleBasic{}, crosschainmodule.AppModuleBasic{}, + ibccrosschain.AppModule{}, observermodule.AppModuleBasic{}, fungiblemodule.AppModuleBasic{}, emissionsmodule.AppModuleBasic{}, @@ -223,6 +228,7 @@ var ( govtypes.ModuleName: {authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, crosschaintypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + ibccrosschaintypes.ModuleName: nil, evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, fungibletypes.ModuleName: {authtypes.Minter, authtypes.Burner}, emissionstypes.ModuleName: nil, @@ -284,20 +290,22 @@ type App struct { ConsensusParamsKeeper consensusparamkeeper.Keeper // scoped keepers - ScopedIBCKeeper capabilitykeeper.ScopedKeeper - ScopedTransferKeeper capabilitykeeper.ScopedKeeper + ScopedIBCKeeper capabilitykeeper.ScopedKeeper + ScopedTransferKeeper capabilitykeeper.ScopedKeeper + ScopedIBCCrosschainKeeper capabilitykeeper.ScopedKeeper // evm keepers EvmKeeper *evmkeeper.Keeper FeeMarketKeeper feemarketkeeper.Keeper // zetachain keepers - AuthorityKeeper authoritykeeper.Keeper - LightclientKeeper lightclientkeeper.Keeper - CrosschainKeeper crosschainkeeper.Keeper - ObserverKeeper *observerkeeper.Keeper - FungibleKeeper fungiblekeeper.Keeper - EmissionsKeeper emissionskeeper.Keeper + AuthorityKeeper authoritykeeper.Keeper + LightclientKeeper lightclientkeeper.Keeper + CrosschainKeeper crosschainkeeper.Keeper + IBCCrosschainKeeper ibccrosschainkeeper.Keeper + ObserverKeeper *observerkeeper.Keeper + FungibleKeeper fungiblekeeper.Keeper + EmissionsKeeper emissionskeeper.Keeper transferModule transfer.AppModule } @@ -345,6 +353,7 @@ func New( authoritytypes.StoreKey, lightclienttypes.StoreKey, crosschaintypes.StoreKey, + ibccrosschaintypes.StoreKey, observertypes.StoreKey, fungibletypes.StoreKey, emissionstypes.StoreKey, @@ -586,6 +595,18 @@ func New( app.AuthorityKeeper, app.LightclientKeeper, ) + + scopedMonitoringcKeeper := app.CapabilityKeeper.ScopeToModule(ibccrosschaintypes.ModuleName) + app.ScopedIBCCrosschainKeeper = scopedMonitoringcKeeper + + app.IBCCrosschainKeeper = *ibccrosschainkeeper.NewKeeper( + appCodec, + keys[ibccrosschaintypes.StoreKey], + keys[ibccrosschaintypes.MemStoreKey], + ) + + ibcRouter.AddRoute(ibccrosschaintypes.ModuleName, ibccrosschain.NewIBCModule(app.IBCCrosschainKeeper)) + app.GroupKeeper = groupkeeper.NewKeeper( keys[group.StoreKey], appCodec, @@ -670,6 +691,7 @@ func New( authoritymodule.NewAppModule(appCodec, app.AuthorityKeeper), lightclientmodule.NewAppModule(appCodec, app.LightclientKeeper), crosschainmodule.NewAppModule(appCodec, app.CrosschainKeeper), + ibccrosschain.NewAppModule(appCodec, app.IBCCrosschainKeeper), observermodule.NewAppModule(appCodec, *app.ObserverKeeper), fungiblemodule.NewAppModule(appCodec, app.FungibleKeeper), emissionsmodule.NewAppModule(appCodec, app.EmissionsKeeper, app.GetSubspace(emissionstypes.ModuleName)), @@ -700,6 +722,7 @@ func New( ibctransfertypes.ModuleName, feemarkettypes.ModuleName, crosschaintypes.ModuleName, + ibccrosschaintypes.ModuleName, observertypes.ModuleName, fungibletypes.ModuleName, emissionstypes.ModuleName, @@ -728,6 +751,7 @@ func New( evmtypes.ModuleName, feemarkettypes.ModuleName, crosschaintypes.ModuleName, + ibccrosschaintypes.ModuleName, observertypes.ModuleName, fungibletypes.ModuleName, emissionstypes.ModuleName, diff --git a/app/init_genesis.go b/app/init_genesis.go index cdddb498e0..d8ab948f6b 100644 --- a/app/init_genesis.go +++ b/app/init_genesis.go @@ -25,6 +25,7 @@ import ( crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" emissionsModuleTypes "github.com/zeta-chain/zetacore/x/emissions/types" fungibleModuleTypes "github.com/zeta-chain/zetacore/x/fungible/types" + ibccrosschaintypes "github.com/zeta-chain/zetacore/x/ibccrosschain/types" lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -52,6 +53,7 @@ func InitGenesisModuleList() []string { vestingtypes.ModuleName, observertypes.ModuleName, crosschaintypes.ModuleName, + ibccrosschaintypes.ModuleName, fungibleModuleTypes.ModuleName, emissionsModuleTypes.ModuleName, authz.ModuleName, diff --git a/app/setup_handlers.go b/app/setup_handlers.go index 3c13cac2ff..7624a37a7e 100644 --- a/app/setup_handlers.go +++ b/app/setup_handlers.go @@ -21,6 +21,7 @@ import ( ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" "github.com/zeta-chain/zetacore/pkg/constant" emissionstypes "github.com/zeta-chain/zetacore/x/emissions/types" + ibccrosschaintypes "github.com/zeta-chain/zetacore/x/ibccrosschain/types" ) func SetupHandlers(app *App) { @@ -88,6 +89,7 @@ func SetupHandlers(app *App) { capabilitytypes.ModuleName, ibcexported.ModuleName, ibctransfertypes.ModuleName, + ibccrosschaintypes.ModuleName, }, } // Use upgrade store loader for the initial loading of all stores when app starts, diff --git a/docs/cli/zetacored/zetacored_query.md b/docs/cli/zetacored/zetacored_query.md index 5d35daf3c5..0ddb86ed17 100644 --- a/docs/cli/zetacored/zetacored_query.md +++ b/docs/cli/zetacored/zetacored_query.md @@ -43,6 +43,7 @@ zetacored query [flags] * [zetacored query group](zetacored_query_group.md) - Querying commands for the group module * [zetacored query ibc](zetacored_query_ibc.md) - Querying commands for the IBC module * [zetacored query ibc-transfer](zetacored_query_ibc-transfer.md) - IBC fungible token transfer query subcommands +* [zetacored query ibccrosschain](zetacored_query_ibccrosschain.md) - Querying commands for the ibccrosschain module * [zetacored query lightclient](zetacored_query_lightclient.md) - Querying commands for the lightclient module * [zetacored query observer](zetacored_query_observer.md) - Querying commands for the observer module * [zetacored query params](zetacored_query_params.md) - Querying commands for the params module diff --git a/docs/cli/zetacored/zetacored_query_ibccrosschain.md b/docs/cli/zetacored/zetacored_query_ibccrosschain.md new file mode 100644 index 0000000000..7da539e1e6 --- /dev/null +++ b/docs/cli/zetacored/zetacored_query_ibccrosschain.md @@ -0,0 +1,29 @@ +# query ibccrosschain + +Querying commands for the ibccrosschain module + +``` +zetacored query ibccrosschain [flags] +``` + +### Options + +``` + -h, --help help for ibccrosschain +``` + +### Options inherited from parent commands + +``` + --chain-id string The network chain ID + --home string directory for config and data + --log_format string The logging format (json|plain) + --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) + --log_no_color Disable colored logs + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored query](zetacored_query.md) - Querying subcommands + diff --git a/docs/cli/zetacored/zetacored_tx.md b/docs/cli/zetacored/zetacored_tx.md index baa70fa53e..048f644399 100644 --- a/docs/cli/zetacored/zetacored_tx.md +++ b/docs/cli/zetacored/zetacored_tx.md @@ -43,6 +43,7 @@ zetacored tx [flags] * [zetacored tx group](zetacored_tx_group.md) - Group transaction subcommands * [zetacored tx ibc](zetacored_tx_ibc.md) - IBC transaction subcommands * [zetacored tx ibc-transfer](zetacored_tx_ibc-transfer.md) - IBC fungible token transfer transaction subcommands +* [zetacored tx ibccrosschain](zetacored_tx_ibccrosschain.md) - ibccrosschain transactions subcommands * [zetacored tx lightclient](zetacored_tx_lightclient.md) - lightclient transactions subcommands * [zetacored tx multi-sign](zetacored_tx_multi-sign.md) - Generate multisig signatures for transactions generated offline * [zetacored tx multisign-batch](zetacored_tx_multisign-batch.md) - Assemble multisig transactions in batch from batch signatures diff --git a/docs/cli/zetacored/zetacored_tx_ibccrosschain.md b/docs/cli/zetacored/zetacored_tx_ibccrosschain.md new file mode 100644 index 0000000000..1c2b122ba1 --- /dev/null +++ b/docs/cli/zetacored/zetacored_tx_ibccrosschain.md @@ -0,0 +1,29 @@ +# tx ibccrosschain + +ibccrosschain transactions subcommands + +``` +zetacored tx ibccrosschain [flags] +``` + +### Options + +``` + -h, --help help for ibccrosschain +``` + +### Options inherited from parent commands + +``` + --chain-id string The network chain ID + --home string directory for config and data + --log_format string The logging format (json|plain) + --log_level string The logging level (trace|debug|info|warn|error|fatal|panic) + --log_no_color Disable colored logs + --trace print out full stack trace on errors +``` + +### SEE ALSO + +* [zetacored tx](zetacored_tx.md) - Transactions subcommands + From 58564ec944d09e7050165024bc5753fadf34ffd9 Mon Sep 17 00:00:00 2001 From: lumtis Date: Sun, 12 May 2024 20:56:51 +0200 Subject: [PATCH 04/21] new mocks --- testutil/keeper/mocks/crosschain/account.go | 2 +- testutil/keeper/mocks/crosschain/authority.go | 2 +- testutil/keeper/mocks/crosschain/bank.go | 2 +- testutil/keeper/mocks/crosschain/fungible.go | 46 +++++++++---------- .../keeper/mocks/crosschain/lightclient.go | 2 +- testutil/keeper/mocks/crosschain/observer.go | 2 +- testutil/keeper/mocks/crosschain/staking.go | 2 +- testutil/keeper/mocks/emissions/account.go | 2 +- testutil/keeper/mocks/emissions/bank.go | 2 +- testutil/keeper/mocks/emissions/observer.go | 2 +- testutil/keeper/mocks/emissions/staking.go | 11 +++-- testutil/keeper/mocks/fungible/account.go | 2 +- testutil/keeper/mocks/fungible/authority.go | 2 +- testutil/keeper/mocks/fungible/bank.go | 2 +- testutil/keeper/mocks/fungible/evm.go | 2 +- testutil/keeper/mocks/fungible/observer.go | 2 +- .../keeper/mocks/lightclient/authority.go | 2 +- testutil/keeper/mocks/mocks.go | 20 ++++++++ testutil/keeper/mocks/observer/authority.go | 2 +- testutil/keeper/mocks/observer/lightclient.go | 2 +- testutil/keeper/mocks/observer/slashing.go | 2 +- testutil/keeper/mocks/observer/staking.go | 2 +- 22 files changed, 68 insertions(+), 47 deletions(-) diff --git a/testutil/keeper/mocks/crosschain/account.go b/testutil/keeper/mocks/crosschain/account.go index fbd7c0377b..99b7f1cf5b 100644 --- a/testutil/keeper/mocks/crosschain/account.go +++ b/testutil/keeper/mocks/crosschain/account.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/crosschain/authority.go b/testutil/keeper/mocks/crosschain/authority.go index 9f08c9d673..fd6ceefa47 100644 --- a/testutil/keeper/mocks/crosschain/authority.go +++ b/testutil/keeper/mocks/crosschain/authority.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/crosschain/bank.go b/testutil/keeper/mocks/crosschain/bank.go index 90f4e17e29..267f2b45b4 100644 --- a/testutil/keeper/mocks/crosschain/bank.go +++ b/testutil/keeper/mocks/crosschain/bank.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/crosschain/fungible.go b/testutil/keeper/mocks/crosschain/fungible.go index 5cab1d5b26..cbcd6d2b32 100644 --- a/testutil/keeper/mocks/crosschain/fungible.go +++ b/testutil/keeper/mocks/crosschain/fungible.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks @@ -214,37 +214,37 @@ func (_m *CrosschainFungibleKeeper) FundGasStabilityPool(ctx types.Context, chai return r0 } -// GetAllForeignCoins provides a mock function with given fields: ctx -func (_m *CrosschainFungibleKeeper) GetAllForeignCoins(ctx types.Context) []fungibletypes.ForeignCoins { +// GetAllForeignCoinMap provides a mock function with given fields: ctx +func (_m *CrosschainFungibleKeeper) GetAllForeignCoinMap(ctx types.Context) map[int64]map[string]fungibletypes.ForeignCoins { ret := _m.Called(ctx) if len(ret) == 0 { - panic("no return value specified for GetAllForeignCoins") + panic("no return value specified for GetAllForeignCoinMap") } - var r0 []fungibletypes.ForeignCoins - if rf, ok := ret.Get(0).(func(types.Context) []fungibletypes.ForeignCoins); ok { + var r0 map[int64]map[string]fungibletypes.ForeignCoins + if rf, ok := ret.Get(0).(func(types.Context) map[int64]map[string]fungibletypes.ForeignCoins); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]fungibletypes.ForeignCoins) + r0 = ret.Get(0).(map[int64]map[string]fungibletypes.ForeignCoins) } } return r0 } -// GetAllForeignCoinsForChain provides a mock function with given fields: ctx, foreignChainID -func (_m *CrosschainFungibleKeeper) GetAllForeignCoinsForChain(ctx types.Context, foreignChainID int64) []fungibletypes.ForeignCoins { - ret := _m.Called(ctx, foreignChainID) +// GetAllForeignCoins provides a mock function with given fields: ctx +func (_m *CrosschainFungibleKeeper) GetAllForeignCoins(ctx types.Context) []fungibletypes.ForeignCoins { + ret := _m.Called(ctx) if len(ret) == 0 { - panic("no return value specified for GetAllForeignCoinsForChain") + panic("no return value specified for GetAllForeignCoins") } var r0 []fungibletypes.ForeignCoins - if rf, ok := ret.Get(0).(func(types.Context, int64) []fungibletypes.ForeignCoins); ok { - r0 = rf(ctx, foreignChainID) + if rf, ok := ret.Get(0).(func(types.Context) []fungibletypes.ForeignCoins); ok { + r0 = rf(ctx) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]fungibletypes.ForeignCoins) @@ -254,20 +254,20 @@ func (_m *CrosschainFungibleKeeper) GetAllForeignCoinsForChain(ctx types.Context return r0 } -// GetAllForeignCoinMap provides a mock function with given fields: ctx -func (_m *CrosschainFungibleKeeper) GetAllForeignCoinMap(ctx types.Context) map[int64]map[string]fungibletypes.ForeignCoins { - ret := _m.Called(ctx) +// GetAllForeignCoinsForChain provides a mock function with given fields: ctx, foreignChainID +func (_m *CrosschainFungibleKeeper) GetAllForeignCoinsForChain(ctx types.Context, foreignChainID int64) []fungibletypes.ForeignCoins { + ret := _m.Called(ctx, foreignChainID) if len(ret) == 0 { - panic("no return value specified for GetAllForeignCoinMap") + panic("no return value specified for GetAllForeignCoinsForChain") } - var r0 map[int64]map[string]fungibletypes.ForeignCoins - if rf, ok := ret.Get(0).(func(types.Context) map[int64]map[string]fungibletypes.ForeignCoins); ok { - r0 = rf(ctx) + var r0 []fungibletypes.ForeignCoins + if rf, ok := ret.Get(0).(func(types.Context, int64) []fungibletypes.ForeignCoins); ok { + r0 = rf(ctx, foreignChainID) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(map[int64]map[string]fungibletypes.ForeignCoins) + r0 = ret.Get(0).([]fungibletypes.ForeignCoins) } } @@ -617,7 +617,7 @@ func (_m *CrosschainFungibleKeeper) WithdrawFromGasStabilityPool(ctx types.Conte return r0 } -// ZEVMDepositAndCallContract provides a mock function with given fields: ctx, sender, to, inboundSenderChainID, inboundAmount, data, indexBytes +// ZETADepositAndCallContract provides a mock function with given fields: ctx, sender, to, inboundSenderChainID, inboundAmount, data, indexBytes func (_m *CrosschainFungibleKeeper) ZETADepositAndCallContract(ctx types.Context, sender common.Address, to common.Address, inboundSenderChainID int64, inboundAmount *big.Int, data []byte, indexBytes [32]byte) (*evmtypes.MsgEthereumTxResponse, error) { ret := _m.Called(ctx, sender, to, inboundSenderChainID, inboundAmount, data, indexBytes) @@ -647,7 +647,7 @@ func (_m *CrosschainFungibleKeeper) ZETADepositAndCallContract(ctx types.Context return r0, r1 } -// ZEVMRevertAndCallContract provides a mock function with given fields: ctx, sender, to, inboundSenderChainID, destinationChainID, remainingAmount, data, indexBytes +// ZETARevertAndCallContract provides a mock function with given fields: ctx, sender, to, inboundSenderChainID, destinationChainID, remainingAmount, data, indexBytes func (_m *CrosschainFungibleKeeper) ZETARevertAndCallContract(ctx types.Context, sender common.Address, to common.Address, inboundSenderChainID int64, destinationChainID int64, remainingAmount *big.Int, data []byte, indexBytes [32]byte) (*evmtypes.MsgEthereumTxResponse, error) { ret := _m.Called(ctx, sender, to, inboundSenderChainID, destinationChainID, remainingAmount, data, indexBytes) diff --git a/testutil/keeper/mocks/crosschain/lightclient.go b/testutil/keeper/mocks/crosschain/lightclient.go index d5ee740bc3..53eaf7c398 100644 --- a/testutil/keeper/mocks/crosschain/lightclient.go +++ b/testutil/keeper/mocks/crosschain/lightclient.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/crosschain/observer.go b/testutil/keeper/mocks/crosschain/observer.go index 79c00e4f9c..37b8ea2720 100644 --- a/testutil/keeper/mocks/crosschain/observer.go +++ b/testutil/keeper/mocks/crosschain/observer.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/crosschain/staking.go b/testutil/keeper/mocks/crosschain/staking.go index 5b7d3c501f..64bbe0fed6 100644 --- a/testutil/keeper/mocks/crosschain/staking.go +++ b/testutil/keeper/mocks/crosschain/staking.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/emissions/account.go b/testutil/keeper/mocks/emissions/account.go index a660d40e72..265c291e1b 100644 --- a/testutil/keeper/mocks/emissions/account.go +++ b/testutil/keeper/mocks/emissions/account.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/emissions/bank.go b/testutil/keeper/mocks/emissions/bank.go index 8149b5e6af..10bc77649b 100644 --- a/testutil/keeper/mocks/emissions/bank.go +++ b/testutil/keeper/mocks/emissions/bank.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/emissions/observer.go b/testutil/keeper/mocks/emissions/observer.go index 594f090907..15a2e21b1d 100644 --- a/testutil/keeper/mocks/emissions/observer.go +++ b/testutil/keeper/mocks/emissions/observer.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/emissions/staking.go b/testutil/keeper/mocks/emissions/staking.go index 7c58333bb5..aaa9ce5e80 100644 --- a/testutil/keeper/mocks/emissions/staking.go +++ b/testutil/keeper/mocks/emissions/staking.go @@ -1,8 +1,9 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks import ( + math "cosmossdk.io/math" mock "github.com/stretchr/testify/mock" types "github.com/cosmos/cosmos-sdk/types" @@ -14,18 +15,18 @@ type EmissionStakingKeeper struct { } // BondedRatio provides a mock function with given fields: ctx -func (_m *EmissionStakingKeeper) BondedRatio(ctx types.Context) types.Dec { +func (_m *EmissionStakingKeeper) BondedRatio(ctx types.Context) math.LegacyDec { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for BondedRatio") } - var r0 types.Dec - if rf, ok := ret.Get(0).(func(types.Context) types.Dec); ok { + var r0 math.LegacyDec + if rf, ok := ret.Get(0).(func(types.Context) math.LegacyDec); ok { r0 = rf(ctx) } else { - r0 = ret.Get(0).(types.Dec) + r0 = ret.Get(0).(math.LegacyDec) } return r0 diff --git a/testutil/keeper/mocks/fungible/account.go b/testutil/keeper/mocks/fungible/account.go index 0522e833b4..94b7a84d75 100644 --- a/testutil/keeper/mocks/fungible/account.go +++ b/testutil/keeper/mocks/fungible/account.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/fungible/authority.go b/testutil/keeper/mocks/fungible/authority.go index 929a99021c..b87791c784 100644 --- a/testutil/keeper/mocks/fungible/authority.go +++ b/testutil/keeper/mocks/fungible/authority.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/fungible/bank.go b/testutil/keeper/mocks/fungible/bank.go index db14226310..20a2590911 100644 --- a/testutil/keeper/mocks/fungible/bank.go +++ b/testutil/keeper/mocks/fungible/bank.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/fungible/evm.go b/testutil/keeper/mocks/fungible/evm.go index 28fd46e25c..f0dcd01094 100644 --- a/testutil/keeper/mocks/fungible/evm.go +++ b/testutil/keeper/mocks/fungible/evm.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/fungible/observer.go b/testutil/keeper/mocks/fungible/observer.go index bbe76b1afa..5e0aca6a0f 100644 --- a/testutil/keeper/mocks/fungible/observer.go +++ b/testutil/keeper/mocks/fungible/observer.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/lightclient/authority.go b/testutil/keeper/mocks/lightclient/authority.go index 03dd6972de..f86b893f9c 100644 --- a/testutil/keeper/mocks/lightclient/authority.go +++ b/testutil/keeper/mocks/lightclient/authority.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/mocks.go b/testutil/keeper/mocks/mocks.go index a18893ca68..35499dd790 100644 --- a/testutil/keeper/mocks/mocks.go +++ b/testutil/keeper/mocks/mocks.go @@ -4,6 +4,7 @@ import ( crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" emissionstypes "github.com/zeta-chain/zetacore/x/emissions/types" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" + ibccrosschaintypes "github.com/zeta-chain/zetacore/x/ibccrosschain/types" lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -47,6 +48,11 @@ type CrosschainLightclientKeeper interface { crosschaintypes.LightclientKeeper } +//go:generate mockery --name CrosschainIBCCrosschainKeeper --filename ibccrosschain.go --case underscore --output ./crosschain +type CrosschainIBCCrosschainKeeper interface { + crosschaintypes.IBCCrosschainKeeper +} + /** * Fungible Mocks */ @@ -132,3 +138,17 @@ type ObserverLightclientKeeper interface { type LightclientAuthorityKeeper interface { lightclienttypes.AuthorityKeeper } + +/** + * IBCCrosschainKeeper Mocks + */ + +//go:generate mockery --name LightclientCrosschainKeeper --filename crosschain.go --case underscore --output ./ibccrosschain +type LightclientCrosschainKeeper interface { + ibccrosschaintypes.CrosschainKeeper +} + +//go:generate mockery --name LightclientTransferKeeper --filename transfer.go --case underscore --output ./ibccrosschain +type LightclientTransferKeeper interface { + ibccrosschaintypes.IBCTransferKeeper +} diff --git a/testutil/keeper/mocks/observer/authority.go b/testutil/keeper/mocks/observer/authority.go index 76e5e0566c..4787b99b8a 100644 --- a/testutil/keeper/mocks/observer/authority.go +++ b/testutil/keeper/mocks/observer/authority.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/observer/lightclient.go b/testutil/keeper/mocks/observer/lightclient.go index 442d006a5f..b25f440330 100644 --- a/testutil/keeper/mocks/observer/lightclient.go +++ b/testutil/keeper/mocks/observer/lightclient.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/observer/slashing.go b/testutil/keeper/mocks/observer/slashing.go index a7793ef8dc..d3f64ff726 100644 --- a/testutil/keeper/mocks/observer/slashing.go +++ b/testutil/keeper/mocks/observer/slashing.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks diff --git a/testutil/keeper/mocks/observer/staking.go b/testutil/keeper/mocks/observer/staking.go index 90007b6c35..72fe2be116 100644 --- a/testutil/keeper/mocks/observer/staking.go +++ b/testutil/keeper/mocks/observer/staking.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.38.0. DO NOT EDIT. +// Code generated by mockery v2.39.1. DO NOT EDIT. package mocks From f227406d651a4366287b144289338d6a332b4e37 Mon Sep 17 00:00:00 2001 From: lumtis Date: Sun, 12 May 2024 20:57:37 +0200 Subject: [PATCH 05/21] add new crosschain circle dep --- app/app.go | 4 ++++ x/crosschain/keeper/keeper.go | 23 +++++++++++++------ x/crosschain/types/expected_keepers.go | 3 +++ x/ibccrosschain/keeper/keeper.go | 28 ++++++++++++++++++----- x/ibccrosschain/types/expected_keepers.go | 7 ++++++ 5 files changed, 52 insertions(+), 13 deletions(-) create mode 100644 x/ibccrosschain/types/expected_keepers.go diff --git a/app/app.go b/app/app.go index 3ec57073b0..cf361a9556 100644 --- a/app/app.go +++ b/app/app.go @@ -603,10 +603,14 @@ func New( appCodec, keys[ibccrosschaintypes.StoreKey], keys[ibccrosschaintypes.MemStoreKey], + &app.CrosschainKeeper, + app.TransferKeeper, ) ibcRouter.AddRoute(ibccrosschaintypes.ModuleName, ibccrosschain.NewIBCModule(app.IBCCrosschainKeeper)) + app.CrosschainKeeper.SetIBCCrosschainKeeper(app.IBCCrosschainKeeper) + app.GroupKeeper = groupkeeper.NewKeeper( keys[group.StoreKey], appCodec, diff --git a/x/crosschain/keeper/keeper.go b/x/crosschain/keeper/keeper.go index a9aa6637ee..3d01e015b8 100644 --- a/x/crosschain/keeper/keeper.go +++ b/x/crosschain/keeper/keeper.go @@ -16,13 +16,14 @@ type ( storeKey storetypes.StoreKey memKey storetypes.StoreKey - stakingKeeper types.StakingKeeper - authKeeper types.AccountKeeper - bankKeeper types.BankKeeper - zetaObserverKeeper types.ObserverKeeper - fungibleKeeper types.FungibleKeeper - authorityKeeper types.AuthorityKeeper - lightclientKeeper types.LightclientKeeper + stakingKeeper types.StakingKeeper + authKeeper types.AccountKeeper + bankKeeper types.BankKeeper + zetaObserverKeeper types.ObserverKeeper + fungibleKeeper types.FungibleKeeper + authorityKeeper types.AuthorityKeeper + lightclientKeeper types.LightclientKeeper + ibcCrosschainKeeper types.IBCCrosschainKeeper } ) @@ -90,6 +91,14 @@ func (k Keeper) GetLightclientKeeper() types.LightclientKeeper { return k.lightclientKeeper } +func (k Keeper) GetIBCCrosschainKeeper() types.IBCCrosschainKeeper { + return k.ibcCrosschainKeeper +} + +func (k *Keeper) SetIBCCrosschainKeeper(ibcCrosschainKeeper types.IBCCrosschainKeeper) { + k.ibcCrosschainKeeper = ibcCrosschainKeeper +} + func (k Keeper) GetStoreKey() storetypes.StoreKey { return k.storeKey } diff --git a/x/crosschain/types/expected_keepers.go b/x/crosschain/types/expected_keepers.go index fb03a86281..a7115ad1e5 100644 --- a/x/crosschain/types/expected_keepers.go +++ b/x/crosschain/types/expected_keepers.go @@ -187,3 +187,6 @@ type AuthorityKeeper interface { type LightclientKeeper interface { VerifyProof(ctx sdk.Context, proof *proofs.Proof, chainID int64, blockHash string, txIndex int64) ([]byte, error) } + +type IBCCrosschainKeeper interface { +} diff --git a/x/ibccrosschain/keeper/keeper.go b/x/ibccrosschain/keeper/keeper.go index 013a53952f..f800792634 100644 --- a/x/ibccrosschain/keeper/keeper.go +++ b/x/ibccrosschain/keeper/keeper.go @@ -12,9 +12,11 @@ import ( // Keeper maintains the link to data storage and exposes getter/setter methods for the various parts of the state machine type Keeper struct { - cdc codec.Codec - storeKey storetypes.StoreKey - memKey storetypes.StoreKey + cdc codec.Codec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + crosschainKeeper types.CrosschainKeeper + ibcTransferKeeper types.IBCTransferKeeper } // NewKeeper creates new instances of the ibccrosschain Keeper @@ -22,11 +24,15 @@ func NewKeeper( cdc codec.Codec, storeKey, memKey storetypes.StoreKey, + crosschainKeeper types.CrosschainKeeper, + ibcTransferKeeper types.IBCTransferKeeper, ) *Keeper { return &Keeper{ - cdc: cdc, - storeKey: storeKey, - memKey: memKey, + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + crosschainKeeper: crosschainKeeper, + ibcTransferKeeper: ibcTransferKeeper, } } @@ -49,3 +55,13 @@ func (k Keeper) GetMemKey() storetypes.StoreKey { func (k Keeper) GetCodec() codec.Codec { return k.cdc } + +// GetCrosschainKeeper returns the crosschain keeper +func (k Keeper) GetCrosschainKeeper() types.CrosschainKeeper { + return k.crosschainKeeper +} + +// GetIBCTransferKeeper returns the ibc transfer keeper +func (k Keeper) GetIBCTransferKeeper() types.IBCTransferKeeper { + return k.ibcTransferKeeper +} diff --git a/x/ibccrosschain/types/expected_keepers.go b/x/ibccrosschain/types/expected_keepers.go new file mode 100644 index 0000000000..8093bbafef --- /dev/null +++ b/x/ibccrosschain/types/expected_keepers.go @@ -0,0 +1,7 @@ +package types + +type CrosschainKeeper interface { +} + +type IBCTransferKeeper interface { +} From 3bda7b8a17225d5e71096377a291376885dc1e36 Mon Sep 17 00:00:00 2001 From: lumtis Date: Sun, 12 May 2024 20:57:57 +0200 Subject: [PATCH 06/21] new sdk keepers --- testutil/keeper/keeper.go | 161 +++++++++++++++--- .../keeper/mocks/crosschain/ibccrosschain.go | 24 +++ .../keeper/mocks/ibccrosschain/crosschain.go | 24 +++ .../keeper/mocks/ibccrosschain/transfer.go | 24 +++ 4 files changed, 213 insertions(+), 20 deletions(-) create mode 100644 testutil/keeper/mocks/crosschain/ibccrosschain.go create mode 100644 testutil/keeper/mocks/ibccrosschain/crosschain.go create mode 100644 testutil/keeper/mocks/ibccrosschain/transfer.go diff --git a/testutil/keeper/keeper.go b/testutil/keeper/keeper.go index a191bfefcc..42dff53b6a 100644 --- a/testutil/keeper/keeper.go +++ b/testutil/keeper/keeper.go @@ -1,6 +1,9 @@ package keeper import ( + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + "github.com/cosmos/ibc-go/v7/modules/apps/transfer" + porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" "math/rand" "testing" "time" @@ -17,6 +20,8 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + capabilitymodule "github.com/cosmos/cosmos-sdk/x/capability" + capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" @@ -30,6 +35,10 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" + ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" ethermint "github.com/evmos/ethermint/types" evmmodule "github.com/evmos/ethermint/x/evm" evmkeeper "github.com/evmos/ethermint/x/evm/keeper" @@ -51,7 +60,12 @@ import ( fungiblemodule "github.com/zeta-chain/zetacore/x/fungible" fungiblekeeper "github.com/zeta-chain/zetacore/x/fungible/keeper" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" + ibccrosschainmodule "github.com/zeta-chain/zetacore/x/ibccrosschain" + ibccrosschainkeeper "github.com/zeta-chain/zetacore/x/ibccrosschain/keeper" + ibccrosschaintypes "github.com/zeta-chain/zetacore/x/ibccrosschain/types" + lightclientmodule "github.com/zeta-chain/zetacore/x/lightclient" lightclientkeeper "github.com/zeta-chain/zetacore/x/lightclient/keeper" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" observermodule "github.com/zeta-chain/zetacore/x/observer" observerkeeper "github.com/zeta-chain/zetacore/x/observer/keeper" observertypes "github.com/zeta-chain/zetacore/x/observer/types" @@ -85,23 +99,31 @@ func NewContext(stateStore sdk.CommitMultiStore) sdk.Context { // SDKKeepers is a struct containing regular SDK module keepers for test purposes type SDKKeepers struct { - ParamsKeeper paramskeeper.Keeper - AuthKeeper authkeeper.AccountKeeper - BankKeeper bankkeeper.Keeper - StakingKeeper stakingkeeper.Keeper - SlashingKeeper slashingkeeper.Keeper - FeeMarketKeeper feemarketkeeper.Keeper - EvmKeeper *evmkeeper.Keeper + ParamsKeeper paramskeeper.Keeper + AuthKeeper authkeeper.AccountKeeper + BankKeeper bankkeeper.Keeper + StakingKeeper stakingkeeper.Keeper + SlashingKeeper slashingkeeper.Keeper + FeeMarketKeeper feemarketkeeper.Keeper + EvmKeeper *evmkeeper.Keeper + CapabilityKeeper *capabilitykeeper.Keeper + IBCKeeper *ibckeeper.Keeper + TransferKeeper ibctransferkeeper.Keeper + ScopedIBCKeeper capabilitykeeper.ScopedKeeper + ScopedTransferKeeper capabilitykeeper.ScopedKeeper + + IBCRouter *porttypes.Router } // ZetaKeepers is a struct containing Zeta module keepers for test purposes type ZetaKeepers struct { - AuthorityKeeper *authoritykeeper.Keeper - CrosschainKeeper *crosschainkeeper.Keeper - EmissionsKeeper *emissionskeeper.Keeper - FungibleKeeper *fungiblekeeper.Keeper - ObserverKeeper *observerkeeper.Keeper - LightclientKeeper *lightclientkeeper.Keeper + AuthorityKeeper *authoritykeeper.Keeper + CrosschainKeeper *crosschainkeeper.Keeper + EmissionsKeeper *emissionskeeper.Keeper + FungibleKeeper *fungiblekeeper.Keeper + ObserverKeeper *observerkeeper.Keeper + LightclientKeeper *lightclientkeeper.Keeper + IBCCrosschainKeeper *ibccrosschainkeeper.Keeper } var moduleAccountPerms = map[string][]string{ @@ -115,6 +137,8 @@ var moduleAccountPerms = map[string][]string{ emissionstypes.ModuleName: {authtypes.Minter}, emissionstypes.UndistributedObserverRewardsPool: nil, emissionstypes.UndistributedTssRewardsPool: nil, + ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + ibccrosschaintypes.ModuleName: nil, } // ModuleAccountAddrs returns all the app's module account addresses. @@ -336,12 +360,92 @@ func EVMKeeper( return k } +// CapabilityKeeper instantiates a capability keeper for testing purposes +func CapabilityKeeper( + cdc codec.Codec, + db *tmdb.MemDB, + ss store.CommitMultiStore, +) *capabilitykeeper.Keeper { + storeKey := sdk.NewKVStoreKey(capabilitytypes.StoreKey) + memKey := storetypes.NewMemoryStoreKey(capabilitytypes.MemStoreKey) + ss.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + + return capabilitykeeper.NewKeeper(cdc, storeKey, memKey) +} + +// IBCKeeper instantiates an ibc keeper for testing purposes +func IBCKeeper( + cdc codec.Codec, + db *tmdb.MemDB, + ss store.CommitMultiStore, + paramKeeper paramskeeper.Keeper, + stakingKeeper stakingkeeper.Keeper, + uppgradeKeeper upgradekeeper.Keeper, + capabilityKeeper capabilitykeeper.Keeper, +) *ibckeeper.Keeper { + storeKey := sdk.NewKVStoreKey(ibccrosschaintypes.StoreKey) + ss.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + + scopedIBCKeeper := capabilityKeeper.ScopeToModule(ibcexported.ModuleName) + + return ibckeeper.NewKeeper( + cdc, + storeKey, + paramKeeper.Subspace(ibcexported.ModuleName), + stakingKeeper, + uppgradeKeeper, + scopedIBCKeeper, + ) +} + +// TransferKeeper instantiates an ibc transfer keeper for testing purposes +func TransferKeeper( + cdc codec.Codec, + db *tmdb.MemDB, + ss store.CommitMultiStore, + paramKeeper paramskeeper.Keeper, + ibcKeeper *ibckeeper.Keeper, + authKeeper authkeeper.AccountKeeper, + bankKeeper bankkeeper.Keeper, + capabilityKeeper capabilitykeeper.Keeper, + ibcRouter *porttypes.Router, +) ibctransferkeeper.Keeper { + storeKey := sdk.NewKVStoreKey(ibctransfertypes.StoreKey) + ss.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + + scopedTransferKeeper := capabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) + + transferKeeper := ibctransferkeeper.NewKeeper( + cdc, + storeKey, + paramKeeper.Subspace(ibctransfertypes.ModuleName), + ibcKeeper.ChannelKeeper, + ibcKeeper.ChannelKeeper, + &ibcKeeper.PortKeeper, + authKeeper, + bankKeeper, + scopedTransferKeeper, + ) + + // create IBC module from bottom to top of stack + var transferStack porttypes.IBCModule + transferStack = transfer.NewIBCModule(transferKeeper) + + // Add transfer stack to IBC Router + ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferStack) + + return transferKeeper +} + // NewSDKKeepers instantiates regular Cosmos SDK keeper such as staking with local storage for testing purposes func NewSDKKeepers( cdc codec.Codec, db *tmdb.MemDB, ss store.CommitMultiStore, ) SDKKeepers { + ibcRouter := porttypes.NewRouter() + + capabilityKeeper := CapabilityKeeper(cdc, db, ss) paramsKeeper := ParamsKeeper(cdc, db, ss) authKeeper := AccountKeeper(cdc, db, ss) bankKeeper := BankKeeper(cdc, db, ss, authKeeper) @@ -350,22 +454,33 @@ func NewSDKKeepers( feeMarketKeeper := FeeMarketKeeper(cdc, db, ss, paramsKeeper, consensusKeeper) evmKeeper := EVMKeeper(cdc, db, ss, authKeeper, bankKeeper, stakingKeeper, feeMarketKeeper, paramsKeeper, consensusKeeper) slashingKeeper := SlashingKeeper(cdc, db, ss, stakingKeeper) + + ibcKeeper := IBCKeeper(cdc, db, ss, paramsKeeper, stakingKeeper, UpgradeKeeper(cdc, db, ss), *capabilityKeeper) + transferKeeper := TransferKeeper(cdc, db, ss, paramsKeeper, ibcKeeper, authKeeper, bankKeeper, *capabilityKeeper, ibcRouter) + return SDKKeepers{ - ParamsKeeper: paramsKeeper, - AuthKeeper: authKeeper, - BankKeeper: bankKeeper, - StakingKeeper: stakingKeeper, - FeeMarketKeeper: feeMarketKeeper, - EvmKeeper: evmKeeper, - SlashingKeeper: slashingKeeper, + CapabilityKeeper: capabilityKeeper, + ParamsKeeper: paramsKeeper, + AuthKeeper: authKeeper, + BankKeeper: bankKeeper, + StakingKeeper: stakingKeeper, + FeeMarketKeeper: feeMarketKeeper, + EvmKeeper: evmKeeper, + SlashingKeeper: slashingKeeper, + IBCKeeper: ibcKeeper, + TransferKeeper: transferKeeper, + IBCRouter: ibcRouter, } } // InitGenesis initializes the test modules genesis state func (sdkk SDKKeepers) InitGenesis(ctx sdk.Context) { + capabilitymodule.InitGenesis(ctx, *sdkk.CapabilityKeeper, *capabilitytypes.DefaultGenesis()) + sdkk.AuthKeeper.InitGenesis(ctx, *authtypes.DefaultGenesisState()) sdkk.BankKeeper.InitGenesis(ctx, banktypes.DefaultGenesisState()) sdkk.StakingKeeper.InitGenesis(ctx, stakingtypes.DefaultGenesisState()) + evmGenesis := *evmtypes.DefaultGenesisState() evmGenesis.Params.EvmDenom = "azeta" evmmodule.InitGenesis(ctx, sdkk.EvmKeeper, sdkk.AuthKeeper, evmGenesis) @@ -405,4 +520,10 @@ func (zk ZetaKeepers) InitGenesis(ctx sdk.Context) { if zk.ObserverKeeper != nil { observermodule.InitGenesis(ctx, *zk.ObserverKeeper, *observertypes.DefaultGenesis()) } + if zk.LightclientKeeper != nil { + lightclientmodule.InitGenesis(ctx, *zk.LightclientKeeper, *lightclienttypes.DefaultGenesis()) + } + if zk.IBCCrosschainKeeper != nil { + ibccrosschainmodule.InitGenesis(ctx, *zk.IBCCrosschainKeeper, *ibccrosschaintypes.DefaultGenesis()) + } } diff --git a/testutil/keeper/mocks/crosschain/ibccrosschain.go b/testutil/keeper/mocks/crosschain/ibccrosschain.go new file mode 100644 index 0000000000..bad4f5b85b --- /dev/null +++ b/testutil/keeper/mocks/crosschain/ibccrosschain.go @@ -0,0 +1,24 @@ +// Code generated by mockery v2.39.1. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// CrosschainIBCCrosschainKeeper is an autogenerated mock type for the CrosschainIBCCrosschainKeeper type +type CrosschainIBCCrosschainKeeper struct { + mock.Mock +} + +// NewCrosschainIBCCrosschainKeeper creates a new instance of CrosschainIBCCrosschainKeeper. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewCrosschainIBCCrosschainKeeper(t interface { + mock.TestingT + Cleanup(func()) +}) *CrosschainIBCCrosschainKeeper { + mock := &CrosschainIBCCrosschainKeeper{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/testutil/keeper/mocks/ibccrosschain/crosschain.go b/testutil/keeper/mocks/ibccrosschain/crosschain.go new file mode 100644 index 0000000000..f7ddd32b15 --- /dev/null +++ b/testutil/keeper/mocks/ibccrosschain/crosschain.go @@ -0,0 +1,24 @@ +// Code generated by mockery v2.39.1. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// LightclientCrosschainKeeper is an autogenerated mock type for the LightclientCrosschainKeeper type +type LightclientCrosschainKeeper struct { + mock.Mock +} + +// NewLightclientCrosschainKeeper creates a new instance of LightclientCrosschainKeeper. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewLightclientCrosschainKeeper(t interface { + mock.TestingT + Cleanup(func()) +}) *LightclientCrosschainKeeper { + mock := &LightclientCrosschainKeeper{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/testutil/keeper/mocks/ibccrosschain/transfer.go b/testutil/keeper/mocks/ibccrosschain/transfer.go new file mode 100644 index 0000000000..8db49ec5be --- /dev/null +++ b/testutil/keeper/mocks/ibccrosschain/transfer.go @@ -0,0 +1,24 @@ +// Code generated by mockery v2.39.1. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// LightclientTransferKeeper is an autogenerated mock type for the LightclientTransferKeeper type +type LightclientTransferKeeper struct { + mock.Mock +} + +// NewLightclientTransferKeeper creates a new instance of LightclientTransferKeeper. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewLightclientTransferKeeper(t interface { + mock.TestingT + Cleanup(func()) +}) *LightclientTransferKeeper { + mock := &LightclientTransferKeeper{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} From 0cb209c563be51b779fa58c83e88389f46f338ee Mon Sep 17 00:00:00 2001 From: lumtis Date: Sun, 12 May 2024 21:43:54 +0200 Subject: [PATCH 07/21] ibccrosschain test keeper --- testutil/keeper/crosschain.go | 34 ++++++- testutil/keeper/ibccrosschain.go | 154 +++++++++++++++++++++++++++++++ testutil/keeper/keeper.go | 6 +- 3 files changed, 190 insertions(+), 4 deletions(-) create mode 100644 testutil/keeper/ibccrosschain.go diff --git a/testutil/keeper/crosschain.go b/testutil/keeper/crosschain.go index daf17479b3..f71f4ae40c 100644 --- a/testutil/keeper/crosschain.go +++ b/testutil/keeper/crosschain.go @@ -5,6 +5,7 @@ import ( "testing" tmdb "github.com/cometbft/cometbft-db" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -45,6 +46,37 @@ var ( CrosschainNoMocks = CrosschainMockOptions{} ) +func initCrosschainKeeper( + cdc codec.Codec, + db *tmdb.MemDB, + ss store.CommitMultiStore, + stakingKeeper types.StakingKeeper, + authKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, + observerKeeper types.ObserverKeeper, + fungibleKeeper types.FungibleKeeper, + authorityKeeper types.AuthorityKeeper, + lightclientKeeper types.LightclientKeeper, +) *keeper.Keeper { + storeKey := sdk.NewKVStoreKey(types.StoreKey) + memKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) + ss.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + ss.MountStoreWithDB(memKey, storetypes.StoreTypeMemory, db) + + return keeper.NewKeeper( + cdc, + storeKey, + memKey, + stakingKeeper, + authKeeper, + bankKeeper, + observerKeeper, + fungibleKeeper, + authorityKeeper, + lightclientKeeper, + ) +} + // CrosschainKeeperWithMocks initializes a crosschain keeper for testing purposes with option to mock specific keepers func CrosschainKeeperWithMocks( t testing.TB, @@ -94,7 +126,7 @@ func CrosschainKeeperWithMocks( var observerKeeper types.ObserverKeeper = observerKeeperTmp var fungibleKeeper types.FungibleKeeper = fungibleKeeperTmp - // Create the fungible keeper + // Create the crosschain keeper stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) require.NoError(t, stateStore.LoadLatestVersion()) diff --git a/testutil/keeper/ibccrosschain.go b/testutil/keeper/ibccrosschain.go new file mode 100644 index 0000000000..358f7e16df --- /dev/null +++ b/testutil/keeper/ibccrosschain.go @@ -0,0 +1,154 @@ +package keeper + +import ( + "testing" + + tmdb "github.com/cometbft/cometbft-db" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + ibccrosschainmocks "github.com/zeta-chain/zetacore/testutil/keeper/mocks/ibccrosschain" + "github.com/zeta-chain/zetacore/x/ibccrosschain/keeper" + "github.com/zeta-chain/zetacore/x/ibccrosschain/types" +) + +type IBCCroscchainMockOptions struct { + UseCrosschainMock bool + UseIBCTransferMock bool +} + +var ( + IBCCrosschainMocksAll = IBCCroscchainMockOptions{ + UseCrosschainMock: true, + UseIBCTransferMock: true, + } + IBCCrosschainNoMocks = IBCCroscchainMockOptions{} +) + +func initIBCCrosschainKeeper( + cdc codec.Codec, + db *tmdb.MemDB, + ss store.CommitMultiStore, + crosschainKeeper types.CrosschainKeeper, + ibcTransferKeeper types.IBCTransferKeeper, +) *keeper.Keeper { + storeKey := sdk.NewKVStoreKey(types.StoreKey) + memKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) + ss.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + ss.MountStoreWithDB(memKey, storetypes.StoreTypeMemory, db) + + return keeper.NewKeeper( + cdc, + storeKey, + memKey, + crosschainKeeper, + ibcTransferKeeper, + ) +} + +func IBCCrosschainKeeperWithMocks( + t testing.TB, + mockOptions IBCCroscchainMockOptions, +) (*keeper.Keeper, sdk.Context, SDKKeepers, ZetaKeepers) { + storeKey := sdk.NewKVStoreKey(types.StoreKey) + memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) + + // Initialize local store + db := tmdb.NewMemDB() + stateStore := store.NewCommitMultiStore(db) + cdc := NewCodec() + + // Create regular keepers + sdkKeepers := NewSDKKeepers(cdc, db, stateStore) + + // Create zeta keepers + authorityKeeper := initAuthorityKeeper(cdc, db, stateStore) + lightclientKeeper := initLightclientKeeper(cdc, db, stateStore, authorityKeeper) + observerKeeper := initObserverKeeper( + cdc, + db, + stateStore, + sdkKeepers.StakingKeeper, + sdkKeepers.SlashingKeeper, + authorityKeeper, + lightclientKeeper, + ) + fungibleKeeper := initFungibleKeeper( + cdc, + db, + stateStore, + sdkKeepers.AuthKeeper, + sdkKeepers.BankKeeper, + sdkKeepers.EvmKeeper, + observerKeeper, + authorityKeeper, + ) + crosschainKeeperTmp := initCrosschainKeeper( + cdc, + db, + stateStore, + sdkKeepers.StakingKeeper, + sdkKeepers.AuthKeeper, + sdkKeepers.BankKeeper, + observerKeeper, + fungibleKeeper, + authorityKeeper, + lightclientKeeper, + ) + + zetaKeepers := ZetaKeepers{ + ObserverKeeper: observerKeeper, + FungibleKeeper: fungibleKeeper, + AuthorityKeeper: &authorityKeeper, + LightclientKeeper: &lightclientKeeper, + CrosschainKeeper: crosschainKeeperTmp, + } + + var crosschainKeeper types.CrosschainKeeper = crosschainKeeperTmp + var ibcTransferKeeper types.IBCTransferKeeper = sdkKeepers.TransferKeeper + + // Create the ibccrosschain keeper + stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) + require.NoError(t, stateStore.LoadLatestVersion()) + + ctx := NewContext(stateStore) + + // Initialize modules genesis + sdkKeepers.InitGenesis(ctx) + zetaKeepers.InitGenesis(ctx) + + // Add a proposer to the context + ctx = sdkKeepers.InitBlockProposer(t, ctx) + + // Initialize mocks for mocked keepers + if mockOptions.UseCrosschainMock { + crosschainKeeper = ibccrosschainmocks.NewLightclientCrosschainKeeper(t) + } + if mockOptions.UseIBCTransferMock { + ibcTransferKeeper = ibccrosschainmocks.NewLightclientTransferKeeper(t) + } + + k := keeper.NewKeeper( + cdc, + storeKey, + memStoreKey, + crosschainKeeper, + ibcTransferKeeper, + ) + + return k, ctx, sdkKeepers, zetaKeepers +} + +// IBCCrosschainKeeperAllMocks creates a new ibccrosschain keeper with all mocked keepers +func IBCCrosschainKeeperAllMocks(t testing.TB) (*keeper.Keeper, sdk.Context) { + k, ctx, _, _ := IBCCrosschainKeeperWithMocks(t, IBCCrosschainMocksAll) + return k, ctx +} + +// IBCCrosschainKeeper creates a new ibccrosschain keeper with no mocked keepers +func IBCCrosschainKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, SDKKeepers, ZetaKeepers) { + return IBCCrosschainKeeperWithMocks(t, IBCCrosschainNoMocks) +} diff --git a/testutil/keeper/keeper.go b/testutil/keeper/keeper.go index 42dff53b6a..32bccc3bc4 100644 --- a/testutil/keeper/keeper.go +++ b/testutil/keeper/keeper.go @@ -1,9 +1,6 @@ package keeper import ( - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - "github.com/cosmos/ibc-go/v7/modules/apps/transfer" - porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" "math/rand" "testing" "time" @@ -22,6 +19,7 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" capabilitymodule "github.com/cosmos/cosmos-sdk/x/capability" capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper" consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types" distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" @@ -35,8 +33,10 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/cosmos/ibc-go/v7/modules/apps/transfer" ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" ethermint "github.com/evmos/ethermint/types" From fda4a176194f7223001e470e40520f349e303a87 Mon Sep 17 00:00:00 2001 From: lumtis Date: Mon, 13 May 2024 10:16:14 +0200 Subject: [PATCH 08/21] add ibccrosschain dep to crosschain test keeper --- testutil/keeper/crosschain.go | 50 +++++++++++++++++++++++--------- testutil/keeper/ibccrosschain.go | 9 ++++++ 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/testutil/keeper/crosschain.go b/testutil/keeper/crosschain.go index f71f4ae40c..e54729ef4f 100644 --- a/testutil/keeper/crosschain.go +++ b/testutil/keeper/crosschain.go @@ -24,24 +24,26 @@ import ( ) type CrosschainMockOptions struct { - UseBankMock bool - UseAccountMock bool - UseStakingMock bool - UseObserverMock bool - UseFungibleMock bool - UseAuthorityMock bool - UseLightclientMock bool + UseBankMock bool + UseAccountMock bool + UseStakingMock bool + UseObserverMock bool + UseFungibleMock bool + UseAuthorityMock bool + UseLightclientMock bool + useIBCCrosschainMock bool } var ( CrosschainMocksAll = CrosschainMockOptions{ - UseBankMock: true, - UseAccountMock: true, - UseStakingMock: true, - UseObserverMock: true, - UseFungibleMock: true, - UseAuthorityMock: true, - UseLightclientMock: true, + UseBankMock: true, + UseAccountMock: true, + UseStakingMock: true, + UseObserverMock: true, + UseFungibleMock: true, + UseAuthorityMock: true, + UseLightclientMock: true, + useIBCCrosschainMock: true, } CrosschainNoMocks = CrosschainMockOptions{} ) @@ -167,6 +169,7 @@ func CrosschainKeeperWithMocks( lightclientKeeper = crosschainmocks.NewCrosschainLightclientKeeper(t) } + // create crosschain keeper k := keeper.NewKeeper( cdc, storeKey, @@ -180,6 +183,25 @@ func CrosschainKeeperWithMocks( lightclientKeeper, ) + // initialize ibccrosschain keeper and set it to the crosschain keeper + // there is a circular dependency between the two keepers, crosschain keeper must be initialized first + + var ibcCrosschainKeeperTmp types.IBCCrosschainKeeper = initIBCCrosschainKeeper( + cdc, + db, + stateStore, + k, + sdkKeepers.TransferKeeper, + *sdkKeepers.CapabilityKeeper, + ) + if mockOptions.useIBCCrosschainMock { + ibcCrosschainKeeperTmp = crosschainmocks.NewCrosschainIBCCrosschainKeeper(t) + } + k.SetIBCCrosschainKeeper(ibcCrosschainKeeperTmp) + + // seal the IBC router + sdkKeepers.IBCKeeper.SetRouter(sdkKeepers.IBCRouter) + return k, ctx, sdkKeepers, zetaKeepers } diff --git a/testutil/keeper/ibccrosschain.go b/testutil/keeper/ibccrosschain.go index 358f7e16df..ff941d9993 100644 --- a/testutil/keeper/ibccrosschain.go +++ b/testutil/keeper/ibccrosschain.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/store" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" "github.com/stretchr/testify/require" ibccrosschainmocks "github.com/zeta-chain/zetacore/testutil/keeper/mocks/ibccrosschain" "github.com/zeta-chain/zetacore/x/ibccrosschain/keeper" @@ -33,12 +34,15 @@ func initIBCCrosschainKeeper( ss store.CommitMultiStore, crosschainKeeper types.CrosschainKeeper, ibcTransferKeeper types.IBCTransferKeeper, + capabilityKeeper capabilitykeeper.Keeper, ) *keeper.Keeper { storeKey := sdk.NewKVStoreKey(types.StoreKey) memKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) ss.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) ss.MountStoreWithDB(memKey, storetypes.StoreTypeMemory, db) + capabilityKeeper.ScopeToModule(types.ModuleName) + return keeper.NewKeeper( cdc, storeKey, @@ -131,6 +135,8 @@ func IBCCrosschainKeeperWithMocks( ibcTransferKeeper = ibccrosschainmocks.NewLightclientTransferKeeper(t) } + sdkKeepers.CapabilityKeeper.ScopeToModule(types.ModuleName) + k := keeper.NewKeeper( cdc, storeKey, @@ -139,6 +145,9 @@ func IBCCrosschainKeeperWithMocks( ibcTransferKeeper, ) + // seal the IBC router + sdkKeepers.IBCKeeper.SetRouter(sdkKeepers.IBCRouter) + return k, ctx, sdkKeepers, zetaKeepers } From 27de5836e3bf0cd2861351fef48a648f120dcbc3 Mon Sep 17 00:00:00 2001 From: lumtis Date: Mon, 13 May 2024 10:27:50 +0200 Subject: [PATCH 09/21] fix lint issues --- x/ibccrosschain/ibc_module.go | 79 ++++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 2 deletions(-) diff --git a/x/ibccrosschain/ibc_module.go b/x/ibccrosschain/ibc_module.go index cf11c8e3bf..e78d7d61ae 100644 --- a/x/ibccrosschain/ibc_module.go +++ b/x/ibccrosschain/ibc_module.go @@ -26,6 +26,8 @@ func NewIBCModule(k keeper.Keeper) IBCModule { } // OnChanOpenInit implements the IBCModule interface +// TODO: Implement the function as middleware +// https://github.com/zeta-chain/node/issues/2163 func (im IBCModule) OnChanOpenInit( ctx sdk.Context, order channeltypes.Order, @@ -36,10 +38,21 @@ func (im IBCModule) OnChanOpenInit( counterparty channeltypes.Counterparty, version string, ) (string, error) { + // Set variable to blank to remove lint error so we can keep variable name for future use + _ = ctx + _ = order + _ = connectionHops + _ = portID + _ = channelID + _ = chanCap + _ = counterparty + return version, nil } // OnChanOpenTry implements the IBCModule interface. +// TODO: Implement the function as middleware +// https://github.com/zeta-chain/node/issues/2163 func (im IBCModule) OnChanOpenTry( ctx sdk.Context, order channeltypes.Order, @@ -50,73 +63,135 @@ func (im IBCModule) OnChanOpenTry( counterparty channeltypes.Counterparty, counterpartyVersion string, ) (string, error) { + // Set variable to blank to remove lint error so we can keep variable name for future us + _ = ctx + _ = order + _ = connectionHops + _ = portID + _ = channelID + _ = chanCap + _ = counterparty + _ = counterpartyVersion + return "", nil } // OnChanOpenAck implements the IBCModule interface +// TODO: Implement the function as middleware +// https://github.com/zeta-chain/node/issues/2163 func (im IBCModule) OnChanOpenAck( ctx sdk.Context, portID, channelID string, - _ string, + counterpartyChannelID string, counterpartyVersion string, ) error { + // Set variable to blank to remove lint error so we can keep variable name for future use + _ = ctx + _ = portID + _ = channelID + _ = counterpartyChannelID + _ = counterpartyVersion + return nil } // OnChanOpenConfirm implements the IBCModule interface +// TODO: Implement the function as middleware +// https://github.com/zeta-chain/node/issues/2163 func (im IBCModule) OnChanOpenConfirm( ctx sdk.Context, portID, channelID string, ) error { + // Set variable to blank to remove lint error so we can keep variable name for future use + _ = ctx + _ = portID + _ = channelID + return nil } // OnChanCloseInit implements the IBCModule interface +// TODO: Implement the function as middleware +// https://github.com/zeta-chain/node/issues/2163 func (im IBCModule) OnChanCloseInit( ctx sdk.Context, portID, channelID string, ) error { + // Set variable to blank to remove lint error so we can keep variable name for future use + _ = ctx + _ = portID + _ = channelID + return nil } // OnChanCloseConfirm implements the IBCModule interface +// TODO: Implement the function as middleware +// https://github.com/zeta-chain/node/issues/2163 func (im IBCModule) OnChanCloseConfirm( ctx sdk.Context, portID, channelID string, ) error { + // Set variable to blank to remove lint error so we can keep variable name for future use + _ = ctx + _ = portID + _ = channelID + return nil } // OnRecvPacket implements the IBCModule interface. A successful acknowledgement // is returned if the packet data is successfully decoded and the receive application -// logic returns without error. +// logic returns without error +// TODO: Implement the function as middleware +// https://github.com/zeta-chain/node/issues/2163 func (im IBCModule) OnRecvPacket( ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress, ) ibcexported.Acknowledgement { + // Set variable to blank to remove lint error so we can keep variable name for future use + _ = ctx + _ = packet + _ = relayer + return nil } // OnAcknowledgementPacket implements the IBCModule interface +// TODO: Implement the function as middleware +// https://github.com/zeta-chain/node/issues/2163 func (im IBCModule) OnAcknowledgementPacket( ctx sdk.Context, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress, ) error { + // Set variable to blank to remove lint error so we can keep variable name for future use + _ = ctx + _ = packet + _ = acknowledgement + _ = relayer + return nil } // OnTimeoutPacket implements the IBCModule interface +// TODO: Implement the function as middleware +// https://github.com/zeta-chain/node/issues/2163 func (im IBCModule) OnTimeoutPacket( ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress, ) error { + // Set variable to blank to remove lint error so we can keep variable name for future use + _ = ctx + _ = packet + _ = relayer + return nil } From ec406982ee7ea3c002b8bec9ad457443c041a0d6 Mon Sep 17 00:00:00 2001 From: lumtis Date: Mon, 13 May 2024 10:30:17 +0200 Subject: [PATCH 10/21] add changelog entry --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index b293e6f464..da5c9e237a 100644 --- a/changelog.md +++ b/changelog.md @@ -14,6 +14,7 @@ * [2145](https://github.com/zeta-chain/node/pull/2145) - add `ibc` and `ibc-transfer` modules * [2135](https://github.com/zeta-chain/node/pull/2135) - add develop build version logic * [2113](https://github.com/zeta-chain/node/pull/2113) - add zetaclientd-supervisor process +* [2154](https://github.com/zeta-chain/node/pull/2154) - add `ibccrosschain` module ### Refactor From abc3cd3c7d7809aacf81d561350efbe5163f5418 Mon Sep 17 00:00:00 2001 From: lumtis Date: Mon, 13 May 2024 11:49:47 +0200 Subject: [PATCH 11/21] fix module name --- x/ibccrosschain/types/keys.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x/ibccrosschain/types/keys.go b/x/ibccrosschain/types/keys.go index c5930b636c..37412bf3fa 100644 --- a/x/ibccrosschain/types/keys.go +++ b/x/ibccrosschain/types/keys.go @@ -2,7 +2,10 @@ package types const ( // ModuleName defines the module name - ModuleName = "ibccrosschain" + // NOTE: module name can't have the name of another module as a prefix + // because of potential store key conflicts + // ibcblockchain or crosschainibc can't be used as module name + ModuleName = "icrosschain" // StoreKey defines the primary module store key StoreKey = ModuleName From 08784e3e4af1f489dca278661bb336bc84403602 Mon Sep 17 00:00:00 2001 From: lumtis Date: Mon, 13 May 2024 12:12:41 +0200 Subject: [PATCH 12/21] fix capability key --- testutil/keeper/keeper.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testutil/keeper/keeper.go b/testutil/keeper/keeper.go index 32bccc3bc4..dc4a6b5bb1 100644 --- a/testutil/keeper/keeper.go +++ b/testutil/keeper/keeper.go @@ -368,7 +368,9 @@ func CapabilityKeeper( ) *capabilitykeeper.Keeper { storeKey := sdk.NewKVStoreKey(capabilitytypes.StoreKey) memKey := storetypes.NewMemoryStoreKey(capabilitytypes.MemStoreKey) + ss.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + ss.MountStoreWithDB(memKey, storetypes.StoreTypeMemory, nil) return capabilitykeeper.NewKeeper(cdc, storeKey, memKey) } From ee91f75f06c09d03058b370c835dc073e9d9ade3 Mon Sep 17 00:00:00 2001 From: lumtis Date: Mon, 13 May 2024 12:30:41 +0200 Subject: [PATCH 13/21] fix unit test --- testutil/keeper/crosschain.go | 21 +++++++++++---------- testutil/keeper/keeper.go | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/testutil/keeper/crosschain.go b/testutil/keeper/crosschain.go index e54729ef4f..fc5f5fe305 100644 --- a/testutil/keeper/crosschain.go +++ b/testutil/keeper/crosschain.go @@ -131,16 +131,6 @@ func CrosschainKeeperWithMocks( // Create the crosschain keeper stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) - require.NoError(t, stateStore.LoadLatestVersion()) - - ctx := NewContext(stateStore) - - // Initialize modules genesis - sdkKeepers.InitGenesis(ctx) - zetaKeepers.InitGenesis(ctx) - - // Add a proposer to the context - ctx = sdkKeepers.InitBlockProposer(t, ctx) // Initialize mocks for mocked keepers var authKeeper types.AccountKeeper = sdkKeepers.AuthKeeper @@ -202,6 +192,17 @@ func CrosschainKeeperWithMocks( // seal the IBC router sdkKeepers.IBCKeeper.SetRouter(sdkKeepers.IBCRouter) + // load the latest version of the state store + require.NoError(t, stateStore.LoadLatestVersion()) + ctx := NewContext(stateStore) + + // initialize modules genesis + sdkKeepers.InitGenesis(ctx) + zetaKeepers.InitGenesis(ctx) + + // add a proposer to the context + ctx = sdkKeepers.InitBlockProposer(t, ctx) + return k, ctx, sdkKeepers, zetaKeepers } diff --git a/testutil/keeper/keeper.go b/testutil/keeper/keeper.go index dc4a6b5bb1..f6f944bbb0 100644 --- a/testutil/keeper/keeper.go +++ b/testutil/keeper/keeper.go @@ -385,7 +385,7 @@ func IBCKeeper( uppgradeKeeper upgradekeeper.Keeper, capabilityKeeper capabilitykeeper.Keeper, ) *ibckeeper.Keeper { - storeKey := sdk.NewKVStoreKey(ibccrosschaintypes.StoreKey) + storeKey := sdk.NewKVStoreKey(ibcexported.StoreKey) ss.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) scopedIBCKeeper := capabilityKeeper.ScopeToModule(ibcexported.ModuleName) From d45242abc90f5b705cd2685bd117242c98f2a1d7 Mon Sep 17 00:00:00 2001 From: lumtis Date: Mon, 13 May 2024 12:32:51 +0200 Subject: [PATCH 14/21] make generate --- docs/cli/zetacored/zetacored_query.md | 2 +- ...ry_ibccrosschain.md => zetacored_query_icrosschain.md} | 8 ++++---- docs/cli/zetacored/zetacored_tx.md | 2 +- ...ed_tx_ibccrosschain.md => zetacored_tx_icrosschain.md} | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) rename docs/cli/zetacored/{zetacored_query_ibccrosschain.md => zetacored_query_icrosschain.md} (78%) rename docs/cli/zetacored/{zetacored_tx_ibccrosschain.md => zetacored_tx_icrosschain.md} (80%) diff --git a/docs/cli/zetacored/zetacored_query.md b/docs/cli/zetacored/zetacored_query.md index 0ddb86ed17..05ebb5ce4a 100644 --- a/docs/cli/zetacored/zetacored_query.md +++ b/docs/cli/zetacored/zetacored_query.md @@ -43,7 +43,7 @@ zetacored query [flags] * [zetacored query group](zetacored_query_group.md) - Querying commands for the group module * [zetacored query ibc](zetacored_query_ibc.md) - Querying commands for the IBC module * [zetacored query ibc-transfer](zetacored_query_ibc-transfer.md) - IBC fungible token transfer query subcommands -* [zetacored query ibccrosschain](zetacored_query_ibccrosschain.md) - Querying commands for the ibccrosschain module +* [zetacored query icrosschain](zetacored_query_icrosschain.md) - Querying commands for the icrosschain module * [zetacored query lightclient](zetacored_query_lightclient.md) - Querying commands for the lightclient module * [zetacored query observer](zetacored_query_observer.md) - Querying commands for the observer module * [zetacored query params](zetacored_query_params.md) - Querying commands for the params module diff --git a/docs/cli/zetacored/zetacored_query_ibccrosschain.md b/docs/cli/zetacored/zetacored_query_icrosschain.md similarity index 78% rename from docs/cli/zetacored/zetacored_query_ibccrosschain.md rename to docs/cli/zetacored/zetacored_query_icrosschain.md index 7da539e1e6..dcbcb59b05 100644 --- a/docs/cli/zetacored/zetacored_query_ibccrosschain.md +++ b/docs/cli/zetacored/zetacored_query_icrosschain.md @@ -1,15 +1,15 @@ -# query ibccrosschain +# query icrosschain -Querying commands for the ibccrosschain module +Querying commands for the icrosschain module ``` -zetacored query ibccrosschain [flags] +zetacored query icrosschain [flags] ``` ### Options ``` - -h, --help help for ibccrosschain + -h, --help help for icrosschain ``` ### Options inherited from parent commands diff --git a/docs/cli/zetacored/zetacored_tx.md b/docs/cli/zetacored/zetacored_tx.md index 048f644399..aa4dff71ee 100644 --- a/docs/cli/zetacored/zetacored_tx.md +++ b/docs/cli/zetacored/zetacored_tx.md @@ -43,7 +43,7 @@ zetacored tx [flags] * [zetacored tx group](zetacored_tx_group.md) - Group transaction subcommands * [zetacored tx ibc](zetacored_tx_ibc.md) - IBC transaction subcommands * [zetacored tx ibc-transfer](zetacored_tx_ibc-transfer.md) - IBC fungible token transfer transaction subcommands -* [zetacored tx ibccrosschain](zetacored_tx_ibccrosschain.md) - ibccrosschain transactions subcommands +* [zetacored tx icrosschain](zetacored_tx_icrosschain.md) - icrosschain transactions subcommands * [zetacored tx lightclient](zetacored_tx_lightclient.md) - lightclient transactions subcommands * [zetacored tx multi-sign](zetacored_tx_multi-sign.md) - Generate multisig signatures for transactions generated offline * [zetacored tx multisign-batch](zetacored_tx_multisign-batch.md) - Assemble multisig transactions in batch from batch signatures diff --git a/docs/cli/zetacored/zetacored_tx_ibccrosschain.md b/docs/cli/zetacored/zetacored_tx_icrosschain.md similarity index 80% rename from docs/cli/zetacored/zetacored_tx_ibccrosschain.md rename to docs/cli/zetacored/zetacored_tx_icrosschain.md index 1c2b122ba1..4c78dbf31b 100644 --- a/docs/cli/zetacored/zetacored_tx_ibccrosschain.md +++ b/docs/cli/zetacored/zetacored_tx_icrosschain.md @@ -1,15 +1,15 @@ -# tx ibccrosschain +# tx icrosschain -ibccrosschain transactions subcommands +icrosschain transactions subcommands ``` -zetacored tx ibccrosschain [flags] +zetacored tx icrosschain [flags] ``` ### Options ``` - -h, --help help for ibccrosschain + -h, --help help for icrosschain ``` ### Options inherited from parent commands From 6ddf23b9d29baf3ebbc7d1af40c479254580b37e Mon Sep 17 00:00:00 2001 From: lumtis Date: Mon, 13 May 2024 15:36:38 +0200 Subject: [PATCH 15/21] fix module basic --- app/app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/app.go b/app/app.go index cf361a9556..2a305544a5 100644 --- a/app/app.go +++ b/app/app.go @@ -211,7 +211,7 @@ var ( authoritymodule.AppModuleBasic{}, lightclientmodule.AppModuleBasic{}, crosschainmodule.AppModuleBasic{}, - ibccrosschain.AppModule{}, + ibccrosschain.AppModuleBasic{}, observermodule.AppModuleBasic{}, fungiblemodule.AppModuleBasic{}, emissionsmodule.AppModuleBasic{}, From 968375232abf607d6cab494b72c385c60c14e145 Mon Sep 17 00:00:00 2001 From: lumtis Date: Mon, 13 May 2024 15:42:09 +0200 Subject: [PATCH 16/21] rename module to clearer name --- docs/cli/zetacored/zetacored_query.md | 2 +- ...crosschain.md => zetacored_query_zetaibccrosschain.md} | 8 ++++---- docs/cli/zetacored/zetacored_tx.md | 2 +- ...x_icrosschain.md => zetacored_tx_zetaibccrosschain.md} | 8 ++++---- x/ibccrosschain/types/keys.go | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) rename docs/cli/zetacored/{zetacored_query_icrosschain.md => zetacored_query_zetaibccrosschain.md} (76%) rename docs/cli/zetacored/{zetacored_tx_icrosschain.md => zetacored_tx_zetaibccrosschain.md} (78%) diff --git a/docs/cli/zetacored/zetacored_query.md b/docs/cli/zetacored/zetacored_query.md index 05ebb5ce4a..8a59a16cda 100644 --- a/docs/cli/zetacored/zetacored_query.md +++ b/docs/cli/zetacored/zetacored_query.md @@ -43,7 +43,6 @@ zetacored query [flags] * [zetacored query group](zetacored_query_group.md) - Querying commands for the group module * [zetacored query ibc](zetacored_query_ibc.md) - Querying commands for the IBC module * [zetacored query ibc-transfer](zetacored_query_ibc-transfer.md) - IBC fungible token transfer query subcommands -* [zetacored query icrosschain](zetacored_query_icrosschain.md) - Querying commands for the icrosschain module * [zetacored query lightclient](zetacored_query_lightclient.md) - Querying commands for the lightclient module * [zetacored query observer](zetacored_query_observer.md) - Querying commands for the observer module * [zetacored query params](zetacored_query_params.md) - Querying commands for the params module @@ -53,4 +52,5 @@ zetacored query [flags] * [zetacored query tx](zetacored_query_tx.md) - Query for a transaction by hash, "[addr]/[seq]" combination or comma-separated signatures in a committed block * [zetacored query txs](zetacored_query_txs.md) - Query for paginated transactions that match a set of events * [zetacored query upgrade](zetacored_query_upgrade.md) - Querying commands for the upgrade module +* [zetacored query zetaibccrosschain](zetacored_query_zetaibccrosschain.md) - Querying commands for the zetaibccrosschain module diff --git a/docs/cli/zetacored/zetacored_query_icrosschain.md b/docs/cli/zetacored/zetacored_query_zetaibccrosschain.md similarity index 76% rename from docs/cli/zetacored/zetacored_query_icrosschain.md rename to docs/cli/zetacored/zetacored_query_zetaibccrosschain.md index dcbcb59b05..5edaf2cc5d 100644 --- a/docs/cli/zetacored/zetacored_query_icrosschain.md +++ b/docs/cli/zetacored/zetacored_query_zetaibccrosschain.md @@ -1,15 +1,15 @@ -# query icrosschain +# query zetaibccrosschain -Querying commands for the icrosschain module +Querying commands for the zetaibccrosschain module ``` -zetacored query icrosschain [flags] +zetacored query zetaibccrosschain [flags] ``` ### Options ``` - -h, --help help for icrosschain + -h, --help help for zetaibccrosschain ``` ### Options inherited from parent commands diff --git a/docs/cli/zetacored/zetacored_tx.md b/docs/cli/zetacored/zetacored_tx.md index aa4dff71ee..4d05fbe5fd 100644 --- a/docs/cli/zetacored/zetacored_tx.md +++ b/docs/cli/zetacored/zetacored_tx.md @@ -43,7 +43,6 @@ zetacored tx [flags] * [zetacored tx group](zetacored_tx_group.md) - Group transaction subcommands * [zetacored tx ibc](zetacored_tx_ibc.md) - IBC transaction subcommands * [zetacored tx ibc-transfer](zetacored_tx_ibc-transfer.md) - IBC fungible token transfer transaction subcommands -* [zetacored tx icrosschain](zetacored_tx_icrosschain.md) - icrosschain transactions subcommands * [zetacored tx lightclient](zetacored_tx_lightclient.md) - lightclient transactions subcommands * [zetacored tx multi-sign](zetacored_tx_multi-sign.md) - Generate multisig signatures for transactions generated offline * [zetacored tx multisign-batch](zetacored_tx_multisign-batch.md) - Assemble multisig transactions in batch from batch signatures @@ -54,4 +53,5 @@ zetacored tx [flags] * [zetacored tx staking](zetacored_tx_staking.md) - Staking transaction subcommands * [zetacored tx validate-signatures](zetacored_tx_validate-signatures.md) - validate transactions signatures * [zetacored tx vesting](zetacored_tx_vesting.md) - Vesting transaction subcommands +* [zetacored tx zetaibccrosschain](zetacored_tx_zetaibccrosschain.md) - zetaibccrosschain transactions subcommands diff --git a/docs/cli/zetacored/zetacored_tx_icrosschain.md b/docs/cli/zetacored/zetacored_tx_zetaibccrosschain.md similarity index 78% rename from docs/cli/zetacored/zetacored_tx_icrosschain.md rename to docs/cli/zetacored/zetacored_tx_zetaibccrosschain.md index 4c78dbf31b..7cce148ce8 100644 --- a/docs/cli/zetacored/zetacored_tx_icrosschain.md +++ b/docs/cli/zetacored/zetacored_tx_zetaibccrosschain.md @@ -1,15 +1,15 @@ -# tx icrosschain +# tx zetaibccrosschain -icrosschain transactions subcommands +zetaibccrosschain transactions subcommands ``` -zetacored tx icrosschain [flags] +zetacored tx zetaibccrosschain [flags] ``` ### Options ``` - -h, --help help for icrosschain + -h, --help help for zetaibccrosschain ``` ### Options inherited from parent commands diff --git a/x/ibccrosschain/types/keys.go b/x/ibccrosschain/types/keys.go index 37412bf3fa..aa73956220 100644 --- a/x/ibccrosschain/types/keys.go +++ b/x/ibccrosschain/types/keys.go @@ -5,7 +5,7 @@ const ( // NOTE: module name can't have the name of another module as a prefix // because of potential store key conflicts // ibcblockchain or crosschainibc can't be used as module name - ModuleName = "icrosschain" + ModuleName = "zetaibccrosschain" // StoreKey defines the primary module store key StoreKey = ModuleName From c7a07d7e093c5211c41d5f51048d19a6cd7cbc46 Mon Sep 17 00:00:00 2001 From: lumtis Date: Mon, 13 May 2024 15:44:59 +0200 Subject: [PATCH 17/21] make use consistent --- testutil/keeper/crosschain.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testutil/keeper/crosschain.go b/testutil/keeper/crosschain.go index fc5f5fe305..8dfa0a0bf1 100644 --- a/testutil/keeper/crosschain.go +++ b/testutil/keeper/crosschain.go @@ -31,7 +31,7 @@ type CrosschainMockOptions struct { UseFungibleMock bool UseAuthorityMock bool UseLightclientMock bool - useIBCCrosschainMock bool + UseIBCCrosschainMock bool } var ( @@ -43,7 +43,7 @@ var ( UseFungibleMock: true, UseAuthorityMock: true, UseLightclientMock: true, - useIBCCrosschainMock: true, + UseIBCCrosschainMock: true, } CrosschainNoMocks = CrosschainMockOptions{} ) @@ -184,7 +184,7 @@ func CrosschainKeeperWithMocks( sdkKeepers.TransferKeeper, *sdkKeepers.CapabilityKeeper, ) - if mockOptions.useIBCCrosschainMock { + if mockOptions.UseIBCCrosschainMock { ibcCrosschainKeeperTmp = crosschainmocks.NewCrosschainIBCCrosschainKeeper(t) } k.SetIBCCrosschainKeeper(ibcCrosschainKeeperTmp) From 314127c61d749ef20552e0135da2dfdb71bda620 Mon Sep 17 00:00:00 2001 From: lumtis Date: Mon, 13 May 2024 15:46:48 +0200 Subject: [PATCH 18/21] add comment in app.go for circular dep --- app/app.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/app.go b/app/app.go index 2a305544a5..df81af9fac 100644 --- a/app/app.go +++ b/app/app.go @@ -596,8 +596,11 @@ func New( app.LightclientKeeper, ) - scopedMonitoringcKeeper := app.CapabilityKeeper.ScopeToModule(ibccrosschaintypes.ModuleName) - app.ScopedIBCCrosschainKeeper = scopedMonitoringcKeeper + // initialize ibccrosschain keeper and set it to the crosschain keeper + // there is a circular dependency between the two keepers, crosschain keeper must be initialized first + + scopedIBCCrosschainKeeper := app.CapabilityKeeper.ScopeToModule(ibccrosschaintypes.ModuleName) + app.ScopedIBCCrosschainKeeper = scopedIBCCrosschainKeeper app.IBCCrosschainKeeper = *ibccrosschainkeeper.NewKeeper( appCodec, From 3ae2f4e3a47227ef0c720f76cde5982489bf173b Mon Sep 17 00:00:00 2001 From: lumtis Date: Mon, 13 May 2024 15:54:33 +0200 Subject: [PATCH 19/21] add issue for querier --- x/ibccrosschain/module.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/ibccrosschain/module.go b/x/ibccrosschain/module.go index 16ce056dd1..a6803e3c94 100644 --- a/x/ibccrosschain/module.go +++ b/x/ibccrosschain/module.go @@ -79,6 +79,7 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, _ *run fmt.Println("RegisterQueryHandlerClient err: %w", err) } // TODO: Uncomment once query created + // https://github.com/zeta-chain/node/issues/2166 //err = types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //if err != nil { // fmt.Println("RegisterQueryHandlerClient err: %w", err) From a022a8bc18c52b41d53c923f4e14b62c976acb10 Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Tue, 14 May 2024 08:58:30 +0200 Subject: [PATCH 20/21] Update x/ibccrosschain/client/cli/tx.go Co-authored-by: Tanmay --- x/ibccrosschain/client/cli/tx.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/ibccrosschain/client/cli/tx.go b/x/ibccrosschain/client/cli/tx.go index 6cc099126b..a5c78a32be 100644 --- a/x/ibccrosschain/client/cli/tx.go +++ b/x/ibccrosschain/client/cli/tx.go @@ -8,7 +8,7 @@ import ( "github.com/zeta-chain/zetacore/x/ibccrosschain/types" ) -// GetTxCmd returns the transaction commands for this module +// GetTxCmd returns the transaction commands for ibccrosschain module func GetTxCmd() *cobra.Command { cmd := &cobra.Command{ Use: types.ModuleName, From e75ed92700d24cf7d735b5ce41b6773e32c195e4 Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Tue, 14 May 2024 08:58:35 +0200 Subject: [PATCH 21/21] Update x/ibccrosschain/client/cli/query.go Co-authored-by: Tanmay --- x/ibccrosschain/client/cli/query.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/ibccrosschain/client/cli/query.go b/x/ibccrosschain/client/cli/query.go index 31cf944881..9d4b18dacb 100644 --- a/x/ibccrosschain/client/cli/query.go +++ b/x/ibccrosschain/client/cli/query.go @@ -8,7 +8,7 @@ import ( "github.com/zeta-chain/zetacore/x/ibccrosschain/types" ) -// GetQueryCmd returns the cli query commands for this module +// GetQueryCmd returns the cli query commands for ibccrosschain module func GetQueryCmd(_ string) *cobra.Command { // Group ibccrosschain queries under a subcommand cmd := &cobra.Command{