From 6b4c5f70e22cd1f0383e599c5584b0c0385dabe8 Mon Sep 17 00:00:00 2001 From: cboh4 Date: Fri, 21 Feb 2025 12:59:25 +0200 Subject: [PATCH 1/8] added cron module --- proto/secret/cron/genesis.proto | 16 + proto/secret/cron/params.proto | 15 + proto/secret/cron/query.proto | 63 + proto/secret/cron/schedule.proto | 42 + proto/secret/cron/tx.proto | 86 ++ proto/secret/cron/v1/schedule.proto | 32 + x/cron/client/cli/query.go | 29 + x/cron/client/cli/query_params.go | 35 + x/cron/client/cli/query_schedule.go | 74 + x/cron/client/cli/query_schedule_test.go | 162 +++ x/cron/client/cli/tx.go | 24 + x/cron/genesis.go | 33 + x/cron/genesis_test.go | 38 + x/cron/keeper/grpc_query.go | 7 + x/cron/keeper/grpc_query_params.go | 20 + x/cron/keeper/grpc_query_params_test.go | 22 + x/cron/keeper/grpc_query_schedule.go | 54 + x/cron/keeper/grpc_query_schedule_test.go | 145 ++ x/cron/keeper/keeper.go | 265 ++++ x/cron/keeper/keeper_test.go | 295 ++++ x/cron/keeper/migrations.go | 22 + x/cron/keeper/msg_server.go | 78 ++ x/cron/keeper/msg_server_test.go | 221 +++ x/cron/keeper/params.go | 31 + x/cron/keeper/params_test.go | 30 + x/cron/migrations/v2/store.go | 56 + x/cron/migrations/v2/store_test.go | 60 + x/cron/module.go | 169 +++ x/cron/module_simulation.go | 47 + x/cron/simulation/helpers.go | 15 + x/cron/types/codec.go | 27 + x/cron/types/constants.go | 3 + x/cron/types/errors.go | 12 + x/cron/types/expected_keepers.go | 19 + x/cron/types/genesis.go | 28 + x/cron/types/genesis.pb.go | 385 ++++++ x/cron/types/genesis_test.go | 51 + x/cron/types/keys.go | 31 + x/cron/types/params.go | 106 ++ x/cron/types/params.pb.go | 355 +++++ x/cron/types/query.pb.go | 1391 +++++++++++++++++++ x/cron/types/query.pb.gw.go | 337 +++++ x/cron/types/schedule.pb.go | 912 +++++++++++++ x/cron/types/tx.go | 125 ++ x/cron/types/tx.pb.go | 1511 +++++++++++++++++++++ x/cron/types/types.go | 1 + x/cron/types/v1/schedule.pb.go | 842 ++++++++++++ 47 files changed, 8322 insertions(+) create mode 100644 proto/secret/cron/genesis.proto create mode 100644 proto/secret/cron/params.proto create mode 100644 proto/secret/cron/query.proto create mode 100644 proto/secret/cron/schedule.proto create mode 100644 proto/secret/cron/tx.proto create mode 100644 proto/secret/cron/v1/schedule.proto create mode 100644 x/cron/client/cli/query.go create mode 100644 x/cron/client/cli/query_params.go create mode 100644 x/cron/client/cli/query_schedule.go create mode 100644 x/cron/client/cli/query_schedule_test.go create mode 100644 x/cron/client/cli/tx.go create mode 100644 x/cron/genesis.go create mode 100644 x/cron/genesis_test.go create mode 100644 x/cron/keeper/grpc_query.go create mode 100644 x/cron/keeper/grpc_query_params.go create mode 100644 x/cron/keeper/grpc_query_params_test.go create mode 100644 x/cron/keeper/grpc_query_schedule.go create mode 100644 x/cron/keeper/grpc_query_schedule_test.go create mode 100644 x/cron/keeper/keeper.go create mode 100644 x/cron/keeper/keeper_test.go create mode 100644 x/cron/keeper/migrations.go create mode 100644 x/cron/keeper/msg_server.go create mode 100644 x/cron/keeper/msg_server_test.go create mode 100644 x/cron/keeper/params.go create mode 100644 x/cron/keeper/params_test.go create mode 100644 x/cron/migrations/v2/store.go create mode 100644 x/cron/migrations/v2/store_test.go create mode 100644 x/cron/module.go create mode 100644 x/cron/module_simulation.go create mode 100644 x/cron/simulation/helpers.go create mode 100644 x/cron/types/codec.go create mode 100644 x/cron/types/constants.go create mode 100644 x/cron/types/errors.go create mode 100644 x/cron/types/expected_keepers.go create mode 100644 x/cron/types/genesis.go create mode 100644 x/cron/types/genesis.pb.go create mode 100644 x/cron/types/genesis_test.go create mode 100644 x/cron/types/keys.go create mode 100644 x/cron/types/params.go create mode 100644 x/cron/types/params.pb.go create mode 100644 x/cron/types/query.pb.go create mode 100644 x/cron/types/query.pb.gw.go create mode 100644 x/cron/types/schedule.pb.go create mode 100644 x/cron/types/tx.go create mode 100644 x/cron/types/tx.pb.go create mode 100644 x/cron/types/types.go create mode 100644 x/cron/types/v1/schedule.pb.go diff --git a/proto/secret/cron/genesis.proto b/proto/secret/cron/genesis.proto new file mode 100644 index 000000000..9a570c257 --- /dev/null +++ b/proto/secret/cron/genesis.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package neutron.cron; + +import "gogoproto/gogo.proto"; +import "neutron/cron/params.proto"; +import "neutron/cron/schedule.proto"; +// this line is used by starport scaffolding # genesis/proto/import + +option go_package = "github.com/neutron-org/neutron/v5/x/cron/types"; + +// Defines the cron module's genesis state. +message GenesisState { + repeated Schedule scheduleList = 2 [(gogoproto.nullable) = false]; + Params params = 1 [(gogoproto.nullable) = false]; + // this line is used by starport scaffolding # genesis/proto/state +} diff --git a/proto/secret/cron/params.proto b/proto/secret/cron/params.proto new file mode 100644 index 000000000..0018d73ed --- /dev/null +++ b/proto/secret/cron/params.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package neutron.cron; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/neutron-org/neutron/v5/x/cron/types"; + +// Defines the parameters for the module. +message Params { + option (gogoproto.goproto_stringer) = false; + // Security address that can remove schedules + string security_address = 1; + // Limit of schedules executed in one block + uint64 limit = 2; +} diff --git a/proto/secret/cron/query.proto b/proto/secret/cron/query.proto new file mode 100644 index 000000000..c75045c1e --- /dev/null +++ b/proto/secret/cron/query.proto @@ -0,0 +1,63 @@ +syntax = "proto3"; +package neutron.cron; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "neutron/cron/params.proto"; +import "neutron/cron/schedule.proto"; +// this line is used by starport scaffolding # 1 + +option go_package = "github.com/neutron-org/neutron/v5/x/cron/types"; + +// Defines the gRPC querier service. +service Query { + // Queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/neutron/cron/params"; + } + + // Queries a Schedule by name. + rpc Schedule(QueryGetScheduleRequest) returns (QueryGetScheduleResponse) { + option (google.api.http).get = "/neutron/cron/schedule/{name}"; + } + + // Queries a list of Schedule items. + rpc Schedules(QuerySchedulesRequest) returns (QuerySchedulesResponse) { + option (google.api.http).get = "/neutron/cron/schedule"; + } + + // this line is used by starport scaffolding # 2 +} + +// The request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// The response type for the Query/Params RPC method. +message QueryParamsResponse { + // params holds all the parameters of this module. + Params params = 1 [(gogoproto.nullable) = false]; +} + +// The request type for the Query/Schedule RPC method. +message QueryGetScheduleRequest { + string name = 1; +} + +// The response type for the Query/Params RPC method. +message QueryGetScheduleResponse { + Schedule schedule = 1 [(gogoproto.nullable) = false]; +} + +// The request type for the Query/Schedules RPC method. +message QuerySchedulesRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// The response type for the Query/Params RPC method. +message QuerySchedulesResponse { + repeated Schedule schedules = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// this line is used by starport scaffolding # 3 diff --git a/proto/secret/cron/schedule.proto b/proto/secret/cron/schedule.proto new file mode 100644 index 000000000..7cfa2caa6 --- /dev/null +++ b/proto/secret/cron/schedule.proto @@ -0,0 +1,42 @@ +syntax = "proto3"; +package neutron.cron; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/neutron-org/neutron/v5/x/cron/types"; + +// Defines when messages will be executed in the block +enum ExecutionStage { + // Execution at the end of the block + EXECUTION_STAGE_END_BLOCKER = 0; + // Execution at the beginning of the block + EXECUTION_STAGE_BEGIN_BLOCKER = 1; +} + +// Defines the schedule for execution +message Schedule { + // Name of schedule + string name = 1; + // Period in blocks + uint64 period = 2; + // Msgs that will be executed every certain number of blocks, specified in the `period` field + repeated MsgExecuteContract msgs = 3 [(gogoproto.nullable) = false]; + // Last execution's block height + uint64 last_execute_height = 4; + // Stage when messages will be executed + ExecutionStage execution_stage = 5; +} + +// Defines the contract and the message to pass +message MsgExecuteContract { + // The address of the smart contract + string contract = 1; + // JSON encoded message to be passed to the contract + string msg = 2; +} + +// Defines the number of current schedules +message ScheduleCount { + // The number of current schedules + int32 count = 1; +} diff --git a/proto/secret/cron/tx.proto b/proto/secret/cron/tx.proto new file mode 100644 index 000000000..be869cdd8 --- /dev/null +++ b/proto/secret/cron/tx.proto @@ -0,0 +1,86 @@ +syntax = "proto3"; +package neutron.cron; + +import "amino/amino.proto"; +import "cosmos/msg/v1/msg.proto"; +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "neutron/cron/params.proto"; +import "neutron/cron/schedule.proto"; + +// this line is used by starport scaffolding # proto/tx/import + +option go_package = "github.com/neutron-org/neutron/v5/x/cron/types"; + +// Defines the Msg service. +service Msg { + option (cosmos.msg.v1.service) = true; + + // Adds new schedule. + rpc AddSchedule(MsgAddSchedule) returns (MsgAddScheduleResponse); + // Removes schedule. + rpc RemoveSchedule(MsgRemoveSchedule) returns (MsgRemoveScheduleResponse); + // Updates the module parameters. + rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); + // this line is used by starport scaffolding # proto/tx/rpc +} + +// The MsgAddSchedule request type. +message MsgAddSchedule { + option (amino.name) = "cron/MsgAddSchedule"; + option (cosmos.msg.v1.signer) = "authority"; + + // The address of the governance account. + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // Name of the schedule + string name = 2; + // Period in blocks + uint64 period = 3; + // Msgs that will be executed every certain number of blocks, specified in the `period` field + repeated MsgExecuteContract msgs = 4 [(gogoproto.nullable) = false]; + // Stage when messages will be executed + ExecutionStage execution_stage = 5; +} + +// Defines the response structure for executing a MsgAddSchedule message. +message MsgAddScheduleResponse {} + +// The MsgRemoveSchedule request type. +message MsgRemoveSchedule { + option (amino.name) = "cron/MsgRemoveSchedule"; + option (cosmos.msg.v1.signer) = "authority"; + + // The address of the governance account. + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // Name of the schedule + string name = 2; +} + +// Defines the response structure for executing a MsgRemoveSchedule message. +message MsgRemoveScheduleResponse {} + +// this line is used by starport scaffolding # proto/tx/message + +// The MsgUpdateParams request type. +// +// Since: 0.47 +message MsgUpdateParams { + option (amino.name) = "cron/MsgUpdateParams"; + option (cosmos.msg.v1.signer) = "authority"; + + // The address of the governance account. + string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // Defines the x/cron parameters to update. + // + // NOTE: All parameters must be supplied. + Params params = 2 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; +} + +// Defines the response structure for executing a MsgUpdateParams message. +// +// Since: 0.47 +message MsgUpdateParamsResponse {} diff --git a/proto/secret/cron/v1/schedule.proto b/proto/secret/cron/v1/schedule.proto new file mode 100644 index 000000000..3593f5058 --- /dev/null +++ b/proto/secret/cron/v1/schedule.proto @@ -0,0 +1,32 @@ +syntax = "proto3"; +package neutron.cron.v1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/neutron-org/neutron/v5/x/cron/types/v1"; + +// Defines the schedule for execution +message Schedule { + // Name of schedule + string name = 1; + // Period in blocks + uint64 period = 2; + // Msgs that will be executed every certain number of blocks, specified in the `period` field + repeated MsgExecuteContract msgs = 3 [(gogoproto.nullable) = false]; + // Last execution's block height + uint64 last_execute_height = 4; +} + +// Defines the contract and the message to pass +message MsgExecuteContract { + // The address of the smart contract + string contract = 1; + // JSON encoded message to be passed to the contract + string msg = 2; +} + +// Defines the number of current schedules +message ScheduleCount { + // The number of current schedules + int32 count = 1; +} diff --git a/x/cron/client/cli/query.go b/x/cron/client/cli/query.go new file mode 100644 index 000000000..0b8d433e1 --- /dev/null +++ b/x/cron/client/cli/query.go @@ -0,0 +1,29 @@ +package cli + +import ( + "fmt" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(_ string) *cobra.Command { + // Group cron 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(CmdQueryParams()) + cmd.AddCommand(CmdListSchedule()) + cmd.AddCommand(CmdShowSchedule()) + + return cmd +} diff --git a/x/cron/client/cli/query_params.go b/x/cron/client/cli/query_params.go new file mode 100644 index 000000000..0500a73ce --- /dev/null +++ b/x/cron/client/cli/query_params.go @@ -0,0 +1,35 @@ +package cli + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/cron/client/cli/query_schedule.go b/x/cron/client/cli/query_schedule.go new file mode 100644 index 000000000..08142d832 --- /dev/null +++ b/x/cron/client/cli/query_schedule.go @@ -0,0 +1,74 @@ +package cli + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +func CmdListSchedule() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-schedule", + Short: "list all schedule", + RunE: func(cmd *cobra.Command, _ []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QuerySchedulesRequest{ + Pagination: pageReq, + } + + res, err := queryClient.Schedules(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddPaginationFlagsToCmd(cmd, cmd.Use) + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdShowSchedule() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-schedule [name]", + Short: "shows a schedule", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + argName := args[0] + + params := &types.QueryGetScheduleRequest{ + Name: argName, + } + + res, err := queryClient.Schedule(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/cron/client/cli/query_schedule_test.go b/x/cron/client/cli/query_schedule_test.go new file mode 100644 index 000000000..27970dd18 --- /dev/null +++ b/x/cron/client/cli/query_schedule_test.go @@ -0,0 +1,162 @@ +package cli_test + +import ( + "fmt" + "strconv" + "testing" + + tmcli "github.com/cometbft/cometbft/libs/cli" + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/neutron-org/neutron/v5/testutil/common/nullify" + "github.com/neutron-org/neutron/v5/testutil/cron/network" + "github.com/neutron-org/neutron/v5/x/cron/client/cli" + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +func networkWithScheduleObjects(t *testing.T, n int) (*network.Network, []types.Schedule) { + t.Helper() + cfg := network.DefaultConfig() + state := types.GenesisState{} + require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state)) + + for i := 0; i < n; i++ { + schedule := types.Schedule{ + Name: strconv.Itoa(i), + Period: 1000, + Msgs: []types.MsgExecuteContract{}, + LastExecuteHeight: uint64(0), + } + state.ScheduleList = append(state.ScheduleList, schedule) + } + state.Params = types.DefaultParams() + buf, err := cfg.Codec.MarshalJSON(&state) + require.NoError(t, err) + cfg.GenesisState[types.ModuleName] = buf + return network.New(t, cfg), state.ScheduleList +} + +func TestShowSchedule(t *testing.T) { + net, objs := networkWithScheduleObjects(t, 2) + + ctx := net.Validators[0].ClientCtx + common := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + for _, tc := range []struct { + desc string + name string + + args []string + err error + obj types.Schedule + }{ + { + desc: "found", + name: objs[0].Name, + + args: common, + obj: objs[0], + err: nil, + }, + { + desc: "not found", + name: strconv.Itoa(100000), + + args: common, + err: status.Error(codes.NotFound, "not found"), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + args := []string{ + tc.name, + } + args = append(args, tc.args...) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowSchedule(), args) + if tc.err != nil { + stat, ok := status.FromError(tc.err) + require.True(t, ok) + require.ErrorIs(t, stat.Err(), tc.err) + } else { + require.NoError(t, err) + var resp types.QueryGetScheduleResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NotNil(t, resp.Schedule) + require.Equal(t, + nullify.Fill(&tc.obj), + nullify.Fill(&resp.Schedule), + ) + } + }) + } +} + +func TestListSchedule(t *testing.T) { + net, objs := networkWithScheduleObjects(t, 5) + + ctx := net.Validators[0].ClientCtx + request := func(next []byte, offset, limit uint64, total bool) []string { + args := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + if next == nil { + args = append(args, fmt.Sprintf("--%s=%d", flags.FlagOffset, offset)) + } else { + args = append(args, fmt.Sprintf("--%s=%s", flags.FlagPageKey, next)) + } + args = append(args, fmt.Sprintf("--%s=%d", flags.FlagLimit, limit)) + if total { + args = append(args, fmt.Sprintf("--%s", flags.FlagCountTotal)) + } + return args + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(objs); i += step { + args := request(nil, uint64(i), uint64(step), false) //nolint:gosec + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListSchedule(), args) + require.NoError(t, err) + var resp types.QuerySchedulesResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.LessOrEqual(t, len(resp.Schedules), step) + require.Subset(t, + nullify.Fill(objs), + nullify.Fill(resp.Schedules), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(objs); i += step { + args := request(next, 0, uint64(step), false) //nolint:gosec + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListSchedule(), args) + require.NoError(t, err) + var resp types.QuerySchedulesResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.LessOrEqual(t, len(resp.Schedules), step) + require.Subset(t, + nullify.Fill(objs), + nullify.Fill(resp.Schedules), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + args := request(nil, 0, uint64(len(objs)), true) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListSchedule(), args) + require.NoError(t, err) + var resp types.QuerySchedulesResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NoError(t, err) + require.Equal(t, len(objs), int(resp.Pagination.Total)) //nolint:gosec + require.ElementsMatch(t, + nullify.Fill(objs), + nullify.Fill(resp.Schedules), + ) + }) +} diff --git a/x/cron/client/cli/tx.go b/x/cron/client/cli/tx.go new file mode 100644 index 000000000..565daeb0d --- /dev/null +++ b/x/cron/client/cli/tx.go @@ -0,0 +1,24 @@ +package cli + +import ( + "fmt" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + + "github.com/neutron-org/neutron/v5/x/cron/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, + } + + return cmd +} diff --git a/x/cron/genesis.go b/x/cron/genesis.go new file mode 100644 index 000000000..78b82c5ae --- /dev/null +++ b/x/cron/genesis.go @@ -0,0 +1,33 @@ +package cron + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/neutron-org/neutron/v5/x/cron/keeper" + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +// InitGenesis initializes the module's state from a provided genesis state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // Set all the schedules + for _, elem := range genState.ScheduleList { + err := k.AddSchedule(ctx, elem.Name, elem.Period, elem.Msgs, elem.ExecutionStage) + if err != nil { + panic(err) + } + } + // this line is used by starport scaffolding # genesis/module/init + err := k.SetParams(ctx, genState.Params) + if err != nil { + panic(err) + } +} + +// ExportGenesis returns the module's exported genesis +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) + genesis.ScheduleList = k.GetAllSchedules(ctx) + + return genesis +} diff --git a/x/cron/genesis_test.go b/x/cron/genesis_test.go new file mode 100644 index 000000000..9ec174bbe --- /dev/null +++ b/x/cron/genesis_test.go @@ -0,0 +1,38 @@ +package cron_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/neutron-org/neutron/v5/testutil/common/nullify" + "github.com/neutron-org/neutron/v5/testutil/cron/keeper" + "github.com/neutron-org/neutron/v5/x/cron" + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +func TestGenesis(t *testing.T) { + k, ctx := keeper.CronKeeper(t, nil, nil) + + genesisState := types.GenesisState{ + Params: types.DefaultParams(), + ScheduleList: []types.Schedule{ + { + Name: "a", + Period: 5, + Msgs: nil, + LastExecuteHeight: uint64(ctx.BlockHeight()), //nolint:gosec + }, + }, + } + + cron.InitGenesis(ctx, *k, genesisState) + got := cron.ExportGenesis(ctx, *k) + require.NotNil(t, got) + + nullify.Fill(&genesisState) + nullify.Fill(got) + + require.Equal(t, genesisState.Params, got.Params) + require.ElementsMatch(t, genesisState.ScheduleList, got.ScheduleList) +} diff --git a/x/cron/keeper/grpc_query.go b/x/cron/keeper/grpc_query.go new file mode 100644 index 000000000..50017a573 --- /dev/null +++ b/x/cron/keeper/grpc_query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +var _ types.QueryServer = Keeper{} diff --git a/x/cron/keeper/grpc_query_params.go b/x/cron/keeper/grpc_query_params.go new file mode 100644 index 000000000..a646a7abb --- /dev/null +++ b/x/cron/keeper/grpc_query_params.go @@ -0,0 +1,20 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} diff --git a/x/cron/keeper/grpc_query_params_test.go b/x/cron/keeper/grpc_query_params_test.go new file mode 100644 index 000000000..64d1d4a13 --- /dev/null +++ b/x/cron/keeper/grpc_query_params_test.go @@ -0,0 +1,22 @@ +package keeper_test + +import ( + "testing" + + testkeeper "github.com/neutron-org/neutron/v5/testutil/cron/keeper" + + "github.com/stretchr/testify/require" + + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +func TestParamsQuery(t *testing.T) { + keeper, ctx := testkeeper.CronKeeper(t, nil, nil) + params := types.DefaultParams() + err := keeper.SetParams(ctx, params) + require.NoError(t, err) + + response, err := keeper.Params(ctx, &types.QueryParamsRequest{}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsResponse{Params: params}, response) +} diff --git a/x/cron/keeper/grpc_query_schedule.go b/x/cron/keeper/grpc_query_schedule.go new file mode 100644 index 000000000..4b4d1d5ee --- /dev/null +++ b/x/cron/keeper/grpc_query_schedule.go @@ -0,0 +1,54 @@ +package keeper + +import ( + "context" + + "cosmossdk.io/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +func (k Keeper) Schedules(c context.Context, req *types.QuerySchedulesRequest) (*types.QuerySchedulesResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + var schedules []types.Schedule + ctx := sdk.UnwrapSDKContext(c) + + scheduleStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.ScheduleKey) + + pageRes, err := query.Paginate(scheduleStore, req.Pagination, func(_, value []byte) error { + var schedule types.Schedule + k.cdc.MustUnmarshal(value, &schedule) + + schedules = append(schedules, schedule) + return nil + }) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QuerySchedulesResponse{Schedules: schedules, Pagination: pageRes}, nil +} + +func (k Keeper) Schedule(c context.Context, req *types.QueryGetScheduleRequest) (*types.QueryGetScheduleResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + val, found := k.GetSchedule( + ctx, + req.Name, + ) + if !found { + return nil, status.Error(codes.NotFound, "schedule not found") + } + + return &types.QueryGetScheduleResponse{Schedule: *val}, nil +} diff --git a/x/cron/keeper/grpc_query_schedule_test.go b/x/cron/keeper/grpc_query_schedule_test.go new file mode 100644 index 000000000..86eaf179a --- /dev/null +++ b/x/cron/keeper/grpc_query_schedule_test.go @@ -0,0 +1,145 @@ +package keeper_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/neutron-org/neutron/v5/testutil/common/nullify" + testutil_keeper "github.com/neutron-org/neutron/v5/testutil/cron/keeper" + cronkeeper "github.com/neutron-org/neutron/v5/x/cron/keeper" + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestScheduleQuerySingle(t *testing.T) { + k, ctx := testutil_keeper.CronKeeper(t, nil, nil) + schedules := createNSchedule(t, ctx, k, 2) + + for _, tc := range []struct { + desc string + request *types.QueryGetScheduleRequest + response *types.QueryGetScheduleResponse + err error + }{ + { + desc: "First", + request: &types.QueryGetScheduleRequest{ + Name: schedules[0].Name, + }, + response: &types.QueryGetScheduleResponse{Schedule: schedules[0]}, + }, + { + desc: "Second", + request: &types.QueryGetScheduleRequest{ + Name: schedules[1].Name, + }, + response: &types.QueryGetScheduleResponse{Schedule: schedules[1]}, + }, + { + desc: "KeyIsAbsent", + request: &types.QueryGetScheduleRequest{ + Name: "absent_key", + }, + err: status.Error(codes.NotFound, "schedule not found"), + }, + { + desc: "InvalidRequest", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + response, err := k.Schedule(ctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} + +func TestScheduleQueryPaginated(t *testing.T) { + k, ctx := testutil_keeper.CronKeeper(t, nil, nil) + schedules := createNSchedule(t, ctx, k, 5) + + request := func(next []byte, offset, limit uint64, total bool) *types.QuerySchedulesRequest { + return &types.QuerySchedulesRequest{ + Pagination: &query.PageRequest{ + Key: next, + Offset: offset, + Limit: limit, + CountTotal: total, + }, + } + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(schedules); i += step { + resp, err := k.Schedules(ctx, request(nil, uint64(i), uint64(step), false)) //nolint:gosec + require.NoError(t, err) + require.LessOrEqual(t, len(resp.Schedules), step) + require.Subset(t, + nullify.Fill(schedules), + nullify.Fill(resp.Schedules), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(schedules); i += step { + resp, err := k.Schedules(ctx, request(next, 0, uint64(step), false)) //nolint:gosec + require.NoError(t, err) + require.LessOrEqual(t, len(resp.Schedules), step) + require.Subset(t, + nullify.Fill(schedules), + nullify.Fill(resp.Schedules), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + resp, err := k.Schedules(ctx, request(nil, 0, 0, true)) + require.NoError(t, err) + require.Equal(t, len(schedules), int(resp.Pagination.Total)) //nolint:gosec + require.ElementsMatch(t, + nullify.Fill(schedules), + nullify.Fill(resp.Schedules), + ) + }) + t.Run("InvalidRequest", func(t *testing.T) { + _, err := k.Schedules(ctx, nil) + require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + }) +} + +func createNSchedule(t *testing.T, ctx sdk.Context, k *cronkeeper.Keeper, n int32) []types.Schedule { + res := make([]types.Schedule, n) + + for idx, item := range res { + item.Name = strconv.Itoa(idx) + item.Period = 1000 + item.Msgs = nil + item.LastExecuteHeight = uint64(ctx.BlockHeight()) //nolint:gosec + item.ExecutionStage = types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER + + err := k.AddSchedule(ctx, item.Name, item.Period, item.Msgs, item.ExecutionStage) + require.NoError(t, err) + + res[idx] = item + } + + return res +} diff --git a/x/cron/keeper/keeper.go b/x/cron/keeper/keeper.go new file mode 100644 index 000000000..61fa71ac4 --- /dev/null +++ b/x/cron/keeper/keeper.go @@ -0,0 +1,265 @@ +package keeper + +import ( + "fmt" + "strconv" + "time" + + "cosmossdk.io/log" + "github.com/hashicorp/go-metrics" + + "github.com/cosmos/cosmos-sdk/telemetry" + + "cosmossdk.io/store/prefix" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +var ( + LabelExecuteReadySchedules = "execute_ready_schedules" + LabelScheduleCount = "schedule_count" + LabelScheduleExecutionsCount = "schedule_executions_count" + + MetricLabelSuccess = "success" + MetricLabelScheduleName = "schedule_name" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + accountKeeper types.AccountKeeper + WasmMsgServer types.WasmMsgServer + authority string + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey, + memKey storetypes.StoreKey, + accountKeeper types.AccountKeeper, + authority string, +) *Keeper { + return &Keeper{ + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + accountKeeper: accountKeeper, + authority: authority, + } +} + +func (k Keeper) GetAuthority() string { + return k.authority +} + +func (k *Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +// ExecuteReadySchedules gets all schedules that are due for execution (with limit that is equal to Params.Limit) +// and executes messages in each one +func (k *Keeper) ExecuteReadySchedules(ctx sdk.Context, executionStage types.ExecutionStage) { + telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), LabelExecuteReadySchedules) + schedules := k.getSchedulesReadyForExecution(ctx, executionStage) + + for _, schedule := range schedules { + err := k.executeSchedule(ctx, schedule) + recordExecutedSchedule(err, schedule) + } +} + +// AddSchedule adds a new schedule to be executed every certain number of blocks, specified in the `period`. +// First schedule execution is supposed to be on `now + period` block. +func (k *Keeper) AddSchedule( + ctx sdk.Context, + name string, + period uint64, + msgs []types.MsgExecuteContract, + executionStage types.ExecutionStage, +) error { + if k.scheduleExists(ctx, name) { + return fmt.Errorf("schedule already exists with name=%v", name) + } + + schedule := types.Schedule{ + Name: name, + Period: period, + Msgs: msgs, + // let's execute newly added schedule on `now + period` block + LastExecuteHeight: uint64(ctx.BlockHeight()), //nolint:gosec + ExecutionStage: executionStage, + } + + k.storeSchedule(ctx, schedule) + k.changeTotalCount(ctx, 1) + + return nil +} + +// RemoveSchedule removes schedule with a given `name` +func (k *Keeper) RemoveSchedule(ctx sdk.Context, name string) { + if !k.scheduleExists(ctx, name) { + return + } + + k.changeTotalCount(ctx, -1) + k.removeSchedule(ctx, name) +} + +// GetSchedule returns schedule with a given `name` +func (k *Keeper) GetSchedule(ctx sdk.Context, name string) (*types.Schedule, bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.ScheduleKey) + bzSchedule := store.Get(types.GetScheduleKey(name)) + if bzSchedule == nil { + return nil, false + } + + var schedule types.Schedule + k.cdc.MustUnmarshal(bzSchedule, &schedule) + return &schedule, true +} + +// GetAllSchedules returns all schedules +func (k *Keeper) GetAllSchedules(ctx sdk.Context) []types.Schedule { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.ScheduleKey) + + res := make([]types.Schedule, 0) + + iterator := storetypes.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var schedule types.Schedule + k.cdc.MustUnmarshal(iterator.Value(), &schedule) + res = append(res, schedule) + } + + return res +} + +func (k *Keeper) GetScheduleCount(ctx sdk.Context) int32 { + return k.getScheduleCount(ctx) +} + +func (k *Keeper) getSchedulesReadyForExecution(ctx sdk.Context, executionStage types.ExecutionStage) []types.Schedule { + params := k.GetParams(ctx) + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.ScheduleKey) + count := uint64(0) + + res := make([]types.Schedule, 0) + + iterator := storetypes.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var schedule types.Schedule + k.cdc.MustUnmarshal(iterator.Value(), &schedule) + + if k.intervalPassed(ctx, schedule) && schedule.ExecutionStage == executionStage { + res = append(res, schedule) + count++ + + if count >= params.Limit { + k.Logger(ctx).Info("limit of schedule executions per block reached") + return res + } + } + } + + return res +} + +// executeSchedule executes all msgs in a given schedule and changes LastExecuteHeight +// if at least one msg execution fails, rollback all messages +func (k *Keeper) executeSchedule(ctx sdk.Context, schedule types.Schedule) error { + // Even if contract execution returned an error, we still increase the height + // and execute it after this interval + schedule.LastExecuteHeight = uint64(ctx.BlockHeight()) //nolint:gosec + k.storeSchedule(ctx, schedule) + + cacheCtx, writeFn := ctx.CacheContext() + + for idx, msg := range schedule.Msgs { + executeMsg := wasmtypes.MsgExecuteContract{ + Sender: k.accountKeeper.GetModuleAddress(types.ModuleName).String(), + Contract: msg.Contract, + Msg: []byte(msg.Msg), + Funds: sdk.NewCoins(), + } + _, err := k.WasmMsgServer.ExecuteContract(cacheCtx, &executeMsg) + if err != nil { + ctx.Logger().Info("executeSchedule: failed to execute contract msg", + "schedule_name", schedule.Name, + "msg_idx", idx, + "msg_contract", msg.Contract, + "msg", msg.Msg, + "error", err, + ) + return err + } + } + + // only save state if all the messages in a schedule were executed successfully + writeFn() + return nil +} + +func (k *Keeper) storeSchedule(ctx sdk.Context, schedule types.Schedule) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.ScheduleKey) + + bzSchedule := k.cdc.MustMarshal(&schedule) + store.Set(types.GetScheduleKey(schedule.Name), bzSchedule) +} + +func (k *Keeper) removeSchedule(ctx sdk.Context, name string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.ScheduleKey) + + store.Delete(types.GetScheduleKey(name)) +} + +func (k *Keeper) scheduleExists(ctx sdk.Context, name string) bool { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.ScheduleKey) + return store.Has(types.GetScheduleKey(name)) +} + +func (k *Keeper) intervalPassed(ctx sdk.Context, schedule types.Schedule) bool { + return uint64(ctx.BlockHeight()) > (schedule.LastExecuteHeight + schedule.Period) //nolint:gosec +} + +func (k *Keeper) changeTotalCount(ctx sdk.Context, incrementAmount int32) { + store := ctx.KVStore(k.storeKey) + count := k.getScheduleCount(ctx) + newCount := types.ScheduleCount{Count: count + incrementAmount} + bzCount := k.cdc.MustMarshal(&newCount) + store.Set(types.ScheduleCountKey, bzCount) + + telemetry.ModuleSetGauge(types.ModuleName, float32(newCount.Count), LabelScheduleCount) +} + +func (k *Keeper) getScheduleCount(ctx sdk.Context) int32 { + store := ctx.KVStore(k.storeKey) + bzCount := store.Get(types.ScheduleCountKey) + if bzCount == nil { + return 0 + } + + var count types.ScheduleCount + k.cdc.MustUnmarshal(bzCount, &count) + return count.Count +} + +func recordExecutedSchedule(err error, schedule types.Schedule) { + telemetry.IncrCounterWithLabels([]string{LabelScheduleExecutionsCount}, 1, []metrics.Label{ + telemetry.NewLabel(telemetry.MetricLabelNameModule, types.ModuleName), + telemetry.NewLabel(MetricLabelSuccess, strconv.FormatBool(err == nil)), + telemetry.NewLabel(MetricLabelScheduleName, schedule.Name), + }) +} diff --git a/x/cron/keeper/keeper_test.go b/x/cron/keeper/keeper_test.go new file mode 100644 index 000000000..4882f7ae4 --- /dev/null +++ b/x/cron/keeper/keeper_test.go @@ -0,0 +1,295 @@ +package keeper_test + +import ( + "fmt" + "strconv" + "testing" + + "github.com/stretchr/testify/assert" + + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" + + "github.com/neutron-org/neutron/v5/testutil" + testutil_keeper "github.com/neutron-org/neutron/v5/testutil/cron/keeper" + mock_types "github.com/neutron-org/neutron/v5/testutil/mocks/cron/types" + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +// ExecuteReadySchedules: +// - calls msgServer.execute() on ready schedules +// - updates ready schedules lastExecuteHeight +// - does not update lastExecuteHeight of unready schedules +// - does not go over the limit +func TestKeeperExecuteReadySchedules(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + accountKeeper := mock_types.NewMockAccountKeeper(ctrl) + addr, err := sdk.AccAddressFromBech32(testutil.TestOwnerAddress) + require.NoError(t, err) + + wasmMsgServer := mock_types.NewMockWasmMsgServer(ctrl) + k, ctx := testutil_keeper.CronKeeper(t, wasmMsgServer, accountKeeper) + ctx = ctx.WithBlockHeight(0) + + err = k.SetParams(ctx, types.Params{ + SecurityAddress: testutil.TestOwnerAddress, + Limit: 2, + }) + require.NoError(t, err) + + schedules := []types.Schedule{ + { + Name: "1_unready1", + Period: 10, + Msgs: []types.MsgExecuteContract{ + { + Contract: "1_neutron", + Msg: "1_msg", + }, + }, + LastExecuteHeight: 4, + ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER, + }, + { + Name: "2_ready1", + Period: 4, + Msgs: []types.MsgExecuteContract{ + { + Contract: "2_neutron", + Msg: "2_msg", + }, + }, + LastExecuteHeight: 0, + ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER, + }, + { + Name: "3_ready2", + Period: 4, + Msgs: []types.MsgExecuteContract{ + { + Contract: "3_neutron", + Msg: "3_msg", + }, + }, + LastExecuteHeight: 0, + ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER, + }, + { + Name: "4_unready2", + Period: 10, + Msgs: []types.MsgExecuteContract{}, + LastExecuteHeight: 4, + ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER, + }, + { + Name: "5_ready3", + Period: 3, + Msgs: []types.MsgExecuteContract{ + { + Contract: "5_neutron", + Msg: "5_msg", + }, + }, + LastExecuteHeight: 0, + ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER, + }, + { + Name: "6_ready4", + Period: 3, + Msgs: []types.MsgExecuteContract{ + { + Contract: "6_neutron", + Msg: "6_msg", + }, + }, + LastExecuteHeight: 0, + ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER, + }, + } + + for _, item := range schedules { + ctx = ctx.WithBlockHeight(int64(item.LastExecuteHeight)) //nolint:gosec + err := k.AddSchedule(ctx, item.Name, item.Period, item.Msgs, item.ExecutionStage) + require.NoError(t, err) + } + + count := k.GetScheduleCount(ctx) + require.Equal(t, count, int32(6)) + + ctx = ctx.WithBlockHeight(5) + + accountKeeper.EXPECT().GetModuleAddress(types.ModuleName).Return(addr).AnyTimes() + wasmMsgServer.EXPECT().ExecuteContract(gomock.Any(), &wasmtypes.MsgExecuteContract{ + Sender: testutil.TestOwnerAddress, + Contract: "2_neutron", + Msg: []byte("2_msg"), + Funds: sdk.NewCoins(), + }).Return(nil, fmt.Errorf("executeerror")) + wasmMsgServer.EXPECT().ExecuteContract(gomock.Any(), &wasmtypes.MsgExecuteContract{ + Sender: testutil.TestOwnerAddress, + Contract: "3_neutron", + Msg: []byte("3_msg"), + Funds: sdk.NewCoins(), + }).Return(&wasmtypes.MsgExecuteContractResponse{}, nil) + + k.ExecuteReadySchedules(ctx, types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER) + + unready1, _ := k.GetSchedule(ctx, "1_unready1") + ready1, _ := k.GetSchedule(ctx, "2_ready1") + ready2, _ := k.GetSchedule(ctx, "3_ready2") + unready2, _ := k.GetSchedule(ctx, "4_unready2") + ready3, _ := k.GetSchedule(ctx, "5_ready3") + ready4, _ := k.GetSchedule(ctx, "6_ready4") + + require.Equal(t, uint64(4), unready1.LastExecuteHeight) + require.Equal(t, uint64(5), ready1.LastExecuteHeight) + require.Equal(t, uint64(5), ready2.LastExecuteHeight) + require.Equal(t, uint64(4), unready2.LastExecuteHeight) + require.Equal(t, uint64(0), ready3.LastExecuteHeight) + require.Equal(t, uint64(0), ready4.LastExecuteHeight) + + // let's make another call at the next height + // Notice that now only one ready schedule left because we got limit of 2 at once + ctx = ctx.WithBlockHeight(6) + + wasmMsgServer.EXPECT().ExecuteContract(gomock.Any(), &wasmtypes.MsgExecuteContract{ + Sender: testutil.TestOwnerAddress, + Contract: "5_neutron", + Msg: []byte("5_msg"), + Funds: sdk.NewCoins(), + }).Return(&wasmtypes.MsgExecuteContractResponse{}, nil) + + k.ExecuteReadySchedules(ctx, types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER) + + unready1, _ = k.GetSchedule(ctx, "1_unready1") + ready1, _ = k.GetSchedule(ctx, "2_ready1") + ready2, _ = k.GetSchedule(ctx, "3_ready2") + unready2, _ = k.GetSchedule(ctx, "4_unready2") + ready3, _ = k.GetSchedule(ctx, "5_ready3") + ready4, _ = k.GetSchedule(ctx, "6_ready4") + + require.Equal(t, uint64(4), unready1.LastExecuteHeight) + require.Equal(t, uint64(5), ready1.LastExecuteHeight) + require.Equal(t, uint64(5), ready2.LastExecuteHeight) + require.Equal(t, uint64(4), unready2.LastExecuteHeight) + require.Equal(t, uint64(6), ready3.LastExecuteHeight) + require.Equal(t, uint64(0), ready4.LastExecuteHeight) + + ctx = ctx.WithBlockHeight(7) + + wasmMsgServer.EXPECT().ExecuteContract(gomock.Any(), &wasmtypes.MsgExecuteContract{ + Sender: testutil.TestOwnerAddress, + Contract: "6_neutron", + Msg: []byte("6_msg"), + Funds: sdk.NewCoins(), + }).Return(&wasmtypes.MsgExecuteContractResponse{}, nil) + + k.ExecuteReadySchedules(ctx, types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER) + + unready1, _ = k.GetSchedule(ctx, "1_unready1") + ready1, _ = k.GetSchedule(ctx, "2_ready1") + ready2, _ = k.GetSchedule(ctx, "3_ready2") + unready2, _ = k.GetSchedule(ctx, "4_unready2") + ready3, _ = k.GetSchedule(ctx, "5_ready3") + ready4, _ = k.GetSchedule(ctx, "6_ready4") + + require.Equal(t, uint64(4), unready1.LastExecuteHeight) + require.Equal(t, uint64(5), ready1.LastExecuteHeight) + require.Equal(t, uint64(5), ready2.LastExecuteHeight) + require.Equal(t, uint64(4), unready2.LastExecuteHeight) + require.Equal(t, uint64(6), ready3.LastExecuteHeight) + require.Equal(t, uint64(7), ready4.LastExecuteHeight) +} + +func TestAddSchedule(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + accountKeeper := mock_types.NewMockAccountKeeper(ctrl) + + wasmMsgServer := mock_types.NewMockWasmMsgServer(ctrl) + k, ctx := testutil_keeper.CronKeeper(t, wasmMsgServer, accountKeeper) + ctx = ctx.WithBlockHeight(0) + + err := k.SetParams(ctx, types.Params{ + SecurityAddress: testutil.TestOwnerAddress, + Limit: 2, + }) + require.NoError(t, err) + + // normal add schedule + err = k.AddSchedule(ctx, "a", 7, []types.MsgExecuteContract{ + { + Contract: "c", + Msg: "m", + }, + }, types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER) + require.NoError(t, err) + + err = k.AddSchedule(ctx, "b", 7, []types.MsgExecuteContract{ + { + Contract: "c", + Msg: "m", + }, + }, types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER) + require.NoError(t, err) + + // second time with same name returns error + err = k.AddSchedule(ctx, "a", 5, []types.MsgExecuteContract{}, types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER) + require.Error(t, err) + + scheduleA, found := k.GetSchedule(ctx, "a") + require.True(t, found) + require.Equal(t, scheduleA.Name, "a") + require.Equal(t, scheduleA.Period, uint64(7)) + require.Equal(t, scheduleA.Msgs, []types.MsgExecuteContract{ + {Contract: "c", Msg: "m"}, + }) + require.Equal(t, scheduleA.ExecutionStage, types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER) + + schedules := k.GetAllSchedules(ctx) + require.Len(t, schedules, 2) + require.Equal(t, schedules[0].ExecutionStage, types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER) + require.Equal(t, schedules[1].ExecutionStage, types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER) + + // remove schedule works + k.RemoveSchedule(ctx, "a") + _, found = k.GetSchedule(ctx, "a") + assert.False(t, found) + + // does not panic even though we don't have it + k.RemoveSchedule(ctx, "a") +} + +func TestGetAllSchedules(t *testing.T) { + k, ctx := testutil_keeper.CronKeeper(t, nil, nil) + + err := k.SetParams(ctx, types.Params{ + SecurityAddress: testutil.TestOwnerAddress, + Limit: 2, + }) + require.NoError(t, err) + + expectedSchedules := make([]types.Schedule, 0, 3) + for i := range []int{1, 2, 3} { + s := types.Schedule{ + Name: strconv.Itoa(i), + Period: 5, + Msgs: nil, + LastExecuteHeight: uint64(ctx.BlockHeight()), //nolint:gosec + ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER, + } + expectedSchedules = append(expectedSchedules, s) + err := k.AddSchedule(ctx, s.Name, s.Period, s.Msgs, s.ExecutionStage) + require.NoError(t, err) + } + + schedules := k.GetAllSchedules(ctx) + assert.Equal(t, 3, len(schedules)) + assert.ElementsMatch(t, schedules, expectedSchedules) + assert.Equal(t, int32(3), k.GetScheduleCount(ctx)) +} diff --git a/x/cron/keeper/migrations.go b/x/cron/keeper/migrations.go new file mode 100644 index 000000000..b4c394bb1 --- /dev/null +++ b/x/cron/keeper/migrations.go @@ -0,0 +1,22 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + v2 "github.com/neutron-org/neutron/v5/x/cron/migrations/v2" +) + +// Migrator is a struct for handling in-place store migrations. +type Migrator struct { + keeper Keeper +} + +// NewMigrator returns a new Migrator. +func NewMigrator(keeper Keeper) Migrator { + return Migrator{keeper: keeper} +} + +// Migrate1to2 migrates from version 1 to 2. +func (m Migrator) Migrate1to2(ctx sdk.Context) error { + return v2.MigrateStore(ctx, m.keeper.cdc, m.keeper.storeKey) +} diff --git a/x/cron/keeper/msg_server.go b/x/cron/keeper/msg_server.go new file mode 100644 index 000000000..ccb0bcbc4 --- /dev/null +++ b/x/cron/keeper/msg_server.go @@ -0,0 +1,78 @@ +package keeper + +import ( + "context" + + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +type msgServer struct { + keeper Keeper +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{keeper: keeper} +} + +var _ types.MsgServer = msgServer{} + +// AddSchedule adds new schedule +func (k msgServer) AddSchedule(goCtx context.Context, req *types.MsgAddSchedule) (*types.MsgAddScheduleResponse, error) { + if err := req.Validate(); err != nil { + return nil, errors.Wrap(err, "failed to validate MsgAddSchedule") + } + + authority := k.keeper.GetAuthority() + if authority != req.Authority { + return nil, errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid authority; expected %s, got %s", authority, req.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + if err := k.keeper.AddSchedule(ctx, req.Name, req.Period, req.Msgs, req.ExecutionStage); err != nil { + return nil, errors.Wrap(err, "failed to add schedule") + } + + return &types.MsgAddScheduleResponse{}, nil +} + +// RemoveSchedule removes schedule +func (k msgServer) RemoveSchedule(goCtx context.Context, req *types.MsgRemoveSchedule) (*types.MsgRemoveScheduleResponse, error) { + if err := req.Validate(); err != nil { + return nil, errors.Wrap(err, "failed to validate MsgRemoveSchedule") + } + + authority := k.keeper.GetAuthority() + if authority != req.Authority { + return nil, errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid authority; expected %s, got %s", authority, req.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + k.keeper.RemoveSchedule(ctx, req.Name) + + return &types.MsgRemoveScheduleResponse{}, nil +} + +// UpdateParams updates the module parameters +func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { + if err := req.Validate(); err != nil { + return nil, errors.Wrap(err, "failed to validate MsgUpdateParams") + } + + authority := k.keeper.GetAuthority() + if authority != req.Authority { + return nil, errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid authority; expected %s, got %s", authority, req.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + if err := k.keeper.SetParams(ctx, req.Params); err != nil { + return nil, err + } + + return &types.MsgUpdateParamsResponse{}, nil +} diff --git a/x/cron/keeper/msg_server_test.go b/x/cron/keeper/msg_server_test.go new file mode 100644 index 000000000..4c0a6e5d3 --- /dev/null +++ b/x/cron/keeper/msg_server_test.go @@ -0,0 +1,221 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/neutron-org/neutron/v5/testutil" + testkeeper "github.com/neutron-org/neutron/v5/testutil/cron/keeper" + cronkeeper "github.com/neutron-org/neutron/v5/x/cron/keeper" + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +func TestMsgAddScheduleValidate(t *testing.T) { + k, ctx := testkeeper.CronKeeper(t, nil, nil) + msgServer := cronkeeper.NewMsgServerImpl(*k) + + tests := []struct { + name string + msg types.MsgAddSchedule + expectedErr string + }{ + { + "empty authority", + types.MsgAddSchedule{ + Authority: "", + Name: "name", + Period: 3, + Msgs: []types.MsgExecuteContract{ + { + Contract: "contract", + Msg: "msg", + }, + }, + ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER, + }, + "authority is invalid", + }, + { + "invalid authority", + types.MsgAddSchedule{ + Authority: "invalid authority", + Name: "name", + Period: 3, + Msgs: []types.MsgExecuteContract{ + { + Contract: "contract", + Msg: "msg", + }, + }, + ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER, + }, + "authority is invalid", + }, + { + "invalid name", + types.MsgAddSchedule{ + Authority: testutil.TestOwnerAddress, + Name: "", + Period: 3, + Msgs: []types.MsgExecuteContract{ + { + Contract: "contract", + Msg: "msg", + }, + }, + ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER, + }, + "name is invalid", + }, + { + "invalid period", + types.MsgAddSchedule{ + Authority: testutil.TestOwnerAddress, + Name: "name", + Period: 0, + Msgs: []types.MsgExecuteContract{ + { + Contract: "contract", + Msg: "msg", + }, + }, + ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER, + }, + "period is invalid", + }, + { + "empty msgs", + types.MsgAddSchedule{ + Authority: testutil.TestOwnerAddress, + Name: "name", + Period: 3, + Msgs: []types.MsgExecuteContract{}, + ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER, + }, + "msgs should not be empty", + }, + { + "invalid execution stage", + types.MsgAddSchedule{ + Authority: testutil.TestOwnerAddress, + Name: "name", + Period: 3, + Msgs: []types.MsgExecuteContract{ + { + Contract: "contract", + Msg: "msg", + }, + }, + ExecutionStage: 7, + }, + "execution stage is invalid", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + resp, err := msgServer.AddSchedule(ctx, &tt.msg) + require.ErrorContains(t, err, tt.expectedErr) + require.Nil(t, resp) + }) + } +} + +func TestMsgRemoveScheduleValidate(t *testing.T) { + k, ctx := testkeeper.CronKeeper(t, nil, nil) + msgServer := cronkeeper.NewMsgServerImpl(*k) + + tests := []struct { + name string + msg types.MsgRemoveSchedule + expectedErr string + }{ + { + "empty authority", + types.MsgRemoveSchedule{ + Authority: "", + Name: "name", + }, + "authority is invalid", + }, + { + "invalid authority", + types.MsgRemoveSchedule{ + Authority: "invalid authority", + Name: "name", + }, + "authority is invalid", + }, + { + "invalid name", + types.MsgRemoveSchedule{ + Authority: testutil.TestOwnerAddress, + Name: "", + }, + "name is invalid", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + resp, err := msgServer.RemoveSchedule(ctx, &tt.msg) + require.ErrorContains(t, err, tt.expectedErr) + require.Nil(t, resp) + }) + } +} + +func TestMsgUpdateParamsValidate(t *testing.T) { + k, ctx := testkeeper.CronKeeper(t, nil, nil) + msgServer := cronkeeper.NewMsgServerImpl(*k) + + tests := []struct { + name string + msg types.MsgUpdateParams + expectedErr string + }{ + { + "empty authority", + types.MsgUpdateParams{ + Authority: "", + }, + "authority is invalid", + }, + { + "invalid authority", + types.MsgUpdateParams{ + Authority: "invalid authority", + }, + "authority is invalid", + }, + { + "empty security_address", + types.MsgUpdateParams{ + Authority: testutil.TestOwnerAddress, + Params: types.Params{ + SecurityAddress: "", + }, + }, + "security_address is invalid", + }, + { + "invalid security_address", + types.MsgUpdateParams{ + Authority: testutil.TestOwnerAddress, + Params: types.Params{ + SecurityAddress: "invalid security_address", + }, + }, + "security_address is invalid", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + resp, err := msgServer.UpdateParams(ctx, &tt.msg) + require.ErrorContains(t, err, tt.expectedErr) + require.Nil(t, resp) + }) + } +} diff --git a/x/cron/keeper/params.go b/x/cron/keeper/params.go new file mode 100644 index 000000000..81b7321e4 --- /dev/null +++ b/x/cron/keeper/params.go @@ -0,0 +1,31 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ParamsKey) + if bz == nil { + return params + } + + k.cdc.MustUnmarshal(bz, ¶ms) + return params +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { + store := ctx.KVStore(k.storeKey) + bz, err := k.cdc.Marshal(¶ms) + if err != nil { + return err + } + + store.Set(types.ParamsKey, bz) + return nil +} diff --git a/x/cron/keeper/params_test.go b/x/cron/keeper/params_test.go new file mode 100644 index 000000000..be0630f66 --- /dev/null +++ b/x/cron/keeper/params_test.go @@ -0,0 +1,30 @@ +package keeper_test + +import ( + "testing" + + "github.com/neutron-org/neutron/v5/app/config" + + "github.com/neutron-org/neutron/v5/testutil" + + testkeeper "github.com/neutron-org/neutron/v5/testutil/cron/keeper" + + "github.com/stretchr/testify/require" + + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +func TestGetParams(t *testing.T) { + _ = config.GetDefaultConfig() + + k, ctx := testkeeper.CronKeeper(t, nil, nil) + params := types.Params{ + SecurityAddress: testutil.TestOwnerAddress, + Limit: 5, + } + + err := k.SetParams(ctx, params) + require.NoError(t, err) + + require.EqualValues(t, params, k.GetParams(ctx)) +} diff --git a/x/cron/migrations/v2/store.go b/x/cron/migrations/v2/store.go new file mode 100644 index 000000000..dae71e591 --- /dev/null +++ b/x/cron/migrations/v2/store.go @@ -0,0 +1,56 @@ +package v2 + +import ( + "cosmossdk.io/errors" + "cosmossdk.io/store/prefix" + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +// MigrateStore performs in-place store migrations. +// The migration adds execution stage for schedules. +func MigrateStore(ctx sdk.Context, cdc codec.BinaryCodec, storeKey storetypes.StoreKey) error { + return migrateSchedules(ctx, cdc, storeKey) +} + +type migrationUpdate struct { + key []byte + val []byte +} + +func migrateSchedules(ctx sdk.Context, cdc codec.BinaryCodec, storeKey storetypes.StoreKey) error { + ctx.Logger().Info("Migrating cron Schedules...") + + store := prefix.NewStore(ctx.KVStore(storeKey), types.ScheduleKey) + iterator := storetypes.KVStorePrefixIterator(store, []byte{}) + schedulesToUpdate := make([]migrationUpdate, 0) + + for ; iterator.Valid(); iterator.Next() { + var schedule types.Schedule + cdc.MustUnmarshal(iterator.Value(), &schedule) + // Set execution in EndBlocker + schedule.ExecutionStage = types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER + + schedulesToUpdate = append(schedulesToUpdate, migrationUpdate{ + key: iterator.Key(), + val: cdc.MustMarshal(&schedule), + }) + } + + err := iterator.Close() + if err != nil { + return errors.Wrap(err, "iterator failed to close during migration") + } + + // Store the updated Schedules + for _, v := range schedulesToUpdate { + store.Set(v.key, v.val) + } + + ctx.Logger().Info("Finished migrating cron Schedules...") + + return nil +} diff --git a/x/cron/migrations/v2/store_test.go b/x/cron/migrations/v2/store_test.go new file mode 100644 index 000000000..a1a3c4fef --- /dev/null +++ b/x/cron/migrations/v2/store_test.go @@ -0,0 +1,60 @@ +package v2_test + +import ( + "testing" + + "cosmossdk.io/store/prefix" + "github.com/stretchr/testify/suite" + + "github.com/neutron-org/neutron/v5/testutil" + v2 "github.com/neutron-org/neutron/v5/x/cron/migrations/v2" + "github.com/neutron-org/neutron/v5/x/cron/types" + v1types "github.com/neutron-org/neutron/v5/x/cron/types/v1" +) + +type V2CronMigrationTestSuite struct { + testutil.IBCConnectionTestSuite +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(V2CronMigrationTestSuite)) +} + +func (suite *V2CronMigrationTestSuite) TestScheduleUpgrade() { + var ( + app = suite.GetNeutronZoneApp(suite.ChainA) + storeKey = app.GetKey(types.StoreKey) + ctx = suite.ChainA.GetContext() + cdc = app.AppCodec() + ) + + schedule := v1types.Schedule{ + Name: "name", + Period: 3, + Msgs: []v1types.MsgExecuteContract{ + { + Contract: "contract", + Msg: "msg", + }, + }, + LastExecuteHeight: 1, + } + + store := prefix.NewStore(ctx.KVStore(storeKey), types.ScheduleKey) + bz := cdc.MustMarshal(&schedule) + store.Set(types.GetScheduleKey(schedule.Name), bz) + + // Run migration + suite.NoError(v2.MigrateStore(ctx, cdc, storeKey)) + + // Check Schedule has correct ExecutionStage + newSchedule, _ := app.CronKeeper.GetSchedule(ctx, schedule.Name) + suite.Equal(newSchedule.Name, schedule.Name) + suite.Equal(newSchedule.Period, schedule.Period) + for i, msg := range newSchedule.Msgs { + suite.Equal(msg.Contract, schedule.Msgs[i].Contract) + suite.Equal(msg.Msg, schedule.Msgs[i].Msg) + } + suite.Equal(newSchedule.LastExecuteHeight, schedule.LastExecuteHeight) + suite.Equal(newSchedule.ExecutionStage, types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER) +} diff --git a/x/cron/module.go b/x/cron/module.go new file mode 100644 index 000000000..e86ee8745 --- /dev/null +++ b/x/cron/module.go @@ -0,0 +1,169 @@ +package cron + +import ( + "context" + "encoding/json" + "fmt" + + "cosmossdk.io/core/appmodule" + + "github.com/gorilla/mux" + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + 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/neutron-org/neutron/v5/x/cron/client/cli" + "github.com/neutron-org/neutron/v5/x/cron/keeper" + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +var ( + _ appmodule.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ appmodule.HasBeginBlocker = AppModule{} + _ appmodule.HasEndBlocker = AppModule{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface that defines the independent methods a Cosmos SDK module needs to implement. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the name of the module as a string +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the amino codec for the module, which is used to marshal and unmarshal structs to/from []byte in order to persist them in the module's KVStore +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns a default GenesisState for the module, marshalled to json.RawMessage. The default GenesisState need to be defined by the module developer and is primarily used for testing +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form +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 capability 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, mux *runtime.ServeMux) { + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck +} + +// GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +var _ appmodule.AppModule = AppModule{} + +// AppModule implements the AppModule interface that defines the inter-dependent methods that modules need to implement +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() { // marker +} + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() { // marker +} + +// Deprecated: use RegisterServices +func (AppModule) QuerierRoute() string { return types.RouterKey } + +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) +} + +// RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the 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 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 is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 +func (AppModule) ConsensusVersion() uint64 { return types.ConsensusVersion } + +// BeginBlock contains the logic that is automatically triggered at the beginning of each block +func (am AppModule) BeginBlock(ctx context.Context) error { + am.keeper.ExecuteReadySchedules(sdk.UnwrapSDKContext(ctx), types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER) + return nil +} + +// EndBlock contains the logic that is automatically triggered at the end of each block +func (am AppModule) EndBlock(ctx context.Context) error { + am.keeper.ExecuteReadySchedules(sdk.UnwrapSDKContext(ctx), types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER) + return nil +} diff --git a/x/cron/module_simulation.go b/x/cron/module_simulation.go new file mode 100644 index 000000000..0ada92486 --- /dev/null +++ b/x/cron/module_simulation.go @@ -0,0 +1,47 @@ +package cron + +import ( + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/testutil/sims" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" + + cronsimulation "github.com/neutron-org/neutron/v5/x/cron/simulation" + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +// avoid unused import issue +var ( + _ = cronsimulation.FindAccount + _ = sims.StakePerAccount + _ = simulation.MsgEntryKind + _ = baseapp.Paramspace +) + +// GenerateGenesisState creates a randomized GenState of the module +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { + accs := make([]string, len(simState.Accounts)) + for i, acc := range simState.Accounts { + accs[i] = acc.Address.String() + } + cronGenesis := types.GenesisState{ + Params: types.DefaultParams(), + } + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&cronGenesis) +} + +// ProposalContents doesn't return any content functions for governance proposals +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalMsg { + return nil +} + +// TODO +// RegisterStoreDecoder registers a decoder +func (am AppModule) RegisterStoreDecoder(_ simtypes.StoreDecoderRegistry) {} + +// WeightedOperations returns the all the gov module operations with their respective weights. +func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { + operations := make([]simtypes.WeightedOperation, 0) + return operations +} diff --git a/x/cron/simulation/helpers.go b/x/cron/simulation/helpers.go new file mode 100644 index 000000000..92c437c0d --- /dev/null +++ b/x/cron/simulation/helpers.go @@ -0,0 +1,15 @@ +package simulation + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +// FindAccount find a specific address from an account list +func FindAccount(accs []simtypes.Account, address string) (simtypes.Account, bool) { + creator, err := sdk.AccAddressFromBech32(address) + if err != nil { + panic(err) + } + return simtypes.FindAccount(accs, creator) +} diff --git a/x/cron/types/codec.go b/x/cron/types/codec.go new file mode 100644 index 000000000..6772e97b9 --- /dev/null +++ b/x/cron/types/codec.go @@ -0,0 +1,27 @@ +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(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgUpdateParams{}, "neutron.cron.MsgUpdateParams", nil) +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations( + (*sdk.Msg)(nil), + &MsgUpdateParams{}, + &MsgAddSchedule{}, + &MsgRemoveSchedule{}, + ) + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/cron/types/constants.go b/x/cron/types/constants.go new file mode 100644 index 000000000..6bad94d03 --- /dev/null +++ b/x/cron/types/constants.go @@ -0,0 +1,3 @@ +package types + +const ConsensusVersion = 1 diff --git a/x/cron/types/errors.go b/x/cron/types/errors.go new file mode 100644 index 000000000..8bc535d7e --- /dev/null +++ b/x/cron/types/errors.go @@ -0,0 +1,12 @@ +package types + +// DONTCOVER + +import ( + "cosmossdk.io/errors" +) + +// x/cron module sentinel errors +var ( + ErrSample = errors.Register(ModuleName, 1100, "sample error") +) diff --git a/x/cron/types/expected_keepers.go b/x/cron/types/expected_keepers.go new file mode 100644 index 000000000..cbed63584 --- /dev/null +++ b/x/cron/types/expected_keepers.go @@ -0,0 +1,19 @@ +package types + +import ( + "context" + + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// AccountKeeper defines the expected account keeper used for simulations (noalias) +type AccountKeeper interface { + GetModuleAddress(moduleName string) sdk.AccAddress + // Methods imported from account should be defined here +} + +type WasmMsgServer interface { + ExecuteContract(context.Context, *wasmtypes.MsgExecuteContract) (*wasmtypes.MsgExecuteContractResponse, error) + // Methods imported from account should be defined here +} diff --git a/x/cron/types/genesis.go b/x/cron/types/genesis.go new file mode 100644 index 000000000..4fad02046 --- /dev/null +++ b/x/cron/types/genesis.go @@ -0,0 +1,28 @@ +package types + +import "fmt" + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + ScheduleList: []Schedule{}, + Params: DefaultParams(), + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + // Check for duplicated index in schedule + scheduleIndexMap := make(map[string]struct{}) + + for _, elem := range gs.ScheduleList { + index := string(GetScheduleKey(elem.Name)) + if _, ok := scheduleIndexMap[index]; ok { + return fmt.Errorf("duplicated index for schedule") + } + scheduleIndexMap[index] = struct{}{} + } + + return gs.Params.Validate() +} diff --git a/x/cron/types/genesis.pb.go b/x/cron/types/genesis.pb.go new file mode 100644 index 000000000..b3678689b --- /dev/null +++ b/x/cron/types/genesis.pb.go @@ -0,0 +1,385 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: neutron/cron/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 + +// Defines the cron module's genesis state. +type GenesisState struct { + ScheduleList []Schedule `protobuf:"bytes,2,rep,name=scheduleList,proto3" json:"scheduleList"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +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_7c41f2dea8ad83c2, []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 (m *GenesisState) GetScheduleList() []Schedule { + if m != nil { + return m.ScheduleList + } + return nil +} + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "neutron.cron.GenesisState") +} + +func init() { proto.RegisterFile("neutron/cron/genesis.proto", fileDescriptor_7c41f2dea8ad83c2) } + +var fileDescriptor_7c41f2dea8ad83c2 = []byte{ + // 231 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xca, 0x4b, 0x2d, 0x2d, + 0x29, 0xca, 0xcf, 0xd3, 0x4f, 0x06, 0x11, 0xe9, 0xa9, 0x79, 0xa9, 0xc5, 0x99, 0xc5, 0x7a, 0x05, + 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x3c, 0x50, 0x39, 0x3d, 0x90, 0x9c, 0x94, 0x48, 0x7a, 0x7e, 0x7a, + 0x3e, 0x58, 0x42, 0x1f, 0xc4, 0x82, 0xa8, 0x91, 0x92, 0x44, 0xd1, 0x5f, 0x90, 0x58, 0x94, 0x98, + 0x0b, 0xd5, 0x2e, 0x25, 0x8d, 0x22, 0x55, 0x9c, 0x9c, 0x91, 0x9a, 0x52, 0x9a, 0x93, 0x0a, 0x91, + 0x54, 0x6a, 0x61, 0xe4, 0xe2, 0x71, 0x87, 0xd8, 0x16, 0x5c, 0x92, 0x58, 0x92, 0x2a, 0xe4, 0xc0, + 0xc5, 0x03, 0x53, 0xe2, 0x93, 0x59, 0x5c, 0x22, 0xc1, 0xa4, 0xc0, 0xac, 0xc1, 0x6d, 0x24, 0xa6, + 0x87, 0xec, 0x06, 0xbd, 0x60, 0xa8, 0x0a, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0x50, 0x74, + 0x08, 0x19, 0x71, 0xb1, 0x41, 0xec, 0x97, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x36, 0x12, 0x41, 0xd5, + 0x1b, 0x00, 0x96, 0x83, 0xea, 0x84, 0xaa, 0x74, 0xf2, 0x38, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, + 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, + 0x63, 0x39, 0x86, 0x28, 0xbd, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, + 0xa8, 0x39, 0xba, 0xf9, 0x45, 0xe9, 0x30, 0xb6, 0x7e, 0x99, 0xa9, 0x7e, 0x05, 0xc4, 0x67, 0x25, + 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x7f, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x5b, + 0x63, 0x56, 0x46, 0x51, 0x01, 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 + if len(m.ScheduleList) > 0 { + for iNdEx := len(m.ScheduleList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ScheduleList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + 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 + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + if len(m.ScheduleList) > 0 { + for _, e := range m.ScheduleList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(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 { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ScheduleList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ScheduleList = append(m.ScheduleList, Schedule{}) + if err := m.ScheduleList[len(m.ScheduleList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + 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/cron/types/genesis_test.go b/x/cron/types/genesis_test.go new file mode 100644 index 000000000..04d14471f --- /dev/null +++ b/x/cron/types/genesis_test.go @@ -0,0 +1,51 @@ +package types_test + +import ( + "testing" + + "github.com/neutron-org/neutron/v5/app/config" + + "github.com/stretchr/testify/require" + + "github.com/neutron-org/neutron/v5/x/cron/types" +) + +func TestGenesisState_Validate(t *testing.T) { + config.GetDefaultConfig() + + for _, tc := range []struct { + desc string + genState *types.GenesisState + valid bool + }{ + { + desc: "valid genesis state", + genState: &types.GenesisState{ + Params: types.Params{ + SecurityAddress: "neutron17dtl0mjt3t77kpuhg2edqzjpszulwhgzcdvagh", + Limit: 1, + }, + }, + valid: true, + }, + { + desc: "invalid genesis state - params are invalid", + genState: &types.GenesisState{ + Params: types.Params{ + SecurityAddress: "", + Limit: 0, + }, + }, + valid: false, + }, + } { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/x/cron/types/keys.go b/x/cron/types/keys.go new file mode 100644 index 000000000..95bb9a676 --- /dev/null +++ b/x/cron/types/keys.go @@ -0,0 +1,31 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "cron" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_cron" +) + +const ( + prefixScheduleKey = iota + 1 + prefixScheduleCountKey + prefixParamsKey +) + +var ( + ScheduleKey = []byte{prefixScheduleKey} + ScheduleCountKey = []byte{prefixScheduleCountKey} + ParamsKey = []byte{prefixParamsKey} +) + +func GetScheduleKey(name string) []byte { + return []byte(name) +} diff --git a/x/cron/types/params.go b/x/cron/types/params.go new file mode 100644 index 000000000..2ad7cf24c --- /dev/null +++ b/x/cron/types/params.go @@ -0,0 +1,106 @@ +package types + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "gopkg.in/yaml.v2" +) + +var _ paramtypes.ParamSet = (*Params)(nil) + +var ( + KeySecurityAddress = []byte("SecurityAddress") + KeyLimit = []byte("Limit") + + DefaultSecurityAddress = "" + DefaultLimit = uint64(5) +) + +// ParamKeyTable the param key table for launch module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new Params instance +func NewParams(securityAddress string, limit uint64) Params { + return Params{ + SecurityAddress: securityAddress, + Limit: limit, + } +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams(DefaultSecurityAddress, DefaultLimit) +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair( + KeySecurityAddress, + &p.SecurityAddress, + validateAddress, + ), + paramtypes.NewParamSetPair( + KeyLimit, + &p.Limit, + validateLimit, + ), + } +} + +// Validate validates the set of params +func (p Params) Validate() error { + err := validateAddress(p.SecurityAddress) + if err != nil { + return fmt.Errorf("invalid security address: %w", err) + } + + err = validateLimit(p.Limit) + if err != nil { + return fmt.Errorf("invalid limit: %w", err) + } + + return nil +} + +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} + +func validateAddress(i interface{}) error { + v, ok := i.(string) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + // address might be explicitly empty in test environments + if len(v) == 0 { + return nil + } + + _, err := sdk.AccAddressFromBech32(v) + if err != nil { + return fmt.Errorf("invalid address: %w", err) + } + + return nil +} + +func validateLimit(i interface{}) error { + l, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if l == 0 { + return fmt.Errorf("limit cannot be zero") + } + + return nil +} diff --git a/x/cron/types/params.pb.go b/x/cron/types/params.pb.go new file mode 100644 index 000000000..6f0715acb --- /dev/null +++ b/x/cron/types/params.pb.go @@ -0,0 +1,355 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: neutron/cron/params.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 + +// Defines the parameters for the module. +type Params struct { + // Security address that can remove schedules + SecurityAddress string `protobuf:"bytes,1,opt,name=security_address,json=securityAddress,proto3" json:"security_address,omitempty"` + // Limit of schedules executed in one block + Limit uint64 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_efa4f5c14a68f6e5, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetSecurityAddress() string { + if m != nil { + return m.SecurityAddress + } + return "" +} + +func (m *Params) GetLimit() uint64 { + if m != nil { + return m.Limit + } + return 0 +} + +func init() { + proto.RegisterType((*Params)(nil), "neutron.cron.Params") +} + +func init() { proto.RegisterFile("neutron/cron/params.proto", fileDescriptor_efa4f5c14a68f6e5) } + +var fileDescriptor_efa4f5c14a68f6e5 = []byte{ + // 198 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0x4b, 0x2d, 0x2d, + 0x29, 0xca, 0xcf, 0xd3, 0x4f, 0x06, 0x11, 0x05, 0x89, 0x45, 0x89, 0xb9, 0xc5, 0x7a, 0x05, 0x45, + 0xf9, 0x25, 0xf9, 0x42, 0x3c, 0x50, 0x29, 0x3d, 0x90, 0x94, 0x94, 0x48, 0x7a, 0x7e, 0x7a, 0x3e, + 0x58, 0x42, 0x1f, 0xc4, 0x82, 0xa8, 0x51, 0xf2, 0xe7, 0x62, 0x0b, 0x00, 0xeb, 0x11, 0xd2, 0xe4, + 0x12, 0x28, 0x4e, 0x4d, 0x2e, 0x2d, 0xca, 0x2c, 0xa9, 0x8c, 0x4f, 0x4c, 0x49, 0x29, 0x4a, 0x2d, + 0x2e, 0x96, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0xe2, 0x87, 0x89, 0x3b, 0x42, 0x84, 0x85, 0x44, + 0xb8, 0x58, 0x73, 0x32, 0x73, 0x33, 0x4b, 0x24, 0x98, 0x14, 0x18, 0x35, 0x58, 0x82, 0x20, 0x1c, + 0x2b, 0x96, 0x19, 0x0b, 0xe4, 0x19, 0x9c, 0x3c, 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, 0x4a, 0x2f, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xea, + 0x32, 0xdd, 0xfc, 0xa2, 0x74, 0x18, 0x5b, 0xbf, 0xcc, 0x54, 0xbf, 0x02, 0xe2, 0x8b, 0x92, 0xca, + 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x0b, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x43, 0x7c, + 0x1b, 0xae, 0xe2, 0x00, 0x00, 0x00, +} + +func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Limit != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.Limit)) + i-- + dAtA[i] = 0x10 + } + if len(m.SecurityAddress) > 0 { + i -= len(m.SecurityAddress) + copy(dAtA[i:], m.SecurityAddress) + i = encodeVarintParams(dAtA, i, uint64(len(m.SecurityAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SecurityAddress) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + if m.Limit != 0 { + n += 1 + sovParams(uint64(m.Limit)) + } + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) 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 ErrIntOverflowParams + } + 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SecurityAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SecurityAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Limit", wireType) + } + m.Limit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Limit |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/cron/types/query.pb.go b/x/cron/types/query.pb.go new file mode 100644 index 000000000..4d8b3eedb --- /dev/null +++ b/x/cron/types/query.pb.go @@ -0,0 +1,1391 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: neutron/cron/query.proto + +package types + +import ( + context "context" + fmt "fmt" + query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + 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 + +// The request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e02f33367c9498fe, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.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 *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// The response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e02f33367c9498fe, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.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 *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// The request type for the Query/Schedule RPC method. +type QueryGetScheduleRequest struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (m *QueryGetScheduleRequest) Reset() { *m = QueryGetScheduleRequest{} } +func (m *QueryGetScheduleRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetScheduleRequest) ProtoMessage() {} +func (*QueryGetScheduleRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e02f33367c9498fe, []int{2} +} +func (m *QueryGetScheduleRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetScheduleRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetScheduleRequest.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 *QueryGetScheduleRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetScheduleRequest.Merge(m, src) +} +func (m *QueryGetScheduleRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetScheduleRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetScheduleRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetScheduleRequest proto.InternalMessageInfo + +func (m *QueryGetScheduleRequest) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +// The response type for the Query/Params RPC method. +type QueryGetScheduleResponse struct { + Schedule Schedule `protobuf:"bytes,1,opt,name=schedule,proto3" json:"schedule"` +} + +func (m *QueryGetScheduleResponse) Reset() { *m = QueryGetScheduleResponse{} } +func (m *QueryGetScheduleResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetScheduleResponse) ProtoMessage() {} +func (*QueryGetScheduleResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e02f33367c9498fe, []int{3} +} +func (m *QueryGetScheduleResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetScheduleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetScheduleResponse.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 *QueryGetScheduleResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetScheduleResponse.Merge(m, src) +} +func (m *QueryGetScheduleResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetScheduleResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetScheduleResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetScheduleResponse proto.InternalMessageInfo + +func (m *QueryGetScheduleResponse) GetSchedule() Schedule { + if m != nil { + return m.Schedule + } + return Schedule{} +} + +// The request type for the Query/Schedules RPC method. +type QuerySchedulesRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QuerySchedulesRequest) Reset() { *m = QuerySchedulesRequest{} } +func (m *QuerySchedulesRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySchedulesRequest) ProtoMessage() {} +func (*QuerySchedulesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e02f33367c9498fe, []int{4} +} +func (m *QuerySchedulesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySchedulesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySchedulesRequest.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 *QuerySchedulesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySchedulesRequest.Merge(m, src) +} +func (m *QuerySchedulesRequest) XXX_Size() int { + return m.Size() +} +func (m *QuerySchedulesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySchedulesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySchedulesRequest proto.InternalMessageInfo + +func (m *QuerySchedulesRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// The response type for the Query/Params RPC method. +type QuerySchedulesResponse struct { + Schedules []Schedule `protobuf:"bytes,1,rep,name=schedules,proto3" json:"schedules"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QuerySchedulesResponse) Reset() { *m = QuerySchedulesResponse{} } +func (m *QuerySchedulesResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySchedulesResponse) ProtoMessage() {} +func (*QuerySchedulesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e02f33367c9498fe, []int{5} +} +func (m *QuerySchedulesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySchedulesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySchedulesResponse.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 *QuerySchedulesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySchedulesResponse.Merge(m, src) +} +func (m *QuerySchedulesResponse) XXX_Size() int { + return m.Size() +} +func (m *QuerySchedulesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySchedulesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySchedulesResponse proto.InternalMessageInfo + +func (m *QuerySchedulesResponse) GetSchedules() []Schedule { + if m != nil { + return m.Schedules + } + return nil +} + +func (m *QuerySchedulesResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "neutron.cron.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "neutron.cron.QueryParamsResponse") + proto.RegisterType((*QueryGetScheduleRequest)(nil), "neutron.cron.QueryGetScheduleRequest") + proto.RegisterType((*QueryGetScheduleResponse)(nil), "neutron.cron.QueryGetScheduleResponse") + proto.RegisterType((*QuerySchedulesRequest)(nil), "neutron.cron.QuerySchedulesRequest") + proto.RegisterType((*QuerySchedulesResponse)(nil), "neutron.cron.QuerySchedulesResponse") +} + +func init() { proto.RegisterFile("neutron/cron/query.proto", fileDescriptor_e02f33367c9498fe) } + +var fileDescriptor_e02f33367c9498fe = []byte{ + // 496 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xcf, 0x6b, 0x13, 0x41, + 0x14, 0xc7, 0xb3, 0xb1, 0x86, 0xe6, 0xe9, 0xe9, 0x19, 0x63, 0x5c, 0xeb, 0xb6, 0xae, 0xb6, 0x8a, + 0xd0, 0x19, 0x1a, 0x11, 0xc4, 0x63, 0x0f, 0x56, 0x6f, 0x35, 0x7a, 0xf2, 0x22, 0x93, 0x38, 0x6c, + 0x83, 0xcd, 0xcc, 0x76, 0x67, 0x36, 0x58, 0x44, 0x10, 0xff, 0x02, 0xc1, 0xb3, 0xff, 0x4f, 0x8f, + 0x05, 0x2f, 0x9e, 0x44, 0x12, 0xef, 0xfe, 0x0b, 0x65, 0xe7, 0x47, 0x9a, 0x6d, 0x96, 0xe6, 0x12, + 0x86, 0x7d, 0xdf, 0xf7, 0xfd, 0x7e, 0x66, 0xde, 0x0b, 0x74, 0x04, 0xcf, 0x75, 0x26, 0x05, 0x1d, + 0x14, 0x3f, 0x47, 0x39, 0xcf, 0x8e, 0x49, 0x9a, 0x49, 0x2d, 0xf1, 0xba, 0xab, 0x90, 0xa2, 0x12, + 0x3e, 0x1e, 0x48, 0x35, 0x92, 0x8a, 0xf6, 0x99, 0xe2, 0x56, 0x46, 0xc7, 0x3b, 0x7d, 0xae, 0xd9, + 0x0e, 0x4d, 0x59, 0x32, 0x14, 0x4c, 0x0f, 0xa5, 0xb0, 0x9d, 0x61, 0x2b, 0x91, 0x89, 0x34, 0x47, + 0x5a, 0x9c, 0xdc, 0xd7, 0xb5, 0x44, 0xca, 0xe4, 0x90, 0x53, 0x96, 0x0e, 0x29, 0x13, 0x42, 0x6a, + 0xd3, 0xa2, 0x5c, 0xf5, 0x76, 0x89, 0x23, 0x65, 0x19, 0x1b, 0xf9, 0xd2, 0x9d, 0x52, 0x49, 0x0d, + 0x0e, 0xf8, 0x87, 0xfc, 0x90, 0xdb, 0x62, 0xdc, 0x02, 0x7c, 0x5d, 0xd0, 0xec, 0x9b, 0x8e, 0x1e, + 0x3f, 0xca, 0xb9, 0xd2, 0xf1, 0x2b, 0xb8, 0x51, 0xfa, 0xaa, 0x52, 0x29, 0x14, 0xc7, 0x2e, 0x34, + 0xac, 0x73, 0x27, 0xd8, 0x08, 0x1e, 0x5d, 0xeb, 0xb6, 0xc8, 0xfc, 0x1d, 0x89, 0x55, 0xef, 0xae, + 0x9c, 0xfc, 0x59, 0xaf, 0xf5, 0x9c, 0x32, 0xde, 0x86, 0x5b, 0xc6, 0x6a, 0x8f, 0xeb, 0x37, 0x2e, + 0xda, 0xa5, 0x20, 0xc2, 0x8a, 0x60, 0x23, 0x6e, 0xcc, 0x9a, 0x3d, 0x73, 0x8e, 0xdf, 0x42, 0x67, + 0x51, 0xee, 0xe2, 0x9f, 0xc1, 0xaa, 0xa7, 0x77, 0x00, 0xed, 0x32, 0x80, 0xef, 0x70, 0x08, 0x33, + 0x75, 0xfc, 0x1e, 0x6e, 0x1a, 0x57, 0x2f, 0xf0, 0x17, 0xc5, 0x17, 0x00, 0xe7, 0xcf, 0xef, 0x4c, + 0xb7, 0x88, 0x9d, 0x15, 0x29, 0x66, 0x45, 0xec, 0x48, 0xdd, 0xac, 0xc8, 0x3e, 0x4b, 0x3c, 0x7e, + 0x6f, 0xae, 0x33, 0xfe, 0x19, 0x40, 0xfb, 0x62, 0x82, 0xa3, 0x7e, 0x0e, 0x4d, 0xcf, 0x51, 0xbc, + 0xdb, 0x95, 0xa5, 0xd8, 0xe7, 0x72, 0xdc, 0x2b, 0xe1, 0xd5, 0x0d, 0xde, 0xc3, 0xa5, 0x78, 0x36, + 0x78, 0x9e, 0xaf, 0xfb, 0xbf, 0x0e, 0x57, 0x0d, 0x1f, 0x7e, 0x84, 0x86, 0x9d, 0x13, 0x6e, 0x94, + 0x29, 0x16, 0xd7, 0x20, 0xbc, 0x77, 0x89, 0xc2, 0x86, 0xc4, 0x6b, 0xdf, 0x7e, 0xfd, 0xfb, 0x51, + 0x6f, 0x63, 0x8b, 0x56, 0x2c, 0x20, 0x7e, 0x0d, 0x60, 0xd5, 0xdf, 0x0e, 0x37, 0x2b, 0xdc, 0x16, + 0xb7, 0x22, 0xdc, 0x5a, 0x26, 0x73, 0xc9, 0x9b, 0x26, 0x79, 0x1d, 0xef, 0xd2, 0xca, 0xfd, 0xa6, + 0x9f, 0x8b, 0x7d, 0xfa, 0x82, 0x63, 0x68, 0xce, 0x66, 0x82, 0xf7, 0x2b, 0xbc, 0x2f, 0xee, 0x44, + 0xf8, 0xe0, 0x72, 0x91, 0x8b, 0x8f, 0x4c, 0x7c, 0x07, 0xdb, 0xd5, 0xf1, 0xbb, 0x2f, 0x4f, 0x26, + 0x51, 0x70, 0x3a, 0x89, 0x82, 0xbf, 0x93, 0x28, 0xf8, 0x3e, 0x8d, 0x6a, 0xa7, 0xd3, 0xa8, 0xf6, + 0x7b, 0x1a, 0xd5, 0xde, 0x91, 0x64, 0xa8, 0x0f, 0xf2, 0x3e, 0x19, 0xc8, 0x91, 0xef, 0xdd, 0x96, + 0x59, 0x32, 0xf3, 0x19, 0x3f, 0xa5, 0x9f, 0xac, 0x99, 0x3e, 0x4e, 0xb9, 0xea, 0x37, 0xcc, 0x3f, + 0xf5, 0xc9, 0x59, 0x00, 0x00, 0x00, 0xff, 0xff, 0x49, 0x47, 0xef, 0x62, 0x6b, 0x04, 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 { + // Queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Queries a Schedule by name. + Schedule(ctx context.Context, in *QueryGetScheduleRequest, opts ...grpc.CallOption) (*QueryGetScheduleResponse, error) + // Queries a list of Schedule items. + Schedules(ctx context.Context, in *QuerySchedulesRequest, opts ...grpc.CallOption) (*QuerySchedulesResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/neutron.cron.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Schedule(ctx context.Context, in *QueryGetScheduleRequest, opts ...grpc.CallOption) (*QueryGetScheduleResponse, error) { + out := new(QueryGetScheduleResponse) + err := c.cc.Invoke(ctx, "/neutron.cron.Query/Schedule", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Schedules(ctx context.Context, in *QuerySchedulesRequest, opts ...grpc.CallOption) (*QuerySchedulesResponse, error) { + out := new(QuerySchedulesResponse) + err := c.cc.Invoke(ctx, "/neutron.cron.Query/Schedules", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // Queries a Schedule by name. + Schedule(context.Context, *QueryGetScheduleRequest) (*QueryGetScheduleResponse, error) + // Queries a list of Schedule items. + Schedules(context.Context, *QuerySchedulesRequest) (*QuerySchedulesResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) Schedule(ctx context.Context, req *QueryGetScheduleRequest) (*QueryGetScheduleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Schedule not implemented") +} +func (*UnimplementedQueryServer) Schedules(ctx context.Context, req *QuerySchedulesRequest) (*QuerySchedulesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Schedules not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/neutron.cron.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Schedule_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetScheduleRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Schedule(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/neutron.cron.Query/Schedule", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Schedule(ctx, req.(*QueryGetScheduleRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Schedules_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QuerySchedulesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Schedules(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/neutron.cron.Query/Schedules", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Schedules(ctx, req.(*QuerySchedulesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "neutron.cron.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "Schedule", + Handler: _Query_Schedule_Handler, + }, + { + MethodName: "Schedules", + Handler: _Query_Schedules_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "neutron/cron/query.proto", +} + +func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryGetScheduleRequest) 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 *QueryGetScheduleRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetScheduleRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryGetScheduleResponse) 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 *QueryGetScheduleResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetScheduleResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Schedule.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QuerySchedulesRequest) 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 *QuerySchedulesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySchedulesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QuerySchedulesResponse) 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 *QuerySchedulesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySchedulesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Schedules) > 0 { + for iNdEx := len(m.Schedules) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Schedules[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryGetScheduleRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetScheduleResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Schedule.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QuerySchedulesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QuerySchedulesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Schedules) > 0 { + for _, e := range m.Schedules { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) 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 ErrIntOverflowQuery + } + 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: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) 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 ErrIntOverflowQuery + } + 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: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetScheduleRequest) 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 ErrIntOverflowQuery + } + 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: QueryGetScheduleRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetScheduleRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetScheduleResponse) 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 ErrIntOverflowQuery + } + 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: QueryGetScheduleResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetScheduleResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Schedule", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Schedule.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QuerySchedulesRequest) 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 ErrIntOverflowQuery + } + 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: QuerySchedulesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySchedulesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QuerySchedulesResponse) 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 ErrIntOverflowQuery + } + 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: QuerySchedulesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySchedulesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Schedules", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Schedules = append(m.Schedules, Schedule{}) + if err := m.Schedules[len(m.Schedules)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/cron/types/query.pb.gw.go b/x/cron/types/query.pb.gw.go new file mode 100644 index 000000000..a3ce24432 --- /dev/null +++ b/x/cron/types/query.pb.gw.go @@ -0,0 +1,337 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: neutron/cron/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_Schedule_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetScheduleRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := client.Schedule(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Schedule_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetScheduleRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := server.Schedule(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_Schedules_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_Schedules_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySchedulesRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Schedules_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Schedules(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Schedules_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySchedulesRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Schedules_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Schedules(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Schedule_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Schedule_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Schedule_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Schedules_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Schedules_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Schedules_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Schedule_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Schedule_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Schedule_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Schedules_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Schedules_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Schedules_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"neutron", "cron", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Schedule_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"neutron", "cron", "schedule", "name"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Schedules_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"neutron", "cron", "schedule"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_Schedule_0 = runtime.ForwardResponseMessage + + forward_Query_Schedules_0 = runtime.ForwardResponseMessage +) diff --git a/x/cron/types/schedule.pb.go b/x/cron/types/schedule.pb.go new file mode 100644 index 000000000..42fb227f7 --- /dev/null +++ b/x/cron/types/schedule.pb.go @@ -0,0 +1,912 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: neutron/cron/schedule.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 + +// Defines when messages will be executed in the block +type ExecutionStage int32 + +const ( + // Execution at the end of the block + ExecutionStage_EXECUTION_STAGE_END_BLOCKER ExecutionStage = 0 + // Execution at the beginning of the block + ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER ExecutionStage = 1 +) + +var ExecutionStage_name = map[int32]string{ + 0: "EXECUTION_STAGE_END_BLOCKER", + 1: "EXECUTION_STAGE_BEGIN_BLOCKER", +} + +var ExecutionStage_value = map[string]int32{ + "EXECUTION_STAGE_END_BLOCKER": 0, + "EXECUTION_STAGE_BEGIN_BLOCKER": 1, +} + +func (x ExecutionStage) String() string { + return proto.EnumName(ExecutionStage_name, int32(x)) +} + +func (ExecutionStage) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_49ace1b59de613ef, []int{0} +} + +// Defines the schedule for execution +type Schedule struct { + // Name of schedule + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Period in blocks + Period uint64 `protobuf:"varint,2,opt,name=period,proto3" json:"period,omitempty"` + // Msgs that will be executed every certain number of blocks, specified in the `period` field + Msgs []MsgExecuteContract `protobuf:"bytes,3,rep,name=msgs,proto3" json:"msgs"` + // Last execution's block height + LastExecuteHeight uint64 `protobuf:"varint,4,opt,name=last_execute_height,json=lastExecuteHeight,proto3" json:"last_execute_height,omitempty"` + // Stage when messages will be executed + ExecutionStage ExecutionStage `protobuf:"varint,5,opt,name=execution_stage,json=executionStage,proto3,enum=neutron.cron.ExecutionStage" json:"execution_stage,omitempty"` +} + +func (m *Schedule) Reset() { *m = Schedule{} } +func (m *Schedule) String() string { return proto.CompactTextString(m) } +func (*Schedule) ProtoMessage() {} +func (*Schedule) Descriptor() ([]byte, []int) { + return fileDescriptor_49ace1b59de613ef, []int{0} +} +func (m *Schedule) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Schedule) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Schedule.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 *Schedule) XXX_Merge(src proto.Message) { + xxx_messageInfo_Schedule.Merge(m, src) +} +func (m *Schedule) XXX_Size() int { + return m.Size() +} +func (m *Schedule) XXX_DiscardUnknown() { + xxx_messageInfo_Schedule.DiscardUnknown(m) +} + +var xxx_messageInfo_Schedule proto.InternalMessageInfo + +func (m *Schedule) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Schedule) GetPeriod() uint64 { + if m != nil { + return m.Period + } + return 0 +} + +func (m *Schedule) GetMsgs() []MsgExecuteContract { + if m != nil { + return m.Msgs + } + return nil +} + +func (m *Schedule) GetLastExecuteHeight() uint64 { + if m != nil { + return m.LastExecuteHeight + } + return 0 +} + +func (m *Schedule) GetExecutionStage() ExecutionStage { + if m != nil { + return m.ExecutionStage + } + return ExecutionStage_EXECUTION_STAGE_END_BLOCKER +} + +// Defines the contract and the message to pass +type MsgExecuteContract struct { + // The address of the smart contract + Contract string `protobuf:"bytes,1,opt,name=contract,proto3" json:"contract,omitempty"` + // JSON encoded message to be passed to the contract + Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` +} + +func (m *MsgExecuteContract) Reset() { *m = MsgExecuteContract{} } +func (m *MsgExecuteContract) String() string { return proto.CompactTextString(m) } +func (*MsgExecuteContract) ProtoMessage() {} +func (*MsgExecuteContract) Descriptor() ([]byte, []int) { + return fileDescriptor_49ace1b59de613ef, []int{1} +} +func (m *MsgExecuteContract) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgExecuteContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgExecuteContract.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 *MsgExecuteContract) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgExecuteContract.Merge(m, src) +} +func (m *MsgExecuteContract) XXX_Size() int { + return m.Size() +} +func (m *MsgExecuteContract) XXX_DiscardUnknown() { + xxx_messageInfo_MsgExecuteContract.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgExecuteContract proto.InternalMessageInfo + +func (m *MsgExecuteContract) GetContract() string { + if m != nil { + return m.Contract + } + return "" +} + +func (m *MsgExecuteContract) GetMsg() string { + if m != nil { + return m.Msg + } + return "" +} + +// Defines the number of current schedules +type ScheduleCount struct { + // The number of current schedules + Count int32 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` +} + +func (m *ScheduleCount) Reset() { *m = ScheduleCount{} } +func (m *ScheduleCount) String() string { return proto.CompactTextString(m) } +func (*ScheduleCount) ProtoMessage() {} +func (*ScheduleCount) Descriptor() ([]byte, []int) { + return fileDescriptor_49ace1b59de613ef, []int{2} +} +func (m *ScheduleCount) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ScheduleCount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ScheduleCount.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 *ScheduleCount) XXX_Merge(src proto.Message) { + xxx_messageInfo_ScheduleCount.Merge(m, src) +} +func (m *ScheduleCount) XXX_Size() int { + return m.Size() +} +func (m *ScheduleCount) XXX_DiscardUnknown() { + xxx_messageInfo_ScheduleCount.DiscardUnknown(m) +} + +var xxx_messageInfo_ScheduleCount proto.InternalMessageInfo + +func (m *ScheduleCount) GetCount() int32 { + if m != nil { + return m.Count + } + return 0 +} + +func init() { + proto.RegisterEnum("neutron.cron.ExecutionStage", ExecutionStage_name, ExecutionStage_value) + proto.RegisterType((*Schedule)(nil), "neutron.cron.Schedule") + proto.RegisterType((*MsgExecuteContract)(nil), "neutron.cron.MsgExecuteContract") + proto.RegisterType((*ScheduleCount)(nil), "neutron.cron.ScheduleCount") +} + +func init() { proto.RegisterFile("neutron/cron/schedule.proto", fileDescriptor_49ace1b59de613ef) } + +var fileDescriptor_49ace1b59de613ef = []byte{ + // 393 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x92, 0xc1, 0xaa, 0xd3, 0x40, + 0x18, 0x85, 0x33, 0x36, 0x2d, 0xed, 0xa8, 0xb5, 0x8e, 0x45, 0x42, 0xab, 0x69, 0x2c, 0x08, 0x41, + 0x30, 0x81, 0x8a, 0x1b, 0x77, 0x26, 0x0e, 0x6d, 0x51, 0x5b, 0x48, 0x2b, 0x88, 0x9b, 0x90, 0xa6, + 0xc3, 0x24, 0xd0, 0x64, 0x4a, 0x66, 0x22, 0xf5, 0x2d, 0x7c, 0xac, 0x2e, 0xbb, 0x74, 0x25, 0xd2, + 0xae, 0x7c, 0x8b, 0x4b, 0x26, 0x69, 0xb9, 0xbd, 0x77, 0x13, 0xce, 0xe1, 0x7c, 0x87, 0x7f, 0xe6, + 0xcf, 0xc0, 0x7e, 0x4a, 0x72, 0x91, 0xb1, 0xd4, 0x0e, 0x8b, 0x0f, 0x0f, 0x23, 0xb2, 0xce, 0x37, + 0xc4, 0xda, 0x66, 0x4c, 0x30, 0xf4, 0xa8, 0x0a, 0xad, 0x22, 0xec, 0x75, 0x29, 0xa3, 0x4c, 0x06, + 0x76, 0xa1, 0x4a, 0x66, 0xf8, 0x1f, 0xc0, 0xe6, 0xa2, 0xaa, 0x21, 0x04, 0xd5, 0x34, 0x48, 0x88, + 0x06, 0x0c, 0x60, 0xb6, 0x3c, 0xa9, 0xd1, 0x73, 0xd8, 0xd8, 0x92, 0x2c, 0x66, 0x6b, 0xed, 0x81, + 0x01, 0x4c, 0xd5, 0xab, 0x1c, 0xfa, 0x00, 0xd5, 0x84, 0x53, 0xae, 0xd5, 0x8c, 0x9a, 0xf9, 0x70, + 0x64, 0x58, 0xb7, 0x67, 0x59, 0x5f, 0x39, 0xc5, 0x3b, 0x12, 0xe6, 0x82, 0xb8, 0x2c, 0x15, 0x59, + 0x10, 0x0a, 0x47, 0xdd, 0xff, 0x1d, 0x28, 0x9e, 0xec, 0x20, 0x0b, 0x3e, 0xdb, 0x04, 0x5c, 0xf8, + 0xa4, 0x64, 0xfc, 0x88, 0xc4, 0x34, 0x12, 0x9a, 0x2a, 0x07, 0x3c, 0x2d, 0xa2, 0xaa, 0x3d, 0x91, + 0x01, 0xc2, 0xf0, 0x49, 0x89, 0xc6, 0x2c, 0xf5, 0xb9, 0x08, 0x28, 0xd1, 0xea, 0x06, 0x30, 0xdb, + 0xa3, 0x17, 0xd7, 0x63, 0xf1, 0x19, 0x5a, 0x14, 0x8c, 0xd7, 0x26, 0x57, 0x7e, 0xe8, 0x40, 0x74, + 0xff, 0x60, 0xa8, 0x07, 0x9b, 0x61, 0xa5, 0xab, 0x8b, 0x5f, 0x3c, 0xea, 0xc0, 0x5a, 0xc2, 0xa9, + 0xbc, 0x79, 0xcb, 0x2b, 0xe4, 0xf0, 0x35, 0x7c, 0x7c, 0x5e, 0x97, 0xcb, 0xf2, 0x54, 0xa0, 0x2e, + 0xac, 0x87, 0x85, 0x90, 0xdd, 0xba, 0x57, 0x9a, 0x37, 0x4b, 0xd8, 0xbe, 0x3e, 0x0c, 0x1a, 0xc0, + 0x3e, 0xfe, 0x8e, 0xdd, 0x6f, 0xcb, 0xe9, 0x7c, 0xe6, 0x2f, 0x96, 0x1f, 0xc7, 0xd8, 0xc7, 0xb3, + 0x4f, 0xbe, 0xf3, 0x65, 0xee, 0x7e, 0xc6, 0x5e, 0x47, 0x41, 0xaf, 0xe0, 0xcb, 0xbb, 0x80, 0x83, + 0xc7, 0xd3, 0xd9, 0x05, 0x01, 0xce, 0x64, 0x7f, 0xd4, 0xc1, 0xe1, 0xa8, 0x83, 0x7f, 0x47, 0x1d, + 0xfc, 0x3e, 0xe9, 0xca, 0xe1, 0xa4, 0x2b, 0x7f, 0x4e, 0xba, 0xf2, 0xc3, 0xa2, 0xb1, 0x88, 0xf2, + 0x95, 0x15, 0xb2, 0xc4, 0xae, 0x56, 0xf2, 0x96, 0x65, 0xf4, 0xac, 0xed, 0x9f, 0xef, 0xed, 0x5d, + 0xf9, 0x46, 0xc4, 0xaf, 0x2d, 0xe1, 0xab, 0x86, 0xfc, 0xfb, 0xef, 0x6e, 0x02, 0x00, 0x00, 0xff, + 0xff, 0xee, 0xcd, 0x08, 0xb7, 0x40, 0x02, 0x00, 0x00, +} + +func (m *Schedule) 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 *Schedule) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Schedule) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ExecutionStage != 0 { + i = encodeVarintSchedule(dAtA, i, uint64(m.ExecutionStage)) + i-- + dAtA[i] = 0x28 + } + if m.LastExecuteHeight != 0 { + i = encodeVarintSchedule(dAtA, i, uint64(m.LastExecuteHeight)) + i-- + dAtA[i] = 0x20 + } + if len(m.Msgs) > 0 { + for iNdEx := len(m.Msgs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Msgs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSchedule(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.Period != 0 { + i = encodeVarintSchedule(dAtA, i, uint64(m.Period)) + i-- + dAtA[i] = 0x10 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintSchedule(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgExecuteContract) 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 *MsgExecuteContract) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExecuteContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Msg) > 0 { + i -= len(m.Msg) + copy(dAtA[i:], m.Msg) + i = encodeVarintSchedule(dAtA, i, uint64(len(m.Msg))) + i-- + dAtA[i] = 0x12 + } + if len(m.Contract) > 0 { + i -= len(m.Contract) + copy(dAtA[i:], m.Contract) + i = encodeVarintSchedule(dAtA, i, uint64(len(m.Contract))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ScheduleCount) 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 *ScheduleCount) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ScheduleCount) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Count != 0 { + i = encodeVarintSchedule(dAtA, i, uint64(m.Count)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintSchedule(dAtA []byte, offset int, v uint64) int { + offset -= sovSchedule(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Schedule) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovSchedule(uint64(l)) + } + if m.Period != 0 { + n += 1 + sovSchedule(uint64(m.Period)) + } + if len(m.Msgs) > 0 { + for _, e := range m.Msgs { + l = e.Size() + n += 1 + l + sovSchedule(uint64(l)) + } + } + if m.LastExecuteHeight != 0 { + n += 1 + sovSchedule(uint64(m.LastExecuteHeight)) + } + if m.ExecutionStage != 0 { + n += 1 + sovSchedule(uint64(m.ExecutionStage)) + } + return n +} + +func (m *MsgExecuteContract) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Contract) + if l > 0 { + n += 1 + l + sovSchedule(uint64(l)) + } + l = len(m.Msg) + if l > 0 { + n += 1 + l + sovSchedule(uint64(l)) + } + return n +} + +func (m *ScheduleCount) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Count != 0 { + n += 1 + sovSchedule(uint64(m.Count)) + } + return n +} + +func sovSchedule(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozSchedule(x uint64) (n int) { + return sovSchedule(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Schedule) 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 ErrIntOverflowSchedule + } + 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: Schedule: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Schedule: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSchedule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSchedule + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSchedule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Period", wireType) + } + m.Period = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSchedule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Period |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Msgs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSchedule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSchedule + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSchedule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Msgs = append(m.Msgs, MsgExecuteContract{}) + if err := m.Msgs[len(m.Msgs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastExecuteHeight", wireType) + } + m.LastExecuteHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSchedule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastExecuteHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecutionStage", wireType) + } + m.ExecutionStage = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSchedule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExecutionStage |= ExecutionStage(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipSchedule(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSchedule + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgExecuteContract) 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 ErrIntOverflowSchedule + } + 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: MsgExecuteContract: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgExecuteContract: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Contract", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSchedule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSchedule + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSchedule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Contract = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSchedule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSchedule + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSchedule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Msg = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSchedule(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSchedule + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ScheduleCount) 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 ErrIntOverflowSchedule + } + 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: ScheduleCount: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ScheduleCount: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType) + } + m.Count = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSchedule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Count |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipSchedule(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSchedule + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipSchedule(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, ErrIntOverflowSchedule + } + 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, ErrIntOverflowSchedule + } + 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, ErrIntOverflowSchedule + } + 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, ErrInvalidLengthSchedule + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupSchedule + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthSchedule + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthSchedule = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowSchedule = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupSchedule = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/cron/types/tx.go b/x/cron/types/tx.go new file mode 100644 index 000000000..27b4ceec4 --- /dev/null +++ b/x/cron/types/tx.go @@ -0,0 +1,125 @@ +package types + +import ( + "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var _ sdk.Msg = &MsgAddSchedule{} + +func (msg *MsgAddSchedule) Route() string { + return RouterKey +} + +func (msg *MsgAddSchedule) Type() string { + return "add-schedule" +} + +func (msg *MsgAddSchedule) GetSigners() []sdk.AccAddress { + authority, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { // should never happen as valid basic rejects invalid addresses + panic(err.Error()) + } + return []sdk.AccAddress{authority} +} + +func (msg *MsgAddSchedule) GetSignBytes() []byte { + return ModuleCdc.MustMarshalJSON(msg) +} + +func (msg *MsgAddSchedule) Validate() error { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return errors.Wrap(err, "authority is invalid") + } + + if msg.Name == "" { + return errors.Wrap(sdkerrors.ErrInvalidRequest, "name is invalid") + } + + if msg.Period == 0 { + return errors.Wrap(sdkerrors.ErrInvalidRequest, "period is invalid") + } + + if len(msg.Msgs) == 0 { + return errors.Wrap(sdkerrors.ErrInvalidRequest, "msgs should not be empty") + } + + if _, ok := ExecutionStage_name[int32(msg.ExecutionStage)]; !ok { + return errors.Wrap(sdkerrors.ErrInvalidRequest, "execution stage is invalid") + } + + return nil +} + +//---------------------------------------------------------------- + +var _ sdk.Msg = &MsgRemoveSchedule{} + +func (msg *MsgRemoveSchedule) Route() string { + return RouterKey +} + +func (msg *MsgRemoveSchedule) Type() string { + return "remove-schedule" +} + +func (msg *MsgRemoveSchedule) GetSigners() []sdk.AccAddress { + authority, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { // should never happen as valid basic rejects invalid addresses + panic(err.Error()) + } + return []sdk.AccAddress{authority} +} + +func (msg *MsgRemoveSchedule) GetSignBytes() []byte { + return ModuleCdc.MustMarshalJSON(msg) +} + +func (msg *MsgRemoveSchedule) Validate() error { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return errors.Wrap(err, "authority is invalid") + } + + if msg.Name == "" { + return errors.Wrap(sdkerrors.ErrInvalidRequest, "name is invalid") + } + + return nil +} + +//---------------------------------------------------------------- + +var _ sdk.Msg = &MsgUpdateParams{} + +func (msg *MsgUpdateParams) Route() string { + return RouterKey +} + +func (msg *MsgUpdateParams) Type() string { + return "update-params" +} + +func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress { + authority, err := sdk.AccAddressFromBech32(msg.Authority) + if err != nil { // should never happen as valid basic rejects invalid addresses + panic(err.Error()) + } + return []sdk.AccAddress{authority} +} + +func (msg *MsgUpdateParams) GetSignBytes() []byte { + return ModuleCdc.MustMarshalJSON(msg) +} + +func (msg *MsgUpdateParams) Validate() error { + if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil { + return errors.Wrap(err, "authority is invalid") + } + + if _, err := sdk.AccAddressFromBech32(msg.Params.SecurityAddress); err != nil { + return errors.Wrap(err, "security_address is invalid") + } + + return nil +} diff --git a/x/cron/types/tx.pb.go b/x/cron/types/tx.pb.go new file mode 100644 index 000000000..c5ffb7299 --- /dev/null +++ b/x/cron/types/tx.pb.go @@ -0,0 +1,1511 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: neutron/cron/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + 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 + +// The MsgAddSchedule request type. +type MsgAddSchedule struct { + // The address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // Name of the schedule + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + // Period in blocks + Period uint64 `protobuf:"varint,3,opt,name=period,proto3" json:"period,omitempty"` + // Msgs that will be executed every certain number of blocks, specified in the `period` field + Msgs []MsgExecuteContract `protobuf:"bytes,4,rep,name=msgs,proto3" json:"msgs"` + // Stage when messages will be executed + ExecutionStage ExecutionStage `protobuf:"varint,5,opt,name=execution_stage,json=executionStage,proto3,enum=neutron.cron.ExecutionStage" json:"execution_stage,omitempty"` +} + +func (m *MsgAddSchedule) Reset() { *m = MsgAddSchedule{} } +func (m *MsgAddSchedule) String() string { return proto.CompactTextString(m) } +func (*MsgAddSchedule) ProtoMessage() {} +func (*MsgAddSchedule) Descriptor() ([]byte, []int) { + return fileDescriptor_c9e0a673aba8d6fd, []int{0} +} +func (m *MsgAddSchedule) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddSchedule) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddSchedule.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 *MsgAddSchedule) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddSchedule.Merge(m, src) +} +func (m *MsgAddSchedule) XXX_Size() int { + return m.Size() +} +func (m *MsgAddSchedule) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddSchedule.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddSchedule proto.InternalMessageInfo + +func (m *MsgAddSchedule) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgAddSchedule) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *MsgAddSchedule) GetPeriod() uint64 { + if m != nil { + return m.Period + } + return 0 +} + +func (m *MsgAddSchedule) GetMsgs() []MsgExecuteContract { + if m != nil { + return m.Msgs + } + return nil +} + +func (m *MsgAddSchedule) GetExecutionStage() ExecutionStage { + if m != nil { + return m.ExecutionStage + } + return ExecutionStage_EXECUTION_STAGE_END_BLOCKER +} + +// Defines the response structure for executing a MsgAddSchedule message. +type MsgAddScheduleResponse struct { +} + +func (m *MsgAddScheduleResponse) Reset() { *m = MsgAddScheduleResponse{} } +func (m *MsgAddScheduleResponse) String() string { return proto.CompactTextString(m) } +func (*MsgAddScheduleResponse) ProtoMessage() {} +func (*MsgAddScheduleResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c9e0a673aba8d6fd, []int{1} +} +func (m *MsgAddScheduleResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddScheduleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddScheduleResponse.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 *MsgAddScheduleResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddScheduleResponse.Merge(m, src) +} +func (m *MsgAddScheduleResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgAddScheduleResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddScheduleResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddScheduleResponse proto.InternalMessageInfo + +// The MsgRemoveSchedule request type. +type MsgRemoveSchedule struct { + // The address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // Name of the schedule + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` +} + +func (m *MsgRemoveSchedule) Reset() { *m = MsgRemoveSchedule{} } +func (m *MsgRemoveSchedule) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveSchedule) ProtoMessage() {} +func (*MsgRemoveSchedule) Descriptor() ([]byte, []int) { + return fileDescriptor_c9e0a673aba8d6fd, []int{2} +} +func (m *MsgRemoveSchedule) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRemoveSchedule) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRemoveSchedule.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 *MsgRemoveSchedule) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveSchedule.Merge(m, src) +} +func (m *MsgRemoveSchedule) XXX_Size() int { + return m.Size() +} +func (m *MsgRemoveSchedule) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveSchedule.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRemoveSchedule proto.InternalMessageInfo + +func (m *MsgRemoveSchedule) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgRemoveSchedule) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +// Defines the response structure for executing a MsgRemoveSchedule message. +type MsgRemoveScheduleResponse struct { +} + +func (m *MsgRemoveScheduleResponse) Reset() { *m = MsgRemoveScheduleResponse{} } +func (m *MsgRemoveScheduleResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveScheduleResponse) ProtoMessage() {} +func (*MsgRemoveScheduleResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c9e0a673aba8d6fd, []int{3} +} +func (m *MsgRemoveScheduleResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRemoveScheduleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRemoveScheduleResponse.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 *MsgRemoveScheduleResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveScheduleResponse.Merge(m, src) +} +func (m *MsgRemoveScheduleResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRemoveScheduleResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveScheduleResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRemoveScheduleResponse proto.InternalMessageInfo + +// The MsgUpdateParams request type. +// +// Since: 0.47 +type MsgUpdateParams struct { + // The address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // Defines the x/cron parameters to update. + // + // NOTE: All parameters must be supplied. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } +func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParams) ProtoMessage() {} +func (*MsgUpdateParams) Descriptor() ([]byte, []int) { + return fileDescriptor_c9e0a673aba8d6fd, []int{4} +} +func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParams.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 *MsgUpdateParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParams.Merge(m, src) +} +func (m *MsgUpdateParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo + +func (m *MsgUpdateParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgUpdateParams) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// Defines the response structure for executing a MsgUpdateParams message. +// +// Since: 0.47 +type MsgUpdateParamsResponse struct { +} + +func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} } +func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsResponse) ProtoMessage() {} +func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c9e0a673aba8d6fd, []int{5} +} +func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsResponse.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 *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src) +} +func (m *MsgUpdateParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgAddSchedule)(nil), "neutron.cron.MsgAddSchedule") + proto.RegisterType((*MsgAddScheduleResponse)(nil), "neutron.cron.MsgAddScheduleResponse") + proto.RegisterType((*MsgRemoveSchedule)(nil), "neutron.cron.MsgRemoveSchedule") + proto.RegisterType((*MsgRemoveScheduleResponse)(nil), "neutron.cron.MsgRemoveScheduleResponse") + proto.RegisterType((*MsgUpdateParams)(nil), "neutron.cron.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "neutron.cron.MsgUpdateParamsResponse") +} + +func init() { proto.RegisterFile("neutron/cron/tx.proto", fileDescriptor_c9e0a673aba8d6fd) } + +var fileDescriptor_c9e0a673aba8d6fd = []byte{ + // 554 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0xbf, 0x6b, 0xdb, 0x40, + 0x14, 0xf6, 0xd9, 0x8e, 0xc1, 0xe7, 0xe0, 0x10, 0xd5, 0x75, 0x64, 0x25, 0x55, 0x8c, 0x68, 0x1b, + 0xd7, 0x10, 0x89, 0xba, 0xb4, 0x05, 0x6f, 0x71, 0x31, 0x74, 0x11, 0xb4, 0x72, 0xbb, 0x64, 0x09, + 0x8a, 0x74, 0x9c, 0x05, 0x95, 0x4e, 0xe8, 0x4e, 0xc6, 0xd9, 0x4a, 0xc7, 0x4c, 0xed, 0x5f, 0xd0, + 0xb5, 0xd0, 0xc5, 0x43, 0xff, 0x88, 0x8c, 0xa1, 0x53, 0xa7, 0x52, 0xec, 0xc1, 0xff, 0x46, 0xd1, + 0xaf, 0x44, 0x17, 0x41, 0x0a, 0x85, 0x2c, 0xa7, 0x7b, 0xef, 0xfb, 0xde, 0xd3, 0x77, 0xdf, 0x3d, + 0x0e, 0xde, 0xf7, 0x50, 0xc8, 0x02, 0xe2, 0x69, 0x56, 0xb4, 0xb0, 0xb9, 0xea, 0x07, 0x84, 0x11, + 0x61, 0x33, 0x4d, 0xab, 0x51, 0x5a, 0xda, 0x36, 0x5d, 0xc7, 0x23, 0x5a, 0xbc, 0x26, 0x04, 0x69, + 0xc7, 0x22, 0xd4, 0x25, 0x54, 0x73, 0x29, 0xd6, 0x66, 0x4f, 0xa3, 0x4f, 0x0a, 0x74, 0x12, 0xe0, + 0x24, 0x8e, 0xb4, 0x24, 0x48, 0xa1, 0x16, 0x26, 0x98, 0x24, 0xf9, 0x68, 0x97, 0x15, 0x70, 0x0a, + 0x7c, 0x33, 0x30, 0xdd, 0xac, 0x60, 0x97, 0x83, 0xa8, 0x35, 0x45, 0x76, 0xf8, 0x01, 0x25, 0xa0, + 0xf2, 0xb5, 0x0c, 0x9b, 0x3a, 0xc5, 0x47, 0xb6, 0x3d, 0x49, 0x01, 0xe1, 0x05, 0xac, 0x9b, 0x21, + 0x9b, 0x92, 0xc0, 0x61, 0x67, 0x22, 0xe8, 0x82, 0x5e, 0x7d, 0x24, 0xfe, 0xfc, 0x71, 0xd8, 0x4a, + 0x55, 0x1c, 0xd9, 0x76, 0x80, 0x28, 0x9d, 0xb0, 0xc0, 0xf1, 0xb0, 0x71, 0x4d, 0x15, 0x04, 0x58, + 0xf5, 0x4c, 0x17, 0x89, 0xe5, 0xa8, 0xc4, 0x88, 0xf7, 0x42, 0x1b, 0xd6, 0x7c, 0x14, 0x38, 0xc4, + 0x16, 0x2b, 0x5d, 0xd0, 0xab, 0x1a, 0x69, 0x24, 0x0c, 0x61, 0xd5, 0xa5, 0x98, 0x8a, 0xd5, 0x6e, + 0xa5, 0xd7, 0x18, 0x74, 0xd5, 0xbc, 0x51, 0xaa, 0x4e, 0xf1, 0x78, 0x8e, 0xac, 0x90, 0xa1, 0x57, + 0xc4, 0x63, 0x81, 0x69, 0xb1, 0x51, 0xf5, 0xe2, 0xf7, 0x7e, 0xc9, 0x88, 0x6b, 0x84, 0x31, 0xdc, + 0x42, 0x31, 0xec, 0x10, 0xef, 0x84, 0x32, 0x13, 0x23, 0x71, 0xa3, 0x0b, 0x7a, 0xcd, 0xc1, 0x1e, + 0xdf, 0x66, 0x9c, 0x91, 0x26, 0x11, 0xc7, 0x68, 0x22, 0x2e, 0x1e, 0x3e, 0xfe, 0xb4, 0x5e, 0xf4, + 0xaf, 0xe5, 0x9f, 0xaf, 0x17, 0xfd, 0x7b, 0xb1, 0x43, 0xbc, 0x1d, 0x8a, 0x08, 0xdb, 0x7c, 0xc6, + 0x40, 0xd4, 0x27, 0x1e, 0x45, 0xca, 0x39, 0x80, 0xdb, 0x3a, 0xc5, 0x06, 0x72, 0xc9, 0x0c, 0xdd, + 0x85, 0x7d, 0xc3, 0x27, 0x45, 0x8d, 0xed, 0x4c, 0x23, 0xff, 0x5b, 0x65, 0x17, 0x76, 0x0a, 0xc9, + 0x2b, 0xa5, 0xdf, 0x01, 0xdc, 0xd2, 0x29, 0x7e, 0xef, 0xdb, 0x26, 0x43, 0x6f, 0xe2, 0xe1, 0xf8, + 0x6f, 0x9d, 0x2f, 0x61, 0x2d, 0x19, 0xaf, 0x58, 0x69, 0x63, 0xd0, 0xe2, 0x5d, 0x4f, 0xba, 0x8f, + 0xea, 0xd1, 0x85, 0x7d, 0x5b, 0x2f, 0xfa, 0xc0, 0x48, 0xe9, 0xc3, 0x83, 0xe2, 0x61, 0x5a, 0xd9, + 0x61, 0xf2, 0xca, 0x94, 0x0e, 0xdc, 0xb9, 0x91, 0xca, 0x0e, 0x32, 0xf8, 0x52, 0x86, 0x15, 0x9d, + 0x62, 0xe1, 0x2d, 0x6c, 0xe4, 0x47, 0x76, 0xaf, 0x30, 0x40, 0x39, 0x54, 0x7a, 0x78, 0x1b, 0x9a, + 0xb5, 0x16, 0x8e, 0x61, 0xf3, 0xc6, 0x4d, 0xee, 0x17, 0xea, 0x78, 0x82, 0x74, 0xf0, 0x0f, 0xc2, + 0x55, 0xef, 0x77, 0x70, 0x93, 0xf3, 0xfe, 0x41, 0xa1, 0x30, 0x0f, 0x4b, 0x8f, 0x6e, 0x85, 0xb3, + 0xae, 0xd2, 0xc6, 0xc7, 0xc8, 0xdf, 0xd1, 0xeb, 0x8b, 0xa5, 0x0c, 0x2e, 0x97, 0x32, 0xf8, 0xb3, + 0x94, 0xc1, 0xe7, 0x95, 0x5c, 0xba, 0x5c, 0xc9, 0xa5, 0x5f, 0x2b, 0xb9, 0x74, 0xac, 0x62, 0x87, + 0x4d, 0xc3, 0x53, 0xd5, 0x22, 0xae, 0x96, 0x76, 0x3c, 0x24, 0x01, 0xce, 0xf6, 0xda, 0xec, 0xb9, + 0x36, 0x4f, 0x9f, 0xac, 0x33, 0x1f, 0xd1, 0xd3, 0x5a, 0xfc, 0x26, 0x3c, 0xfb, 0x1b, 0x00, 0x00, + 0xff, 0xff, 0x37, 0xae, 0x51, 0x3e, 0xcf, 0x04, 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 { + // Adds new schedule. + AddSchedule(ctx context.Context, in *MsgAddSchedule, opts ...grpc.CallOption) (*MsgAddScheduleResponse, error) + // Removes schedule. + RemoveSchedule(ctx context.Context, in *MsgRemoveSchedule, opts ...grpc.CallOption) (*MsgRemoveScheduleResponse, error) + // Updates the module parameters. + UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) AddSchedule(ctx context.Context, in *MsgAddSchedule, opts ...grpc.CallOption) (*MsgAddScheduleResponse, error) { + out := new(MsgAddScheduleResponse) + err := c.cc.Invoke(ctx, "/neutron.cron.Msg/AddSchedule", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) RemoveSchedule(ctx context.Context, in *MsgRemoveSchedule, opts ...grpc.CallOption) (*MsgRemoveScheduleResponse, error) { + out := new(MsgRemoveScheduleResponse) + err := c.cc.Invoke(ctx, "/neutron.cron.Msg/RemoveSchedule", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { + out := new(MsgUpdateParamsResponse) + err := c.cc.Invoke(ctx, "/neutron.cron.Msg/UpdateParams", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // Adds new schedule. + AddSchedule(context.Context, *MsgAddSchedule) (*MsgAddScheduleResponse, error) + // Removes schedule. + RemoveSchedule(context.Context, *MsgRemoveSchedule) (*MsgRemoveScheduleResponse, error) + // Updates the module parameters. + UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) AddSchedule(ctx context.Context, req *MsgAddSchedule) (*MsgAddScheduleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddSchedule not implemented") +} +func (*UnimplementedMsgServer) RemoveSchedule(ctx context.Context, req *MsgRemoveSchedule) (*MsgRemoveScheduleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RemoveSchedule not implemented") +} +func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_AddSchedule_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAddSchedule) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).AddSchedule(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/neutron.cron.Msg/AddSchedule", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).AddSchedule(ctx, req.(*MsgAddSchedule)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_RemoveSchedule_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRemoveSchedule) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RemoveSchedule(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/neutron.cron.Msg/RemoveSchedule", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RemoveSchedule(ctx, req.(*MsgRemoveSchedule)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateParams) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/neutron.cron.Msg/UpdateParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "neutron.cron.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "AddSchedule", + Handler: _Msg_AddSchedule_Handler, + }, + { + MethodName: "RemoveSchedule", + Handler: _Msg_RemoveSchedule_Handler, + }, + { + MethodName: "UpdateParams", + Handler: _Msg_UpdateParams_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "neutron/cron/tx.proto", +} + +func (m *MsgAddSchedule) 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 *MsgAddSchedule) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddSchedule) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ExecutionStage != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ExecutionStage)) + i-- + dAtA[i] = 0x28 + } + if len(m.Msgs) > 0 { + for iNdEx := len(m.Msgs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Msgs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if m.Period != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Period)) + i-- + dAtA[i] = 0x18 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintTx(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgAddScheduleResponse) 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 *MsgAddScheduleResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddScheduleResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgRemoveSchedule) 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 *MsgRemoveSchedule) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRemoveSchedule) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintTx(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRemoveScheduleResponse) 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 *MsgRemoveScheduleResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRemoveScheduleResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParams) 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 *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsResponse) 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 *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgAddSchedule) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Period != 0 { + n += 1 + sovTx(uint64(m.Period)) + } + if len(m.Msgs) > 0 { + for _, e := range m.Msgs { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + if m.ExecutionStage != 0 { + n += 1 + sovTx(uint64(m.ExecutionStage)) + } + return n +} + +func (m *MsgAddScheduleResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgRemoveSchedule) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRemoveScheduleResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgAddSchedule) 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 ErrIntOverflowTx + } + 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: MsgAddSchedule: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddSchedule: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Period", wireType) + } + m.Period = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Period |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Msgs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Msgs = append(m.Msgs, MsgExecuteContract{}) + if err := m.Msgs[len(m.Msgs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecutionStage", wireType) + } + m.ExecutionStage = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExecutionStage |= ExecutionStage(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgAddScheduleResponse) 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 ErrIntOverflowTx + } + 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: MsgAddScheduleResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgAddScheduleResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRemoveSchedule) 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 ErrIntOverflowTx + } + 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: MsgRemoveSchedule: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRemoveSchedule: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRemoveScheduleResponse) 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 ErrIntOverflowTx + } + 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: MsgRemoveScheduleResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRemoveScheduleResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParams) 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 ErrIntOverflowTx + } + 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: MsgUpdateParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParamsResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/cron/types/types.go b/x/cron/types/types.go new file mode 100644 index 000000000..ab1254f4c --- /dev/null +++ b/x/cron/types/types.go @@ -0,0 +1 @@ +package types diff --git a/x/cron/types/v1/schedule.pb.go b/x/cron/types/v1/schedule.pb.go new file mode 100644 index 000000000..a37932a39 --- /dev/null +++ b/x/cron/types/v1/schedule.pb.go @@ -0,0 +1,842 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: neutron/cron/v1/schedule.proto + +package v1 + +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 + +// Defines the schedule for execution +type Schedule struct { + // Name of schedule + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // Period in blocks + Period uint64 `protobuf:"varint,2,opt,name=period,proto3" json:"period,omitempty"` + // Msgs that will be executed every certain number of blocks, specified in the `period` field + Msgs []MsgExecuteContract `protobuf:"bytes,3,rep,name=msgs,proto3" json:"msgs"` + // Last execution's block height + LastExecuteHeight uint64 `protobuf:"varint,4,opt,name=last_execute_height,json=lastExecuteHeight,proto3" json:"last_execute_height,omitempty"` +} + +func (m *Schedule) Reset() { *m = Schedule{} } +func (m *Schedule) String() string { return proto.CompactTextString(m) } +func (*Schedule) ProtoMessage() {} +func (*Schedule) Descriptor() ([]byte, []int) { + return fileDescriptor_cd4938034d592826, []int{0} +} +func (m *Schedule) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Schedule) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Schedule.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 *Schedule) XXX_Merge(src proto.Message) { + xxx_messageInfo_Schedule.Merge(m, src) +} +func (m *Schedule) XXX_Size() int { + return m.Size() +} +func (m *Schedule) XXX_DiscardUnknown() { + xxx_messageInfo_Schedule.DiscardUnknown(m) +} + +var xxx_messageInfo_Schedule proto.InternalMessageInfo + +func (m *Schedule) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Schedule) GetPeriod() uint64 { + if m != nil { + return m.Period + } + return 0 +} + +func (m *Schedule) GetMsgs() []MsgExecuteContract { + if m != nil { + return m.Msgs + } + return nil +} + +func (m *Schedule) GetLastExecuteHeight() uint64 { + if m != nil { + return m.LastExecuteHeight + } + return 0 +} + +// Defines the contract and the message to pass +type MsgExecuteContract struct { + // The address of the smart contract + Contract string `protobuf:"bytes,1,opt,name=contract,proto3" json:"contract,omitempty"` + // JSON encoded message to be passed to the contract + Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` +} + +func (m *MsgExecuteContract) Reset() { *m = MsgExecuteContract{} } +func (m *MsgExecuteContract) String() string { return proto.CompactTextString(m) } +func (*MsgExecuteContract) ProtoMessage() {} +func (*MsgExecuteContract) Descriptor() ([]byte, []int) { + return fileDescriptor_cd4938034d592826, []int{1} +} +func (m *MsgExecuteContract) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgExecuteContract) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgExecuteContract.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 *MsgExecuteContract) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgExecuteContract.Merge(m, src) +} +func (m *MsgExecuteContract) XXX_Size() int { + return m.Size() +} +func (m *MsgExecuteContract) XXX_DiscardUnknown() { + xxx_messageInfo_MsgExecuteContract.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgExecuteContract proto.InternalMessageInfo + +func (m *MsgExecuteContract) GetContract() string { + if m != nil { + return m.Contract + } + return "" +} + +func (m *MsgExecuteContract) GetMsg() string { + if m != nil { + return m.Msg + } + return "" +} + +// Defines the number of current schedules +type ScheduleCount struct { + // The number of current schedules + Count int32 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` +} + +func (m *ScheduleCount) Reset() { *m = ScheduleCount{} } +func (m *ScheduleCount) String() string { return proto.CompactTextString(m) } +func (*ScheduleCount) ProtoMessage() {} +func (*ScheduleCount) Descriptor() ([]byte, []int) { + return fileDescriptor_cd4938034d592826, []int{2} +} +func (m *ScheduleCount) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ScheduleCount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ScheduleCount.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 *ScheduleCount) XXX_Merge(src proto.Message) { + xxx_messageInfo_ScheduleCount.Merge(m, src) +} +func (m *ScheduleCount) XXX_Size() int { + return m.Size() +} +func (m *ScheduleCount) XXX_DiscardUnknown() { + xxx_messageInfo_ScheduleCount.DiscardUnknown(m) +} + +var xxx_messageInfo_ScheduleCount proto.InternalMessageInfo + +func (m *ScheduleCount) GetCount() int32 { + if m != nil { + return m.Count + } + return 0 +} + +func init() { + proto.RegisterType((*Schedule)(nil), "neutron.cron.v1.Schedule") + proto.RegisterType((*MsgExecuteContract)(nil), "neutron.cron.v1.MsgExecuteContract") + proto.RegisterType((*ScheduleCount)(nil), "neutron.cron.v1.ScheduleCount") +} + +func init() { proto.RegisterFile("neutron/cron/v1/schedule.proto", fileDescriptor_cd4938034d592826) } + +var fileDescriptor_cd4938034d592826 = []byte{ + // 316 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x91, 0xc1, 0x4a, 0xc3, 0x30, + 0x18, 0xc7, 0x1b, 0xd7, 0x8d, 0x2d, 0x22, 0x6a, 0x1c, 0x52, 0x76, 0x88, 0x63, 0x22, 0xec, 0x62, + 0x42, 0x15, 0x8f, 0x5e, 0x36, 0x04, 0x41, 0xbc, 0xd4, 0x9b, 0x97, 0xb1, 0x65, 0x21, 0x1d, 0xac, + 0x4d, 0x69, 0xd2, 0x32, 0xdf, 0xc2, 0x97, 0xf0, 0x5d, 0x76, 0xdc, 0xd1, 0x93, 0x48, 0xfb, 0x22, + 0x92, 0x34, 0xf3, 0xa0, 0x97, 0xf0, 0xfb, 0xf3, 0xff, 0xfe, 0xf9, 0xbe, 0x2f, 0x81, 0x38, 0xe5, + 0x85, 0xce, 0x65, 0x4a, 0x99, 0x39, 0xca, 0x90, 0x2a, 0x16, 0xf3, 0x65, 0xb1, 0xe6, 0x24, 0xcb, + 0xa5, 0x96, 0xe8, 0xd8, 0xf9, 0xc4, 0xf8, 0xa4, 0x0c, 0x07, 0x7d, 0x21, 0x85, 0xb4, 0x1e, 0x35, + 0xd4, 0x94, 0x8d, 0x3e, 0x00, 0xec, 0xbe, 0xb8, 0x24, 0x42, 0xd0, 0x4f, 0xe7, 0x09, 0x0f, 0xc0, + 0x10, 0x8c, 0x7b, 0x91, 0x65, 0x74, 0x0e, 0x3b, 0x19, 0xcf, 0x57, 0x72, 0x19, 0x1c, 0x0c, 0xc1, + 0xd8, 0x8f, 0x9c, 0x42, 0xf7, 0xd0, 0x4f, 0x94, 0x50, 0x41, 0x6b, 0xd8, 0x1a, 0x1f, 0xde, 0x5c, + 0x92, 0x3f, 0xed, 0xc8, 0xb3, 0x12, 0x0f, 0x1b, 0xce, 0x0a, 0xcd, 0xa7, 0x32, 0xd5, 0xf9, 0x9c, + 0xe9, 0x89, 0xbf, 0xfd, 0xba, 0xf0, 0x22, 0x1b, 0x43, 0x04, 0x9e, 0xad, 0xe7, 0x4a, 0xcf, 0x78, + 0x53, 0x33, 0x8b, 0xf9, 0x4a, 0xc4, 0x3a, 0xf0, 0x6d, 0x8f, 0x53, 0x63, 0xb9, 0xf4, 0xa3, 0x35, + 0x46, 0x13, 0x88, 0xfe, 0xdf, 0x88, 0x06, 0xb0, 0xcb, 0x1c, 0xbb, 0xa1, 0x7f, 0x35, 0x3a, 0x81, + 0xad, 0x44, 0x09, 0x3b, 0x75, 0x2f, 0x32, 0x38, 0xba, 0x82, 0x47, 0xfb, 0x55, 0xa7, 0xb2, 0x48, + 0x35, 0xea, 0xc3, 0x36, 0x33, 0x60, 0xb3, 0xed, 0xa8, 0x11, 0x93, 0xa7, 0x6d, 0x85, 0xc1, 0xae, + 0xc2, 0xe0, 0xbb, 0xc2, 0xe0, 0xbd, 0xc6, 0xde, 0xae, 0xc6, 0xde, 0x67, 0x8d, 0xbd, 0xd7, 0x50, + 0xac, 0x74, 0x5c, 0x2c, 0x08, 0x93, 0x09, 0x75, 0xfb, 0x5e, 0xcb, 0x5c, 0xec, 0x99, 0x96, 0x77, + 0x74, 0xd3, 0xfc, 0x87, 0x7e, 0xcb, 0xb8, 0xa2, 0x65, 0xb8, 0xe8, 0xd8, 0x67, 0xbe, 0xfd, 0x09, + 0x00, 0x00, 0xff, 0xff, 0x43, 0xbd, 0xcc, 0x86, 0xaf, 0x01, 0x00, 0x00, +} + +func (m *Schedule) 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 *Schedule) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Schedule) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.LastExecuteHeight != 0 { + i = encodeVarintSchedule(dAtA, i, uint64(m.LastExecuteHeight)) + i-- + dAtA[i] = 0x20 + } + if len(m.Msgs) > 0 { + for iNdEx := len(m.Msgs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Msgs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSchedule(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.Period != 0 { + i = encodeVarintSchedule(dAtA, i, uint64(m.Period)) + i-- + dAtA[i] = 0x10 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintSchedule(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgExecuteContract) 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 *MsgExecuteContract) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExecuteContract) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Msg) > 0 { + i -= len(m.Msg) + copy(dAtA[i:], m.Msg) + i = encodeVarintSchedule(dAtA, i, uint64(len(m.Msg))) + i-- + dAtA[i] = 0x12 + } + if len(m.Contract) > 0 { + i -= len(m.Contract) + copy(dAtA[i:], m.Contract) + i = encodeVarintSchedule(dAtA, i, uint64(len(m.Contract))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ScheduleCount) 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 *ScheduleCount) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ScheduleCount) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Count != 0 { + i = encodeVarintSchedule(dAtA, i, uint64(m.Count)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintSchedule(dAtA []byte, offset int, v uint64) int { + offset -= sovSchedule(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Schedule) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovSchedule(uint64(l)) + } + if m.Period != 0 { + n += 1 + sovSchedule(uint64(m.Period)) + } + if len(m.Msgs) > 0 { + for _, e := range m.Msgs { + l = e.Size() + n += 1 + l + sovSchedule(uint64(l)) + } + } + if m.LastExecuteHeight != 0 { + n += 1 + sovSchedule(uint64(m.LastExecuteHeight)) + } + return n +} + +func (m *MsgExecuteContract) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Contract) + if l > 0 { + n += 1 + l + sovSchedule(uint64(l)) + } + l = len(m.Msg) + if l > 0 { + n += 1 + l + sovSchedule(uint64(l)) + } + return n +} + +func (m *ScheduleCount) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Count != 0 { + n += 1 + sovSchedule(uint64(m.Count)) + } + return n +} + +func sovSchedule(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozSchedule(x uint64) (n int) { + return sovSchedule(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Schedule) 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 ErrIntOverflowSchedule + } + 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: Schedule: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Schedule: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSchedule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSchedule + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSchedule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Period", wireType) + } + m.Period = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSchedule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Period |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Msgs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSchedule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSchedule + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSchedule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Msgs = append(m.Msgs, MsgExecuteContract{}) + if err := m.Msgs[len(m.Msgs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LastExecuteHeight", wireType) + } + m.LastExecuteHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSchedule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LastExecuteHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipSchedule(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSchedule + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgExecuteContract) 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 ErrIntOverflowSchedule + } + 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: MsgExecuteContract: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgExecuteContract: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Contract", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSchedule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSchedule + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSchedule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Contract = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSchedule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSchedule + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSchedule + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Msg = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSchedule(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSchedule + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ScheduleCount) 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 ErrIntOverflowSchedule + } + 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: ScheduleCount: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ScheduleCount: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType) + } + m.Count = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSchedule + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Count |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipSchedule(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSchedule + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipSchedule(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, ErrIntOverflowSchedule + } + 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, ErrIntOverflowSchedule + } + 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, ErrIntOverflowSchedule + } + 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, ErrInvalidLengthSchedule + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupSchedule + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthSchedule + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthSchedule = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowSchedule = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupSchedule = fmt.Errorf("proto: unexpected end of group") +) From 1c9ad74e0a851eb8f2ab5167d46b5c6267987e40 Mon Sep 17 00:00:00 2001 From: cboh4 Date: Wed, 26 Feb 2025 14:02:43 +0200 Subject: [PATCH 2/8] fix compilation errors, remove excessive code --- app/app.go | 4 + app/config.go | 2 + app/keepers/keepers.go | 17 ++ app/modules.go | 4 + go.mod | 4 +- proto/secret/cron/genesis.proto | 8 +- proto/secret/cron/params.proto | 4 +- proto/secret/cron/query.proto | 14 +- proto/secret/cron/schedule.proto | 4 +- proto/secret/cron/tx.proto | 8 +- proto/secret/cron/v1/schedule.proto | 4 +- x/cron/client/cli/query.go | 2 +- x/cron/client/cli/query_params.go | 3 +- x/cron/client/cli/query_schedule.go | 2 +- x/cron/client/cli/query_schedule_test.go | 162 ------------ x/cron/client/cli/tx.go | 2 +- x/cron/genesis.go | 4 +- x/cron/genesis_test.go | 38 --- x/cron/keeper/grpc_query.go | 2 +- x/cron/keeper/grpc_query_params.go | 2 +- x/cron/keeper/grpc_query_params_test.go | 22 -- x/cron/keeper/grpc_query_schedule.go | 2 +- x/cron/keeper/grpc_query_schedule_test.go | 145 ----------- x/cron/keeper/keeper.go | 13 +- x/cron/keeper/keeper_test.go | 295 ---------------------- x/cron/keeper/migrations.go | 2 +- x/cron/keeper/msg_server.go | 27 +- x/cron/keeper/msg_server_test.go | 221 ---------------- x/cron/keeper/params.go | 2 +- x/cron/keeper/params_test.go | 30 --- x/cron/migrations/v2/store.go | 2 +- x/cron/migrations/v2/store_test.go | 60 ----- x/cron/module.go | 6 +- x/cron/module_simulation.go | 4 +- x/cron/types/codec.go | 2 +- x/cron/types/expected_keepers.go | 2 +- x/cron/types/genesis.pb.go | 43 ++-- x/cron/types/genesis_test.go | 51 ---- x/cron/types/params.pb.go | 38 +-- x/cron/types/query.pb.go | 117 ++++----- x/cron/types/query.pb.gw.go | 8 +- x/cron/types/schedule.pb.go | 82 +++--- x/cron/types/tx.pb.go | 127 +++++----- x/cron/types/v1/schedule.pb.go | 67 ++--- 44 files changed, 331 insertions(+), 1327 deletions(-) delete mode 100644 x/cron/client/cli/query_schedule_test.go delete mode 100644 x/cron/genesis_test.go delete mode 100644 x/cron/keeper/grpc_query_params_test.go delete mode 100644 x/cron/keeper/grpc_query_schedule_test.go delete mode 100644 x/cron/keeper/keeper_test.go delete mode 100644 x/cron/keeper/msg_server_test.go delete mode 100644 x/cron/keeper/params_test.go delete mode 100644 x/cron/migrations/v2/store_test.go delete mode 100644 x/cron/types/genesis_test.go diff --git a/app/app.go b/app/app.go index da50fa38f..9d2a9f104 100644 --- a/app/app.go +++ b/app/app.go @@ -82,6 +82,7 @@ import ( slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + crontypes "github.com/scrtlabs/SecretNetwork/x/cron/types" "cosmossdk.io/log" upgradetypes "cosmossdk.io/x/upgrade/types" @@ -591,6 +592,7 @@ func SetOrderBeginBlockers(app *SecretNetworkApp) { compute.ModuleName, reg.ModuleName, ibcswitchtypes.ModuleName, + crontypes.ModuleName, circuittypes.ModuleName, ) } @@ -624,6 +626,7 @@ func SetOrderInitGenesis(app *SecretNetworkApp) { ibcfeetypes.ModuleName, feegrant.ModuleName, + crontypes.ModuleName, circuittypes.ModuleName, ) } @@ -653,6 +656,7 @@ func SetOrderEndBlockers(app *SecretNetworkApp) { compute.ModuleName, reg.ModuleName, ibcswitchtypes.ModuleName, + crontypes.ModuleName, circuittypes.ModuleName, ) } diff --git a/app/config.go b/app/config.go index f00eec733..f9ad289a6 100644 --- a/app/config.go +++ b/app/config.go @@ -33,6 +33,7 @@ import ( "github.com/cosmos/ibc-go/v8/modules/apps/transfer" ibc "github.com/cosmos/ibc-go/v8/modules/core" ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + "github.com/scrtlabs/SecretNetwork/x/cron" ibcswitch "github.com/scrtlabs/SecretNetwork/x/emergencybutton" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -78,6 +79,7 @@ var mbasics = module.NewBasicManager( ica.AppModuleBasic{}, packetforwardrouter.AppModuleBasic{}, ibcfee.AppModuleBasic{}, + cron.AppModuleBasic{}, }, // our stuff customModuleBasics()..., diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index c50078b06..a2bdfb85f 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -55,6 +55,9 @@ import ( ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" "github.com/scrtlabs/SecretNetwork/x/compute" + cronkeeper "github.com/scrtlabs/SecretNetwork/x/cron/keeper" + crontypes "github.com/scrtlabs/SecretNetwork/x/cron/types" + reg "github.com/scrtlabs/SecretNetwork/x/registration" ibcpacketforwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8/packetforward/keeper" @@ -81,6 +84,7 @@ type SecretAppKeepers struct { AuthzKeeper *authzkeeper.Keeper BankKeeper *bankkeeper.BaseKeeper CapabilityKeeper *capabilitykeeper.Keeper + CronKeeper *cronkeeper.Keeper StakingKeeper *stakingkeeper.Keeper SlashingKeeper *slashingkeeper.Keeper MintKeeper *mintkeeper.Keeper @@ -237,6 +241,15 @@ func (ak *SecretAppKeepers) InitSdkKeepers( ) ak.CircuitKeeper = &circuitKeeper + cronKeeper := cronkeeper.NewKeeper( + appCodec, + ak.keys[crontypes.StoreKey], + ak.memKeys[crontypes.StoreKey], + ak.AccountKeeper, + authtypes.NewModuleAddress(crontypes.ModuleName).String(), + ) + ak.CronKeeper = cronKeeper + feegrantKeeper := feegrantkeeper.NewKeeper( appCodec, runtime.NewKVStoreService(ak.keys[feegrant.StoreKey]), @@ -537,6 +550,8 @@ func (ak *SecretAppKeepers) InitCustomKeepers( ak.ComputeKeeper = &computeKeeper wasmHooks.ContractKeeper = ak.ComputeKeeper + ak.CronKeeper.WasmMsgServer = compute.NewMsgServerImpl(*ak.ComputeKeeper) + // Compute receive: Switch -> Fee -> Packet Forward -> WASM Hooks var computeStack porttypes.IBCModule computeStack = compute.NewIBCHandler(ak.ComputeKeeper, ak.IbcKeeper.ChannelKeeper, ak.IbcFeeKeeper) @@ -589,6 +604,7 @@ func (ak *SecretAppKeepers) InitKeys() { ibcswitch.StoreKey, ibchookstypes.StoreKey, circuittypes.StoreKey, + crontypes.StoreKey, ) ak.tKeys = storetypes.NewTransientStoreKeys(paramstypes.TStoreKey) @@ -612,6 +628,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(compute.ModuleName) paramsKeeper.Subspace(reg.ModuleName) paramsKeeper.Subspace(ibcswitch.ModuleName).WithKeyTable(ibcswitchtypes.ParamKeyTable()) + paramsKeeper.Subspace(crontypes.ModuleName) return paramsKeeper } diff --git a/app/modules.go b/app/modules.go index bfdc6e8d8..905826cc0 100644 --- a/app/modules.go +++ b/app/modules.go @@ -39,6 +39,8 @@ import ( ibc "github.com/cosmos/ibc-go/v8/modules/core" ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" "github.com/scrtlabs/SecretNetwork/x/compute" + "github.com/scrtlabs/SecretNetwork/x/cron" + crontypes "github.com/scrtlabs/SecretNetwork/x/cron/types" ibcswitch "github.com/scrtlabs/SecretNetwork/x/emergencybutton" reg "github.com/scrtlabs/SecretNetwork/x/registration" ) @@ -55,6 +57,7 @@ var ModuleAccountPermissions = map[string][]string{ ibcfeetypes.ModuleName: nil, ibcswitch.ModuleName: nil, compute.ModuleName: {authtypes.Burner}, + crontypes.ModuleName: nil, } func Modules( @@ -88,5 +91,6 @@ func Modules( packetforward.NewAppModule(app.AppKeepers.PacketForwardKeeper, app.AppKeepers.GetSubspace(packetforwardtypes.ModuleName)), ibcfee.NewAppModule(app.AppKeepers.IbcFeeKeeper), ibcswitch.NewAppModule(app.AppKeepers.IbcSwitchKeeper, app.AppKeepers.GetSubspace(ibcswitch.ModuleName)), + cron.NewAppModule(app.appCodec, *app.AppKeepers.CronKeeper), } } diff --git a/go.mod b/go.mod index 152b06544..91d73f2e9 100644 --- a/go.mod +++ b/go.mod @@ -73,7 +73,9 @@ require ( github.com/cosmos/cosmos-proto v1.0.0-beta.5 github.com/cosmos/rosetta v0.50.4 github.com/gogo/protobuf v1.3.2 + github.com/hashicorp/go-metrics v0.5.3 golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 + gopkg.in/yaml.v2 v2.4.0 ) require ( @@ -153,7 +155,6 @@ require ( github.com/hashicorp/go-getter v1.7.4 // indirect github.com/hashicorp/go-hclog v1.5.0 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect - github.com/hashicorp/go-metrics v0.5.3 // indirect github.com/hashicorp/go-plugin v1.5.2 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect github.com/hashicorp/go-version v1.6.0 // indirect @@ -226,7 +227,6 @@ require ( google.golang.org/api v0.186.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.1 // indirect nhooyr.io/websocket v1.8.6 // indirect diff --git a/proto/secret/cron/genesis.proto b/proto/secret/cron/genesis.proto index 9a570c257..9e8644c85 100644 --- a/proto/secret/cron/genesis.proto +++ b/proto/secret/cron/genesis.proto @@ -1,12 +1,12 @@ syntax = "proto3"; -package neutron.cron; +package secret.cron; import "gogoproto/gogo.proto"; -import "neutron/cron/params.proto"; -import "neutron/cron/schedule.proto"; +import "secret/cron/params.proto"; +import "secret/cron/schedule.proto"; // this line is used by starport scaffolding # genesis/proto/import -option go_package = "github.com/neutron-org/neutron/v5/x/cron/types"; +option go_package = "github.com/scrtlabs/SecretNetwork/x/cron/types"; // Defines the cron module's genesis state. message GenesisState { diff --git a/proto/secret/cron/params.proto b/proto/secret/cron/params.proto index 0018d73ed..d55884e3d 100644 --- a/proto/secret/cron/params.proto +++ b/proto/secret/cron/params.proto @@ -1,9 +1,9 @@ syntax = "proto3"; -package neutron.cron; +package secret.cron; import "gogoproto/gogo.proto"; -option go_package = "github.com/neutron-org/neutron/v5/x/cron/types"; +option go_package = "github.com/scrtlabs/SecretNetwork/x/cron/types"; // Defines the parameters for the module. message Params { diff --git a/proto/secret/cron/query.proto b/proto/secret/cron/query.proto index c75045c1e..ca5015168 100644 --- a/proto/secret/cron/query.proto +++ b/proto/secret/cron/query.proto @@ -1,30 +1,30 @@ syntax = "proto3"; -package neutron.cron; +package secret.cron; import "cosmos/base/query/v1beta1/pagination.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -import "neutron/cron/params.proto"; -import "neutron/cron/schedule.proto"; +import "secret/cron/params.proto"; +import "secret/cron/schedule.proto"; // this line is used by starport scaffolding # 1 -option go_package = "github.com/neutron-org/neutron/v5/x/cron/types"; +option go_package = "github.com/scrtlabs/SecretNetwork/x/cron/types"; // Defines the gRPC querier service. service Query { // Queries the parameters of the module. rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/neutron/cron/params"; + option (google.api.http).get = "/secret/cron/params"; } // Queries a Schedule by name. rpc Schedule(QueryGetScheduleRequest) returns (QueryGetScheduleResponse) { - option (google.api.http).get = "/neutron/cron/schedule/{name}"; + option (google.api.http).get = "/secret/cron/schedule/{name}"; } // Queries a list of Schedule items. rpc Schedules(QuerySchedulesRequest) returns (QuerySchedulesResponse) { - option (google.api.http).get = "/neutron/cron/schedule"; + option (google.api.http).get = "/secret/cron/schedule"; } // this line is used by starport scaffolding # 2 diff --git a/proto/secret/cron/schedule.proto b/proto/secret/cron/schedule.proto index 7cfa2caa6..96bf2db9d 100644 --- a/proto/secret/cron/schedule.proto +++ b/proto/secret/cron/schedule.proto @@ -1,9 +1,9 @@ syntax = "proto3"; -package neutron.cron; +package secret.cron; import "gogoproto/gogo.proto"; -option go_package = "github.com/neutron-org/neutron/v5/x/cron/types"; +option go_package = "github.com/scrtlabs/SecretNetwork/x/cron/types"; // Defines when messages will be executed in the block enum ExecutionStage { diff --git a/proto/secret/cron/tx.proto b/proto/secret/cron/tx.proto index be869cdd8..43b177fa3 100644 --- a/proto/secret/cron/tx.proto +++ b/proto/secret/cron/tx.proto @@ -1,16 +1,16 @@ syntax = "proto3"; -package neutron.cron; +package secret.cron; import "amino/amino.proto"; import "cosmos/msg/v1/msg.proto"; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; -import "neutron/cron/params.proto"; -import "neutron/cron/schedule.proto"; +import "secret/cron/params.proto"; +import "secret/cron/schedule.proto"; // this line is used by starport scaffolding # proto/tx/import -option go_package = "github.com/neutron-org/neutron/v5/x/cron/types"; +option go_package = "github.com/scrtlabs/SecretNetwork/x/cron/types"; // Defines the Msg service. service Msg { diff --git a/proto/secret/cron/v1/schedule.proto b/proto/secret/cron/v1/schedule.proto index 3593f5058..deecc36ec 100644 --- a/proto/secret/cron/v1/schedule.proto +++ b/proto/secret/cron/v1/schedule.proto @@ -1,9 +1,9 @@ syntax = "proto3"; -package neutron.cron.v1; +package secret.cron.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/neutron-org/neutron/v5/x/cron/types/v1"; +option go_package = "github.com/scrtlabs/SecretNetwork/x/cron/types/v1"; // Defines the schedule for execution message Schedule { diff --git a/x/cron/client/cli/query.go b/x/cron/client/cli/query.go index 0b8d433e1..a334e6c18 100644 --- a/x/cron/client/cli/query.go +++ b/x/cron/client/cli/query.go @@ -7,7 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" - "github.com/neutron-org/neutron/v5/x/cron/types" + "github.com/scrtlabs/SecretNetwork/x/cron/types" ) // GetQueryCmd returns the cli query commands for this module diff --git a/x/cron/client/cli/query_params.go b/x/cron/client/cli/query_params.go index 0500a73ce..5965cd126 100644 --- a/x/cron/client/cli/query_params.go +++ b/x/cron/client/cli/query_params.go @@ -5,9 +5,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/scrtlabs/SecretNetwork/x/cron/types" "github.com/spf13/cobra" - - "github.com/neutron-org/neutron/v5/x/cron/types" ) func CmdQueryParams() *cobra.Command { diff --git a/x/cron/client/cli/query_schedule.go b/x/cron/client/cli/query_schedule.go index 08142d832..f29cc63b7 100644 --- a/x/cron/client/cli/query_schedule.go +++ b/x/cron/client/cli/query_schedule.go @@ -7,7 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" - "github.com/neutron-org/neutron/v5/x/cron/types" + "github.com/scrtlabs/SecretNetwork/x/cron/types" ) func CmdListSchedule() *cobra.Command { diff --git a/x/cron/client/cli/query_schedule_test.go b/x/cron/client/cli/query_schedule_test.go deleted file mode 100644 index 27970dd18..000000000 --- a/x/cron/client/cli/query_schedule_test.go +++ /dev/null @@ -1,162 +0,0 @@ -package cli_test - -import ( - "fmt" - "strconv" - "testing" - - tmcli "github.com/cometbft/cometbft/libs/cli" - "github.com/cosmos/cosmos-sdk/client/flags" - clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" - "github.com/stretchr/testify/require" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - "github.com/neutron-org/neutron/v5/testutil/common/nullify" - "github.com/neutron-org/neutron/v5/testutil/cron/network" - "github.com/neutron-org/neutron/v5/x/cron/client/cli" - "github.com/neutron-org/neutron/v5/x/cron/types" -) - -func networkWithScheduleObjects(t *testing.T, n int) (*network.Network, []types.Schedule) { - t.Helper() - cfg := network.DefaultConfig() - state := types.GenesisState{} - require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state)) - - for i := 0; i < n; i++ { - schedule := types.Schedule{ - Name: strconv.Itoa(i), - Period: 1000, - Msgs: []types.MsgExecuteContract{}, - LastExecuteHeight: uint64(0), - } - state.ScheduleList = append(state.ScheduleList, schedule) - } - state.Params = types.DefaultParams() - buf, err := cfg.Codec.MarshalJSON(&state) - require.NoError(t, err) - cfg.GenesisState[types.ModuleName] = buf - return network.New(t, cfg), state.ScheduleList -} - -func TestShowSchedule(t *testing.T) { - net, objs := networkWithScheduleObjects(t, 2) - - ctx := net.Validators[0].ClientCtx - common := []string{ - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - } - for _, tc := range []struct { - desc string - name string - - args []string - err error - obj types.Schedule - }{ - { - desc: "found", - name: objs[0].Name, - - args: common, - obj: objs[0], - err: nil, - }, - { - desc: "not found", - name: strconv.Itoa(100000), - - args: common, - err: status.Error(codes.NotFound, "not found"), - }, - } { - t.Run(tc.desc, func(t *testing.T) { - args := []string{ - tc.name, - } - args = append(args, tc.args...) - out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowSchedule(), args) - if tc.err != nil { - stat, ok := status.FromError(tc.err) - require.True(t, ok) - require.ErrorIs(t, stat.Err(), tc.err) - } else { - require.NoError(t, err) - var resp types.QueryGetScheduleResponse - require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) - require.NotNil(t, resp.Schedule) - require.Equal(t, - nullify.Fill(&tc.obj), - nullify.Fill(&resp.Schedule), - ) - } - }) - } -} - -func TestListSchedule(t *testing.T) { - net, objs := networkWithScheduleObjects(t, 5) - - ctx := net.Validators[0].ClientCtx - request := func(next []byte, offset, limit uint64, total bool) []string { - args := []string{ - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - } - if next == nil { - args = append(args, fmt.Sprintf("--%s=%d", flags.FlagOffset, offset)) - } else { - args = append(args, fmt.Sprintf("--%s=%s", flags.FlagPageKey, next)) - } - args = append(args, fmt.Sprintf("--%s=%d", flags.FlagLimit, limit)) - if total { - args = append(args, fmt.Sprintf("--%s", flags.FlagCountTotal)) - } - return args - } - t.Run("ByOffset", func(t *testing.T) { - step := 2 - for i := 0; i < len(objs); i += step { - args := request(nil, uint64(i), uint64(step), false) //nolint:gosec - out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListSchedule(), args) - require.NoError(t, err) - var resp types.QuerySchedulesResponse - require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) - require.LessOrEqual(t, len(resp.Schedules), step) - require.Subset(t, - nullify.Fill(objs), - nullify.Fill(resp.Schedules), - ) - } - }) - t.Run("ByKey", func(t *testing.T) { - step := 2 - var next []byte - for i := 0; i < len(objs); i += step { - args := request(next, 0, uint64(step), false) //nolint:gosec - out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListSchedule(), args) - require.NoError(t, err) - var resp types.QuerySchedulesResponse - require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) - require.LessOrEqual(t, len(resp.Schedules), step) - require.Subset(t, - nullify.Fill(objs), - nullify.Fill(resp.Schedules), - ) - next = resp.Pagination.NextKey - } - }) - t.Run("Total", func(t *testing.T) { - args := request(nil, 0, uint64(len(objs)), true) - out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListSchedule(), args) - require.NoError(t, err) - var resp types.QuerySchedulesResponse - require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) - require.NoError(t, err) - require.Equal(t, len(objs), int(resp.Pagination.Total)) //nolint:gosec - require.ElementsMatch(t, - nullify.Fill(objs), - nullify.Fill(resp.Schedules), - ) - }) -} diff --git a/x/cron/client/cli/tx.go b/x/cron/client/cli/tx.go index 565daeb0d..429f7f5ec 100644 --- a/x/cron/client/cli/tx.go +++ b/x/cron/client/cli/tx.go @@ -7,7 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" - "github.com/neutron-org/neutron/v5/x/cron/types" + "github.com/scrtlabs/SecretNetwork/x/cron/types" ) // GetTxCmd returns the transaction commands for this module diff --git a/x/cron/genesis.go b/x/cron/genesis.go index 78b82c5ae..450aba558 100644 --- a/x/cron/genesis.go +++ b/x/cron/genesis.go @@ -3,8 +3,8 @@ package cron import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/neutron-org/neutron/v5/x/cron/keeper" - "github.com/neutron-org/neutron/v5/x/cron/types" + "github.com/scrtlabs/SecretNetwork/x/cron/keeper" + "github.com/scrtlabs/SecretNetwork/x/cron/types" ) // InitGenesis initializes the module's state from a provided genesis state. diff --git a/x/cron/genesis_test.go b/x/cron/genesis_test.go deleted file mode 100644 index 9ec174bbe..000000000 --- a/x/cron/genesis_test.go +++ /dev/null @@ -1,38 +0,0 @@ -package cron_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/neutron-org/neutron/v5/testutil/common/nullify" - "github.com/neutron-org/neutron/v5/testutil/cron/keeper" - "github.com/neutron-org/neutron/v5/x/cron" - "github.com/neutron-org/neutron/v5/x/cron/types" -) - -func TestGenesis(t *testing.T) { - k, ctx := keeper.CronKeeper(t, nil, nil) - - genesisState := types.GenesisState{ - Params: types.DefaultParams(), - ScheduleList: []types.Schedule{ - { - Name: "a", - Period: 5, - Msgs: nil, - LastExecuteHeight: uint64(ctx.BlockHeight()), //nolint:gosec - }, - }, - } - - cron.InitGenesis(ctx, *k, genesisState) - got := cron.ExportGenesis(ctx, *k) - require.NotNil(t, got) - - nullify.Fill(&genesisState) - nullify.Fill(got) - - require.Equal(t, genesisState.Params, got.Params) - require.ElementsMatch(t, genesisState.ScheduleList, got.ScheduleList) -} diff --git a/x/cron/keeper/grpc_query.go b/x/cron/keeper/grpc_query.go index 50017a573..a8b699c8c 100644 --- a/x/cron/keeper/grpc_query.go +++ b/x/cron/keeper/grpc_query.go @@ -1,7 +1,7 @@ package keeper import ( - "github.com/neutron-org/neutron/v5/x/cron/types" + "github.com/scrtlabs/SecretNetwork/x/cron/types" ) var _ types.QueryServer = Keeper{} diff --git a/x/cron/keeper/grpc_query_params.go b/x/cron/keeper/grpc_query_params.go index a646a7abb..77f3b0f68 100644 --- a/x/cron/keeper/grpc_query_params.go +++ b/x/cron/keeper/grpc_query_params.go @@ -7,7 +7,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/neutron-org/neutron/v5/x/cron/types" + "github.com/scrtlabs/SecretNetwork/x/cron/types" ) func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { diff --git a/x/cron/keeper/grpc_query_params_test.go b/x/cron/keeper/grpc_query_params_test.go deleted file mode 100644 index 64d1d4a13..000000000 --- a/x/cron/keeper/grpc_query_params_test.go +++ /dev/null @@ -1,22 +0,0 @@ -package keeper_test - -import ( - "testing" - - testkeeper "github.com/neutron-org/neutron/v5/testutil/cron/keeper" - - "github.com/stretchr/testify/require" - - "github.com/neutron-org/neutron/v5/x/cron/types" -) - -func TestParamsQuery(t *testing.T) { - keeper, ctx := testkeeper.CronKeeper(t, nil, nil) - params := types.DefaultParams() - err := keeper.SetParams(ctx, params) - require.NoError(t, err) - - response, err := keeper.Params(ctx, &types.QueryParamsRequest{}) - require.NoError(t, err) - require.Equal(t, &types.QueryParamsResponse{Params: params}, response) -} diff --git a/x/cron/keeper/grpc_query_schedule.go b/x/cron/keeper/grpc_query_schedule.go index 4b4d1d5ee..c4bd0e124 100644 --- a/x/cron/keeper/grpc_query_schedule.go +++ b/x/cron/keeper/grpc_query_schedule.go @@ -9,7 +9,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/neutron-org/neutron/v5/x/cron/types" + "github.com/scrtlabs/SecretNetwork/x/cron/types" ) func (k Keeper) Schedules(c context.Context, req *types.QuerySchedulesRequest) (*types.QuerySchedulesResponse, error) { diff --git a/x/cron/keeper/grpc_query_schedule_test.go b/x/cron/keeper/grpc_query_schedule_test.go deleted file mode 100644 index 86eaf179a..000000000 --- a/x/cron/keeper/grpc_query_schedule_test.go +++ /dev/null @@ -1,145 +0,0 @@ -package keeper_test - -import ( - "strconv" - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/query" - "github.com/stretchr/testify/require" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - "github.com/neutron-org/neutron/v5/testutil/common/nullify" - testutil_keeper "github.com/neutron-org/neutron/v5/testutil/cron/keeper" - cronkeeper "github.com/neutron-org/neutron/v5/x/cron/keeper" - "github.com/neutron-org/neutron/v5/x/cron/types" -) - -// Prevent strconv unused error -var _ = strconv.IntSize - -func TestScheduleQuerySingle(t *testing.T) { - k, ctx := testutil_keeper.CronKeeper(t, nil, nil) - schedules := createNSchedule(t, ctx, k, 2) - - for _, tc := range []struct { - desc string - request *types.QueryGetScheduleRequest - response *types.QueryGetScheduleResponse - err error - }{ - { - desc: "First", - request: &types.QueryGetScheduleRequest{ - Name: schedules[0].Name, - }, - response: &types.QueryGetScheduleResponse{Schedule: schedules[0]}, - }, - { - desc: "Second", - request: &types.QueryGetScheduleRequest{ - Name: schedules[1].Name, - }, - response: &types.QueryGetScheduleResponse{Schedule: schedules[1]}, - }, - { - desc: "KeyIsAbsent", - request: &types.QueryGetScheduleRequest{ - Name: "absent_key", - }, - err: status.Error(codes.NotFound, "schedule not found"), - }, - { - desc: "InvalidRequest", - err: status.Error(codes.InvalidArgument, "invalid request"), - }, - } { - t.Run(tc.desc, func(t *testing.T) { - response, err := k.Schedule(ctx, tc.request) - if tc.err != nil { - require.ErrorIs(t, err, tc.err) - } else { - require.NoError(t, err) - require.Equal(t, - nullify.Fill(tc.response), - nullify.Fill(response), - ) - } - }) - } -} - -func TestScheduleQueryPaginated(t *testing.T) { - k, ctx := testutil_keeper.CronKeeper(t, nil, nil) - schedules := createNSchedule(t, ctx, k, 5) - - request := func(next []byte, offset, limit uint64, total bool) *types.QuerySchedulesRequest { - return &types.QuerySchedulesRequest{ - Pagination: &query.PageRequest{ - Key: next, - Offset: offset, - Limit: limit, - CountTotal: total, - }, - } - } - t.Run("ByOffset", func(t *testing.T) { - step := 2 - for i := 0; i < len(schedules); i += step { - resp, err := k.Schedules(ctx, request(nil, uint64(i), uint64(step), false)) //nolint:gosec - require.NoError(t, err) - require.LessOrEqual(t, len(resp.Schedules), step) - require.Subset(t, - nullify.Fill(schedules), - nullify.Fill(resp.Schedules), - ) - } - }) - t.Run("ByKey", func(t *testing.T) { - step := 2 - var next []byte - for i := 0; i < len(schedules); i += step { - resp, err := k.Schedules(ctx, request(next, 0, uint64(step), false)) //nolint:gosec - require.NoError(t, err) - require.LessOrEqual(t, len(resp.Schedules), step) - require.Subset(t, - nullify.Fill(schedules), - nullify.Fill(resp.Schedules), - ) - next = resp.Pagination.NextKey - } - }) - t.Run("Total", func(t *testing.T) { - resp, err := k.Schedules(ctx, request(nil, 0, 0, true)) - require.NoError(t, err) - require.Equal(t, len(schedules), int(resp.Pagination.Total)) //nolint:gosec - require.ElementsMatch(t, - nullify.Fill(schedules), - nullify.Fill(resp.Schedules), - ) - }) - t.Run("InvalidRequest", func(t *testing.T) { - _, err := k.Schedules(ctx, nil) - require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) - }) -} - -func createNSchedule(t *testing.T, ctx sdk.Context, k *cronkeeper.Keeper, n int32) []types.Schedule { - res := make([]types.Schedule, n) - - for idx, item := range res { - item.Name = strconv.Itoa(idx) - item.Period = 1000 - item.Msgs = nil - item.LastExecuteHeight = uint64(ctx.BlockHeight()) //nolint:gosec - item.ExecutionStage = types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER - - err := k.AddSchedule(ctx, item.Name, item.Period, item.Msgs, item.ExecutionStage) - require.NoError(t, err) - - res[idx] = item - } - - return res -} diff --git a/x/cron/keeper/keeper.go b/x/cron/keeper/keeper.go index 61fa71ac4..a34d4ce5c 100644 --- a/x/cron/keeper/keeper.go +++ b/x/cron/keeper/keeper.go @@ -11,13 +11,13 @@ import ( "github.com/cosmos/cosmos-sdk/telemetry" "cosmossdk.io/store/prefix" - wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + wasmtypes "github.com/scrtlabs/SecretNetwork/x/compute" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/neutron-org/neutron/v5/x/cron/types" + "github.com/scrtlabs/SecretNetwork/x/cron/types" ) var ( @@ -186,13 +186,12 @@ func (k *Keeper) executeSchedule(ctx sdk.Context, schedule types.Schedule) error k.storeSchedule(ctx, schedule) cacheCtx, writeFn := ctx.CacheContext() - for idx, msg := range schedule.Msgs { executeMsg := wasmtypes.MsgExecuteContract{ - Sender: k.accountKeeper.GetModuleAddress(types.ModuleName).String(), - Contract: msg.Contract, - Msg: []byte(msg.Msg), - Funds: sdk.NewCoins(), + Sender: k.accountKeeper.GetModuleAddress(types.ModuleName), + Contract: sdk.AccAddress(msg.Contract), + Msg: []byte(msg.Msg), + SentFunds: sdk.NewCoins(), } _, err := k.WasmMsgServer.ExecuteContract(cacheCtx, &executeMsg) if err != nil { diff --git a/x/cron/keeper/keeper_test.go b/x/cron/keeper/keeper_test.go deleted file mode 100644 index 4882f7ae4..000000000 --- a/x/cron/keeper/keeper_test.go +++ /dev/null @@ -1,295 +0,0 @@ -package keeper_test - -import ( - "fmt" - "strconv" - "testing" - - "github.com/stretchr/testify/assert" - - wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/require" - - "github.com/neutron-org/neutron/v5/testutil" - testutil_keeper "github.com/neutron-org/neutron/v5/testutil/cron/keeper" - mock_types "github.com/neutron-org/neutron/v5/testutil/mocks/cron/types" - "github.com/neutron-org/neutron/v5/x/cron/types" -) - -// ExecuteReadySchedules: -// - calls msgServer.execute() on ready schedules -// - updates ready schedules lastExecuteHeight -// - does not update lastExecuteHeight of unready schedules -// - does not go over the limit -func TestKeeperExecuteReadySchedules(t *testing.T) { - ctrl := gomock.NewController(t) - defer ctrl.Finish() - - accountKeeper := mock_types.NewMockAccountKeeper(ctrl) - addr, err := sdk.AccAddressFromBech32(testutil.TestOwnerAddress) - require.NoError(t, err) - - wasmMsgServer := mock_types.NewMockWasmMsgServer(ctrl) - k, ctx := testutil_keeper.CronKeeper(t, wasmMsgServer, accountKeeper) - ctx = ctx.WithBlockHeight(0) - - err = k.SetParams(ctx, types.Params{ - SecurityAddress: testutil.TestOwnerAddress, - Limit: 2, - }) - require.NoError(t, err) - - schedules := []types.Schedule{ - { - Name: "1_unready1", - Period: 10, - Msgs: []types.MsgExecuteContract{ - { - Contract: "1_neutron", - Msg: "1_msg", - }, - }, - LastExecuteHeight: 4, - ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER, - }, - { - Name: "2_ready1", - Period: 4, - Msgs: []types.MsgExecuteContract{ - { - Contract: "2_neutron", - Msg: "2_msg", - }, - }, - LastExecuteHeight: 0, - ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER, - }, - { - Name: "3_ready2", - Period: 4, - Msgs: []types.MsgExecuteContract{ - { - Contract: "3_neutron", - Msg: "3_msg", - }, - }, - LastExecuteHeight: 0, - ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER, - }, - { - Name: "4_unready2", - Period: 10, - Msgs: []types.MsgExecuteContract{}, - LastExecuteHeight: 4, - ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER, - }, - { - Name: "5_ready3", - Period: 3, - Msgs: []types.MsgExecuteContract{ - { - Contract: "5_neutron", - Msg: "5_msg", - }, - }, - LastExecuteHeight: 0, - ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER, - }, - { - Name: "6_ready4", - Period: 3, - Msgs: []types.MsgExecuteContract{ - { - Contract: "6_neutron", - Msg: "6_msg", - }, - }, - LastExecuteHeight: 0, - ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER, - }, - } - - for _, item := range schedules { - ctx = ctx.WithBlockHeight(int64(item.LastExecuteHeight)) //nolint:gosec - err := k.AddSchedule(ctx, item.Name, item.Period, item.Msgs, item.ExecutionStage) - require.NoError(t, err) - } - - count := k.GetScheduleCount(ctx) - require.Equal(t, count, int32(6)) - - ctx = ctx.WithBlockHeight(5) - - accountKeeper.EXPECT().GetModuleAddress(types.ModuleName).Return(addr).AnyTimes() - wasmMsgServer.EXPECT().ExecuteContract(gomock.Any(), &wasmtypes.MsgExecuteContract{ - Sender: testutil.TestOwnerAddress, - Contract: "2_neutron", - Msg: []byte("2_msg"), - Funds: sdk.NewCoins(), - }).Return(nil, fmt.Errorf("executeerror")) - wasmMsgServer.EXPECT().ExecuteContract(gomock.Any(), &wasmtypes.MsgExecuteContract{ - Sender: testutil.TestOwnerAddress, - Contract: "3_neutron", - Msg: []byte("3_msg"), - Funds: sdk.NewCoins(), - }).Return(&wasmtypes.MsgExecuteContractResponse{}, nil) - - k.ExecuteReadySchedules(ctx, types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER) - - unready1, _ := k.GetSchedule(ctx, "1_unready1") - ready1, _ := k.GetSchedule(ctx, "2_ready1") - ready2, _ := k.GetSchedule(ctx, "3_ready2") - unready2, _ := k.GetSchedule(ctx, "4_unready2") - ready3, _ := k.GetSchedule(ctx, "5_ready3") - ready4, _ := k.GetSchedule(ctx, "6_ready4") - - require.Equal(t, uint64(4), unready1.LastExecuteHeight) - require.Equal(t, uint64(5), ready1.LastExecuteHeight) - require.Equal(t, uint64(5), ready2.LastExecuteHeight) - require.Equal(t, uint64(4), unready2.LastExecuteHeight) - require.Equal(t, uint64(0), ready3.LastExecuteHeight) - require.Equal(t, uint64(0), ready4.LastExecuteHeight) - - // let's make another call at the next height - // Notice that now only one ready schedule left because we got limit of 2 at once - ctx = ctx.WithBlockHeight(6) - - wasmMsgServer.EXPECT().ExecuteContract(gomock.Any(), &wasmtypes.MsgExecuteContract{ - Sender: testutil.TestOwnerAddress, - Contract: "5_neutron", - Msg: []byte("5_msg"), - Funds: sdk.NewCoins(), - }).Return(&wasmtypes.MsgExecuteContractResponse{}, nil) - - k.ExecuteReadySchedules(ctx, types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER) - - unready1, _ = k.GetSchedule(ctx, "1_unready1") - ready1, _ = k.GetSchedule(ctx, "2_ready1") - ready2, _ = k.GetSchedule(ctx, "3_ready2") - unready2, _ = k.GetSchedule(ctx, "4_unready2") - ready3, _ = k.GetSchedule(ctx, "5_ready3") - ready4, _ = k.GetSchedule(ctx, "6_ready4") - - require.Equal(t, uint64(4), unready1.LastExecuteHeight) - require.Equal(t, uint64(5), ready1.LastExecuteHeight) - require.Equal(t, uint64(5), ready2.LastExecuteHeight) - require.Equal(t, uint64(4), unready2.LastExecuteHeight) - require.Equal(t, uint64(6), ready3.LastExecuteHeight) - require.Equal(t, uint64(0), ready4.LastExecuteHeight) - - ctx = ctx.WithBlockHeight(7) - - wasmMsgServer.EXPECT().ExecuteContract(gomock.Any(), &wasmtypes.MsgExecuteContract{ - Sender: testutil.TestOwnerAddress, - Contract: "6_neutron", - Msg: []byte("6_msg"), - Funds: sdk.NewCoins(), - }).Return(&wasmtypes.MsgExecuteContractResponse{}, nil) - - k.ExecuteReadySchedules(ctx, types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER) - - unready1, _ = k.GetSchedule(ctx, "1_unready1") - ready1, _ = k.GetSchedule(ctx, "2_ready1") - ready2, _ = k.GetSchedule(ctx, "3_ready2") - unready2, _ = k.GetSchedule(ctx, "4_unready2") - ready3, _ = k.GetSchedule(ctx, "5_ready3") - ready4, _ = k.GetSchedule(ctx, "6_ready4") - - require.Equal(t, uint64(4), unready1.LastExecuteHeight) - require.Equal(t, uint64(5), ready1.LastExecuteHeight) - require.Equal(t, uint64(5), ready2.LastExecuteHeight) - require.Equal(t, uint64(4), unready2.LastExecuteHeight) - require.Equal(t, uint64(6), ready3.LastExecuteHeight) - require.Equal(t, uint64(7), ready4.LastExecuteHeight) -} - -func TestAddSchedule(t *testing.T) { - ctrl := gomock.NewController(t) - defer ctrl.Finish() - - accountKeeper := mock_types.NewMockAccountKeeper(ctrl) - - wasmMsgServer := mock_types.NewMockWasmMsgServer(ctrl) - k, ctx := testutil_keeper.CronKeeper(t, wasmMsgServer, accountKeeper) - ctx = ctx.WithBlockHeight(0) - - err := k.SetParams(ctx, types.Params{ - SecurityAddress: testutil.TestOwnerAddress, - Limit: 2, - }) - require.NoError(t, err) - - // normal add schedule - err = k.AddSchedule(ctx, "a", 7, []types.MsgExecuteContract{ - { - Contract: "c", - Msg: "m", - }, - }, types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER) - require.NoError(t, err) - - err = k.AddSchedule(ctx, "b", 7, []types.MsgExecuteContract{ - { - Contract: "c", - Msg: "m", - }, - }, types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER) - require.NoError(t, err) - - // second time with same name returns error - err = k.AddSchedule(ctx, "a", 5, []types.MsgExecuteContract{}, types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER) - require.Error(t, err) - - scheduleA, found := k.GetSchedule(ctx, "a") - require.True(t, found) - require.Equal(t, scheduleA.Name, "a") - require.Equal(t, scheduleA.Period, uint64(7)) - require.Equal(t, scheduleA.Msgs, []types.MsgExecuteContract{ - {Contract: "c", Msg: "m"}, - }) - require.Equal(t, scheduleA.ExecutionStage, types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER) - - schedules := k.GetAllSchedules(ctx) - require.Len(t, schedules, 2) - require.Equal(t, schedules[0].ExecutionStage, types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER) - require.Equal(t, schedules[1].ExecutionStage, types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER) - - // remove schedule works - k.RemoveSchedule(ctx, "a") - _, found = k.GetSchedule(ctx, "a") - assert.False(t, found) - - // does not panic even though we don't have it - k.RemoveSchedule(ctx, "a") -} - -func TestGetAllSchedules(t *testing.T) { - k, ctx := testutil_keeper.CronKeeper(t, nil, nil) - - err := k.SetParams(ctx, types.Params{ - SecurityAddress: testutil.TestOwnerAddress, - Limit: 2, - }) - require.NoError(t, err) - - expectedSchedules := make([]types.Schedule, 0, 3) - for i := range []int{1, 2, 3} { - s := types.Schedule{ - Name: strconv.Itoa(i), - Period: 5, - Msgs: nil, - LastExecuteHeight: uint64(ctx.BlockHeight()), //nolint:gosec - ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER, - } - expectedSchedules = append(expectedSchedules, s) - err := k.AddSchedule(ctx, s.Name, s.Period, s.Msgs, s.ExecutionStage) - require.NoError(t, err) - } - - schedules := k.GetAllSchedules(ctx) - assert.Equal(t, 3, len(schedules)) - assert.ElementsMatch(t, schedules, expectedSchedules) - assert.Equal(t, int32(3), k.GetScheduleCount(ctx)) -} diff --git a/x/cron/keeper/migrations.go b/x/cron/keeper/migrations.go index b4c394bb1..64aaba98f 100644 --- a/x/cron/keeper/migrations.go +++ b/x/cron/keeper/migrations.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - v2 "github.com/neutron-org/neutron/v5/x/cron/migrations/v2" + v2 "github.com/scrtlabs/SecretNetwork/x/cron/migrations/v2" ) // Migrator is a struct for handling in-place store migrations. diff --git a/x/cron/keeper/msg_server.go b/x/cron/keeper/msg_server.go index ccb0bcbc4..d9dfaf862 100644 --- a/x/cron/keeper/msg_server.go +++ b/x/cron/keeper/msg_server.go @@ -5,9 +5,8 @@ import ( "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/neutron-org/neutron/v5/x/cron/types" + "github.com/scrtlabs/SecretNetwork/x/cron/types" ) type msgServer struct { @@ -28,10 +27,10 @@ func (k msgServer) AddSchedule(goCtx context.Context, req *types.MsgAddSchedule) return nil, errors.Wrap(err, "failed to validate MsgAddSchedule") } - authority := k.keeper.GetAuthority() - if authority != req.Authority { - return nil, errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid authority; expected %s, got %s", authority, req.Authority) - } + // authority := k.keeper.GetAuthority() + // if authority != req.Authority { + // return nil, errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid authority; expected %s, got %s", authority, req.Authority) + // } ctx := sdk.UnwrapSDKContext(goCtx) if err := k.keeper.AddSchedule(ctx, req.Name, req.Period, req.Msgs, req.ExecutionStage); err != nil { @@ -47,10 +46,10 @@ func (k msgServer) RemoveSchedule(goCtx context.Context, req *types.MsgRemoveSch return nil, errors.Wrap(err, "failed to validate MsgRemoveSchedule") } - authority := k.keeper.GetAuthority() - if authority != req.Authority { - return nil, errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid authority; expected %s, got %s", authority, req.Authority) - } + // authority := k.keeper.GetAuthority() + // if authority != req.Authority { + // return nil, errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid authority; expected %s, got %s", authority, req.Authority) + // } ctx := sdk.UnwrapSDKContext(goCtx) k.keeper.RemoveSchedule(ctx, req.Name) @@ -64,10 +63,10 @@ func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParam return nil, errors.Wrap(err, "failed to validate MsgUpdateParams") } - authority := k.keeper.GetAuthority() - if authority != req.Authority { - return nil, errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid authority; expected %s, got %s", authority, req.Authority) - } + // authority := k.keeper.GetAuthority() + // if authority != req.Authority { + // return nil, errors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid authority; expected %s, got %s", authority, req.Authority) + // } ctx := sdk.UnwrapSDKContext(goCtx) if err := k.keeper.SetParams(ctx, req.Params); err != nil { diff --git a/x/cron/keeper/msg_server_test.go b/x/cron/keeper/msg_server_test.go deleted file mode 100644 index 4c0a6e5d3..000000000 --- a/x/cron/keeper/msg_server_test.go +++ /dev/null @@ -1,221 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/neutron-org/neutron/v5/testutil" - testkeeper "github.com/neutron-org/neutron/v5/testutil/cron/keeper" - cronkeeper "github.com/neutron-org/neutron/v5/x/cron/keeper" - "github.com/neutron-org/neutron/v5/x/cron/types" -) - -func TestMsgAddScheduleValidate(t *testing.T) { - k, ctx := testkeeper.CronKeeper(t, nil, nil) - msgServer := cronkeeper.NewMsgServerImpl(*k) - - tests := []struct { - name string - msg types.MsgAddSchedule - expectedErr string - }{ - { - "empty authority", - types.MsgAddSchedule{ - Authority: "", - Name: "name", - Period: 3, - Msgs: []types.MsgExecuteContract{ - { - Contract: "contract", - Msg: "msg", - }, - }, - ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER, - }, - "authority is invalid", - }, - { - "invalid authority", - types.MsgAddSchedule{ - Authority: "invalid authority", - Name: "name", - Period: 3, - Msgs: []types.MsgExecuteContract{ - { - Contract: "contract", - Msg: "msg", - }, - }, - ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER, - }, - "authority is invalid", - }, - { - "invalid name", - types.MsgAddSchedule{ - Authority: testutil.TestOwnerAddress, - Name: "", - Period: 3, - Msgs: []types.MsgExecuteContract{ - { - Contract: "contract", - Msg: "msg", - }, - }, - ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER, - }, - "name is invalid", - }, - { - "invalid period", - types.MsgAddSchedule{ - Authority: testutil.TestOwnerAddress, - Name: "name", - Period: 0, - Msgs: []types.MsgExecuteContract{ - { - Contract: "contract", - Msg: "msg", - }, - }, - ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER, - }, - "period is invalid", - }, - { - "empty msgs", - types.MsgAddSchedule{ - Authority: testutil.TestOwnerAddress, - Name: "name", - Period: 3, - Msgs: []types.MsgExecuteContract{}, - ExecutionStage: types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER, - }, - "msgs should not be empty", - }, - { - "invalid execution stage", - types.MsgAddSchedule{ - Authority: testutil.TestOwnerAddress, - Name: "name", - Period: 3, - Msgs: []types.MsgExecuteContract{ - { - Contract: "contract", - Msg: "msg", - }, - }, - ExecutionStage: 7, - }, - "execution stage is invalid", - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - resp, err := msgServer.AddSchedule(ctx, &tt.msg) - require.ErrorContains(t, err, tt.expectedErr) - require.Nil(t, resp) - }) - } -} - -func TestMsgRemoveScheduleValidate(t *testing.T) { - k, ctx := testkeeper.CronKeeper(t, nil, nil) - msgServer := cronkeeper.NewMsgServerImpl(*k) - - tests := []struct { - name string - msg types.MsgRemoveSchedule - expectedErr string - }{ - { - "empty authority", - types.MsgRemoveSchedule{ - Authority: "", - Name: "name", - }, - "authority is invalid", - }, - { - "invalid authority", - types.MsgRemoveSchedule{ - Authority: "invalid authority", - Name: "name", - }, - "authority is invalid", - }, - { - "invalid name", - types.MsgRemoveSchedule{ - Authority: testutil.TestOwnerAddress, - Name: "", - }, - "name is invalid", - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - resp, err := msgServer.RemoveSchedule(ctx, &tt.msg) - require.ErrorContains(t, err, tt.expectedErr) - require.Nil(t, resp) - }) - } -} - -func TestMsgUpdateParamsValidate(t *testing.T) { - k, ctx := testkeeper.CronKeeper(t, nil, nil) - msgServer := cronkeeper.NewMsgServerImpl(*k) - - tests := []struct { - name string - msg types.MsgUpdateParams - expectedErr string - }{ - { - "empty authority", - types.MsgUpdateParams{ - Authority: "", - }, - "authority is invalid", - }, - { - "invalid authority", - types.MsgUpdateParams{ - Authority: "invalid authority", - }, - "authority is invalid", - }, - { - "empty security_address", - types.MsgUpdateParams{ - Authority: testutil.TestOwnerAddress, - Params: types.Params{ - SecurityAddress: "", - }, - }, - "security_address is invalid", - }, - { - "invalid security_address", - types.MsgUpdateParams{ - Authority: testutil.TestOwnerAddress, - Params: types.Params{ - SecurityAddress: "invalid security_address", - }, - }, - "security_address is invalid", - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - resp, err := msgServer.UpdateParams(ctx, &tt.msg) - require.ErrorContains(t, err, tt.expectedErr) - require.Nil(t, resp) - }) - } -} diff --git a/x/cron/keeper/params.go b/x/cron/keeper/params.go index 81b7321e4..15891508f 100644 --- a/x/cron/keeper/params.go +++ b/x/cron/keeper/params.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/neutron-org/neutron/v5/x/cron/types" + "github.com/scrtlabs/SecretNetwork/x/cron/types" ) // GetParams get all parameters as types.Params diff --git a/x/cron/keeper/params_test.go b/x/cron/keeper/params_test.go deleted file mode 100644 index be0630f66..000000000 --- a/x/cron/keeper/params_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/neutron-org/neutron/v5/app/config" - - "github.com/neutron-org/neutron/v5/testutil" - - testkeeper "github.com/neutron-org/neutron/v5/testutil/cron/keeper" - - "github.com/stretchr/testify/require" - - "github.com/neutron-org/neutron/v5/x/cron/types" -) - -func TestGetParams(t *testing.T) { - _ = config.GetDefaultConfig() - - k, ctx := testkeeper.CronKeeper(t, nil, nil) - params := types.Params{ - SecurityAddress: testutil.TestOwnerAddress, - Limit: 5, - } - - err := k.SetParams(ctx, params) - require.NoError(t, err) - - require.EqualValues(t, params, k.GetParams(ctx)) -} diff --git a/x/cron/migrations/v2/store.go b/x/cron/migrations/v2/store.go index dae71e591..31ad49101 100644 --- a/x/cron/migrations/v2/store.go +++ b/x/cron/migrations/v2/store.go @@ -7,7 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/neutron-org/neutron/v5/x/cron/types" + "github.com/scrtlabs/SecretNetwork/x/cron/types" ) // MigrateStore performs in-place store migrations. diff --git a/x/cron/migrations/v2/store_test.go b/x/cron/migrations/v2/store_test.go deleted file mode 100644 index a1a3c4fef..000000000 --- a/x/cron/migrations/v2/store_test.go +++ /dev/null @@ -1,60 +0,0 @@ -package v2_test - -import ( - "testing" - - "cosmossdk.io/store/prefix" - "github.com/stretchr/testify/suite" - - "github.com/neutron-org/neutron/v5/testutil" - v2 "github.com/neutron-org/neutron/v5/x/cron/migrations/v2" - "github.com/neutron-org/neutron/v5/x/cron/types" - v1types "github.com/neutron-org/neutron/v5/x/cron/types/v1" -) - -type V2CronMigrationTestSuite struct { - testutil.IBCConnectionTestSuite -} - -func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(V2CronMigrationTestSuite)) -} - -func (suite *V2CronMigrationTestSuite) TestScheduleUpgrade() { - var ( - app = suite.GetNeutronZoneApp(suite.ChainA) - storeKey = app.GetKey(types.StoreKey) - ctx = suite.ChainA.GetContext() - cdc = app.AppCodec() - ) - - schedule := v1types.Schedule{ - Name: "name", - Period: 3, - Msgs: []v1types.MsgExecuteContract{ - { - Contract: "contract", - Msg: "msg", - }, - }, - LastExecuteHeight: 1, - } - - store := prefix.NewStore(ctx.KVStore(storeKey), types.ScheduleKey) - bz := cdc.MustMarshal(&schedule) - store.Set(types.GetScheduleKey(schedule.Name), bz) - - // Run migration - suite.NoError(v2.MigrateStore(ctx, cdc, storeKey)) - - // Check Schedule has correct ExecutionStage - newSchedule, _ := app.CronKeeper.GetSchedule(ctx, schedule.Name) - suite.Equal(newSchedule.Name, schedule.Name) - suite.Equal(newSchedule.Period, schedule.Period) - for i, msg := range newSchedule.Msgs { - suite.Equal(msg.Contract, schedule.Msgs[i].Contract) - suite.Equal(msg.Msg, schedule.Msgs[i].Msg) - } - suite.Equal(newSchedule.LastExecuteHeight, schedule.LastExecuteHeight) - suite.Equal(newSchedule.ExecutionStage, types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER) -} diff --git a/x/cron/module.go b/x/cron/module.go index e86ee8745..994ef7e17 100644 --- a/x/cron/module.go +++ b/x/cron/module.go @@ -20,9 +20,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/neutron-org/neutron/v5/x/cron/client/cli" - "github.com/neutron-org/neutron/v5/x/cron/keeper" - "github.com/neutron-org/neutron/v5/x/cron/types" + "github.com/scrtlabs/SecretNetwork/x/cron/client/cli" + "github.com/scrtlabs/SecretNetwork/x/cron/keeper" + "github.com/scrtlabs/SecretNetwork/x/cron/types" ) var ( diff --git a/x/cron/module_simulation.go b/x/cron/module_simulation.go index 0ada92486..a93a336e9 100644 --- a/x/cron/module_simulation.go +++ b/x/cron/module_simulation.go @@ -7,8 +7,8 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" - cronsimulation "github.com/neutron-org/neutron/v5/x/cron/simulation" - "github.com/neutron-org/neutron/v5/x/cron/types" + cronsimulation "github.com/scrtlabs/SecretNetwork/x/cron/simulation" + "github.com/scrtlabs/SecretNetwork/x/cron/types" ) // avoid unused import issue diff --git a/x/cron/types/codec.go b/x/cron/types/codec.go index 6772e97b9..7776c54d1 100644 --- a/x/cron/types/codec.go +++ b/x/cron/types/codec.go @@ -8,7 +8,7 @@ import ( ) func RegisterCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgUpdateParams{}, "neutron.cron.MsgUpdateParams", nil) + cdc.RegisterConcrete(&MsgUpdateParams{}, "secret.cron.MsgUpdateParams", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { diff --git a/x/cron/types/expected_keepers.go b/x/cron/types/expected_keepers.go index cbed63584..fc2e837af 100644 --- a/x/cron/types/expected_keepers.go +++ b/x/cron/types/expected_keepers.go @@ -3,8 +3,8 @@ package types import ( "context" - wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" sdk "github.com/cosmos/cosmos-sdk/types" + wasmtypes "github.com/scrtlabs/SecretNetwork/x/compute" ) // AccountKeeper defines the expected account keeper used for simulations (noalias) diff --git a/x/cron/types/genesis.pb.go b/x/cron/types/genesis.pb.go index b3678689b..2198fa768 100644 --- a/x/cron/types/genesis.pb.go +++ b/x/cron/types/genesis.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: neutron/cron/genesis.proto +// source: secret/cron/genesis.proto package types @@ -33,7 +33,7 @@ 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_7c41f2dea8ad83c2, []int{0} + return fileDescriptor_0e9b2ffd73e56838, []int{0} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -77,28 +77,29 @@ func (m *GenesisState) GetParams() Params { } func init() { - proto.RegisterType((*GenesisState)(nil), "neutron.cron.GenesisState") + proto.RegisterType((*GenesisState)(nil), "secret.cron.GenesisState") } -func init() { proto.RegisterFile("neutron/cron/genesis.proto", fileDescriptor_7c41f2dea8ad83c2) } +func init() { proto.RegisterFile("secret/cron/genesis.proto", fileDescriptor_0e9b2ffd73e56838) } -var fileDescriptor_7c41f2dea8ad83c2 = []byte{ - // 231 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xca, 0x4b, 0x2d, 0x2d, - 0x29, 0xca, 0xcf, 0xd3, 0x4f, 0x06, 0x11, 0xe9, 0xa9, 0x79, 0xa9, 0xc5, 0x99, 0xc5, 0x7a, 0x05, - 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x3c, 0x50, 0x39, 0x3d, 0x90, 0x9c, 0x94, 0x48, 0x7a, 0x7e, 0x7a, - 0x3e, 0x58, 0x42, 0x1f, 0xc4, 0x82, 0xa8, 0x91, 0x92, 0x44, 0xd1, 0x5f, 0x90, 0x58, 0x94, 0x98, - 0x0b, 0xd5, 0x2e, 0x25, 0x8d, 0x22, 0x55, 0x9c, 0x9c, 0x91, 0x9a, 0x52, 0x9a, 0x93, 0x0a, 0x91, - 0x54, 0x6a, 0x61, 0xe4, 0xe2, 0x71, 0x87, 0xd8, 0x16, 0x5c, 0x92, 0x58, 0x92, 0x2a, 0xe4, 0xc0, - 0xc5, 0x03, 0x53, 0xe2, 0x93, 0x59, 0x5c, 0x22, 0xc1, 0xa4, 0xc0, 0xac, 0xc1, 0x6d, 0x24, 0xa6, - 0x87, 0xec, 0x06, 0xbd, 0x60, 0xa8, 0x0a, 0x27, 0x96, 0x13, 0xf7, 0xe4, 0x19, 0x82, 0x50, 0x74, - 0x08, 0x19, 0x71, 0xb1, 0x41, 0xec, 0x97, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x36, 0x12, 0x41, 0xd5, - 0x1b, 0x00, 0x96, 0x83, 0xea, 0x84, 0xaa, 0x74, 0xf2, 0x38, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, - 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, - 0x63, 0x39, 0x86, 0x28, 0xbd, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, - 0xa8, 0x39, 0xba, 0xf9, 0x45, 0xe9, 0x30, 0xb6, 0x7e, 0x99, 0xa9, 0x7e, 0x05, 0xc4, 0x67, 0x25, - 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x7f, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x5b, - 0x63, 0x56, 0x46, 0x51, 0x01, 0x00, 0x00, +var fileDescriptor_0e9b2ffd73e56838 = []byte{ + // 241 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0x4e, 0x4d, 0x2e, + 0x4a, 0x2d, 0xd1, 0x4f, 0x2e, 0xca, 0xcf, 0xd3, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, + 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x86, 0x48, 0xe9, 0x81, 0xa4, 0xa4, 0x44, 0xd2, 0xf3, + 0xd3, 0xf3, 0xc1, 0xe2, 0xfa, 0x20, 0x16, 0x44, 0x89, 0x94, 0x04, 0xb2, 0xee, 0x82, 0xc4, 0xa2, + 0xc4, 0x5c, 0xa8, 0x66, 0x29, 0x29, 0x64, 0x99, 0xe2, 0xe4, 0x8c, 0xd4, 0x94, 0xd2, 0x9c, 0x54, + 0x88, 0x9c, 0x52, 0x13, 0x23, 0x17, 0x8f, 0x3b, 0xc4, 0xaa, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, + 0x7b, 0x2e, 0x1e, 0x98, 0x12, 0x9f, 0xcc, 0xe2, 0x12, 0x09, 0x26, 0x05, 0x66, 0x0d, 0x6e, 0x23, + 0x51, 0x3d, 0x24, 0x07, 0xe8, 0x05, 0x43, 0x15, 0x38, 0xb1, 0x9c, 0xb8, 0x27, 0xcf, 0x10, 0x84, + 0xa2, 0x41, 0xc8, 0x90, 0x8b, 0x0d, 0x62, 0xbb, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xb7, 0x91, 0x30, + 0x8a, 0xd6, 0x00, 0xb0, 0x14, 0x54, 0x23, 0x54, 0xa1, 0x93, 0xc7, 0x89, 0x47, 0x72, 0x8c, 0x17, + 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, + 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, + 0xea, 0x17, 0x27, 0x17, 0x95, 0xe4, 0x24, 0x26, 0x15, 0xeb, 0x07, 0x83, 0xcd, 0xf3, 0x4b, 0x2d, + 0x29, 0xcf, 0x2f, 0xca, 0xd6, 0xaf, 0x80, 0xf8, 0xab, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, + 0xec, 0x2b, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, 0xff, 0x8e, 0x52, 0x4b, 0x01, 0x00, + 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/cron/types/genesis_test.go b/x/cron/types/genesis_test.go deleted file mode 100644 index 04d14471f..000000000 --- a/x/cron/types/genesis_test.go +++ /dev/null @@ -1,51 +0,0 @@ -package types_test - -import ( - "testing" - - "github.com/neutron-org/neutron/v5/app/config" - - "github.com/stretchr/testify/require" - - "github.com/neutron-org/neutron/v5/x/cron/types" -) - -func TestGenesisState_Validate(t *testing.T) { - config.GetDefaultConfig() - - for _, tc := range []struct { - desc string - genState *types.GenesisState - valid bool - }{ - { - desc: "valid genesis state", - genState: &types.GenesisState{ - Params: types.Params{ - SecurityAddress: "neutron17dtl0mjt3t77kpuhg2edqzjpszulwhgzcdvagh", - Limit: 1, - }, - }, - valid: true, - }, - { - desc: "invalid genesis state - params are invalid", - genState: &types.GenesisState{ - Params: types.Params{ - SecurityAddress: "", - Limit: 0, - }, - }, - valid: false, - }, - } { - t.Run(tc.desc, func(t *testing.T) { - err := tc.genState.Validate() - if tc.valid { - require.NoError(t, err) - } else { - require.Error(t, err) - } - }) - } -} diff --git a/x/cron/types/params.pb.go b/x/cron/types/params.pb.go index 6f0715acb..727b94b0e 100644 --- a/x/cron/types/params.pb.go +++ b/x/cron/types/params.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: neutron/cron/params.proto +// source: secret/cron/params.proto package types @@ -34,7 +34,7 @@ type Params struct { func (m *Params) Reset() { *m = Params{} } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_efa4f5c14a68f6e5, []int{0} + return fileDescriptor_b2b633a1a1b37414, []int{0} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -78,26 +78,26 @@ func (m *Params) GetLimit() uint64 { } func init() { - proto.RegisterType((*Params)(nil), "neutron.cron.Params") + proto.RegisterType((*Params)(nil), "secret.cron.Params") } -func init() { proto.RegisterFile("neutron/cron/params.proto", fileDescriptor_efa4f5c14a68f6e5) } +func init() { proto.RegisterFile("secret/cron/params.proto", fileDescriptor_b2b633a1a1b37414) } -var fileDescriptor_efa4f5c14a68f6e5 = []byte{ - // 198 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcc, 0x4b, 0x2d, 0x2d, - 0x29, 0xca, 0xcf, 0xd3, 0x4f, 0x06, 0x11, 0x05, 0x89, 0x45, 0x89, 0xb9, 0xc5, 0x7a, 0x05, 0x45, - 0xf9, 0x25, 0xf9, 0x42, 0x3c, 0x50, 0x29, 0x3d, 0x90, 0x94, 0x94, 0x48, 0x7a, 0x7e, 0x7a, 0x3e, - 0x58, 0x42, 0x1f, 0xc4, 0x82, 0xa8, 0x51, 0xf2, 0xe7, 0x62, 0x0b, 0x00, 0xeb, 0x11, 0xd2, 0xe4, - 0x12, 0x28, 0x4e, 0x4d, 0x2e, 0x2d, 0xca, 0x2c, 0xa9, 0x8c, 0x4f, 0x4c, 0x49, 0x29, 0x4a, 0x2d, - 0x2e, 0x96, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0xe2, 0x87, 0x89, 0x3b, 0x42, 0x84, 0x85, 0x44, - 0xb8, 0x58, 0x73, 0x32, 0x73, 0x33, 0x4b, 0x24, 0x98, 0x14, 0x18, 0x35, 0x58, 0x82, 0x20, 0x1c, - 0x2b, 0x96, 0x19, 0x0b, 0xe4, 0x19, 0x9c, 0x3c, 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, 0x4a, 0x2f, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xea, - 0x32, 0xdd, 0xfc, 0xa2, 0x74, 0x18, 0x5b, 0xbf, 0xcc, 0x54, 0xbf, 0x02, 0xe2, 0x8b, 0x92, 0xca, - 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x0b, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x43, 0x7c, - 0x1b, 0xae, 0xe2, 0x00, 0x00, 0x00, +var fileDescriptor_b2b633a1a1b37414 = []byte{ + // 207 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x28, 0x4e, 0x4d, 0x2e, + 0x4a, 0x2d, 0xd1, 0x4f, 0x2e, 0xca, 0xcf, 0xd3, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, + 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x86, 0xc8, 0xe8, 0x81, 0x64, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, + 0xf3, 0xc1, 0xe2, 0xfa, 0x20, 0x16, 0x44, 0x89, 0x92, 0x3f, 0x17, 0x5b, 0x00, 0x58, 0x8b, 0x90, + 0x26, 0x97, 0x40, 0x71, 0x6a, 0x72, 0x69, 0x51, 0x66, 0x49, 0x65, 0x7c, 0x62, 0x4a, 0x4a, 0x51, + 0x6a, 0x71, 0xb1, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x3f, 0x4c, 0xdc, 0x11, 0x22, 0x2c, + 0x24, 0xc2, 0xc5, 0x9a, 0x93, 0x99, 0x9b, 0x59, 0x22, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0x12, 0x04, + 0xe1, 0x58, 0xb1, 0xcc, 0x58, 0x20, 0xcf, 0xe0, 0xe4, 0x71, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, + 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, + 0xc7, 0x72, 0x0c, 0x51, 0x7a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, + 0xc5, 0xc9, 0x45, 0x25, 0x39, 0x89, 0x49, 0xc5, 0xfa, 0xc1, 0x60, 0x17, 0xfa, 0xa5, 0x96, 0x94, + 0xe7, 0x17, 0x65, 0xeb, 0x57, 0x40, 0x3c, 0x51, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x76, + 0xa1, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xf9, 0xd2, 0x4e, 0xc9, 0xe0, 0x00, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/cron/types/query.pb.go b/x/cron/types/query.pb.go index 4d8b3eedb..f616d87d8 100644 --- a/x/cron/types/query.pb.go +++ b/x/cron/types/query.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: neutron/cron/query.proto +// source: secret/cron/query.proto package types @@ -38,7 +38,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e02f33367c9498fe, []int{0} + return fileDescriptor_097808e20bacb68e, []int{0} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -77,7 +77,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e02f33367c9498fe, []int{1} + return fileDescriptor_097808e20bacb68e, []int{1} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -122,7 +122,7 @@ func (m *QueryGetScheduleRequest) Reset() { *m = QueryGetScheduleRequest func (m *QueryGetScheduleRequest) String() string { return proto.CompactTextString(m) } func (*QueryGetScheduleRequest) ProtoMessage() {} func (*QueryGetScheduleRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e02f33367c9498fe, []int{2} + return fileDescriptor_097808e20bacb68e, []int{2} } func (m *QueryGetScheduleRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -167,7 +167,7 @@ func (m *QueryGetScheduleResponse) Reset() { *m = QueryGetScheduleRespon func (m *QueryGetScheduleResponse) String() string { return proto.CompactTextString(m) } func (*QueryGetScheduleResponse) ProtoMessage() {} func (*QueryGetScheduleResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e02f33367c9498fe, []int{3} + return fileDescriptor_097808e20bacb68e, []int{3} } func (m *QueryGetScheduleResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -212,7 +212,7 @@ func (m *QuerySchedulesRequest) Reset() { *m = QuerySchedulesRequest{} } func (m *QuerySchedulesRequest) String() string { return proto.CompactTextString(m) } func (*QuerySchedulesRequest) ProtoMessage() {} func (*QuerySchedulesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_e02f33367c9498fe, []int{4} + return fileDescriptor_097808e20bacb68e, []int{4} } func (m *QuerySchedulesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -258,7 +258,7 @@ func (m *QuerySchedulesResponse) Reset() { *m = QuerySchedulesResponse{} func (m *QuerySchedulesResponse) String() string { return proto.CompactTextString(m) } func (*QuerySchedulesResponse) ProtoMessage() {} func (*QuerySchedulesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_e02f33367c9498fe, []int{5} + return fileDescriptor_097808e20bacb68e, []int{5} } func (m *QuerySchedulesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -302,49 +302,50 @@ func (m *QuerySchedulesResponse) GetPagination() *query.PageResponse { } func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "neutron.cron.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "neutron.cron.QueryParamsResponse") - proto.RegisterType((*QueryGetScheduleRequest)(nil), "neutron.cron.QueryGetScheduleRequest") - proto.RegisterType((*QueryGetScheduleResponse)(nil), "neutron.cron.QueryGetScheduleResponse") - proto.RegisterType((*QuerySchedulesRequest)(nil), "neutron.cron.QuerySchedulesRequest") - proto.RegisterType((*QuerySchedulesResponse)(nil), "neutron.cron.QuerySchedulesResponse") -} - -func init() { proto.RegisterFile("neutron/cron/query.proto", fileDescriptor_e02f33367c9498fe) } - -var fileDescriptor_e02f33367c9498fe = []byte{ - // 496 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xcf, 0x6b, 0x13, 0x41, - 0x14, 0xc7, 0xb3, 0xb1, 0x86, 0xe6, 0xe9, 0xe9, 0x19, 0x63, 0x5c, 0xeb, 0xb6, 0xae, 0xb6, 0x8a, - 0xd0, 0x19, 0x1a, 0x11, 0xc4, 0x63, 0x0f, 0x56, 0x6f, 0x35, 0x7a, 0xf2, 0x22, 0x93, 0x38, 0x6c, - 0x83, 0xcd, 0xcc, 0x76, 0x67, 0x36, 0x58, 0x44, 0x10, 0xff, 0x02, 0xc1, 0xb3, 0xff, 0x4f, 0x8f, - 0x05, 0x2f, 0x9e, 0x44, 0x12, 0xef, 0xfe, 0x0b, 0x65, 0xe7, 0x47, 0x9a, 0x6d, 0x96, 0xe6, 0x12, - 0x86, 0x7d, 0xdf, 0xf7, 0xfd, 0x7e, 0x66, 0xde, 0x0b, 0x74, 0x04, 0xcf, 0x75, 0x26, 0x05, 0x1d, - 0x14, 0x3f, 0x47, 0x39, 0xcf, 0x8e, 0x49, 0x9a, 0x49, 0x2d, 0xf1, 0xba, 0xab, 0x90, 0xa2, 0x12, - 0x3e, 0x1e, 0x48, 0x35, 0x92, 0x8a, 0xf6, 0x99, 0xe2, 0x56, 0x46, 0xc7, 0x3b, 0x7d, 0xae, 0xd9, - 0x0e, 0x4d, 0x59, 0x32, 0x14, 0x4c, 0x0f, 0xa5, 0xb0, 0x9d, 0x61, 0x2b, 0x91, 0x89, 0x34, 0x47, - 0x5a, 0x9c, 0xdc, 0xd7, 0xb5, 0x44, 0xca, 0xe4, 0x90, 0x53, 0x96, 0x0e, 0x29, 0x13, 0x42, 0x6a, - 0xd3, 0xa2, 0x5c, 0xf5, 0x76, 0x89, 0x23, 0x65, 0x19, 0x1b, 0xf9, 0xd2, 0x9d, 0x52, 0x49, 0x0d, - 0x0e, 0xf8, 0x87, 0xfc, 0x90, 0xdb, 0x62, 0xdc, 0x02, 0x7c, 0x5d, 0xd0, 0xec, 0x9b, 0x8e, 0x1e, - 0x3f, 0xca, 0xb9, 0xd2, 0xf1, 0x2b, 0xb8, 0x51, 0xfa, 0xaa, 0x52, 0x29, 0x14, 0xc7, 0x2e, 0x34, - 0xac, 0x73, 0x27, 0xd8, 0x08, 0x1e, 0x5d, 0xeb, 0xb6, 0xc8, 0xfc, 0x1d, 0x89, 0x55, 0xef, 0xae, - 0x9c, 0xfc, 0x59, 0xaf, 0xf5, 0x9c, 0x32, 0xde, 0x86, 0x5b, 0xc6, 0x6a, 0x8f, 0xeb, 0x37, 0x2e, - 0xda, 0xa5, 0x20, 0xc2, 0x8a, 0x60, 0x23, 0x6e, 0xcc, 0x9a, 0x3d, 0x73, 0x8e, 0xdf, 0x42, 0x67, - 0x51, 0xee, 0xe2, 0x9f, 0xc1, 0xaa, 0xa7, 0x77, 0x00, 0xed, 0x32, 0x80, 0xef, 0x70, 0x08, 0x33, - 0x75, 0xfc, 0x1e, 0x6e, 0x1a, 0x57, 0x2f, 0xf0, 0x17, 0xc5, 0x17, 0x00, 0xe7, 0xcf, 0xef, 0x4c, - 0xb7, 0x88, 0x9d, 0x15, 0x29, 0x66, 0x45, 0xec, 0x48, 0xdd, 0xac, 0xc8, 0x3e, 0x4b, 0x3c, 0x7e, - 0x6f, 0xae, 0x33, 0xfe, 0x19, 0x40, 0xfb, 0x62, 0x82, 0xa3, 0x7e, 0x0e, 0x4d, 0xcf, 0x51, 0xbc, - 0xdb, 0x95, 0xa5, 0xd8, 0xe7, 0x72, 0xdc, 0x2b, 0xe1, 0xd5, 0x0d, 0xde, 0xc3, 0xa5, 0x78, 0x36, - 0x78, 0x9e, 0xaf, 0xfb, 0xbf, 0x0e, 0x57, 0x0d, 0x1f, 0x7e, 0x84, 0x86, 0x9d, 0x13, 0x6e, 0x94, - 0x29, 0x16, 0xd7, 0x20, 0xbc, 0x77, 0x89, 0xc2, 0x86, 0xc4, 0x6b, 0xdf, 0x7e, 0xfd, 0xfb, 0x51, - 0x6f, 0x63, 0x8b, 0x56, 0x2c, 0x20, 0x7e, 0x0d, 0x60, 0xd5, 0xdf, 0x0e, 0x37, 0x2b, 0xdc, 0x16, - 0xb7, 0x22, 0xdc, 0x5a, 0x26, 0x73, 0xc9, 0x9b, 0x26, 0x79, 0x1d, 0xef, 0xd2, 0xca, 0xfd, 0xa6, - 0x9f, 0x8b, 0x7d, 0xfa, 0x82, 0x63, 0x68, 0xce, 0x66, 0x82, 0xf7, 0x2b, 0xbc, 0x2f, 0xee, 0x44, - 0xf8, 0xe0, 0x72, 0x91, 0x8b, 0x8f, 0x4c, 0x7c, 0x07, 0xdb, 0xd5, 0xf1, 0xbb, 0x2f, 0x4f, 0x26, - 0x51, 0x70, 0x3a, 0x89, 0x82, 0xbf, 0x93, 0x28, 0xf8, 0x3e, 0x8d, 0x6a, 0xa7, 0xd3, 0xa8, 0xf6, - 0x7b, 0x1a, 0xd5, 0xde, 0x91, 0x64, 0xa8, 0x0f, 0xf2, 0x3e, 0x19, 0xc8, 0x91, 0xef, 0xdd, 0x96, - 0x59, 0x32, 0xf3, 0x19, 0x3f, 0xa5, 0x9f, 0xac, 0x99, 0x3e, 0x4e, 0xb9, 0xea, 0x37, 0xcc, 0x3f, - 0xf5, 0xc9, 0x59, 0x00, 0x00, 0x00, 0xff, 0xff, 0x49, 0x47, 0xef, 0x62, 0x6b, 0x04, 0x00, 0x00, + proto.RegisterType((*QueryParamsRequest)(nil), "secret.cron.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "secret.cron.QueryParamsResponse") + proto.RegisterType((*QueryGetScheduleRequest)(nil), "secret.cron.QueryGetScheduleRequest") + proto.RegisterType((*QueryGetScheduleResponse)(nil), "secret.cron.QueryGetScheduleResponse") + proto.RegisterType((*QuerySchedulesRequest)(nil), "secret.cron.QuerySchedulesRequest") + proto.RegisterType((*QuerySchedulesResponse)(nil), "secret.cron.QuerySchedulesResponse") +} + +func init() { proto.RegisterFile("secret/cron/query.proto", fileDescriptor_097808e20bacb68e) } + +var fileDescriptor_097808e20bacb68e = []byte{ + // 497 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xcf, 0x6e, 0xd3, 0x40, + 0x10, 0xc6, 0xe3, 0x50, 0xa2, 0x66, 0x7a, 0x9b, 0x34, 0x24, 0x32, 0xc5, 0xad, 0x4c, 0xf9, 0x23, + 0x24, 0x76, 0x95, 0x72, 0x40, 0x5c, 0x7b, 0xa0, 0x3d, 0xa1, 0x92, 0xdc, 0xb8, 0xa0, 0xb5, 0x59, + 0x39, 0x11, 0x89, 0xd7, 0xf5, 0x6e, 0x80, 0x0a, 0xf5, 0xc2, 0x13, 0x20, 0x71, 0xe5, 0x81, 0x7a, + 0xac, 0xc4, 0x85, 0x13, 0x42, 0x09, 0xbc, 0x07, 0xf2, 0xfe, 0x69, 0xed, 0xba, 0x34, 0xb7, 0x95, + 0xe7, 0x9b, 0xef, 0xfb, 0xed, 0xce, 0x18, 0x7a, 0x92, 0xc7, 0x39, 0x57, 0x34, 0xce, 0x45, 0x4a, + 0x8f, 0xe7, 0x3c, 0x3f, 0x21, 0x59, 0x2e, 0x94, 0xc0, 0x0d, 0x53, 0x20, 0x45, 0xc1, 0x7f, 0x12, + 0x0b, 0x39, 0x13, 0x92, 0x46, 0x4c, 0x72, 0xa3, 0xa2, 0x1f, 0x06, 0x11, 0x57, 0x6c, 0x40, 0x33, + 0x96, 0x4c, 0x52, 0xa6, 0x26, 0x22, 0x35, 0x8d, 0xfe, 0x66, 0x22, 0x12, 0xa1, 0x8f, 0xb4, 0x38, + 0xd9, 0xaf, 0x5b, 0x89, 0x10, 0xc9, 0x94, 0x53, 0x96, 0x4d, 0x28, 0x4b, 0x53, 0xa1, 0x74, 0x8b, + 0xb4, 0xd5, 0x7e, 0x99, 0x22, 0x63, 0x39, 0x9b, 0xb9, 0x8a, 0x5f, 0xae, 0xc8, 0x78, 0xcc, 0xdf, + 0xcd, 0xa7, 0xdc, 0xd4, 0xc2, 0x4d, 0xc0, 0xd7, 0x05, 0xcb, 0x91, 0x6e, 0x18, 0xf2, 0xe3, 0x39, + 0x97, 0x2a, 0x3c, 0x84, 0x4e, 0xe5, 0xab, 0xcc, 0x44, 0x2a, 0x39, 0x0e, 0xa0, 0x65, 0x8c, 0xfb, + 0xde, 0x8e, 0xf7, 0x78, 0x63, 0xaf, 0x43, 0x4a, 0x17, 0x24, 0x46, 0xbc, 0xbf, 0x76, 0xf6, 0x6b, + 0xbb, 0x31, 0xb4, 0xc2, 0xf0, 0x29, 0xf4, 0xb4, 0xd3, 0x01, 0x57, 0x23, 0x9b, 0x6c, 0x43, 0x10, + 0x61, 0x2d, 0x65, 0x33, 0xae, 0xbd, 0xda, 0x43, 0x7d, 0x0e, 0x47, 0xd0, 0xaf, 0xcb, 0x6d, 0xfa, + 0x73, 0x58, 0x77, 0xf0, 0x36, 0xbf, 0x5b, 0xc9, 0x77, 0x0d, 0x96, 0xe0, 0x42, 0x1c, 0xbe, 0x85, + 0xae, 0x36, 0x75, 0x02, 0x77, 0x4d, 0x7c, 0x09, 0x70, 0xf9, 0xf4, 0xd6, 0xf3, 0x21, 0x31, 0x73, + 0x22, 0xc5, 0x9c, 0x88, 0x99, 0xa6, 0x9d, 0x13, 0x39, 0x62, 0x89, 0xa3, 0x1f, 0x96, 0x3a, 0xc3, + 0xef, 0x1e, 0xdc, 0xb9, 0x9a, 0x60, 0xa1, 0x5f, 0x40, 0xdb, 0x71, 0x14, 0xaf, 0x76, 0x6b, 0x15, + 0xf5, 0xa5, 0x1a, 0x0f, 0x2a, 0x74, 0x4d, 0x4d, 0xf7, 0x68, 0x25, 0x9d, 0xc9, 0x2d, 0xe3, 0xed, + 0xfd, 0x6d, 0xc2, 0x6d, 0x8d, 0x87, 0x63, 0x68, 0x99, 0x29, 0xe1, 0x76, 0x05, 0xa2, 0xbe, 0x02, + 0xfe, 0xce, 0xff, 0x05, 0x26, 0x22, 0xbc, 0xfb, 0xe5, 0xc7, 0x9f, 0x6f, 0xcd, 0x2e, 0x76, 0x68, + 0x7d, 0xf3, 0xf0, 0x14, 0xd6, 0xdd, 0xcd, 0x70, 0xb7, 0x6e, 0x55, 0x5f, 0x07, 0xff, 0xc1, 0x0a, + 0x95, 0x4d, 0xdd, 0xd5, 0xa9, 0x01, 0x6e, 0xd1, 0xeb, 0xb6, 0x9a, 0x7e, 0x2e, 0xd6, 0xe8, 0x14, + 0x25, 0xb4, 0x2f, 0x66, 0x81, 0x61, 0xdd, 0xf9, 0xea, 0x2a, 0xf8, 0xf7, 0x6f, 0xd4, 0xd8, 0xec, + 0x7b, 0x3a, 0xbb, 0x87, 0xdd, 0x6b, 0xb3, 0xf7, 0x0f, 0xcf, 0x16, 0x81, 0x77, 0xbe, 0x08, 0xbc, + 0xdf, 0x8b, 0xc0, 0xfb, 0xba, 0x0c, 0x1a, 0xe7, 0xcb, 0xa0, 0xf1, 0x73, 0x19, 0x34, 0xde, 0x90, + 0x64, 0xa2, 0xc6, 0xf3, 0x88, 0xc4, 0x62, 0x46, 0x65, 0x9c, 0xab, 0x29, 0x8b, 0x24, 0x1d, 0x69, + 0x8f, 0x57, 0x5c, 0x7d, 0x14, 0xf9, 0x7b, 0xfa, 0xc9, 0x98, 0xa9, 0x93, 0x8c, 0xcb, 0xa8, 0xa5, + 0x7f, 0xce, 0x67, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0xfe, 0x68, 0xcb, 0x84, 0x5a, 0x04, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -377,7 +378,7 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/neutron.cron.Query/Params", in, out, opts...) + err := c.cc.Invoke(ctx, "/secret.cron.Query/Params", in, out, opts...) if err != nil { return nil, err } @@ -386,7 +387,7 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . func (c *queryClient) Schedule(ctx context.Context, in *QueryGetScheduleRequest, opts ...grpc.CallOption) (*QueryGetScheduleResponse, error) { out := new(QueryGetScheduleResponse) - err := c.cc.Invoke(ctx, "/neutron.cron.Query/Schedule", in, out, opts...) + err := c.cc.Invoke(ctx, "/secret.cron.Query/Schedule", in, out, opts...) if err != nil { return nil, err } @@ -395,7 +396,7 @@ func (c *queryClient) Schedule(ctx context.Context, in *QueryGetScheduleRequest, func (c *queryClient) Schedules(ctx context.Context, in *QuerySchedulesRequest, opts ...grpc.CallOption) (*QuerySchedulesResponse, error) { out := new(QuerySchedulesResponse) - err := c.cc.Invoke(ctx, "/neutron.cron.Query/Schedules", in, out, opts...) + err := c.cc.Invoke(ctx, "/secret.cron.Query/Schedules", in, out, opts...) if err != nil { return nil, err } @@ -440,7 +441,7 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/neutron.cron.Query/Params", + FullMethod: "/secret.cron.Query/Params", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) @@ -458,7 +459,7 @@ func _Query_Schedule_Handler(srv interface{}, ctx context.Context, dec func(inte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/neutron.cron.Query/Schedule", + FullMethod: "/secret.cron.Query/Schedule", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).Schedule(ctx, req.(*QueryGetScheduleRequest)) @@ -476,7 +477,7 @@ func _Query_Schedules_Handler(srv interface{}, ctx context.Context, dec func(int } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/neutron.cron.Query/Schedules", + FullMethod: "/secret.cron.Query/Schedules", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).Schedules(ctx, req.(*QuerySchedulesRequest)) @@ -485,7 +486,7 @@ func _Query_Schedules_Handler(srv interface{}, ctx context.Context, dec func(int } var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "neutron.cron.Query", + ServiceName: "secret.cron.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { @@ -502,7 +503,7 @@ var _Query_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "neutron/cron/query.proto", + Metadata: "secret/cron/query.proto", } func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { diff --git a/x/cron/types/query.pb.gw.go b/x/cron/types/query.pb.gw.go index a3ce24432..5377127ef 100644 --- a/x/cron/types/query.pb.gw.go +++ b/x/cron/types/query.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: neutron/cron/query.proto +// source: secret/cron/query.proto /* Package types is a reverse proxy. @@ -321,11 +321,11 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"neutron", "cron", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"secret", "cron", "params"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Schedule_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"neutron", "cron", "schedule", "name"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Schedule_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"secret", "cron", "schedule", "name"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Schedules_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"neutron", "cron", "schedule"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Schedules_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"secret", "cron", "schedule"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/x/cron/types/schedule.pb.go b/x/cron/types/schedule.pb.go index 42fb227f7..7f6f5fc7f 100644 --- a/x/cron/types/schedule.pb.go +++ b/x/cron/types/schedule.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: neutron/cron/schedule.proto +// source: secret/cron/schedule.proto package types @@ -48,7 +48,7 @@ func (x ExecutionStage) String() string { } func (ExecutionStage) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_49ace1b59de613ef, []int{0} + return fileDescriptor_3d6729589d2158da, []int{0} } // Defines the schedule for execution @@ -62,14 +62,14 @@ type Schedule struct { // Last execution's block height LastExecuteHeight uint64 `protobuf:"varint,4,opt,name=last_execute_height,json=lastExecuteHeight,proto3" json:"last_execute_height,omitempty"` // Stage when messages will be executed - ExecutionStage ExecutionStage `protobuf:"varint,5,opt,name=execution_stage,json=executionStage,proto3,enum=neutron.cron.ExecutionStage" json:"execution_stage,omitempty"` + ExecutionStage ExecutionStage `protobuf:"varint,5,opt,name=execution_stage,json=executionStage,proto3,enum=secret.cron.ExecutionStage" json:"execution_stage,omitempty"` } func (m *Schedule) Reset() { *m = Schedule{} } func (m *Schedule) String() string { return proto.CompactTextString(m) } func (*Schedule) ProtoMessage() {} func (*Schedule) Descriptor() ([]byte, []int) { - return fileDescriptor_49ace1b59de613ef, []int{0} + return fileDescriptor_3d6729589d2158da, []int{0} } func (m *Schedule) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -145,7 +145,7 @@ func (m *MsgExecuteContract) Reset() { *m = MsgExecuteContract{} } func (m *MsgExecuteContract) String() string { return proto.CompactTextString(m) } func (*MsgExecuteContract) ProtoMessage() {} func (*MsgExecuteContract) Descriptor() ([]byte, []int) { - return fileDescriptor_49ace1b59de613ef, []int{1} + return fileDescriptor_3d6729589d2158da, []int{1} } func (m *MsgExecuteContract) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -198,7 +198,7 @@ func (m *ScheduleCount) Reset() { *m = ScheduleCount{} } func (m *ScheduleCount) String() string { return proto.CompactTextString(m) } func (*ScheduleCount) ProtoMessage() {} func (*ScheduleCount) Descriptor() ([]byte, []int) { - return fileDescriptor_49ace1b59de613ef, []int{2} + return fileDescriptor_3d6729589d2158da, []int{2} } func (m *ScheduleCount) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -235,41 +235,41 @@ func (m *ScheduleCount) GetCount() int32 { } func init() { - proto.RegisterEnum("neutron.cron.ExecutionStage", ExecutionStage_name, ExecutionStage_value) - proto.RegisterType((*Schedule)(nil), "neutron.cron.Schedule") - proto.RegisterType((*MsgExecuteContract)(nil), "neutron.cron.MsgExecuteContract") - proto.RegisterType((*ScheduleCount)(nil), "neutron.cron.ScheduleCount") -} - -func init() { proto.RegisterFile("neutron/cron/schedule.proto", fileDescriptor_49ace1b59de613ef) } - -var fileDescriptor_49ace1b59de613ef = []byte{ - // 393 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x92, 0xc1, 0xaa, 0xd3, 0x40, - 0x18, 0x85, 0x33, 0x36, 0x2d, 0xed, 0xa8, 0xb5, 0x8e, 0x45, 0x42, 0xab, 0x69, 0x2c, 0x08, 0x41, - 0x30, 0x81, 0x8a, 0x1b, 0x77, 0x26, 0x0e, 0x6d, 0x51, 0x5b, 0x48, 0x2b, 0x88, 0x9b, 0x90, 0xa6, - 0xc3, 0x24, 0xd0, 0x64, 0x4a, 0x66, 0x22, 0xf5, 0x2d, 0x7c, 0xac, 0x2e, 0xbb, 0x74, 0x25, 0xd2, - 0xae, 0x7c, 0x8b, 0x4b, 0x26, 0x69, 0xb9, 0xbd, 0x77, 0x13, 0xce, 0xe1, 0x7c, 0x87, 0x7f, 0xe6, - 0xcf, 0xc0, 0x7e, 0x4a, 0x72, 0x91, 0xb1, 0xd4, 0x0e, 0x8b, 0x0f, 0x0f, 0x23, 0xb2, 0xce, 0x37, - 0xc4, 0xda, 0x66, 0x4c, 0x30, 0xf4, 0xa8, 0x0a, 0xad, 0x22, 0xec, 0x75, 0x29, 0xa3, 0x4c, 0x06, - 0x76, 0xa1, 0x4a, 0x66, 0xf8, 0x1f, 0xc0, 0xe6, 0xa2, 0xaa, 0x21, 0x04, 0xd5, 0x34, 0x48, 0x88, - 0x06, 0x0c, 0x60, 0xb6, 0x3c, 0xa9, 0xd1, 0x73, 0xd8, 0xd8, 0x92, 0x2c, 0x66, 0x6b, 0xed, 0x81, - 0x01, 0x4c, 0xd5, 0xab, 0x1c, 0xfa, 0x00, 0xd5, 0x84, 0x53, 0xae, 0xd5, 0x8c, 0x9a, 0xf9, 0x70, - 0x64, 0x58, 0xb7, 0x67, 0x59, 0x5f, 0x39, 0xc5, 0x3b, 0x12, 0xe6, 0x82, 0xb8, 0x2c, 0x15, 0x59, - 0x10, 0x0a, 0x47, 0xdd, 0xff, 0x1d, 0x28, 0x9e, 0xec, 0x20, 0x0b, 0x3e, 0xdb, 0x04, 0x5c, 0xf8, - 0xa4, 0x64, 0xfc, 0x88, 0xc4, 0x34, 0x12, 0x9a, 0x2a, 0x07, 0x3c, 0x2d, 0xa2, 0xaa, 0x3d, 0x91, - 0x01, 0xc2, 0xf0, 0x49, 0x89, 0xc6, 0x2c, 0xf5, 0xb9, 0x08, 0x28, 0xd1, 0xea, 0x06, 0x30, 0xdb, - 0xa3, 0x17, 0xd7, 0x63, 0xf1, 0x19, 0x5a, 0x14, 0x8c, 0xd7, 0x26, 0x57, 0x7e, 0xe8, 0x40, 0x74, - 0xff, 0x60, 0xa8, 0x07, 0x9b, 0x61, 0xa5, 0xab, 0x8b, 0x5f, 0x3c, 0xea, 0xc0, 0x5a, 0xc2, 0xa9, - 0xbc, 0x79, 0xcb, 0x2b, 0xe4, 0xf0, 0x35, 0x7c, 0x7c, 0x5e, 0x97, 0xcb, 0xf2, 0x54, 0xa0, 0x2e, - 0xac, 0x87, 0x85, 0x90, 0xdd, 0xba, 0x57, 0x9a, 0x37, 0x4b, 0xd8, 0xbe, 0x3e, 0x0c, 0x1a, 0xc0, - 0x3e, 0xfe, 0x8e, 0xdd, 0x6f, 0xcb, 0xe9, 0x7c, 0xe6, 0x2f, 0x96, 0x1f, 0xc7, 0xd8, 0xc7, 0xb3, - 0x4f, 0xbe, 0xf3, 0x65, 0xee, 0x7e, 0xc6, 0x5e, 0x47, 0x41, 0xaf, 0xe0, 0xcb, 0xbb, 0x80, 0x83, - 0xc7, 0xd3, 0xd9, 0x05, 0x01, 0xce, 0x64, 0x7f, 0xd4, 0xc1, 0xe1, 0xa8, 0x83, 0x7f, 0x47, 0x1d, - 0xfc, 0x3e, 0xe9, 0xca, 0xe1, 0xa4, 0x2b, 0x7f, 0x4e, 0xba, 0xf2, 0xc3, 0xa2, 0xb1, 0x88, 0xf2, - 0x95, 0x15, 0xb2, 0xc4, 0xae, 0x56, 0xf2, 0x96, 0x65, 0xf4, 0xac, 0xed, 0x9f, 0xef, 0xed, 0x5d, - 0xf9, 0x46, 0xc4, 0xaf, 0x2d, 0xe1, 0xab, 0x86, 0xfc, 0xfb, 0xef, 0x6e, 0x02, 0x00, 0x00, 0xff, - 0xff, 0xee, 0xcd, 0x08, 0xb7, 0x40, 0x02, 0x00, 0x00, + proto.RegisterEnum("secret.cron.ExecutionStage", ExecutionStage_name, ExecutionStage_value) + proto.RegisterType((*Schedule)(nil), "secret.cron.Schedule") + proto.RegisterType((*MsgExecuteContract)(nil), "secret.cron.MsgExecuteContract") + proto.RegisterType((*ScheduleCount)(nil), "secret.cron.ScheduleCount") +} + +func init() { proto.RegisterFile("secret/cron/schedule.proto", fileDescriptor_3d6729589d2158da) } + +var fileDescriptor_3d6729589d2158da = []byte{ + // 398 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x52, 0x4f, 0x8b, 0xd3, 0x40, + 0x1c, 0xcd, 0xd8, 0x74, 0xd9, 0x9d, 0xc5, 0xba, 0x8e, 0x8b, 0x84, 0x2e, 0xa6, 0xb1, 0x20, 0x04, + 0x0f, 0x09, 0xac, 0x27, 0x8f, 0x26, 0x1d, 0xda, 0xa2, 0xa6, 0x90, 0x54, 0x10, 0x2f, 0x21, 0x9d, + 0x0e, 0x93, 0x60, 0x93, 0x29, 0x99, 0x09, 0xd6, 0x6f, 0xe1, 0xc7, 0xea, 0xb1, 0x47, 0x4f, 0x22, + 0xed, 0xc1, 0xaf, 0x21, 0x99, 0xa4, 0xc5, 0xba, 0xb7, 0xf7, 0xe6, 0xbd, 0x37, 0xbf, 0x3f, 0x33, + 0xb0, 0x2f, 0x28, 0x29, 0xa9, 0x74, 0x49, 0xc9, 0x0b, 0x57, 0x90, 0x94, 0x2e, 0xab, 0x15, 0x75, + 0xd6, 0x25, 0x97, 0x1c, 0x5d, 0x37, 0x9a, 0x53, 0x6b, 0xfd, 0x5b, 0xc6, 0x19, 0x57, 0xe7, 0x6e, + 0x8d, 0x1a, 0xcb, 0xf0, 0x0f, 0x80, 0x97, 0x51, 0x9b, 0x42, 0x08, 0xea, 0x45, 0x92, 0x53, 0x03, + 0x58, 0xc0, 0xbe, 0x0a, 0x15, 0x46, 0xcf, 0xe1, 0xc5, 0x9a, 0x96, 0x19, 0x5f, 0x1a, 0x8f, 0x2c, + 0x60, 0xeb, 0x61, 0xcb, 0xd0, 0x5b, 0xa8, 0xe7, 0x82, 0x09, 0xa3, 0x63, 0x75, 0xec, 0xeb, 0xfb, + 0x81, 0xf3, 0x4f, 0x29, 0xe7, 0xa3, 0x60, 0x78, 0x43, 0x49, 0x25, 0xa9, 0xcf, 0x0b, 0x59, 0x26, + 0x44, 0x7a, 0xfa, 0xf6, 0xd7, 0x40, 0x0b, 0x55, 0x04, 0x39, 0xf0, 0xd9, 0x2a, 0x11, 0x32, 0xa6, + 0x8d, 0x27, 0x4e, 0x69, 0xc6, 0x52, 0x69, 0xe8, 0xea, 0xfe, 0xa7, 0xb5, 0xd4, 0xa6, 0x27, 0x4a, + 0x40, 0x23, 0xf8, 0xa4, 0xb1, 0x66, 0xbc, 0x88, 0x85, 0x4c, 0x18, 0x35, 0xba, 0x16, 0xb0, 0x7b, + 0xf7, 0x77, 0x67, 0x55, 0xf1, 0xd1, 0x13, 0xd5, 0x96, 0xb0, 0x47, 0xcf, 0xf8, 0xd0, 0x83, 0xe8, + 0x61, 0x5f, 0xa8, 0x0f, 0x2f, 0x49, 0x8b, 0xdb, 0xb1, 0x4f, 0x1c, 0xdd, 0xc0, 0x4e, 0x2e, 0x98, + 0x9a, 0xfb, 0x2a, 0xac, 0xe1, 0xf0, 0x15, 0x7c, 0x7c, 0x5c, 0x96, 0xcf, 0xab, 0x42, 0xa2, 0x5b, + 0xd8, 0x25, 0x35, 0x50, 0xd9, 0x6e, 0xd8, 0x90, 0xd7, 0x73, 0xd8, 0x3b, 0x6f, 0x06, 0x0d, 0xe0, + 0x1d, 0xfe, 0x8c, 0xfd, 0x4f, 0xf3, 0xe9, 0x2c, 0x88, 0xa3, 0xf9, 0xbb, 0x31, 0x8e, 0x71, 0x30, + 0x8a, 0xbd, 0x0f, 0x33, 0xff, 0x3d, 0x0e, 0x6f, 0x34, 0xf4, 0x12, 0xbe, 0xf8, 0xdf, 0xe0, 0xe1, + 0xf1, 0x34, 0x38, 0x59, 0x80, 0x37, 0xd9, 0xee, 0x4d, 0xb0, 0xdb, 0x9b, 0xe0, 0xf7, 0xde, 0x04, + 0x3f, 0x0e, 0xa6, 0xb6, 0x3b, 0x98, 0xda, 0xcf, 0x83, 0xa9, 0x7d, 0x71, 0x58, 0x26, 0xd3, 0x6a, + 0xe1, 0x10, 0x9e, 0xbb, 0x82, 0x94, 0x72, 0x95, 0x2c, 0x84, 0x1b, 0xa9, 0xd5, 0x04, 0x54, 0x7e, + 0xe3, 0xe5, 0x57, 0x77, 0xd3, 0x7c, 0x10, 0xf9, 0x7d, 0x4d, 0xc5, 0xe2, 0x42, 0xbd, 0xfd, 0x9b, + 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x69, 0xe1, 0x6f, 0x81, 0x3c, 0x02, 0x00, 0x00, } func (m *Schedule) Marshal() (dAtA []byte, err error) { diff --git a/x/cron/types/tx.pb.go b/x/cron/types/tx.pb.go index c5ffb7299..1b502c253 100644 --- a/x/cron/types/tx.pb.go +++ b/x/cron/types/tx.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: neutron/cron/tx.proto +// source: secret/cron/tx.proto package types @@ -42,14 +42,14 @@ type MsgAddSchedule struct { // Msgs that will be executed every certain number of blocks, specified in the `period` field Msgs []MsgExecuteContract `protobuf:"bytes,4,rep,name=msgs,proto3" json:"msgs"` // Stage when messages will be executed - ExecutionStage ExecutionStage `protobuf:"varint,5,opt,name=execution_stage,json=executionStage,proto3,enum=neutron.cron.ExecutionStage" json:"execution_stage,omitempty"` + ExecutionStage ExecutionStage `protobuf:"varint,5,opt,name=execution_stage,json=executionStage,proto3,enum=secret.cron.ExecutionStage" json:"execution_stage,omitempty"` } func (m *MsgAddSchedule) Reset() { *m = MsgAddSchedule{} } func (m *MsgAddSchedule) String() string { return proto.CompactTextString(m) } func (*MsgAddSchedule) ProtoMessage() {} func (*MsgAddSchedule) Descriptor() ([]byte, []int) { - return fileDescriptor_c9e0a673aba8d6fd, []int{0} + return fileDescriptor_dc5dfbc481f4f7b1, []int{0} } func (m *MsgAddSchedule) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -121,7 +121,7 @@ func (m *MsgAddScheduleResponse) Reset() { *m = MsgAddScheduleResponse{} func (m *MsgAddScheduleResponse) String() string { return proto.CompactTextString(m) } func (*MsgAddScheduleResponse) ProtoMessage() {} func (*MsgAddScheduleResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c9e0a673aba8d6fd, []int{1} + return fileDescriptor_dc5dfbc481f4f7b1, []int{1} } func (m *MsgAddScheduleResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -162,7 +162,7 @@ func (m *MsgRemoveSchedule) Reset() { *m = MsgRemoveSchedule{} } func (m *MsgRemoveSchedule) String() string { return proto.CompactTextString(m) } func (*MsgRemoveSchedule) ProtoMessage() {} func (*MsgRemoveSchedule) Descriptor() ([]byte, []int) { - return fileDescriptor_c9e0a673aba8d6fd, []int{2} + return fileDescriptor_dc5dfbc481f4f7b1, []int{2} } func (m *MsgRemoveSchedule) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -213,7 +213,7 @@ func (m *MsgRemoveScheduleResponse) Reset() { *m = MsgRemoveScheduleResp func (m *MsgRemoveScheduleResponse) String() string { return proto.CompactTextString(m) } func (*MsgRemoveScheduleResponse) ProtoMessage() {} func (*MsgRemoveScheduleResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c9e0a673aba8d6fd, []int{3} + return fileDescriptor_dc5dfbc481f4f7b1, []int{3} } func (m *MsgRemoveScheduleResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -258,7 +258,7 @@ func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParams) ProtoMessage() {} func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_c9e0a673aba8d6fd, []int{4} + return fileDescriptor_dc5dfbc481f4f7b1, []int{4} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -311,7 +311,7 @@ func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParamsResponse) ProtoMessage() {} func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c9e0a673aba8d6fd, []int{5} + return fileDescriptor_dc5dfbc481f4f7b1, []int{5} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -341,53 +341,54 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgAddSchedule)(nil), "neutron.cron.MsgAddSchedule") - proto.RegisterType((*MsgAddScheduleResponse)(nil), "neutron.cron.MsgAddScheduleResponse") - proto.RegisterType((*MsgRemoveSchedule)(nil), "neutron.cron.MsgRemoveSchedule") - proto.RegisterType((*MsgRemoveScheduleResponse)(nil), "neutron.cron.MsgRemoveScheduleResponse") - proto.RegisterType((*MsgUpdateParams)(nil), "neutron.cron.MsgUpdateParams") - proto.RegisterType((*MsgUpdateParamsResponse)(nil), "neutron.cron.MsgUpdateParamsResponse") -} - -func init() { proto.RegisterFile("neutron/cron/tx.proto", fileDescriptor_c9e0a673aba8d6fd) } - -var fileDescriptor_c9e0a673aba8d6fd = []byte{ - // 554 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0xbf, 0x6b, 0xdb, 0x40, - 0x14, 0xf6, 0xd9, 0x8e, 0xc1, 0xe7, 0xe0, 0x10, 0xd5, 0x75, 0x64, 0x25, 0x55, 0x8c, 0x68, 0x1b, - 0xd7, 0x10, 0x89, 0xba, 0xb4, 0x05, 0x6f, 0x71, 0x31, 0x74, 0x11, 0xb4, 0x72, 0xbb, 0x64, 0x09, - 0x8a, 0x74, 0x9c, 0x05, 0x95, 0x4e, 0xe8, 0x4e, 0xc6, 0xd9, 0x4a, 0xc7, 0x4c, 0xed, 0x5f, 0xd0, - 0xb5, 0xd0, 0xc5, 0x43, 0xff, 0x88, 0x8c, 0xa1, 0x53, 0xa7, 0x52, 0xec, 0xc1, 0xff, 0x46, 0xd1, - 0xaf, 0x44, 0x17, 0x41, 0x0a, 0x85, 0x2c, 0xa7, 0x7b, 0xef, 0xfb, 0xde, 0xd3, 0x77, 0xdf, 0x3d, - 0x0e, 0xde, 0xf7, 0x50, 0xc8, 0x02, 0xe2, 0x69, 0x56, 0xb4, 0xb0, 0xb9, 0xea, 0x07, 0x84, 0x11, - 0x61, 0x33, 0x4d, 0xab, 0x51, 0x5a, 0xda, 0x36, 0x5d, 0xc7, 0x23, 0x5a, 0xbc, 0x26, 0x04, 0x69, - 0xc7, 0x22, 0xd4, 0x25, 0x54, 0x73, 0x29, 0xd6, 0x66, 0x4f, 0xa3, 0x4f, 0x0a, 0x74, 0x12, 0xe0, - 0x24, 0x8e, 0xb4, 0x24, 0x48, 0xa1, 0x16, 0x26, 0x98, 0x24, 0xf9, 0x68, 0x97, 0x15, 0x70, 0x0a, - 0x7c, 0x33, 0x30, 0xdd, 0xac, 0x60, 0x97, 0x83, 0xa8, 0x35, 0x45, 0x76, 0xf8, 0x01, 0x25, 0xa0, - 0xf2, 0xb5, 0x0c, 0x9b, 0x3a, 0xc5, 0x47, 0xb6, 0x3d, 0x49, 0x01, 0xe1, 0x05, 0xac, 0x9b, 0x21, - 0x9b, 0x92, 0xc0, 0x61, 0x67, 0x22, 0xe8, 0x82, 0x5e, 0x7d, 0x24, 0xfe, 0xfc, 0x71, 0xd8, 0x4a, - 0x55, 0x1c, 0xd9, 0x76, 0x80, 0x28, 0x9d, 0xb0, 0xc0, 0xf1, 0xb0, 0x71, 0x4d, 0x15, 0x04, 0x58, - 0xf5, 0x4c, 0x17, 0x89, 0xe5, 0xa8, 0xc4, 0x88, 0xf7, 0x42, 0x1b, 0xd6, 0x7c, 0x14, 0x38, 0xc4, - 0x16, 0x2b, 0x5d, 0xd0, 0xab, 0x1a, 0x69, 0x24, 0x0c, 0x61, 0xd5, 0xa5, 0x98, 0x8a, 0xd5, 0x6e, - 0xa5, 0xd7, 0x18, 0x74, 0xd5, 0xbc, 0x51, 0xaa, 0x4e, 0xf1, 0x78, 0x8e, 0xac, 0x90, 0xa1, 0x57, - 0xc4, 0x63, 0x81, 0x69, 0xb1, 0x51, 0xf5, 0xe2, 0xf7, 0x7e, 0xc9, 0x88, 0x6b, 0x84, 0x31, 0xdc, - 0x42, 0x31, 0xec, 0x10, 0xef, 0x84, 0x32, 0x13, 0x23, 0x71, 0xa3, 0x0b, 0x7a, 0xcd, 0xc1, 0x1e, - 0xdf, 0x66, 0x9c, 0x91, 0x26, 0x11, 0xc7, 0x68, 0x22, 0x2e, 0x1e, 0x3e, 0xfe, 0xb4, 0x5e, 0xf4, - 0xaf, 0xe5, 0x9f, 0xaf, 0x17, 0xfd, 0x7b, 0xb1, 0x43, 0xbc, 0x1d, 0x8a, 0x08, 0xdb, 0x7c, 0xc6, - 0x40, 0xd4, 0x27, 0x1e, 0x45, 0xca, 0x39, 0x80, 0xdb, 0x3a, 0xc5, 0x06, 0x72, 0xc9, 0x0c, 0xdd, - 0x85, 0x7d, 0xc3, 0x27, 0x45, 0x8d, 0xed, 0x4c, 0x23, 0xff, 0x5b, 0x65, 0x17, 0x76, 0x0a, 0xc9, - 0x2b, 0xa5, 0xdf, 0x01, 0xdc, 0xd2, 0x29, 0x7e, 0xef, 0xdb, 0x26, 0x43, 0x6f, 0xe2, 0xe1, 0xf8, - 0x6f, 0x9d, 0x2f, 0x61, 0x2d, 0x19, 0xaf, 0x58, 0x69, 0x63, 0xd0, 0xe2, 0x5d, 0x4f, 0xba, 0x8f, - 0xea, 0xd1, 0x85, 0x7d, 0x5b, 0x2f, 0xfa, 0xc0, 0x48, 0xe9, 0xc3, 0x83, 0xe2, 0x61, 0x5a, 0xd9, - 0x61, 0xf2, 0xca, 0x94, 0x0e, 0xdc, 0xb9, 0x91, 0xca, 0x0e, 0x32, 0xf8, 0x52, 0x86, 0x15, 0x9d, - 0x62, 0xe1, 0x2d, 0x6c, 0xe4, 0x47, 0x76, 0xaf, 0x30, 0x40, 0x39, 0x54, 0x7a, 0x78, 0x1b, 0x9a, - 0xb5, 0x16, 0x8e, 0x61, 0xf3, 0xc6, 0x4d, 0xee, 0x17, 0xea, 0x78, 0x82, 0x74, 0xf0, 0x0f, 0xc2, - 0x55, 0xef, 0x77, 0x70, 0x93, 0xf3, 0xfe, 0x41, 0xa1, 0x30, 0x0f, 0x4b, 0x8f, 0x6e, 0x85, 0xb3, - 0xae, 0xd2, 0xc6, 0xc7, 0xc8, 0xdf, 0xd1, 0xeb, 0x8b, 0xa5, 0x0c, 0x2e, 0x97, 0x32, 0xf8, 0xb3, - 0x94, 0xc1, 0xe7, 0x95, 0x5c, 0xba, 0x5c, 0xc9, 0xa5, 0x5f, 0x2b, 0xb9, 0x74, 0xac, 0x62, 0x87, - 0x4d, 0xc3, 0x53, 0xd5, 0x22, 0xae, 0x96, 0x76, 0x3c, 0x24, 0x01, 0xce, 0xf6, 0xda, 0xec, 0xb9, - 0x36, 0x4f, 0x9f, 0xac, 0x33, 0x1f, 0xd1, 0xd3, 0x5a, 0xfc, 0x26, 0x3c, 0xfb, 0x1b, 0x00, 0x00, - 0xff, 0xff, 0x37, 0xae, 0x51, 0x3e, 0xcf, 0x04, 0x00, 0x00, + proto.RegisterType((*MsgAddSchedule)(nil), "secret.cron.MsgAddSchedule") + proto.RegisterType((*MsgAddScheduleResponse)(nil), "secret.cron.MsgAddScheduleResponse") + proto.RegisterType((*MsgRemoveSchedule)(nil), "secret.cron.MsgRemoveSchedule") + proto.RegisterType((*MsgRemoveScheduleResponse)(nil), "secret.cron.MsgRemoveScheduleResponse") + proto.RegisterType((*MsgUpdateParams)(nil), "secret.cron.MsgUpdateParams") + proto.RegisterType((*MsgUpdateParamsResponse)(nil), "secret.cron.MsgUpdateParamsResponse") +} + +func init() { proto.RegisterFile("secret/cron/tx.proto", fileDescriptor_dc5dfbc481f4f7b1) } + +var fileDescriptor_dc5dfbc481f4f7b1 = []byte{ + // 561 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0x41, 0x8b, 0xd3, 0x40, + 0x14, 0xc7, 0x9b, 0x6d, 0xb7, 0xd0, 0xa9, 0x74, 0xd9, 0x6c, 0xe9, 0xa6, 0xa9, 0x64, 0x4b, 0x95, + 0xb5, 0x16, 0x4c, 0xb0, 0xc2, 0x82, 0xbd, 0x6d, 0x75, 0xc1, 0x4b, 0x55, 0x52, 0x04, 0xf1, 0xb2, + 0xa4, 0xc9, 0x30, 0x0d, 0x6e, 0x32, 0x61, 0xde, 0x74, 0xed, 0xde, 0xc4, 0xe3, 0x7a, 0xf1, 0x0b, + 0x78, 0x17, 0x4f, 0x3d, 0xf8, 0x21, 0xf6, 0xb8, 0x78, 0xf2, 0x24, 0xd2, 0x1e, 0xfa, 0x35, 0x24, + 0x93, 0x64, 0x37, 0x69, 0xa1, 0x07, 0xc1, 0x4b, 0x32, 0xef, 0xfd, 0xde, 0x7b, 0xf3, 0x9f, 0x37, + 0x8f, 0x41, 0x55, 0xc0, 0x36, 0xc3, 0xdc, 0xb0, 0x19, 0xf5, 0x0d, 0x3e, 0xd5, 0x03, 0x46, 0x39, + 0x95, 0xcb, 0x91, 0x57, 0x0f, 0xbd, 0xea, 0xae, 0xe5, 0xb9, 0x3e, 0x35, 0xc4, 0x37, 0xe2, 0xea, + 0xbe, 0x4d, 0xc1, 0xa3, 0x60, 0x78, 0x40, 0x8c, 0xf3, 0xc7, 0xe1, 0x2f, 0x06, 0xf5, 0x08, 0x9c, + 0x0a, 0xcb, 0x88, 0x8c, 0x18, 0x55, 0x09, 0x25, 0x34, 0xf2, 0x87, 0xab, 0xd8, 0xab, 0xa4, 0xf7, + 0x0f, 0x2c, 0x66, 0x79, 0x49, 0xbc, 0x9a, 0x26, 0x60, 0x8f, 0xb1, 0x33, 0x39, 0xc3, 0x11, 0x6b, + 0x7d, 0xdd, 0x42, 0x95, 0x01, 0x90, 0x63, 0xc7, 0x19, 0xc6, 0x40, 0x3e, 0x42, 0x25, 0x6b, 0xc2, + 0xc7, 0x94, 0xb9, 0xfc, 0x42, 0x91, 0x9a, 0x52, 0xbb, 0xd4, 0x57, 0x7e, 0xfe, 0x78, 0x54, 0x8d, + 0x35, 0x1c, 0x3b, 0x0e, 0xc3, 0x00, 0x43, 0xce, 0x5c, 0x9f, 0x98, 0xb7, 0xa1, 0xb2, 0x8c, 0x0a, + 0xbe, 0xe5, 0x61, 0x65, 0x2b, 0x4c, 0x31, 0xc5, 0x5a, 0xae, 0xa1, 0x62, 0x80, 0x99, 0x4b, 0x1d, + 0x25, 0xdf, 0x94, 0xda, 0x05, 0x33, 0xb6, 0xe4, 0xa7, 0xa8, 0xe0, 0x01, 0x01, 0xa5, 0xd0, 0xcc, + 0xb7, 0xcb, 0xdd, 0x03, 0x3d, 0xd5, 0x25, 0x7d, 0x00, 0xe4, 0x64, 0x8a, 0xed, 0x09, 0xc7, 0xcf, + 0xa8, 0xcf, 0x99, 0x65, 0xf3, 0x7e, 0xe1, 0xea, 0xf7, 0x41, 0xce, 0x14, 0x29, 0xf2, 0x73, 0xb4, + 0x83, 0x05, 0x76, 0xa9, 0x7f, 0x0a, 0xdc, 0x22, 0x58, 0xd9, 0x6e, 0x4a, 0xed, 0x4a, 0xb7, 0x91, + 0xa9, 0x72, 0x92, 0xc4, 0x0c, 0xc3, 0x10, 0xb3, 0x82, 0x33, 0x76, 0xef, 0xf0, 0xd3, 0x72, 0xd6, + 0xb9, 0x15, 0x7f, 0xb9, 0x9c, 0x75, 0xf6, 0x44, 0x7f, 0xb2, 0xcd, 0x68, 0x29, 0xa8, 0x96, 0xf5, + 0x98, 0x18, 0x02, 0xea, 0x03, 0x6e, 0x5d, 0x4a, 0x68, 0x77, 0x00, 0xc4, 0xc4, 0x1e, 0x3d, 0xc7, + 0xff, 0xa3, 0x79, 0xbd, 0x87, 0xeb, 0x1a, 0x6b, 0x89, 0xc6, 0xec, 0xb6, 0xad, 0x06, 0xaa, 0xaf, + 0x39, 0x6f, 0x94, 0x7e, 0x97, 0xd0, 0xce, 0x00, 0xc8, 0x9b, 0xc0, 0xb1, 0x38, 0x7e, 0x2d, 0x26, + 0xe3, 0x9f, 0x75, 0x1e, 0xa1, 0x62, 0x34, 0x5b, 0x42, 0x69, 0xb9, 0xbb, 0x97, 0x69, 0x7a, 0x54, + 0xbc, 0x5f, 0x0a, 0xaf, 0xeb, 0xdb, 0x72, 0xd6, 0x91, 0xcc, 0x38, 0xba, 0xf7, 0x60, 0xfd, 0x2c, + 0xd5, 0xe4, 0x2c, 0x69, 0x61, 0xad, 0x3a, 0xda, 0x5f, 0x71, 0x25, 0xe7, 0xe8, 0x7e, 0xde, 0x42, + 0xf9, 0x01, 0x10, 0xf9, 0x15, 0x2a, 0xa7, 0xe7, 0xb5, 0xb1, 0x3a, 0x3d, 0x29, 0xa8, 0xde, 0xdb, + 0x00, 0x93, 0xc2, 0xf2, 0x5b, 0x54, 0x59, 0xb9, 0x46, 0x6d, 0x35, 0x2d, 0xcb, 0xd5, 0xc3, 0xcd, + 0xfc, 0xa6, 0xb2, 0x89, 0xee, 0x64, 0xda, 0x7e, 0x77, 0x35, 0x2f, 0x4d, 0xd5, 0xfb, 0x9b, 0x68, + 0x52, 0x53, 0xdd, 0xfe, 0x18, 0x76, 0xb6, 0xff, 0xe2, 0x6a, 0xae, 0x49, 0xd7, 0x73, 0x4d, 0xfa, + 0x33, 0xd7, 0xa4, 0x2f, 0x0b, 0x2d, 0x77, 0xbd, 0xd0, 0x72, 0xbf, 0x16, 0x5a, 0xee, 0x9d, 0x4e, + 0x5c, 0x3e, 0x9e, 0x8c, 0x74, 0x9b, 0x7a, 0x06, 0xd8, 0x8c, 0x9f, 0x59, 0x23, 0x30, 0x86, 0xa2, + 0xf2, 0x4b, 0xcc, 0x3f, 0x50, 0xf6, 0xde, 0x98, 0xc6, 0xcf, 0xd4, 0x45, 0x80, 0x61, 0x54, 0x14, + 0x4f, 0xc1, 0x93, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x28, 0x09, 0xad, 0x41, 0xc2, 0x04, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -420,7 +421,7 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { func (c *msgClient) AddSchedule(ctx context.Context, in *MsgAddSchedule, opts ...grpc.CallOption) (*MsgAddScheduleResponse, error) { out := new(MsgAddScheduleResponse) - err := c.cc.Invoke(ctx, "/neutron.cron.Msg/AddSchedule", in, out, opts...) + err := c.cc.Invoke(ctx, "/secret.cron.Msg/AddSchedule", in, out, opts...) if err != nil { return nil, err } @@ -429,7 +430,7 @@ func (c *msgClient) AddSchedule(ctx context.Context, in *MsgAddSchedule, opts .. func (c *msgClient) RemoveSchedule(ctx context.Context, in *MsgRemoveSchedule, opts ...grpc.CallOption) (*MsgRemoveScheduleResponse, error) { out := new(MsgRemoveScheduleResponse) - err := c.cc.Invoke(ctx, "/neutron.cron.Msg/RemoveSchedule", in, out, opts...) + err := c.cc.Invoke(ctx, "/secret.cron.Msg/RemoveSchedule", in, out, opts...) if err != nil { return nil, err } @@ -438,7 +439,7 @@ func (c *msgClient) RemoveSchedule(ctx context.Context, in *MsgRemoveSchedule, o func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) { out := new(MsgUpdateParamsResponse) - err := c.cc.Invoke(ctx, "/neutron.cron.Msg/UpdateParams", in, out, opts...) + err := c.cc.Invoke(ctx, "/secret.cron.Msg/UpdateParams", in, out, opts...) if err != nil { return nil, err } @@ -483,7 +484,7 @@ func _Msg_AddSchedule_Handler(srv interface{}, ctx context.Context, dec func(int } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/neutron.cron.Msg/AddSchedule", + FullMethod: "/secret.cron.Msg/AddSchedule", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).AddSchedule(ctx, req.(*MsgAddSchedule)) @@ -501,7 +502,7 @@ func _Msg_RemoveSchedule_Handler(srv interface{}, ctx context.Context, dec func( } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/neutron.cron.Msg/RemoveSchedule", + FullMethod: "/secret.cron.Msg/RemoveSchedule", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).RemoveSchedule(ctx, req.(*MsgRemoveSchedule)) @@ -519,7 +520,7 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/neutron.cron.Msg/UpdateParams", + FullMethod: "/secret.cron.Msg/UpdateParams", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams)) @@ -528,7 +529,7 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in } var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "neutron.cron.Msg", + ServiceName: "secret.cron.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { @@ -545,7 +546,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "neutron/cron/tx.proto", + Metadata: "secret/cron/tx.proto", } func (m *MsgAddSchedule) Marshal() (dAtA []byte, err error) { diff --git a/x/cron/types/v1/schedule.pb.go b/x/cron/types/v1/schedule.pb.go index a37932a39..db2717010 100644 --- a/x/cron/types/v1/schedule.pb.go +++ b/x/cron/types/v1/schedule.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: neutron/cron/v1/schedule.proto +// source: secret/cron/v1/schedule.proto package v1 @@ -39,7 +39,7 @@ func (m *Schedule) Reset() { *m = Schedule{} } func (m *Schedule) String() string { return proto.CompactTextString(m) } func (*Schedule) ProtoMessage() {} func (*Schedule) Descriptor() ([]byte, []int) { - return fileDescriptor_cd4938034d592826, []int{0} + return fileDescriptor_e9ea3196663ffe81, []int{0} } func (m *Schedule) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -108,7 +108,7 @@ func (m *MsgExecuteContract) Reset() { *m = MsgExecuteContract{} } func (m *MsgExecuteContract) String() string { return proto.CompactTextString(m) } func (*MsgExecuteContract) ProtoMessage() {} func (*MsgExecuteContract) Descriptor() ([]byte, []int) { - return fileDescriptor_cd4938034d592826, []int{1} + return fileDescriptor_e9ea3196663ffe81, []int{1} } func (m *MsgExecuteContract) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -161,7 +161,7 @@ func (m *ScheduleCount) Reset() { *m = ScheduleCount{} } func (m *ScheduleCount) String() string { return proto.CompactTextString(m) } func (*ScheduleCount) ProtoMessage() {} func (*ScheduleCount) Descriptor() ([]byte, []int) { - return fileDescriptor_cd4938034d592826, []int{2} + return fileDescriptor_e9ea3196663ffe81, []int{2} } func (m *ScheduleCount) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -198,35 +198,36 @@ func (m *ScheduleCount) GetCount() int32 { } func init() { - proto.RegisterType((*Schedule)(nil), "neutron.cron.v1.Schedule") - proto.RegisterType((*MsgExecuteContract)(nil), "neutron.cron.v1.MsgExecuteContract") - proto.RegisterType((*ScheduleCount)(nil), "neutron.cron.v1.ScheduleCount") -} - -func init() { proto.RegisterFile("neutron/cron/v1/schedule.proto", fileDescriptor_cd4938034d592826) } - -var fileDescriptor_cd4938034d592826 = []byte{ - // 316 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x91, 0xc1, 0x4a, 0xc3, 0x30, - 0x18, 0xc7, 0x1b, 0xd7, 0x8d, 0x2d, 0x22, 0x6a, 0x1c, 0x52, 0x76, 0x88, 0x63, 0x22, 0xec, 0x62, - 0x42, 0x15, 0x8f, 0x5e, 0x36, 0x04, 0x41, 0xbc, 0xd4, 0x9b, 0x97, 0xb1, 0x65, 0x21, 0x1d, 0xac, - 0x4d, 0x69, 0xd2, 0x32, 0xdf, 0xc2, 0x97, 0xf0, 0x5d, 0x76, 0xdc, 0xd1, 0x93, 0x48, 0xfb, 0x22, - 0x92, 0x34, 0xf3, 0xa0, 0x97, 0xf0, 0xfb, 0xf3, 0xff, 0xfe, 0xf9, 0xbe, 0x2f, 0x81, 0x38, 0xe5, - 0x85, 0xce, 0x65, 0x4a, 0x99, 0x39, 0xca, 0x90, 0x2a, 0x16, 0xf3, 0x65, 0xb1, 0xe6, 0x24, 0xcb, - 0xa5, 0x96, 0xe8, 0xd8, 0xf9, 0xc4, 0xf8, 0xa4, 0x0c, 0x07, 0x7d, 0x21, 0x85, 0xb4, 0x1e, 0x35, - 0xd4, 0x94, 0x8d, 0x3e, 0x00, 0xec, 0xbe, 0xb8, 0x24, 0x42, 0xd0, 0x4f, 0xe7, 0x09, 0x0f, 0xc0, - 0x10, 0x8c, 0x7b, 0x91, 0x65, 0x74, 0x0e, 0x3b, 0x19, 0xcf, 0x57, 0x72, 0x19, 0x1c, 0x0c, 0xc1, - 0xd8, 0x8f, 0x9c, 0x42, 0xf7, 0xd0, 0x4f, 0x94, 0x50, 0x41, 0x6b, 0xd8, 0x1a, 0x1f, 0xde, 0x5c, - 0x92, 0x3f, 0xed, 0xc8, 0xb3, 0x12, 0x0f, 0x1b, 0xce, 0x0a, 0xcd, 0xa7, 0x32, 0xd5, 0xf9, 0x9c, - 0xe9, 0x89, 0xbf, 0xfd, 0xba, 0xf0, 0x22, 0x1b, 0x43, 0x04, 0x9e, 0xad, 0xe7, 0x4a, 0xcf, 0x78, - 0x53, 0x33, 0x8b, 0xf9, 0x4a, 0xc4, 0x3a, 0xf0, 0x6d, 0x8f, 0x53, 0x63, 0xb9, 0xf4, 0xa3, 0x35, - 0x46, 0x13, 0x88, 0xfe, 0xdf, 0x88, 0x06, 0xb0, 0xcb, 0x1c, 0xbb, 0xa1, 0x7f, 0x35, 0x3a, 0x81, - 0xad, 0x44, 0x09, 0x3b, 0x75, 0x2f, 0x32, 0x38, 0xba, 0x82, 0x47, 0xfb, 0x55, 0xa7, 0xb2, 0x48, - 0x35, 0xea, 0xc3, 0x36, 0x33, 0x60, 0xb3, 0xed, 0xa8, 0x11, 0x93, 0xa7, 0x6d, 0x85, 0xc1, 0xae, - 0xc2, 0xe0, 0xbb, 0xc2, 0xe0, 0xbd, 0xc6, 0xde, 0xae, 0xc6, 0xde, 0x67, 0x8d, 0xbd, 0xd7, 0x50, - 0xac, 0x74, 0x5c, 0x2c, 0x08, 0x93, 0x09, 0x75, 0xfb, 0x5e, 0xcb, 0x5c, 0xec, 0x99, 0x96, 0x77, - 0x74, 0xd3, 0xfc, 0x87, 0x7e, 0xcb, 0xb8, 0xa2, 0x65, 0xb8, 0xe8, 0xd8, 0x67, 0xbe, 0xfd, 0x09, - 0x00, 0x00, 0xff, 0xff, 0x43, 0xbd, 0xcc, 0x86, 0xaf, 0x01, 0x00, 0x00, + proto.RegisterType((*Schedule)(nil), "secret.cron.v1.Schedule") + proto.RegisterType((*MsgExecuteContract)(nil), "secret.cron.v1.MsgExecuteContract") + proto.RegisterType((*ScheduleCount)(nil), "secret.cron.v1.ScheduleCount") +} + +func init() { proto.RegisterFile("secret/cron/v1/schedule.proto", fileDescriptor_e9ea3196663ffe81) } + +var fileDescriptor_e9ea3196663ffe81 = []byte{ + // 323 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x91, 0xc1, 0x4a, 0x3b, 0x31, + 0x10, 0xc6, 0x37, 0xff, 0x6e, 0x4b, 0x9b, 0x3f, 0x8a, 0xc6, 0x22, 0x4b, 0xc1, 0x58, 0x16, 0x84, + 0x9e, 0x12, 0x56, 0xaf, 0x9e, 0x5a, 0x04, 0x41, 0xf4, 0xb0, 0xbd, 0x79, 0x29, 0xdb, 0x34, 0x64, + 0x8b, 0xdd, 0x4d, 0x49, 0x66, 0x6b, 0x7d, 0x0b, 0x1f, 0xc2, 0x87, 0xe9, 0xb1, 0x47, 0x4f, 0x22, + 0xed, 0x8b, 0xc8, 0x66, 0x57, 0x41, 0xbc, 0x7d, 0x1f, 0xbf, 0xf9, 0x32, 0x33, 0x19, 0x7c, 0x66, + 0xa5, 0x30, 0x12, 0xb8, 0x30, 0x3a, 0xe7, 0xab, 0x88, 0x5b, 0x91, 0xca, 0x59, 0xb1, 0x90, 0x6c, + 0x69, 0x34, 0x68, 0x72, 0x58, 0x61, 0x56, 0x62, 0xb6, 0x8a, 0x7a, 0x5d, 0xa5, 0x95, 0x76, 0x88, + 0x97, 0xaa, 0xaa, 0x0a, 0xdf, 0x10, 0x6e, 0x8f, 0xeb, 0x20, 0x21, 0xd8, 0xcf, 0x93, 0x4c, 0x06, + 0xa8, 0x8f, 0x06, 0x9d, 0xd8, 0x69, 0x72, 0x8a, 0x5b, 0x4b, 0x69, 0xe6, 0x7a, 0x16, 0xfc, 0xeb, + 0xa3, 0x81, 0x1f, 0xd7, 0x8e, 0x5c, 0x63, 0x3f, 0xb3, 0xca, 0x06, 0x8d, 0x7e, 0x63, 0xf0, 0xff, + 0x32, 0x64, 0xbf, 0xbb, 0xb1, 0x7b, 0xab, 0x6e, 0xd6, 0x52, 0x14, 0x20, 0x47, 0x3a, 0x07, 0x93, + 0x08, 0x18, 0xfa, 0x9b, 0x8f, 0x73, 0x2f, 0x76, 0x29, 0xc2, 0xf0, 0xc9, 0x22, 0xb1, 0x30, 0x91, + 0x55, 0xcd, 0x24, 0x95, 0x73, 0x95, 0x42, 0xe0, 0xbb, 0x16, 0xc7, 0x25, 0xaa, 0xd3, 0xb7, 0x0e, + 0x84, 0x43, 0x4c, 0xfe, 0xbe, 0x48, 0x7a, 0xb8, 0x2d, 0x6a, 0x5d, 0xcf, 0xfc, 0xe3, 0xc9, 0x11, + 0x6e, 0x64, 0x56, 0xb9, 0xa1, 0x3b, 0x71, 0x29, 0xc3, 0x0b, 0x7c, 0xf0, 0xbd, 0xe9, 0x48, 0x17, + 0x39, 0x90, 0x2e, 0x6e, 0x8a, 0x52, 0xb8, 0x6c, 0x33, 0xae, 0xcc, 0xf0, 0x6e, 0xb3, 0xa3, 0x68, + 0xbb, 0xa3, 0xe8, 0x73, 0x47, 0xd1, 0xeb, 0x9e, 0x7a, 0xdb, 0x3d, 0xf5, 0xde, 0xf7, 0xd4, 0x7b, + 0x8c, 0xd4, 0x1c, 0xd2, 0x62, 0xca, 0x84, 0xce, 0xb8, 0x15, 0x06, 0x16, 0xc9, 0xd4, 0xf2, 0xb1, + 0xdb, 0xfb, 0x41, 0xc2, 0xb3, 0x36, 0x4f, 0x7c, 0x5d, 0x5d, 0x03, 0x5e, 0x96, 0xd2, 0xf2, 0x55, + 0x34, 0x6d, 0xb9, 0x5f, 0xbe, 0xfa, 0x0a, 0x00, 0x00, 0xff, 0xff, 0xa7, 0x7e, 0x3b, 0xfa, 0xac, + 0x01, 0x00, 0x00, } func (m *Schedule) Marshal() (dAtA []byte, err error) { From a271ab5f2804764687cea7b660ee7060842c8160 Mon Sep 17 00:00:00 2001 From: cboh4 Date: Thu, 10 Apr 2025 14:13:29 +0300 Subject: [PATCH 3/8] pass scheduled msgs to the enclave, calculate implicit hash of the messages that would be executed in the next round --- app/app.go | 1 + app/keepers/keepers.go | 8 +- cosmwasm/enclaves/Cargo.lock | 5 +- cosmwasm/enclaves/execute/Enclave.edl | 4 +- cosmwasm/enclaves/execute/src/ecalls.rs | 4 + .../enclaves/shared/block-verifier/Cargo.toml | 1 + .../src/submit_block_signatures.rs | 57 +++++ .../block-verifier/src/verify/header.rs | 1 + cosmwasm/packages/sgx-vm/src/random.rs | 25 ++- go-cosmwasm/api/bindings.h | 1 + go-cosmwasm/api/lib.go | 6 +- go-cosmwasm/api/lib_mock.go | 2 +- go-cosmwasm/src/lib.rs | 10 +- x/compute/internal/keeper/keeper.go | 149 ++++++++++++ x/compute/internal/keeper/test_common.go | 18 +- x/compute/internal/types/expected_keepers.go | 5 + x/compute/module.go | 71 +++++- x/cron/keeper/keeper.go | 212 ++++++++++++++---- x/cron/module.go | 32 +-- x/cron/types/expected_keepers.go | 18 +- 20 files changed, 541 insertions(+), 89 deletions(-) diff --git a/app/app.go b/app/app.go index 9d2a9f104..32894d934 100644 --- a/app/app.go +++ b/app/app.go @@ -323,6 +323,7 @@ func NewSecretNetworkApp( panic(err) } app.txConfig = txConfig + app.AppKeepers.CronKeeper.SetTxConfig(txConfig) app.AppKeepers.InitCustomKeepers(appCodec, legacyAmino, bApp, bootstrap, homePath, computeConfig) app.setupUpgradeStoreLoaders() diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index a2bdfb85f..815226c54 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -383,6 +383,7 @@ func (ak *SecretAppKeepers) InitCustomKeepers( bootstrap, ) ak.RegKeeper = ®Keeper + ak.CronKeeper.SetRegKeeper(regKeeper) // Assaf: // Rules: @@ -528,6 +529,7 @@ func (ak *SecretAppKeepers) InitCustomKeepers( runtime.NewKVStoreService(ak.keys[compute.StoreKey]), *ak.AccountKeeper, ak.BankKeeper, + *ak.CronKeeper, *ak.GovKeeper, *ak.DistrKeeper, *ak.MintKeeper, @@ -550,7 +552,11 @@ func (ak *SecretAppKeepers) InitCustomKeepers( ak.ComputeKeeper = &computeKeeper wasmHooks.ContractKeeper = ak.ComputeKeeper - ak.CronKeeper.WasmMsgServer = compute.NewMsgServerImpl(*ak.ComputeKeeper) + // wasmMsgServer := compute.NewMsgServerImpl(*ak.ComputeKeeper) + // fmt.Printf("wasmMsgServer: %+v\n", wasmMsgServer) + // ak.CronKeeper.WasmMsgServer = compute.NewCronWasmMsgServerAdapter(wasmMsgServer) + // ak.ComputeKeeper.SetCronKeeper(*ak.CronKeeper) + // fmt.Printf("ak.CronKeeper.WasmMsgServer: %+v\n", ak.CronKeeper.WasmMsgServer) // Compute receive: Switch -> Fee -> Packet Forward -> WASM Hooks var computeStack porttypes.IBCModule diff --git a/cosmwasm/enclaves/Cargo.lock b/cosmwasm/enclaves/Cargo.lock index d019e6993..4e4a5a46d 100644 --- a/cosmwasm/enclaves/Cargo.lock +++ b/cosmwasm/enclaves/Cargo.lock @@ -251,6 +251,7 @@ dependencies = [ "sgx_trts", "sgx_tstd", "sgx_types", + "sha2 0.10.8", "tendermint", "tendermint-light-client-verifier", "tendermint-proto", @@ -2096,7 +2097,7 @@ dependencies = [ [[package]] name = "tendermint" version = "0.38.0" -source = "git+https://github.com/scrtlabs/tendermint-rs?tag=v0.38.0-secret.4#fca937579f9348ffb7386217cf0162fe76352bc4" +source = "git+https://github.com/scrtlabs/tendermint-rs?tag=v0.38.0-secret.3#d4ccb1eb5e6ccb795e04d4b6e6f5e642c85ac636" dependencies = [ "bytes 1.7.1", "digest 0.10.7", @@ -2124,7 +2125,7 @@ dependencies = [ [[package]] name = "tendermint-light-client-verifier" version = "0.38.0" -source = "git+https://github.com/scrtlabs/tendermint-rs?tag=v0.38.0-secret.4#fca937579f9348ffb7386217cf0162fe76352bc4" +source = "git+https://github.com/scrtlabs/tendermint-rs?tag=v0.38.0-secret.1#2ab96d83b3609c8830f024e73553ae85fb200d5a" dependencies = [ "derive_more", "flex-error", diff --git a/cosmwasm/enclaves/execute/Enclave.edl b/cosmwasm/enclaves/execute/Enclave.edl index c14eca50d..431164bdb 100644 --- a/cosmwasm/enclaves/execute/Enclave.edl +++ b/cosmwasm/enclaves/execute/Enclave.edl @@ -199,7 +199,9 @@ enclave { [in, count=in_encrypted_random_len] const uint8_t* in_encrypted_random, uintptr_t in_encrypted_random_len, [out, count=32] uint8_t* decrypted, - [out, count=32] uint8_t* next_validator_set_evidence + [out, count=32] uint8_t* next_validator_set_evidence, + [in, count=in_cron_msgs_len] const uint8_t* in_cron_msgs, + uintptr_t in_cron_msgs_len ); }; diff --git a/cosmwasm/enclaves/execute/src/ecalls.rs b/cosmwasm/enclaves/execute/src/ecalls.rs index be2b33ec2..146530dcf 100644 --- a/cosmwasm/enclaves/execute/src/ecalls.rs +++ b/cosmwasm/enclaves/execute/src/ecalls.rs @@ -17,6 +17,8 @@ pub unsafe extern "C" fn ecall_submit_block_signatures( in_encrypted_random_len: u32, decrypted_random: &mut [u8; 32], next_validator_set_evidence: &mut [u8; 32], + in_cron_msgs: *const u8, + in_cron_msgs_len: u32, ) -> sgx_status_t { #[cfg(feature = "light-client-validation")] { @@ -31,6 +33,8 @@ pub unsafe extern "C" fn ecall_submit_block_signatures( in_encrypted_random_len, decrypted_random, next_validator_set_evidence, + in_cron_msgs, + in_cron_msgs_len, ) } diff --git a/cosmwasm/enclaves/shared/block-verifier/Cargo.toml b/cosmwasm/enclaves/shared/block-verifier/Cargo.toml index 0700afe78..8cc9a349c 100644 --- a/cosmwasm/enclaves/shared/block-verifier/Cargo.toml +++ b/cosmwasm/enclaves/shared/block-verifier/Cargo.toml @@ -18,6 +18,7 @@ sgx_trts = {rev = "d2d339cbb005f676bb700059bd51dc689c025f6b", git = "https://git sgx_types = { rev = "d2d339cbb005f676bb700059bd51dc689c025f6b", git = "https://github.com/apache/teaclave-sgx-sdk.git" } [dependencies] +sha2 = "0.10" tendermint = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.4", default-features = false, features = ["rust-crypto"] } tendermint-proto = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.4", default-features = false } tendermint-light-client-verifier = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.4", default-features = false, features = ["rust-crypto"] } diff --git a/cosmwasm/enclaves/shared/block-verifier/src/submit_block_signatures.rs b/cosmwasm/enclaves/shared/block-verifier/src/submit_block_signatures.rs index be358fa8b..c18e61ab8 100644 --- a/cosmwasm/enclaves/shared/block-verifier/src/submit_block_signatures.rs +++ b/cosmwasm/enclaves/shared/block-verifier/src/submit_block_signatures.rs @@ -5,6 +5,7 @@ use sgx_types::sgx_status_t; use enclave_utils::{validate_const_ptr, validate_input_length, validate_mut_ptr, KEY_MANAGER}; use log::debug; use log::error; +use tendermint::Hash; macro_rules! unwrap_or_return { ($result:expr) => { @@ -18,6 +19,8 @@ macro_rules! unwrap_or_return { use crate::txs::tx_from_bytes; use crate::wasm_messages::VERIFIED_BLOCK_MESSAGES; +use sha2::{Digest, Sha256}; + const MAX_VARIABLE_LENGTH: u32 = 100_000; const MAX_BLOCK_DATA_LENGTH: u32 = 22_020_096; // 21 MiB = max block size const RANDOM_PROOF_LEN: u32 = 80; @@ -37,6 +40,8 @@ pub unsafe fn submit_block_signatures_impl( in_encrypted_random_len: u32, decrypted_random: &mut [u8; 32], next_validator_set_evidence: &mut [u8; 32], + in_cron_msgs: *const u8, + in_cron_msgs_len: u32, ) -> sgx_status_t { if let Err(e) = validate_inputs( in_header, @@ -62,6 +67,12 @@ pub unsafe fn submit_block_signatures_impl( &[] }; + let cron_msgs_slice = if in_cron_msgs_len != 0 && !in_cron_msgs.is_null() { + slice::from_raw_parts(in_cron_msgs, in_cron_msgs_len as usize) + } else { + &[] + }; + let (validator_set, height) = { let extra = KEY_MANAGER.extra_data.lock().unwrap(); let validator_set = match extra.decode_validator_set() { @@ -86,6 +97,20 @@ pub unsafe fn submit_block_signatures_impl( let txs = unwrap_or_return!(crate::verify::txs::validate_txs(txs_slice, &header)); + let cron_msgs = if cron_msgs_slice.len() > 0 { + let msgs = crate::txs::txs_from_bytes(cron_msgs_slice).map_err(|e| { + error!("Error parsing cron msgs from proto: {:?}", e); + sgx_status_t::SGX_ERROR_INVALID_PARAMETER + }); + if msgs.is_err() { + error!("Error parsing cron msgs from proto: {:?}", msgs); + return sgx_status_t::SGX_ERROR_INVALID_PARAMETER; + } + Some(msgs.unwrap()) + } else { + None + }; + let mut message_verifier = VERIFIED_BLOCK_MESSAGES.lock().unwrap(); if message_verifier.remaining() != 0 { @@ -104,6 +129,38 @@ pub unsafe fn submit_block_signatures_impl( message_verifier.append_msg_from_tx(parsed_tx); } + let mut hasher = Sha256::new(); + hasher.update(cron_msgs_slice); + let hash_result = hasher.finalize(); + let hash_result: [u8; 32] = hash_result.into(); + + let implicit_hash = tendermint::Hash::Sha256(hash_result); + + debug!("implicit_hash: {:?}", &implicit_hash); + + debug!( + "header.header.implicit_hash: {:?}", + &header.header.implicit_hash + ); + + if implicit_hash != header.header.implicit_hash { + error!("Implicit hash does not match header implicit hash"); + return sgx_status_t::SGX_ERROR_INVALID_PARAMETER; + } + + if let Some(cron_msgs) = cron_msgs { + for msg in cron_msgs { + let parsed_cron_msg = unwrap_or_return!(tx_from_bytes(msg.as_slice()).map_err(|_| { + error!("Unable to parse tx bytes from proto"); + sgx_status_t::SGX_ERROR_INVALID_PARAMETER + })); + + dbg!(&parsed_cron_msg); + + message_verifier.append_msg_from_tx(parsed_cron_msg); + } + } + message_verifier.set_block_info( header.header.height.value(), header.header.time.unix_timestamp_nanos(), diff --git a/cosmwasm/enclaves/shared/block-verifier/src/verify/header.rs b/cosmwasm/enclaves/shared/block-verifier/src/verify/header.rs index 1c78157cd..41e61874f 100644 --- a/cosmwasm/enclaves/shared/block-verifier/src/verify/header.rs +++ b/cosmwasm/enclaves/shared/block-verifier/src/verify/header.rs @@ -36,6 +36,7 @@ pub fn validate_block_header( signed_header: &signed_header, validators: validator_set, next_validators: None, + implicit_hash: signed_header.header.implicit_hash, }; let result = verify_block(&untrusted_block); diff --git a/cosmwasm/packages/sgx-vm/src/random.rs b/cosmwasm/packages/sgx-vm/src/random.rs index 0d667eb15..c07630321 100644 --- a/cosmwasm/packages/sgx-vm/src/random.rs +++ b/cosmwasm/packages/sgx-vm/src/random.rs @@ -1,6 +1,6 @@ use sgx_types::*; -use log::{debug, error, warn}; +use log::{debug, error, info, warn}; use crate::enclave::ENCLAVE_DOORBELL; @@ -18,6 +18,8 @@ extern "C" { in_encrypted_random_len: u32, decrypted_random: &mut [u8; 32], next_validator_set_evidence: &mut [u8; 32], + in_cron_msgs: *const u8, + in_cron_msgs_len: u32, ) -> sgx_status_t; } @@ -26,7 +28,8 @@ pub fn untrusted_submit_block_signatures( commit: &[u8], txs: &[u8], encrypted_random: &[u8], -) -> SgxResult<([u8; 32], [u8; 32])>{ + cron_msgs: &[u8], +) -> SgxResult<([u8; 32], [u8; 32])> { debug!("Hello from just before - untrusted_submit_block_signatures"); const RETRY_LIMIT: i32 = 3; @@ -36,7 +39,7 @@ pub fn untrusted_submit_block_signatures( // this is here so we can loop { let (retval, decrypted, next_validator_set_evidence, status) = - submit_block_signature_impl(header, commit, txs, encrypted_random)?; + submit_block_signature_impl(header, commit, txs, encrypted_random, cron_msgs)?; if status != sgx_status_t::SGX_SUCCESS { return Err(status); } else if retval != sgx_status_t::SGX_SUCCESS { @@ -56,7 +59,7 @@ pub fn untrusted_submit_block_signatures( return Err(retval); } } else { - return Ok((decrypted, next_validator_set_evidence)); + return Ok((decrypted, next_validator_set_evidence)); } } } @@ -66,7 +69,8 @@ fn submit_block_signature_impl( commit: &[u8], txs: &[u8], encrypted_random: &[u8], -) -> SgxResult<(sgx_status_t, [u8; 32], [u8; 32], sgx_status_t)>{ + cron_msgs: &[u8], +) -> SgxResult<(sgx_status_t, [u8; 32], [u8; 32], sgx_status_t)> { // Bind the token to a local variable to ensure its // destructor runs in the end of the function let enclave_access_token = ENCLAVE_DOORBELL @@ -97,9 +101,16 @@ fn submit_block_signature_impl( encrypted_random.as_ptr(), encrypted_random.len() as u32, &mut random_decrypted, - &mut next_validator_set_evidence + &mut next_validator_set_evidence, + cron_msgs.as_ptr(), + cron_msgs.len() as u32, ) }; - Ok((retval, random_decrypted, next_validator_set_evidence, status)) + Ok(( + retval, + random_decrypted, + next_validator_set_evidence, + status, + )) } diff --git a/go-cosmwasm/api/bindings.h b/go-cosmwasm/api/bindings.h index 1e5ff31cf..02f296f05 100644 --- a/go-cosmwasm/api/bindings.h +++ b/go-cosmwasm/api/bindings.h @@ -247,6 +247,7 @@ TwoBuffers submit_block_signatures(Buffer header, Buffer commit, Buffer txs, Buffer random, + Buffer cron_msgs, Buffer *err); void submit_validator_set_evidence(Buffer evidence, Buffer *err); diff --git a/go-cosmwasm/api/lib.go b/go-cosmwasm/api/lib.go index fe53633d5..45dba3a7d 100644 --- a/go-cosmwasm/api/lib.go +++ b/go-cosmwasm/api/lib.go @@ -46,7 +46,7 @@ func HealthCheck() ([]byte, error) { return receiveVector(res), nil } -func SubmitBlockSignatures(header []byte, commit []byte, txs []byte, encRandom []byte /* valSet []byte, nextValSet []byte */) ([]byte, []byte, error) { +func SubmitBlockSignatures(header []byte, commit []byte, txs []byte, encRandom []byte, cronMsgs []byte /* valSet []byte, nextValSet []byte */) ([]byte, []byte, error) { errmsg := C.Buffer{} spidSlice := sendSlice(header) defer freeAfterSend(spidSlice) @@ -56,8 +56,10 @@ func SubmitBlockSignatures(header []byte, commit []byte, txs []byte, encRandom [ defer freeAfterSend(encRandomSlice) txsSlice := sendSlice(txs) defer freeAfterSend(txsSlice) + cronMsgsSlice := sendSlice(cronMsgs) + defer freeAfterSend(cronMsgsSlice) - res, err := C.submit_block_signatures(spidSlice, apiKeySlice, txsSlice, encRandomSlice /* valSetSlice, nextValSetSlice,*/, &errmsg) + res, err := C.submit_block_signatures(spidSlice, apiKeySlice, txsSlice, encRandomSlice, cronMsgsSlice /* valSetSlice, nextValSetSlice,*/, &errmsg) if err != nil { return nil, nil, errorWithMessage(err, errmsg) } diff --git a/go-cosmwasm/api/lib_mock.go b/go-cosmwasm/api/lib_mock.go index 5238b7104..c0a9e4182 100644 --- a/go-cosmwasm/api/lib_mock.go +++ b/go-cosmwasm/api/lib_mock.go @@ -39,7 +39,7 @@ func InitBootstrap(spid []byte, apiKey []byte) ([]byte, error) { return nil, nil } -func SubmitBlockSignatures(header []byte, commit []byte, txs []byte, random []byte /* valSet []byte, nextValSet []byte*/) ([]byte, []byte, error) { +func SubmitBlockSignatures(header []byte, commit []byte, txs []byte, random []byte, cronmsgs []byte /* valSet []byte, nextValSet []byte*/) ([]byte, []byte, error) { return nil, nil, nil } diff --git a/go-cosmwasm/src/lib.rs b/go-cosmwasm/src/lib.rs index a84cafb85..0d43b833d 100644 --- a/go-cosmwasm/src/lib.rs +++ b/go-cosmwasm/src/lib.rs @@ -267,6 +267,7 @@ pub extern "C" fn submit_block_signatures( commit: Buffer, txs: Buffer, random: Buffer, + cron_msgs: Buffer, // val_set: Buffer, // next_val_set: Buffer, err: Option<&mut Buffer>, @@ -304,6 +305,11 @@ pub extern "C" fn submit_block_signatures( } Some(r) => r, }; + + let cron_msgs_slice = match unsafe { cron_msgs.read() } { + None => &[], + Some(r) => r, + }; // let val_set_slice = match unsafe { val_set.read() } { // None => { // set_error(Error::empty_arg("api_key"), err); @@ -325,8 +331,8 @@ pub extern "C" fn submit_block_signatures( commit_slice, txs_slice, random_slice, - // val_set_slice, - // next_val_set_slice, + cron_msgs_slice, // val_set_slice, + // next_val_set_slice, ) { Err(e) => { set_error(Error::enclave_err(e.to_string()), err); diff --git a/x/compute/internal/keeper/keeper.go b/x/compute/internal/keeper/keeper.go index 5f0f595fb..4716806c4 100644 --- a/x/compute/internal/keeper/keeper.go +++ b/x/compute/internal/keeper/keeper.go @@ -47,12 +47,16 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" sdktx "github.com/cosmos/cosmos-sdk/types/tx" + "github.com/cosmos/cosmos-sdk/types/tx/signing" sdktxsigning "github.com/cosmos/cosmos-sdk/types/tx/signing" wasm "github.com/scrtlabs/SecretNetwork/go-cosmwasm" v010wasmTypes "github.com/scrtlabs/SecretNetwork/go-cosmwasm/types/v010" v1wasmTypes "github.com/scrtlabs/SecretNetwork/go-cosmwasm/types/v1" + cronkeeper "github.com/scrtlabs/SecretNetwork/x/cron/keeper" + crontypes "github.com/scrtlabs/SecretNetwork/x/cron/types" + "github.com/scrtlabs/SecretNetwork/x/compute/internal/types" ) @@ -78,6 +82,7 @@ type Keeper struct { bankKeeper bankkeeper.Keeper portKeeper portkeeper.Keeper capabilityKeeper capabilitykeeper.ScopedKeeper + cronKeeper cronkeeper.Keeper wasmer wasm.Wasmer queryPlugins QueryPlugins messenger Messenger @@ -106,6 +111,7 @@ func NewKeeper( storeService store.KVStoreService, accountKeeper authkeeper.AccountKeeper, bankKeeper bankkeeper.Keeper, + cronKeeper cronkeeper.Keeper, govKeeper govkeeper.Keeper, distKeeper distrkeeper.Keeper, mintKeeper mintkeeper.Keeper, @@ -137,6 +143,7 @@ func NewKeeper( wasmer: *wasmer, accountKeeper: accountKeeper, bankKeeper: bankKeeper, + cronKeeper: cronKeeper, portKeeper: portKeeper, capabilityKeeper: capabilityKeeper, messenger: NewMessageHandler( @@ -161,6 +168,10 @@ func NewKeeper( return keeper } +func (k *Keeper) SetCronKeeper(cronKeeper cronkeeper.Keeper) { + k.cronKeeper = cronKeeper +} + func (k Keeper) SetValidatorSetEvidence(ctx sdk.Context) error { store := k.storeService.OpenKVStore(ctx) validator_set_evidence, err := store.Get(types.ValidatorSetEvidencePrefix) @@ -996,6 +1007,144 @@ func (k Keeper) GetContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) return &contract } +func (k Keeper) GetScheduledMsgs(ctx sdk.Context, execution_stage crontypes.ExecutionStage) ([]types.MsgExecuteContract, [][]byte, error) { + cronScheduledMsgs := k.cronKeeper.GetScheduledMsgs(ctx, execution_stage) + + // // Update the schedule's last execution height. + // schedule.LastExecuteHeight = uint64(ctx.BlockHeight()) //nolint:gosec + // k.storeSchedule(ctx, schedule) + + // Get the module private key once. + var txBytesList [][]byte + var executeMsgList []types.MsgExecuteContract + privKey := cronkeeper.GetModulePrivateKey() + pubKey := privKey.PubKey() + senderAddr := sdk.AccAddress(pubKey.Address()) + + // Retrieve the account info using the derived address. + senderAcc := k.accountKeeper.GetAccount(ctx, senderAddr) + if senderAcc == nil { + return nil, nil, fmt.Errorf("account not found for address %s", senderAddr.String()) + } + accountNumber := senderAcc.GetAccountNumber() + sequence := senderAcc.GetSequence() + chainID := ctx.ChainID() + + cacheCtx, writeFn := ctx.CacheContext() + for _, msg := range cronScheduledMsgs { + // Convert contract address from bech32. + contractAddr, err := sdk.AccAddressFromBech32(msg.Contract) + if err != nil { + ctx.Logger().Info("executeSchedule: failed to convert contract address from bech32.", "err", err) + return nil, nil, err + } + // contractAddr := msg.Contract + fmt.Printf("contractAddr: %s\n", contractAddr.String()) + + encryptedMsg, err := cronkeeper.Encrypt(ctx, &k.cronKeeper, []byte(msg.Msg)) + // encryptedMsg := msg.Msg + if err != nil { + ctx.Logger().Info("executeSchedule: failed to decode base64 msg", "err", err) + return nil, nil, err + } + executeMsg := types.MsgExecuteContract{ + Sender: senderAddr, + Contract: contractAddr, + Msg: encryptedMsg, + SentFunds: sdk.NewCoins(), + CallbackCodeHash: "", + } + + // Create a new transaction builder using the shared txConfig. + txBuilder := k.cronKeeper.GetTxConfig().NewTxBuilder() + if err := txBuilder.SetMsgs(&executeMsg); err != nil { + return nil, nil, err + } + // Set fee and gas (adjust as needed). + txBuilder.SetFeeAmount(sdk.NewCoins()) + txBuilder.SetGasLimit(0) + + // Prepare signer data using the correct account info. + signerData := authsigning.SignerData{ + Address: senderAddr.String(), + ChainID: chainID, + AccountNumber: accountNumber, + Sequence: sequence, + PubKey: pubKey, + } + + sigData := signing.SingleSignatureData{ + SignMode: signing.SignMode_SIGN_MODE_DIRECT, + Signature: nil, + } + + sig := signing.SignatureV2{ + PubKey: pubKey, + Data: &sigData, + Sequence: sequence, + } + + sigs := []signing.SignatureV2{sig} + if err := txBuilder.SetSignatures(sigs...); err != nil { + return nil, nil, err + } + + bytesToSign, err := authsigning.GetSignBytesAdapter(ctx, k.cronKeeper.GetTxConfig().SignModeHandler(), signing.SignMode_SIGN_MODE_DIRECT, signerData, txBuilder.GetTx()) + if err != nil { + return nil, nil, err + } + + // Sign those bytes + sigBytes, err := privKey.Sign(bytesToSign) + if err != nil { + return nil, nil, err + } + + // Construct the SignatureV2 struct + sigData = signing.SingleSignatureData{ + SignMode: signing.SignMode_SIGN_MODE_DIRECT, + Signature: sigBytes, + } + sig = signing.SignatureV2{ + PubKey: pubKey, + Data: &sigData, + Sequence: sequence, + } + + err = txBuilder.SetSignatures(sig) + if err != nil { + return nil, nil, fmt.Errorf("unable to set signatures on payload: %w", err) + } + + txBytes, err := k.cronKeeper.GetTxConfig().TxEncoder()(txBuilder.GetTx()) + if err != nil { + return nil, nil, err + } + + cacheCtx = cacheCtx.WithTxBytes(txBytes) + + txBytesList = append(txBytesList, txBytes) + executeMsgList = append(executeMsgList, executeMsg) + + // Execute the contract. + // _, err = k.Execute(cacheCtx, executeMsg.Contract, executeMsg.Sender, executeMsg.Msg, executeMsg.SentFunds, executeMsg.CallbackSig, wasmTypes.HandleTypeExecute) + // if err != nil { + // ctx.Logger().Info("executeSchedule: failed to execute contract msg", + // "schedule_name", ExecuteScheduledMsgs.Name, + // "msg_idx", idx, + // "msg_contract", msg.Contract, + // "msg", msg.Msg, + // "error", err, + // ) + // return err + // } + } + + // Commit changes if all messages were executed successfully. + writeFn() + return executeMsgList, txBytesList, nil +} + func (k Keeper) containsContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) bool { store := k.storeService.OpenKVStore(ctx) has, err := store.Has(types.GetContractAddressKey(contractAddress)) diff --git a/x/compute/internal/keeper/test_common.go b/x/compute/internal/keeper/test_common.go index da29e0ef2..5d5033c3a 100644 --- a/x/compute/internal/keeper/test_common.go +++ b/x/compute/internal/keeper/test_common.go @@ -51,6 +51,7 @@ import ( tmproto "github.com/cometbft/cometbft/proto/tendermint/types" tmtypes "github.com/cometbft/cometbft/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + // tmenclave "github.com/scrtlabs/tm-secret-enclave" dbm "github.com/cosmos/cosmos-db" @@ -116,6 +117,9 @@ import ( "cosmossdk.io/x/upgrade" + cronkeeper "github.com/scrtlabs/SecretNetwork/x/cron/keeper" + crontypes "github.com/scrtlabs/SecretNetwork/x/cron/types" + wasmtypes "github.com/scrtlabs/SecretNetwork/x/compute/internal/types" "github.com/scrtlabs/SecretNetwork/x/registration" ) @@ -497,6 +501,14 @@ func CreateTestInput(t *testing.T, isCheckTx bool, supportedFeatures string, enc ) govKeeper.SetLegacyRouter(govRouter) + cronKeeper := cronkeeper.NewKeeper( + encodingConfig.Codec, + keys[crontypes.StoreKey], + memKeys[crontypes.StoreKey], + authKeeper, + authtypes.NewModuleAddress(crontypes.ModuleName).String(), + ) + // bank := bankKeeper. // bk := bank.Keeper(bankKeeper) @@ -577,6 +589,7 @@ func CreateTestInput(t *testing.T, isCheckTx bool, supportedFeatures string, enc runtime.NewKVStoreService(keys[wasmtypes.StoreKey]), authKeeper, bankKeeper, + *cronKeeper, *govKeeper, distKeeper, mintKeeper, @@ -1105,9 +1118,10 @@ func updateLightClientHelper(t *testing.T, ctx sdk.Context) { random, proof, err := tmenclave.GetRandom(blockHeader.AppHash, uint64(blockHeader.Height)) require.NoError(t, err) - randomAndProofBz := append(random, proof...) + randomAndProofBz := append(random, proof...) //nolint:all + cronmsgs := []byte{} - _, _, err = api.SubmitBlockSignatures(headerBz, commitBz, dataBz, randomAndProofBz) + _, _, err = api.SubmitBlockSignatures(headerBz, commitBz, dataBz, randomAndProofBz, cronmsgs) require.NoError(t, err) }*/ diff --git a/x/compute/internal/types/expected_keepers.go b/x/compute/internal/types/expected_keepers.go index c93c7f4ba..7e3c6420b 100644 --- a/x/compute/internal/types/expected_keepers.go +++ b/x/compute/internal/types/expected_keepers.go @@ -2,6 +2,7 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/scrtlabs/SecretNetwork/x/cron/types" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" @@ -23,3 +24,7 @@ type ChannelKeeper interface { IterateChannels(ctx sdk.Context, cb func(channeltypes.IdentifiedChannel) bool) SetChannel(ctx sdk.Context, portID, channelID string, channel channeltypes.Channel) } + +type CronKeeper interface { + GetScheduledMsgs(ctx sdk.Context) []types.MsgExecuteContract +} diff --git a/x/compute/module.go b/x/compute/module.go index 55f04444e..e18e9b80a 100644 --- a/x/compute/module.go +++ b/x/compute/module.go @@ -2,7 +2,10 @@ package compute import ( "context" + "crypto/sha256" + "encoding/hex" "encoding/json" + "fmt" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -15,9 +18,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/scrtlabs/SecretNetwork/go-cosmwasm/api" + wasmtypes "github.com/scrtlabs/SecretNetwork/go-cosmwasm/types" "github.com/scrtlabs/SecretNetwork/x/compute/client/cli" "github.com/scrtlabs/SecretNetwork/x/compute/internal/keeper" "github.com/scrtlabs/SecretNetwork/x/compute/internal/types" + crontypes "github.com/scrtlabs/SecretNetwork/x/cron/types" + tmenclave "github.com/scrtlabs/tm-secret-enclave" ) var ( @@ -146,12 +152,32 @@ func (am AppModule) BeginBlock(c context.Context) error { // Note: as of tendermint v0.38.0 block begin request info is no longer available ctx := c.(sdk.Context) block_header := ctx.BlockHeader() + + execCronMsgs, bytesCronMsgs, err := am.keeper.GetScheduledMsgs(ctx, crontypes.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER) + if err != nil { + ctx.Logger().Error("Failed to get scheduled cron msgs") + return err + } + + cron_msgs := tm_type.Data{Txs: bytesCronMsgs} + cron_data, err := cron_msgs.Marshal() + if err != nil { + ctx.Logger().Error("Failed to marshal cron_msgs") + return err + } + // hash := sha256.Sum256(cron_data) + header, err := block_header.Marshal() if err != nil { ctx.Logger().Error("Failed to marshal block header") return err } + // fmt.Printf("---------------bytesCronMsgs--------------\n%+v\n", bytesCronMsgs) + // fmt.Printf("---------------execCronMsgs--------------\n%+v\n", execCronMsgs) + // fmt.Printf("ImplicitHash: %+v\n", hex.EncodeToString(hash[:])) + // fmt.Printf("beginBlock: block_header: %+v\n", block_header) + commit := ctx.Commit() b_commit, err := commit.Marshal() if err != nil { @@ -168,12 +194,25 @@ func (am AppModule) BeginBlock(c context.Context) error { } if block_header.EncryptedRandom != nil { randomAndProof := append(block_header.EncryptedRandom.Random, block_header.EncryptedRandom.Proof...) - random, validator_set_evidence, err := api.SubmitBlockSignatures(header, b_commit, data, randomAndProof) + random, validator_set_evidence, err := api.SubmitBlockSignatures(header, b_commit, data, randomAndProof, cron_data) if err != nil { ctx.Logger().Error("Failed to submit block signatures") return err } + for idx, msg := range execCronMsgs { + fmt.Printf("idx, msg: %+v %+v\n", idx, msg) + ctx = ctx.WithTxBytes(bytesCronMsgs[idx]) + res, err := am.keeper.Execute(ctx, msg.Contract, msg.Sender, msg.Msg, msg.SentFunds, msg.CallbackSig, wasmtypes.HandleTypeExecute) + if err != nil { + ctx.Logger().Error("Failed to execute cron message", "error", err) + return err + } + fmt.Printf("res: %+v\n", res) + } + + fmt.Printf("setRandomSeed\n") + am.keeper.SetRandomSeed(ctx, random, validator_set_evidence) } else { ctx.Logger().Debug("Non-encrypted block", "Block_hash", block_header.LastBlockId.Hash, "Height", ctx.BlockHeight(), "Txs", len(x2_data)) @@ -181,6 +220,36 @@ func (am AppModule) BeginBlock(c context.Context) error { return nil } +// EndBlock returns the end blocker for the compute module. +func (am AppModule) EndBlock(c context.Context) error { + ctx := c.(sdk.Context) + block_header := ctx.BlockHeader() + fmt.Printf("endBlock: block_header: %+v\n", block_header) + + _, bytesCronMsgs, err := am.keeper.GetScheduledMsgs(ctx, crontypes.ExecutionStage_EXECUTION_STAGE_END_BLOCKER) + if err != nil { + ctx.Logger().Error("Failed to get scheduled cron msgs") + return err + } + + cron_msgs := tm_type.Data{Txs: bytesCronMsgs} + cron_data, err := cron_msgs.Marshal() + if err != nil { + ctx.Logger().Error("Failed to marshal cron_msgs") + return err + } + hash := sha256.Sum256(cron_data) + + fmt.Printf("Hash of the executed msgs in the next round: %+v\n", hex.EncodeToString(hash[:])) + err = tmenclave.SetImplicitHash(hash[:]) + if err != nil { + ctx.Logger().Error("Failed to set implicit hash %+v", err) + return err + } + fmt.Printf("---------------EndBlock--------------\n") + return nil +} + // IsAppModule implements the appmodule.AppModule interface. func (AppModule) IsAppModule() {} diff --git a/x/cron/keeper/keeper.go b/x/cron/keeper/keeper.go index a34d4ce5c..bdb25202c 100644 --- a/x/cron/keeper/keeper.go +++ b/x/cron/keeper/keeper.go @@ -1,23 +1,30 @@ package keeper import ( + "crypto/sha256" + "encoding/base64" "fmt" + "io" "strconv" - "time" "cosmossdk.io/log" "github.com/hashicorp/go-metrics" + "github.com/miscreant/miscreant.go" + "golang.org/x/crypto/curve25519" + "golang.org/x/crypto/hkdf" "github.com/cosmos/cosmos-sdk/telemetry" "cosmossdk.io/store/prefix" - wasmtypes "github.com/scrtlabs/SecretNetwork/x/compute" storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" + secp256k1 "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/scrtlabs/SecretNetwork/x/cron/types" + regtypes "github.com/scrtlabs/SecretNetwork/x/registration" ) var ( @@ -35,11 +42,68 @@ type ( storeKey storetypes.StoreKey memKey storetypes.StoreKey accountKeeper types.AccountKeeper - WasmMsgServer types.WasmMsgServer - authority string + regKeeper types.RegKeeper + // WasmMsgServer types.WasmMsgServer + authority string + txConfig client.TxConfig } ) +func (k *Keeper) GetTxConfig() client.TxConfig { + return k.txConfig +} + +// GetScheduledMsgs implements types.CronKeeper. +func (k *Keeper) GetScheduledMsgs(ctx sdk.Context, execution_stage types.ExecutionStage) []types.MsgExecuteContract { + // func (k *Keeper) GetScheduledMsgs(ctx sdk.Context) [][]byte { + schedules := k.getSchedulesReadyForExecution(ctx, execution_stage) + fmt.Printf("schedules: %+v\n", schedules) + var msgExecuteContractList []types.MsgExecuteContract + for _, schedule := range schedules { + fmt.Printf("schedule:%+v\n", schedule) + msgs, err := k.getCronsMsgs(ctx, schedule, execution_stage) + if err != nil { + ctx.Logger().Error("Failed to get crons msgs", "error", err) + continue + } + fmt.Printf("------------msgs by schedule ----------------\n") + fmt.Printf("%+v\n", msgs) + + msgExecuteContractList = append(msgExecuteContractList, msgs...) + if execution_stage == types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER { + recordExecutedSchedule(nil, schedule) + } + } + return msgExecuteContractList +} + +// executeSchedule executes all msgs in a given schedule and changes LastExecuteHeight +// if at least one msg execution fails, rollback all messages +func (k *Keeper) getCronsMsgs(ctx sdk.Context, schedule types.Schedule, execution_stage types.ExecutionStage) ([]types.MsgExecuteContract, error) { + // Even if contract execution returned an error, we still increase the height + // and execute it after this interval + if execution_stage == types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER { + schedule.LastExecuteHeight = uint64(ctx.BlockHeight()) //nolint:gosec + k.storeSchedule(ctx, schedule) + } + + var cronMsgs []types.MsgExecuteContract + + for _, msg := range schedule.Msgs { + contractAddr, err := sdk.AccAddressFromBech32(msg.Contract) + if err != nil { + ctx.Logger().Info("getCronsMsgs: failed to extract contract address", "err", err) + return nil, err + } + executeMsg := types.MsgExecuteContract{ + Contract: contractAddr.String(), + Msg: msg.Msg, + } + cronMsgs = append(cronMsgs, executeMsg) + } + return cronMsgs, nil +} + func NewKeeper( cdc codec.BinaryCodec, storeKey, @@ -52,10 +116,21 @@ func NewKeeper( storeKey: storeKey, memKey: memKey, accountKeeper: accountKeeper, + regKeeper: nil, authority: authority, + txConfig: nil, } } +// SetTxConfig injects the transaction configuration into the keeper. +func (k *Keeper) SetTxConfig(txConfig client.TxConfig) { + k.txConfig = txConfig +} + +func (k *Keeper) SetRegKeeper(regKeeper types.RegKeeper) { + k.regKeeper = regKeeper +} + func (k Keeper) GetAuthority() string { return k.authority } @@ -64,18 +139,6 @@ func (k *Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } -// ExecuteReadySchedules gets all schedules that are due for execution (with limit that is equal to Params.Limit) -// and executes messages in each one -func (k *Keeper) ExecuteReadySchedules(ctx sdk.Context, executionStage types.ExecutionStage) { - telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), LabelExecuteReadySchedules) - schedules := k.getSchedulesReadyForExecution(ctx, executionStage) - - for _, schedule := range schedules { - err := k.executeSchedule(ctx, schedule) - recordExecutedSchedule(err, schedule) - } -} - // AddSchedule adds a new schedule to be executed every certain number of blocks, specified in the `period`. // First schedule execution is supposed to be on `now + period` block. func (k *Keeper) AddSchedule( @@ -163,7 +226,7 @@ func (k *Keeper) getSchedulesReadyForExecution(ctx sdk.Context, executionStage t var schedule types.Schedule k.cdc.MustUnmarshal(iterator.Value(), &schedule) - if k.intervalPassed(ctx, schedule) && schedule.ExecutionStage == executionStage { + if k.intervalPassed(ctx, schedule, executionStage) { res = append(res, schedule) count++ @@ -177,38 +240,85 @@ func (k *Keeper) getSchedulesReadyForExecution(ctx sdk.Context, executionStage t return res } -// executeSchedule executes all msgs in a given schedule and changes LastExecuteHeight -// if at least one msg execution fails, rollback all messages -func (k *Keeper) executeSchedule(ctx sdk.Context, schedule types.Schedule) error { - // Even if contract execution returned an error, we still increase the height - // and execute it after this interval - schedule.LastExecuteHeight = uint64(ctx.BlockHeight()) //nolint:gosec - k.storeSchedule(ctx, schedule) +var hkdfSalt = []byte{ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x02, 0x4b, 0xea, 0xd8, 0xdf, 0x69, 0x99, + 0x08, 0x52, 0xc2, 0x02, 0xdb, 0x0e, 0x00, 0x97, + 0xc1, 0xa1, 0x2e, 0xa6, 0x37, 0xd7, 0xe9, 0x6d, +} - cacheCtx, writeFn := ctx.CacheContext() - for idx, msg := range schedule.Msgs { - executeMsg := wasmtypes.MsgExecuteContract{ - Sender: k.accountKeeper.GetModuleAddress(types.ModuleName), - Contract: sdk.AccAddress(msg.Contract), - Msg: []byte(msg.Msg), - SentFunds: sdk.NewCoins(), - } - _, err := k.WasmMsgServer.ExecuteContract(cacheCtx, &executeMsg) - if err != nil { - ctx.Logger().Info("executeSchedule: failed to execute contract msg", - "schedule_name", schedule.Name, - "msg_idx", idx, - "msg_contract", msg.Contract, - "msg", msg.Msg, - "error", err, - ) - return err - } +func getTxEncryptionKey(ctx sdk.Context, k *Keeper, txSenderPrivKey []byte, nonce []byte) ([]byte, error) { + consensusIoPubKey := k.regKeeper.GetMasterKey(ctx, regtypes.MasterIoKeyId) + + txEncryptionIkm, err := curve25519.X25519(txSenderPrivKey, consensusIoPubKey.Bytes) + if err != nil { + fmt.Println("Failed to get tx encryption key") + return nil, err } - // only save state if all the messages in a schedule were executed successfully - writeFn() - return nil + kdfFunc := hkdf.New(sha256.New, append(txEncryptionIkm, nonce...), hkdfSalt, []byte{}) + + txEncryptionKey := make([]byte, 32) + if _, err := io.ReadFull(kdfFunc, txEncryptionKey); err != nil { + return nil, err + } + + return txEncryptionKey, nil +} + +// Encrypt encrypts deterministically by deriving the ephemeral keys and nonce from the plaintext. +func Encrypt(ctx sdk.Context, k *Keeper, plaintext []byte) ([]byte, error) { + txSenderPrivKey := sha256.Sum256(plaintext) + // var txSenderPrivKey [32]byte + // rand.Read(txSenderPrivKey[:]) //nolint:errcheck + + var txSenderPubKey [32]byte + curve25519.ScalarBaseMult(&txSenderPubKey, &txSenderPrivKey) + // if err != nil { + // log.Println(err) + // return nil, err + // } + + // Derive a deterministic nonce by hashing the plaintext with an appended constant. + nonceData := append(plaintext, []byte("nonce")...) // "nonce" is a constant string to differentiate from key derivation + nonceHash := sha256.Sum256(nonceData) + nonce := nonceHash[:] // convert fixed array to a slice + + txEncryptionKey, err := getTxEncryptionKey(ctx, k, txSenderPrivKey[:], nonce) + if err != nil { + // log.Println(err) + return nil, err + } + + return encryptData(txEncryptionKey, txSenderPubKey[:], plaintext, nonce) +} + +func encryptData(aesEncryptionKey []byte, txSenderPubKey []byte, plaintext []byte, nonce []byte) ([]byte, error) { + cipher, err := miscreant.NewAESCMACSIV(aesEncryptionKey) + if err != nil { + // log.Println(err) + return nil, err + } + + ciphertext, err := cipher.Seal(nil, plaintext, []byte{}) + if err != nil { + // log.Println(err) + return nil, err + } + + // ciphertext = nonce(32) || wallet_pubkey(32) || ciphertext + ciphertext = append(nonce, append(txSenderPubKey, ciphertext...)...) + + return ciphertext, nil +} + +func GetModulePrivateKey() cryptotypes.PrivKey { + privKeyBase64 := "8Ke2frmnGdVPipv7+xh9jClrl5EaBb9cowSUgj5GvrY=" + privKeyBytes, err := base64.StdEncoding.DecodeString(privKeyBase64) + if err != nil { + fmt.Printf("failed to decode private key: %v", err) + } + return &secp256k1.PrivKey{Key: privKeyBytes} } func (k *Keeper) storeSchedule(ctx sdk.Context, schedule types.Schedule) { @@ -229,8 +339,12 @@ func (k *Keeper) scheduleExists(ctx sdk.Context, name string) bool { return store.Has(types.GetScheduleKey(name)) } -func (k *Keeper) intervalPassed(ctx sdk.Context, schedule types.Schedule) bool { - return uint64(ctx.BlockHeight()) > (schedule.LastExecuteHeight + schedule.Period) //nolint:gosec +func (k *Keeper) intervalPassed(ctx sdk.Context, schedule types.Schedule, executionStage types.ExecutionStage) bool { + delta := 0 + if executionStage == types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER { + delta = 1 + } + return uint64(ctx.BlockHeight())+uint64(delta) > (schedule.LastExecuteHeight + schedule.Period) //nolint:gosec } func (k *Keeper) changeTotalCount(ctx sdk.Context, incrementAmount int32) { diff --git a/x/cron/module.go b/x/cron/module.go index 994ef7e17..5178e8559 100644 --- a/x/cron/module.go +++ b/x/cron/module.go @@ -26,10 +26,10 @@ import ( ) var ( - _ appmodule.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} - _ appmodule.HasBeginBlocker = AppModule{} - _ appmodule.HasEndBlocker = AppModule{} + _ appmodule.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + // _ appmodule.HasBeginBlocker = AppModule{} + // _ appmodule.HasEndBlocker = AppModule{} ) // ---------------------------------------------------------------------------- @@ -156,14 +156,16 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw // ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 func (AppModule) ConsensusVersion() uint64 { return types.ConsensusVersion } -// BeginBlock contains the logic that is automatically triggered at the beginning of each block -func (am AppModule) BeginBlock(ctx context.Context) error { - am.keeper.ExecuteReadySchedules(sdk.UnwrapSDKContext(ctx), types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER) - return nil -} - -// EndBlock contains the logic that is automatically triggered at the end of each block -func (am AppModule) EndBlock(ctx context.Context) error { - am.keeper.ExecuteReadySchedules(sdk.UnwrapSDKContext(ctx), types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER) - return nil -} +// // BeginBlock contains the logic that is automatically triggered at the beginning of each block +// func (am AppModule) BeginBlock(ctx context.Context) error { +// // am.keeper.ExecuteReadySchedules(sdk.UnwrapSDKContext(ctx), types.ExecutionStage_EXECUTION_STAGE_BEGIN_BLOCKER) +// return nil +// } + +// // EndBlock contains the logic that is automatically triggered at the end of each block +// func (am AppModule) EndBlock(ctx context.Context) error { +// // am.keeper.ExecuteReadySchedules(sdk.UnwrapSDKContext(ctx), types.ExecutionStage_EXECUTION_STAGE_END_BLOCKER) +// // api.SubmitBlockSignatures() +// // am.keeper.GetScheduledMsgs(); +// return nil +// } diff --git a/x/cron/types/expected_keepers.go b/x/cron/types/expected_keepers.go index fc2e837af..46d13d579 100644 --- a/x/cron/types/expected_keepers.go +++ b/x/cron/types/expected_keepers.go @@ -1,19 +1,25 @@ package types import ( - "context" + context "context" sdk "github.com/cosmos/cosmos-sdk/types" - wasmtypes "github.com/scrtlabs/SecretNetwork/x/compute" + regtypes "github.com/scrtlabs/SecretNetwork/x/registration" ) // AccountKeeper defines the expected account keeper used for simulations (noalias) type AccountKeeper interface { - GetModuleAddress(moduleName string) sdk.AccAddress + GetModuleAddress(name string) sdk.AccAddress + GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI + GetModuleAccount(ctx context.Context, name string) sdk.ModuleAccountI // Methods imported from account should be defined here } -type WasmMsgServer interface { - ExecuteContract(context.Context, *wasmtypes.MsgExecuteContract) (*wasmtypes.MsgExecuteContractResponse, error) - // Methods imported from account should be defined here +type RegKeeper interface { + GetMasterKey(ctx sdk.Context, keyType string) *regtypes.MasterKey } + +// type WasmMsgServer interface { +// ExecuteContract(context.Context, *MsgExecuteContract) (*MsgExecuteContract, error) +// // Methods imported from account should be defined here +// } From d6eccce4d7df5cb3b05c391ef91bf0ee692f710f Mon Sep 17 00:00:00 2001 From: cboh4 Date: Thu, 10 Apr 2025 14:26:05 +0300 Subject: [PATCH 4/8] update go mod and dockerfile --- deployment/dockerfiles/Dockerfile | 2 +- go.mod | 8 +++++--- go.sum | 16 ++++++++-------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/deployment/dockerfiles/Dockerfile b/deployment/dockerfiles/Dockerfile index e29c11a41..7344e9e65 100644 --- a/deployment/dockerfiles/Dockerfile +++ b/deployment/dockerfiles/Dockerfile @@ -70,7 +70,7 @@ ENV FEATURES=${FEATURES} ENV FEATURES_U=${FEATURES_U} ENV MITIGATION_CVE_2020_0551=${MITIGATION_CVE_2020_0551} -RUN git clone --branch mrenclave1 --depth 1 https://github.com/scrtlabs/tm-secret-enclave.git +RUN git clone --branch header-implicit-hash --depth 1 https://github.com/scrtlabs/tm-secret-enclave.git WORKDIR tm-secret-enclave diff --git a/go.mod b/go.mod index 91d73f2e9..671925669 100644 --- a/go.mod +++ b/go.mod @@ -8,8 +8,9 @@ replace ( cosmossdk.io/api => github.com/scrtlabs/cosmos-sdk-api v0.7.6-secret.0 cosmossdk.io/store => github.com/scrtlabs/cosmos-sdk-store v1.1.1-secret.1 cosmossdk.io/x/tx => github.com/scrtlabs/cosmos-sdk-x-tx v0.13.7-secret.0 - github.com/cometbft/cometbft => github.com/scrtlabs/tendermint v0.38.17-secret.4 - github.com/cosmos/cosmos-sdk => github.com/scrtlabs/cosmos-sdk v0.50.11-secret.0 + // github.com/cometbft/cometbft => github.com/scrtlabs/tendermint v0.38.17-secret.0 + github.com/cometbft/cometbft => github.com/scrtlabs/tendermint v0.38.17-secret-7-add-implicit-hash + github.com/cosmos/cosmos-sdk => github.com/scrtlabs/cosmos-sdk v0.50.11-secret-4-implicit-hash github.com/cosmos/iavl => github.com/scrtlabs/iavl v1.2.2-secret.0 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 @@ -57,7 +58,7 @@ require ( cosmossdk.io/x/upgrade v0.1.4 github.com/cosmos/ibc-go/modules/capability v1.0.1 golang.org/x/text v0.21.0 - google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 + google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a ) require ( @@ -74,6 +75,7 @@ require ( github.com/cosmos/rosetta v0.50.4 github.com/gogo/protobuf v1.3.2 github.com/hashicorp/go-metrics v0.5.3 + github.com/scrtlabs/tm-secret-enclave v1.12.3-implicit-hash golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index 89cb8993c..672a9761f 100644 --- a/go.sum +++ b/go.sum @@ -1593,8 +1593,8 @@ github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWR github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sasha-s/go-deadlock v0.3.5 h1:tNCOEEDG6tBqrNDOX35j/7hL5FcFViG6awUGROb2NsU= github.com/sasha-s/go-deadlock v0.3.5/go.mod h1:bugP6EGbdGYObIlx7pUZtWqlvo8k9H6vCBBsiChJQ5U= -github.com/scrtlabs/cosmos-sdk v0.50.11-secret.0 h1:+PAHZrJHw5HNPM14OHQYnA1ZZW9cHIDMXIQCuqW/G2Q= -github.com/scrtlabs/cosmos-sdk v0.50.11-secret.0/go.mod h1:OZuS2yTLgQWoC4P+NDEAR7zVZE7HL4gaRe7MNvNLzJU= +github.com/scrtlabs/cosmos-sdk v0.50.11-secret-4-implicit-hash h1:BKQ6Z0piKAKaFpsBHRvJkfi07ozNyd1u6otmpGCD9cw= +github.com/scrtlabs/cosmos-sdk v0.50.11-secret-4-implicit-hash/go.mod h1:dJQYQ36O/vHv5h7HJECpnSQzelkobTPgwy1ND4pG1dI= github.com/scrtlabs/cosmos-sdk-api v0.7.6-secret.0 h1:9IGLySVhC2qSrxT3fZvvqwjKsnXWSSKnywQDzT8y1Gs= github.com/scrtlabs/cosmos-sdk-api v0.7.6-secret.0/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= github.com/scrtlabs/cosmos-sdk-store v1.1.1-secret.1 h1:TELtwBkSg0xBrs2ObFE0pVVWF6E31fPCDX2tk8OiJPo= @@ -1603,10 +1603,10 @@ github.com/scrtlabs/cosmos-sdk-x-tx v0.13.7-secret.0 h1:i3k5706sDHKhaCvzokB+n33/ github.com/scrtlabs/cosmos-sdk-x-tx v0.13.7-secret.0/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w= github.com/scrtlabs/iavl v1.2.2-secret.0 h1:P96PL1Lf8OBSW9pMrlaRxhceZ4z9Hc7jk12g9ShWeHw= github.com/scrtlabs/iavl v1.2.2-secret.0/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= -github.com/scrtlabs/tendermint v0.38.17-secret.4 h1:09j6LyYIvwOY4umiDwxyK1p/oz9aZWHXVbt+Xjqndck= -github.com/scrtlabs/tendermint v0.38.17-secret.4/go.mod h1:sNoZhVMiH5XByh5E+21n9hLVep/Z3n0Qs3OwJr7EpN0= -github.com/scrtlabs/tm-secret-enclave v1.12.2 h1:fl1rOFYB4+9orTzjAnp6r5EmIm5/6c78EERrWcgEWHA= -github.com/scrtlabs/tm-secret-enclave v1.12.2/go.mod h1:nxZQtzzAqBNBLOEXSv4cKlUnVA4vRmHOn6ujr3kxVME= +github.com/scrtlabs/tendermint v0.38.17-secret-7-add-implicit-hash h1:enOfMMDhEANlxnmf0aQfRIa3aIwWKUYsgSx86lQVJb0= +github.com/scrtlabs/tendermint v0.38.17-secret-7-add-implicit-hash/go.mod h1:vVQJOjosVUoChSxdYGQQ2Ojy35m/8el7r1LziCy4ox4= +github.com/scrtlabs/tm-secret-enclave v1.12.3-implicit-hash h1:vssSAjnieWcH4XsGjpGv5MRk1fJTL4boCWrwbgkCFDQ= +github.com/scrtlabs/tm-secret-enclave v1.12.3-implicit-hash/go.mod h1:nxZQtzzAqBNBLOEXSv4cKlUnVA4vRmHOn6ujr3kxVME= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= @@ -2452,8 +2452,8 @@ google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98/go. google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ= google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU= -google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= -google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= +google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a h1:OAiGFfOiA0v9MRYsSidp3ubZaBnteRUyn3xB2ZQ5G/E= +google.golang.org/genproto/googleapis/api v0.0.0-20241202173237-19429a94021a/go.mod h1:jehYqy3+AhJU9ve55aNOaSml7wUXjF9x6z2LcCfpAhY= google.golang.org/genproto/googleapis/bytestream v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:ylj+BE99M198VPbBh6A8d9n3w8fChvyLK3wwBOjXBFA= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234015-3fc162c6f38a/go.mod h1:xURIpW9ES5+/GZhnV6beoEtxQrnkRGIfP5VQG2tCBLc= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= From dee996bfe0f55070b79ba722ddfe66dda3f4ed80 Mon Sep 17 00:00:00 2001 From: cboh4 Date: Mon, 14 Apr 2025 15:56:04 +0300 Subject: [PATCH 5/8] avoid returning error, as it cause consensus failure --- x/compute/internal/keeper/keeper.go | 12 ------------ x/compute/module.go | 5 ++--- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/x/compute/internal/keeper/keeper.go b/x/compute/internal/keeper/keeper.go index 4716806c4..d66428fc7 100644 --- a/x/compute/internal/keeper/keeper.go +++ b/x/compute/internal/keeper/keeper.go @@ -1126,18 +1126,6 @@ func (k Keeper) GetScheduledMsgs(ctx sdk.Context, execution_stage crontypes.Exec txBytesList = append(txBytesList, txBytes) executeMsgList = append(executeMsgList, executeMsg) - // Execute the contract. - // _, err = k.Execute(cacheCtx, executeMsg.Contract, executeMsg.Sender, executeMsg.Msg, executeMsg.SentFunds, executeMsg.CallbackSig, wasmTypes.HandleTypeExecute) - // if err != nil { - // ctx.Logger().Info("executeSchedule: failed to execute contract msg", - // "schedule_name", ExecuteScheduledMsgs.Name, - // "msg_idx", idx, - // "msg_contract", msg.Contract, - // "msg", msg.Msg, - // "error", err, - // ) - // return err - // } } // Commit changes if all messages were executed successfully. diff --git a/x/compute/module.go b/x/compute/module.go index e18e9b80a..381f77242 100644 --- a/x/compute/module.go +++ b/x/compute/module.go @@ -203,12 +203,11 @@ func (am AppModule) BeginBlock(c context.Context) error { for idx, msg := range execCronMsgs { fmt.Printf("idx, msg: %+v %+v\n", idx, msg) ctx = ctx.WithTxBytes(bytesCronMsgs[idx]) - res, err := am.keeper.Execute(ctx, msg.Contract, msg.Sender, msg.Msg, msg.SentFunds, msg.CallbackSig, wasmtypes.HandleTypeExecute) + _, err := am.keeper.Execute(ctx, msg.Contract, msg.Sender, msg.Msg, msg.SentFunds, msg.CallbackSig, wasmtypes.HandleTypeExecute) if err != nil { ctx.Logger().Error("Failed to execute cron message", "error", err) - return err + // return err } - fmt.Printf("res: %+v\n", res) } fmt.Printf("setRandomSeed\n") From d3b6e5943fe279e4b867e711e5d8e4615c11a426 Mon Sep 17 00:00:00 2001 From: cboh4 Date: Tue, 27 May 2025 16:21:46 +0300 Subject: [PATCH 6/8] add verification for the block header hash inside the enclave --- cosmwasm/enclaves/Cargo.lock | 5 +++-- cosmwasm/enclaves/execute/Cargo.toml | 6 +++--- cosmwasm/enclaves/shared/block-verifier/Cargo.toml | 6 +++--- .../block-verifier/src/submit_block_signatures.rs | 11 ++++------- .../shared/block-verifier/src/verify/header.rs | 14 ++++++++++++-- cosmwasm/enclaves/shared/utils/Cargo.toml | 4 ++-- go.mod | 4 ++-- go.sum | 8 ++++---- x/compute/module.go | 12 +++--------- 9 files changed, 36 insertions(+), 34 deletions(-) diff --git a/cosmwasm/enclaves/Cargo.lock b/cosmwasm/enclaves/Cargo.lock index 4e4a5a46d..d5a9b78dd 100644 --- a/cosmwasm/enclaves/Cargo.lock +++ b/cosmwasm/enclaves/Cargo.lock @@ -2097,7 +2097,7 @@ dependencies = [ [[package]] name = "tendermint" version = "0.38.0" -source = "git+https://github.com/scrtlabs/tendermint-rs?tag=v0.38.0-secret.3#d4ccb1eb5e6ccb795e04d4b6e6f5e642c85ac636" +source = "git+https://github.com/scrtlabs/tendermint-rs?tag=v0.38.0-secret.9-add-implicit-hash#cd93ead0165d175b3e51a30951cd6a5390cffcdc" dependencies = [ "bytes 1.7.1", "digest 0.10.7", @@ -2129,6 +2129,7 @@ source = "git+https://github.com/scrtlabs/tendermint-rs?tag=v0.38.0-secret.1#2ab dependencies = [ "derive_more", "flex-error", + "log", "serde 1.0.205", "tendermint", "time", @@ -2137,7 +2138,7 @@ dependencies = [ [[package]] name = "tendermint-proto" version = "0.38.0" -source = "git+https://github.com/scrtlabs/tendermint-rs?tag=v0.38.0-secret.4#fca937579f9348ffb7386217cf0162fe76352bc4" +source = "git+https://github.com/scrtlabs/tendermint-rs?tag=v0.38.0-secret.9-add-implicit-hash#cd93ead0165d175b3e51a30951cd6a5390cffcdc" dependencies = [ "bytes 1.7.1", "flex-error", diff --git a/cosmwasm/enclaves/execute/Cargo.toml b/cosmwasm/enclaves/execute/Cargo.toml index 26e77814a..aca6b10ab 100644 --- a/cosmwasm/enclaves/execute/Cargo.toml +++ b/cosmwasm/enclaves/execute/Cargo.toml @@ -91,9 +91,9 @@ block-verifier = { path = "../shared/block-verifier", optional = true } time = "=0.3.17" ed25519-dalek = { version = "1.0", default-features = false } sha2 = "0.10" -tendermint = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.4", default-features = false, features = ["rust-crypto"] } -tendermint-proto = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.4", default-features = false } -tendermint-light-client-verifier = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.4", default-features = false, features = ["rust-crypto"] } +tendermint = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.9-add-implicit-hash", default-features = false, features = ["rust-crypto"] } +tendermint-proto = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.9-add-implicit-hash", default-features = false } +tendermint-light-client-verifier = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.9-add-implicit-hash", default-features = false, features = ["rust-crypto"] } [dependencies.webpki] git = "https://github.com/mesalock-linux/webpki" diff --git a/cosmwasm/enclaves/shared/block-verifier/Cargo.toml b/cosmwasm/enclaves/shared/block-verifier/Cargo.toml index 8cc9a349c..67599b54e 100644 --- a/cosmwasm/enclaves/shared/block-verifier/Cargo.toml +++ b/cosmwasm/enclaves/shared/block-verifier/Cargo.toml @@ -19,9 +19,9 @@ sgx_types = { rev = "d2d339cbb005f676bb700059bd51dc689c025f6b", git = "https://g [dependencies] sha2 = "0.10" -tendermint = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.4", default-features = false, features = ["rust-crypto"] } -tendermint-proto = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.4", default-features = false } -tendermint-light-client-verifier = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.4", default-features = false, features = ["rust-crypto"] } +tendermint = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.9-add-implicit-hash", default-features = false, features = ["rust-crypto"] } +tendermint-proto = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.9-add-implicit-hash", default-features = false } +tendermint-light-client-verifier = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.9-add-implicit-hash", default-features = false, features = ["rust-crypto"] } lazy_static = "1.4.0" log = "0.4.17" diff --git a/cosmwasm/enclaves/shared/block-verifier/src/submit_block_signatures.rs b/cosmwasm/enclaves/shared/block-verifier/src/submit_block_signatures.rs index c18e61ab8..d4f95c59d 100644 --- a/cosmwasm/enclaves/shared/block-verifier/src/submit_block_signatures.rs +++ b/cosmwasm/enclaves/shared/block-verifier/src/submit_block_signatures.rs @@ -1,3 +1,4 @@ +use core::convert::TryInto; use std::slice; use sgx_types::sgx_status_t; @@ -5,7 +6,10 @@ use sgx_types::sgx_status_t; use enclave_utils::{validate_const_ptr, validate_input_length, validate_mut_ptr, KEY_MANAGER}; use log::debug; use log::error; +use std::convert::TryFrom; +use tendermint::signature::Ed25519Signature; use tendermint::Hash; +use tendermint::Signature; macro_rules! unwrap_or_return { ($result:expr) => { @@ -136,13 +140,6 @@ pub unsafe fn submit_block_signatures_impl( let implicit_hash = tendermint::Hash::Sha256(hash_result); - debug!("implicit_hash: {:?}", &implicit_hash); - - debug!( - "header.header.implicit_hash: {:?}", - &header.header.implicit_hash - ); - if implicit_hash != header.header.implicit_hash { error!("Implicit hash does not match header implicit hash"); return sgx_status_t::SGX_ERROR_INVALID_PARAMETER; diff --git a/cosmwasm/enclaves/shared/block-verifier/src/verify/header.rs b/cosmwasm/enclaves/shared/block-verifier/src/verify/header.rs index 41e61874f..f88f0560c 100644 --- a/cosmwasm/enclaves/shared/block-verifier/src/verify/header.rs +++ b/cosmwasm/enclaves/shared/block-verifier/src/verify/header.rs @@ -1,5 +1,8 @@ +use crate::verify::block::verify_block; +use core::time::Duration; use log::error; use sgx_types::sgx_status_t; +use sha2::{Digest, Sha256}; use tendermint::block::signed_header::SignedHeader; use tendermint::block::{Commit, Header}; use tendermint::validator::Set; @@ -7,8 +10,6 @@ use tendermint_light_client_verifier::types::UntrustedBlockState; use tendermint_proto::v0_38::types::Header as RawHeader; use tendermint_proto::Protobuf; -use crate::verify::block::verify_block; - pub fn validate_block_header( block_header_slice: &[u8], validator_set: &Set, @@ -32,6 +33,15 @@ pub fn validate_block_header( return Err(sgx_status_t::SGX_ERROR_FILE_RECOVERY_NEEDED); } + if signed_header.header.hash() != signed_header.commit.block_id.hash { + error!( + "Error verifying block hash in header! got {:?}, expected: {:?}", + signed_header.header.hash(), + signed_header.commit.block_id.hash + ); + return Err(sgx_status_t::SGX_ERROR_INVALID_PARAMETER); + } + let untrusted_block = UntrustedBlockState { signed_header: &signed_header, validators: validator_set, diff --git a/cosmwasm/enclaves/shared/utils/Cargo.toml b/cosmwasm/enclaves/shared/utils/Cargo.toml index 489265ad2..e2b80dfa8 100644 --- a/cosmwasm/enclaves/shared/utils/Cargo.toml +++ b/cosmwasm/enclaves/shared/utils/Cargo.toml @@ -32,6 +32,6 @@ serde = { git = "https://github.com/mesalock-linux/serde-sgx", features = [ "derive" ] } serde_json = { git = "https://github.com/mesalock-linux/serde-json-sgx" } -tendermint-proto = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.4", default-features = false } -tendermint = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.4", default-features = false, features = ["rust-crypto"] } +tendermint-proto = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.9-add-implicit-hash", default-features = false } +tendermint = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.9-add-implicit-hash", default-features = false, features = ["rust-crypto"] } enclave_crypto = { path = "../crypto" } diff --git a/go.mod b/go.mod index 671925669..1e65fc66e 100644 --- a/go.mod +++ b/go.mod @@ -9,8 +9,8 @@ replace ( cosmossdk.io/store => github.com/scrtlabs/cosmos-sdk-store v1.1.1-secret.1 cosmossdk.io/x/tx => github.com/scrtlabs/cosmos-sdk-x-tx v0.13.7-secret.0 // github.com/cometbft/cometbft => github.com/scrtlabs/tendermint v0.38.17-secret.0 - github.com/cometbft/cometbft => github.com/scrtlabs/tendermint v0.38.17-secret-7-add-implicit-hash - github.com/cosmos/cosmos-sdk => github.com/scrtlabs/cosmos-sdk v0.50.11-secret-4-implicit-hash + github.com/cometbft/cometbft => github.com/scrtlabs/tendermint v0.38.17-secret-23-add-implicit-hash + github.com/cosmos/cosmos-sdk => github.com/scrtlabs/cosmos-sdk v0.50.11-secret-15-implicit-hash github.com/cosmos/iavl => github.com/scrtlabs/iavl v1.2.2-secret.0 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 diff --git a/go.sum b/go.sum index 672a9761f..35641639d 100644 --- a/go.sum +++ b/go.sum @@ -1593,8 +1593,8 @@ github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWR github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sasha-s/go-deadlock v0.3.5 h1:tNCOEEDG6tBqrNDOX35j/7hL5FcFViG6awUGROb2NsU= github.com/sasha-s/go-deadlock v0.3.5/go.mod h1:bugP6EGbdGYObIlx7pUZtWqlvo8k9H6vCBBsiChJQ5U= -github.com/scrtlabs/cosmos-sdk v0.50.11-secret-4-implicit-hash h1:BKQ6Z0piKAKaFpsBHRvJkfi07ozNyd1u6otmpGCD9cw= -github.com/scrtlabs/cosmos-sdk v0.50.11-secret-4-implicit-hash/go.mod h1:dJQYQ36O/vHv5h7HJECpnSQzelkobTPgwy1ND4pG1dI= +github.com/scrtlabs/cosmos-sdk v0.50.11-secret-15-implicit-hash h1:4nIG7McsrhkbMQkrLz6VRd0UQiOg24RX6Gf7Z1T42kA= +github.com/scrtlabs/cosmos-sdk v0.50.11-secret-15-implicit-hash/go.mod h1:2emBr6HobBqfY1gpDsRuCWgQiQYIwG+U600DiwzSgTs= github.com/scrtlabs/cosmos-sdk-api v0.7.6-secret.0 h1:9IGLySVhC2qSrxT3fZvvqwjKsnXWSSKnywQDzT8y1Gs= github.com/scrtlabs/cosmos-sdk-api v0.7.6-secret.0/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38= github.com/scrtlabs/cosmos-sdk-store v1.1.1-secret.1 h1:TELtwBkSg0xBrs2ObFE0pVVWF6E31fPCDX2tk8OiJPo= @@ -1603,8 +1603,8 @@ github.com/scrtlabs/cosmos-sdk-x-tx v0.13.7-secret.0 h1:i3k5706sDHKhaCvzokB+n33/ github.com/scrtlabs/cosmos-sdk-x-tx v0.13.7-secret.0/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w= github.com/scrtlabs/iavl v1.2.2-secret.0 h1:P96PL1Lf8OBSW9pMrlaRxhceZ4z9Hc7jk12g9ShWeHw= github.com/scrtlabs/iavl v1.2.2-secret.0/go.mod h1:GiM43q0pB+uG53mLxLDzimxM9l/5N9UuSY3/D0huuVw= -github.com/scrtlabs/tendermint v0.38.17-secret-7-add-implicit-hash h1:enOfMMDhEANlxnmf0aQfRIa3aIwWKUYsgSx86lQVJb0= -github.com/scrtlabs/tendermint v0.38.17-secret-7-add-implicit-hash/go.mod h1:vVQJOjosVUoChSxdYGQQ2Ojy35m/8el7r1LziCy4ox4= +github.com/scrtlabs/tendermint v0.38.17-secret-23-add-implicit-hash h1:DNE7aW19nTUgFMUNIIRgJBi/I6vYYEP4WQLQclY1ZIw= +github.com/scrtlabs/tendermint v0.38.17-secret-23-add-implicit-hash/go.mod h1:vVQJOjosVUoChSxdYGQQ2Ojy35m/8el7r1LziCy4ox4= github.com/scrtlabs/tm-secret-enclave v1.12.3-implicit-hash h1:vssSAjnieWcH4XsGjpGv5MRk1fJTL4boCWrwbgkCFDQ= github.com/scrtlabs/tm-secret-enclave v1.12.3-implicit-hash/go.mod h1:nxZQtzzAqBNBLOEXSv4cKlUnVA4vRmHOn6ujr3kxVME= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= diff --git a/x/compute/module.go b/x/compute/module.go index 381f77242..2509cca4b 100644 --- a/x/compute/module.go +++ b/x/compute/module.go @@ -158,6 +158,9 @@ func (am AppModule) BeginBlock(c context.Context) error { ctx.Logger().Error("Failed to get scheduled cron msgs") return err } + // hash := sha256.Sum256([]byte("random")) + // block_header.ImplicitHash = hash[:] + // block_header.AppHash = hash[:] cron_msgs := tm_type.Data{Txs: bytesCronMsgs} cron_data, err := cron_msgs.Marshal() @@ -165,7 +168,6 @@ func (am AppModule) BeginBlock(c context.Context) error { ctx.Logger().Error("Failed to marshal cron_msgs") return err } - // hash := sha256.Sum256(cron_data) header, err := block_header.Marshal() if err != nil { @@ -173,11 +175,6 @@ func (am AppModule) BeginBlock(c context.Context) error { return err } - // fmt.Printf("---------------bytesCronMsgs--------------\n%+v\n", bytesCronMsgs) - // fmt.Printf("---------------execCronMsgs--------------\n%+v\n", execCronMsgs) - // fmt.Printf("ImplicitHash: %+v\n", hex.EncodeToString(hash[:])) - // fmt.Printf("beginBlock: block_header: %+v\n", block_header) - commit := ctx.Commit() b_commit, err := commit.Marshal() if err != nil { @@ -222,8 +219,6 @@ func (am AppModule) BeginBlock(c context.Context) error { // EndBlock returns the end blocker for the compute module. func (am AppModule) EndBlock(c context.Context) error { ctx := c.(sdk.Context) - block_header := ctx.BlockHeader() - fmt.Printf("endBlock: block_header: %+v\n", block_header) _, bytesCronMsgs, err := am.keeper.GetScheduledMsgs(ctx, crontypes.ExecutionStage_EXECUTION_STAGE_END_BLOCKER) if err != nil { @@ -245,7 +240,6 @@ func (am AppModule) EndBlock(c context.Context) error { ctx.Logger().Error("Failed to set implicit hash %+v", err) return err } - fmt.Printf("---------------EndBlock--------------\n") return nil } From 63fc72181a86d979b8f64e9d2d64cb3cfff8ae5c Mon Sep 17 00:00:00 2001 From: cboh4 Date: Tue, 27 May 2025 16:29:50 +0300 Subject: [PATCH 7/8] update go.mod --- go.mod | 1 - 1 file changed, 1 deletion(-) diff --git a/go.mod b/go.mod index 1e65fc66e..1827a8698 100644 --- a/go.mod +++ b/go.mod @@ -202,7 +202,6 @@ require ( github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sasha-s/go-deadlock v0.3.5 // indirect - github.com/scrtlabs/tm-secret-enclave v1.12.2 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect From aae46b58dbc1d98529b2335f6f2d26e5233a1eaf Mon Sep 17 00:00:00 2001 From: cboh4 Date: Wed, 28 May 2025 13:33:43 +0300 Subject: [PATCH 8/8] fix the execution order of scheduled messages within the enclave --- app/keepers/keepers.go | 6 ----- .../src/submit_block_signatures.rs | 24 +++++++++---------- x/compute/module.go | 7 ------ 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 815226c54..2242d2ffc 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -552,12 +552,6 @@ func (ak *SecretAppKeepers) InitCustomKeepers( ak.ComputeKeeper = &computeKeeper wasmHooks.ContractKeeper = ak.ComputeKeeper - // wasmMsgServer := compute.NewMsgServerImpl(*ak.ComputeKeeper) - // fmt.Printf("wasmMsgServer: %+v\n", wasmMsgServer) - // ak.CronKeeper.WasmMsgServer = compute.NewCronWasmMsgServerAdapter(wasmMsgServer) - // ak.ComputeKeeper.SetCronKeeper(*ak.CronKeeper) - // fmt.Printf("ak.CronKeeper.WasmMsgServer: %+v\n", ak.CronKeeper.WasmMsgServer) - // Compute receive: Switch -> Fee -> Packet Forward -> WASM Hooks var computeStack porttypes.IBCModule computeStack = compute.NewIBCHandler(ak.ComputeKeeper, ak.IbcKeeper.ChannelKeeper, ak.IbcFeeKeeper) diff --git a/cosmwasm/enclaves/shared/block-verifier/src/submit_block_signatures.rs b/cosmwasm/enclaves/shared/block-verifier/src/submit_block_signatures.rs index d4f95c59d..496dc3bb1 100644 --- a/cosmwasm/enclaves/shared/block-verifier/src/submit_block_signatures.rs +++ b/cosmwasm/enclaves/shared/block-verifier/src/submit_block_signatures.rs @@ -122,17 +122,6 @@ pub unsafe fn submit_block_signatures_impl( message_verifier.clear(); } - for tx in txs.iter() { - // doing this a different way makes the code unreadable or requires creating a copy of - - let parsed_tx = unwrap_or_return!(tx_from_bytes(tx.as_slice()).map_err(|_| { - error!("Unable to parse tx bytes from proto"); - sgx_status_t::SGX_ERROR_INVALID_PARAMETER - })); - - message_verifier.append_msg_from_tx(parsed_tx); - } - let mut hasher = Sha256::new(); hasher.update(cron_msgs_slice); let hash_result = hasher.finalize(); @@ -152,12 +141,21 @@ pub unsafe fn submit_block_signatures_impl( sgx_status_t::SGX_ERROR_INVALID_PARAMETER })); - dbg!(&parsed_cron_msg); - message_verifier.append_msg_from_tx(parsed_cron_msg); } } + for tx in txs.iter() { + // doing this a different way makes the code unreadable or requires creating a copy of + + let parsed_tx = unwrap_or_return!(tx_from_bytes(tx.as_slice()).map_err(|_| { + error!("Unable to parse tx bytes from proto"); + sgx_status_t::SGX_ERROR_INVALID_PARAMETER + })); + + message_verifier.append_msg_from_tx(parsed_tx); + } + message_verifier.set_block_info( header.header.height.value(), header.header.time.unix_timestamp_nanos(), diff --git a/x/compute/module.go b/x/compute/module.go index 2509cca4b..869559648 100644 --- a/x/compute/module.go +++ b/x/compute/module.go @@ -158,9 +158,6 @@ func (am AppModule) BeginBlock(c context.Context) error { ctx.Logger().Error("Failed to get scheduled cron msgs") return err } - // hash := sha256.Sum256([]byte("random")) - // block_header.ImplicitHash = hash[:] - // block_header.AppHash = hash[:] cron_msgs := tm_type.Data{Txs: bytesCronMsgs} cron_data, err := cron_msgs.Marshal() @@ -198,17 +195,13 @@ func (am AppModule) BeginBlock(c context.Context) error { } for idx, msg := range execCronMsgs { - fmt.Printf("idx, msg: %+v %+v\n", idx, msg) ctx = ctx.WithTxBytes(bytesCronMsgs[idx]) _, err := am.keeper.Execute(ctx, msg.Contract, msg.Sender, msg.Msg, msg.SentFunds, msg.CallbackSig, wasmtypes.HandleTypeExecute) if err != nil { ctx.Logger().Error("Failed to execute cron message", "error", err) - // return err } } - fmt.Printf("setRandomSeed\n") - am.keeper.SetRandomSeed(ctx, random, validator_set_evidence) } else { ctx.Logger().Debug("Non-encrypted block", "Block_hash", block_header.LastBlockId.Hash, "Height", ctx.BlockHeight(), "Txs", len(x2_data))