From a5118b77b8c02bacbb1e67bd6be4efecb478f529 Mon Sep 17 00:00:00 2001 From: jayy04 <103467857+jayy04@users.noreply.github.com> Date: Tue, 5 Mar 2024 21:58:35 -0500 Subject: [PATCH 1/3] [CT-646] stream offchain updates through stream manager (#1138) * [CT-646] stream offchain updates through stream manager * comments * fix lint * get rid of finished * comments * comments --- protocol/app/app.go | 9 +- .../streaming/grpc/grpc_streaming_manager.go | 102 +++++++++++++++++- .../streaming/grpc/noop_streaming_manager.go | 3 +- protocol/streaming/grpc/types/manager.go | 1 - .../x/clob/keeper/grpc_stream_orderbook.go | 8 ++ protocol/x/clob/keeper/orders.go | 2 + protocol/x/clob/types/errors.go | 12 +++ 7 files changed, 125 insertions(+), 12 deletions(-) diff --git a/protocol/app/app.go b/protocol/app/app.go index 2ac4d17519..53d18c9b37 100644 --- a/protocol/app/app.go +++ b/protocol/app/app.go @@ -961,7 +961,9 @@ func New( clobFlags := clobflags.GetClobFlagValuesFromOptions(appOpts) logger.Info("Parsed CLOB flags", "Flags", clobFlags) - memClob := clobmodulememclob.NewMemClobPriceTimePriority(app.IndexerEventManager.Enabled()) + memClob := clobmodulememclob.NewMemClobPriceTimePriority( + app.IndexerEventManager.Enabled() || app.GrpcStreamingManager.Enabled(), + ) app.ClobKeeper = clobmodulekeeper.NewKeeper( appCodec, @@ -1758,8 +1760,5 @@ func getGrpcStreamingManagerFromOptions( logger log.Logger, ) (manager streamingtypes.GrpcStreamingManager) { // TODO(CT-625): add command line flags for full node streaming. - if appFlags.NonValidatingFullNode { - return streaming.NewGrpcStreamingManager() - } - return streaming.NewNoopGrpcStreamingManager() + return streaming.NewGrpcStreamingManager() } diff --git a/protocol/streaming/grpc/grpc_streaming_manager.go b/protocol/streaming/grpc/grpc_streaming_manager.go index 6b9250145f..5ab3fbbde8 100644 --- a/protocol/streaming/grpc/grpc_streaming_manager.go +++ b/protocol/streaming/grpc/grpc_streaming_manager.go @@ -1,6 +1,10 @@ package grpc import ( + "sync" + + "github.com/cosmos/gogoproto/proto" + ocutypes "github.com/dydxprotocol/v4-chain/protocol/indexer/off_chain_updates/types" "github.com/dydxprotocol/v4-chain/protocol/streaming/grpc/types" clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" ) @@ -9,10 +13,23 @@ var _ types.GrpcStreamingManager = (*GrpcStreamingManagerImpl)(nil) // GrpcStreamingManagerImpl is an implementation for managing gRPC streaming subscriptions. type GrpcStreamingManagerImpl struct { + sync.Mutex + + // orderbookSubscriptions maps subscription IDs to their respective orderbook subscriptions. + orderbookSubscriptions map[uint32]*OrderbookSubscription + nextSubscriptionId uint32 +} + +// OrderbookSubscription represents a active subscription to the orderbook updates stream. +type OrderbookSubscription struct { + clobPairIds []uint32 + srv clobtypes.Query_StreamOrderbookUpdatesServer } func NewGrpcStreamingManager() *GrpcStreamingManagerImpl { - return &GrpcStreamingManagerImpl{} + return &GrpcStreamingManagerImpl{ + orderbookSubscriptions: make(map[uint32]*OrderbookSubscription), + } } func (sm *GrpcStreamingManagerImpl) Enabled() bool { @@ -24,15 +41,92 @@ func (sm *GrpcStreamingManagerImpl) Subscribe( req clobtypes.StreamOrderbookUpdatesRequest, srv clobtypes.Query_StreamOrderbookUpdatesServer, ) ( - finished chan bool, err error, ) { - return nil, nil + clobPairIds := req.GetClobPairId() + + // Perform some basic validation on the request. + if len(clobPairIds) == 0 { + return clobtypes.ErrInvalidGrpcStreamingRequest + } + + subscription := &OrderbookSubscription{ + clobPairIds: clobPairIds, + srv: srv, + } + + sm.Lock() + defer sm.Unlock() + + sm.orderbookSubscriptions[sm.nextSubscriptionId] = subscription + sm.nextSubscriptionId++ + + return nil } // SendOrderbookUpdates groups updates by their clob pair ids and // sends messages to the subscribers. func (sm *GrpcStreamingManagerImpl) SendOrderbookUpdates( - updates *clobtypes.OffchainUpdates, + offchainUpdates *clobtypes.OffchainUpdates, ) { + // Group updates by clob pair id. + updates := make(map[uint32]*clobtypes.OffchainUpdates) + for _, message := range offchainUpdates.Messages { + clobPairId := message.OrderId.ClobPairId + if _, ok := updates[clobPairId]; !ok { + updates[clobPairId] = clobtypes.NewOffchainUpdates() + } + updates[clobPairId].Messages = append(updates[clobPairId].Messages, message) + } + + // Unmarshal messages to v1 updates. + v1updates := make(map[uint32][]ocutypes.OffChainUpdateV1) + for clobPairId, update := range updates { + v1update, err := GetOffchainUpdatesV1(update) + if err != nil { + panic(err) + } + v1updates[clobPairId] = v1update + } + + sm.Lock() + defer sm.Unlock() + + // Send updates to subscribers. + idsToRemove := make([]uint32, 0) + for id, subscription := range sm.orderbookSubscriptions { + for _, clobPairId := range subscription.clobPairIds { + if updates, ok := v1updates[clobPairId]; ok { + if err := subscription.srv.Send( + &clobtypes.StreamOrderbookUpdatesResponse{ + Updates: updates, + Snapshot: false, + }, + ); err != nil { + idsToRemove = append(idsToRemove, id) + break + } + } + } + } + + // Clean up subscriptions that have been closed. + // If a Send update has failed for any clob pair id, the whole subscription will be removed. + for _, id := range idsToRemove { + delete(sm.orderbookSubscriptions, id) + } +} + +// GetOffchainUpdatesV1 unmarshals messages in offchain updates to OffchainUpdateV1. +func GetOffchainUpdatesV1(offchainUpdates *clobtypes.OffchainUpdates) ([]ocutypes.OffChainUpdateV1, error) { + v1updates := make([]ocutypes.OffChainUpdateV1, 0) + for _, message := range offchainUpdates.Messages { + var update ocutypes.OffChainUpdateV1 + err := proto.Unmarshal(message.Message.Value, &update) + if err != nil { + return nil, err + } + v1updates = append(v1updates, update) + } + return v1updates, nil } diff --git a/protocol/streaming/grpc/noop_streaming_manager.go b/protocol/streaming/grpc/noop_streaming_manager.go index b4670ba66f..467b18864b 100644 --- a/protocol/streaming/grpc/noop_streaming_manager.go +++ b/protocol/streaming/grpc/noop_streaming_manager.go @@ -21,10 +21,9 @@ func (sm *NoopGrpcStreamingManager) Subscribe( req clobtypes.StreamOrderbookUpdatesRequest, srv clobtypes.Query_StreamOrderbookUpdatesServer, ) ( - finished chan bool, err error, ) { - return nil, nil + return clobtypes.ErrGrpcStreamingManagerNotEnabled } func (sm *NoopGrpcStreamingManager) SendOrderbookUpdates( diff --git a/protocol/streaming/grpc/types/manager.go b/protocol/streaming/grpc/types/manager.go index 7bf043c41d..49882209a6 100644 --- a/protocol/streaming/grpc/types/manager.go +++ b/protocol/streaming/grpc/types/manager.go @@ -12,7 +12,6 @@ type GrpcStreamingManager interface { req clobtypes.StreamOrderbookUpdatesRequest, srv clobtypes.Query_StreamOrderbookUpdatesServer, ) ( - finished chan bool, err error, ) SendOrderbookUpdates(*clobtypes.OffchainUpdates) diff --git a/protocol/x/clob/keeper/grpc_stream_orderbook.go b/protocol/x/clob/keeper/grpc_stream_orderbook.go index 05e65a8690..710a6ceec6 100644 --- a/protocol/x/clob/keeper/grpc_stream_orderbook.go +++ b/protocol/x/clob/keeper/grpc_stream_orderbook.go @@ -8,5 +8,13 @@ func (k Keeper) StreamOrderbookUpdates( req *types.StreamOrderbookUpdatesRequest, stream types.Query_StreamOrderbookUpdatesServer, ) error { + err := k.GetGrpcStreamingManager().Subscribe(*req, stream) + if err != nil { + return err + } + + // Keep this scope alive because once this scope exits - the stream is closed + ctx := stream.Context() + <-ctx.Done() return nil } diff --git a/protocol/x/clob/keeper/orders.go b/protocol/x/clob/keeper/orders.go index c6169c11e8..4df957e2db 100644 --- a/protocol/x/clob/keeper/orders.go +++ b/protocol/x/clob/keeper/orders.go @@ -1311,6 +1311,8 @@ func (k Keeper) SendOffchainMessages( } k.GetIndexerEventManager().SendOffchainData(update) } + + k.GetGrpcStreamingManager().SendOrderbookUpdates(offchainUpdates) } // getFillQuoteQuantums returns the total fillAmount price in quote quantums based on the maker subticks. diff --git a/protocol/x/clob/types/errors.go b/protocol/x/clob/types/errors.go index 882015c7a1..bb19647efe 100644 --- a/protocol/x/clob/types/errors.go +++ b/protocol/x/clob/types/errors.go @@ -523,4 +523,16 @@ var ( 10001, "Subaccount cannot open more orders due to equity tier limit.", ) + + // GrpcStreamingManager errors. + ErrGrpcStreamingManagerNotEnabled = errorsmod.Register( + ModuleName, + 11000, + "GrpcStreamingManager is not enabled", + ) + ErrInvalidGrpcStreamingRequest = errorsmod.Register( + ModuleName, + 11001, + "Invalid gRPC streaming request", + ) ) From 55d0b6da199d0d5496cd0a4f40f4cc2a3a533fb4 Mon Sep 17 00:00:00 2001 From: jayy04 <103467857+jayy04@users.noreply.github.com> Date: Wed, 6 Mar 2024 10:48:42 -0500 Subject: [PATCH 2/3] [CT-652] add command line flag for full node streaming (#1145) --- protocol/app/app.go | 10 ++++++---- protocol/app/flags/flags.go | 32 ++++++++++++++++++++++++++++++++ protocol/app/flags/flags_test.go | 29 +++++++++++++++++++++++++++-- 3 files changed, 65 insertions(+), 6 deletions(-) diff --git a/protocol/app/app.go b/protocol/app/app.go index 53d18c9b37..b737375fdb 100644 --- a/protocol/app/app.go +++ b/protocol/app/app.go @@ -685,7 +685,7 @@ func New( indexerFlags.SendOffchainData, ) - app.GrpcStreamingManager = getGrpcStreamingManagerFromOptions(appFlags, appOpts, logger) + app.GrpcStreamingManager = getGrpcStreamingManagerFromOptions(appFlags, logger) timeProvider := &timelib.TimeProviderImpl{} @@ -1756,9 +1756,11 @@ func getIndexerFromOptions( // options. This function will default to returning a no-op instance. func getGrpcStreamingManagerFromOptions( appFlags flags.Flags, - appOpts servertypes.AppOptions, logger log.Logger, ) (manager streamingtypes.GrpcStreamingManager) { - // TODO(CT-625): add command line flags for full node streaming. - return streaming.NewGrpcStreamingManager() + if appFlags.GrpcStreamingEnabled { + logger.Info("GRPC streaming is enabled") + return streaming.NewGrpcStreamingManager() + } + return streaming.NewNoopGrpcStreamingManager() } diff --git a/protocol/app/flags/flags.go b/protocol/app/flags/flags.go index 6f67611a22..18fa78a19b 100644 --- a/protocol/app/flags/flags.go +++ b/protocol/app/flags/flags.go @@ -19,6 +19,9 @@ type Flags struct { // Existing flags GrpcAddress string GrpcEnable bool + + // Grpc Streaming + GrpcStreamingEnabled bool } // List of CLI flags. @@ -31,6 +34,9 @@ const ( // Cosmos flags below. These config values can be set as flags or in config.toml. GrpcAddress = "grpc.address" GrpcEnable = "grpc.enable" + + // Grpc Streaming + GrpcStreamingEnabled = "grpc-streaming-enabled" ) // Default values. @@ -39,6 +45,8 @@ const ( DefaultDdTraceAgentPort = 8126 DefaultNonValidatingFullNode = false DefaultDdErrorTrackingFormat = false + + DefaultGrpcStreamingEnabled = false ) // AddFlagsToCmd adds flags to app initialization. @@ -67,6 +75,11 @@ func AddFlagsToCmd(cmd *cobra.Command) { DefaultDdErrorTrackingFormat, "Enable formatting of log error tags to datadog error tracking format", ) + cmd.Flags().Bool( + GrpcStreamingEnabled, + DefaultGrpcStreamingEnabled, + "Whether to enable grpc streaming for full nodes", + ) } // Validate checks that the flags are valid. @@ -75,6 +88,17 @@ func (f *Flags) Validate() error { if !f.NonValidatingFullNode && !f.GrpcEnable { return fmt.Errorf("grpc.enable must be set to true - validating requires gRPC server") } + + // Grpc streaming + if f.GrpcStreamingEnabled { + if !f.GrpcEnable { + return fmt.Errorf("grpc.enable must be set to true - grpc streaming requires gRPC server") + } + + if !f.NonValidatingFullNode { + return fmt.Errorf("grpc-streaming-enabled can only be set to true for non-validating full nodes") + } + } return nil } @@ -93,6 +117,8 @@ func GetFlagValuesFromOptions( // These are the default values from the Cosmos flags. GrpcAddress: config.DefaultGRPCAddress, GrpcEnable: true, + + GrpcStreamingEnabled: DefaultGrpcStreamingEnabled, } // Populate the flags if they exist. @@ -132,5 +158,11 @@ func GetFlagValuesFromOptions( } } + if option := appOpts.Get(GrpcStreamingEnabled); option != nil { + if v, err := cast.ToBoolE(option); err == nil { + result.GrpcStreamingEnabled = v + } + } + return result } diff --git a/protocol/app/flags/flags_test.go b/protocol/app/flags/flags_test.go index aaba0016b3..c170ec864f 100644 --- a/protocol/app/flags/flags_test.go +++ b/protocol/app/flags/flags_test.go @@ -2,9 +2,10 @@ package flags_test import ( "fmt" - "github.com/cosmos/cosmos-sdk/server/config" "testing" + "github.com/cosmos/cosmos-sdk/server/config" + "github.com/dydxprotocol/v4-chain/protocol/app/flags" "github.com/dydxprotocol/v4-chain/protocol/mocks" "github.com/spf13/cobra" @@ -27,7 +28,11 @@ func TestAddFlagsToCommand(t *testing.T) { }, fmt.Sprintf("Has %s flag", flags.DdTraceAgentPort): { flagName: flags.DdTraceAgentPort, - }} + }, + fmt.Sprintf("Has %s flag", flags.GrpcStreamingEnabled): { + flagName: flags.GrpcStreamingEnabled, + }, + } for name, tc := range tests { t.Run(name, func(t *testing.T) { @@ -62,6 +67,22 @@ func TestValidate(t *testing.T) { }, expectedErr: fmt.Errorf("grpc.enable must be set to true - validating requires gRPC server"), }, + "failure - gRPC streaming enabled for validating nodes": { + flags: flags.Flags{ + NonValidatingFullNode: false, + GrpcEnable: true, + GrpcStreamingEnabled: true, + }, + expectedErr: fmt.Errorf("grpc-streaming-enabled can only be set to true for non-validating full nodes"), + }, + "failure - gRPC streaming enabled with gRPC disabled": { + flags: flags.Flags{ + NonValidatingFullNode: true, + GrpcEnable: false, + GrpcStreamingEnabled: true, + }, + expectedErr: fmt.Errorf("grpc.enable must be set to true - grpc streaming requires gRPC server"), + }, } for name, tc := range tests { t.Run(name, func(t *testing.T) { @@ -86,6 +107,7 @@ func TestGetFlagValuesFromOptions(t *testing.T) { expectedDdTraceAgentPort uint16 expectedGrpcAddress string expectedGrpcEnable bool + expectedGrpcStreamingEnable bool }{ "Sets to default if unset": { expectedNonValidatingFullNodeFlag: false, @@ -93,6 +115,7 @@ func TestGetFlagValuesFromOptions(t *testing.T) { expectedDdTraceAgentPort: 8126, expectedGrpcAddress: "localhost:9090", expectedGrpcEnable: true, + expectedGrpcStreamingEnable: false, }, "Sets values from options": { optsMap: map[string]any{ @@ -101,12 +124,14 @@ func TestGetFlagValuesFromOptions(t *testing.T) { flags.DdTraceAgentPort: uint16(777), flags.GrpcEnable: false, flags.GrpcAddress: "localhost:9091", + flags.GrpcStreamingEnabled: "true", }, expectedNonValidatingFullNodeFlag: true, expectedDdAgentHost: "agentHostTest", expectedDdTraceAgentPort: 777, expectedGrpcEnable: false, expectedGrpcAddress: "localhost:9091", + expectedGrpcStreamingEnable: true, }, } From 1aaa2ccdcd6757a31444673d0eb4aa0f0b674a93 Mon Sep 17 00:00:00 2001 From: Tian Date: Wed, 6 Mar 2024 16:43:04 -0500 Subject: [PATCH 3/3] [TRA-86] scaffold x/vault (#1148) * scaffold x/vault --- .../src/codegen/dydxprotocol/bundle.ts | 205 +++++++------- .../src/codegen/dydxprotocol/rpc.query.ts | 1 + .../src/codegen/dydxprotocol/vault/genesis.ts | 42 +++ .../dydxprotocol/vault/query.rpc.Query.ts | 18 ++ .../src/codegen/dydxprotocol/vault/query.ts | 1 + .../src/codegen/dydxprotocol/vault/tx.ts | 1 + .../v4-protos/src/codegen/gogoproto/bundle.ts | 4 +- .../v4-protos/src/codegen/google/bundle.ts | 24 +- proto/dydxprotocol/vault/genesis.proto | 7 + proto/dydxprotocol/vault/query.proto | 7 + proto/dydxprotocol/vault/tx.proto | 7 + protocol/app/app.go | 21 ++ protocol/app/app_test.go | 2 + .../app/testdata/default_genesis_state.json | 1 + .../scripts/genesis/sample_pregenesis.json | 1 + .../containertest/preupgrade_genesis.json | 1 + protocol/testutil/constants/genesis.go | 1 + protocol/x/vault/client/cli/query.go | 24 ++ protocol/x/vault/client/cli/tx.go | 22 ++ protocol/x/vault/genesis.go | 16 ++ protocol/x/vault/keeper/grpc_query.go | 7 + protocol/x/vault/keeper/keeper.go | 43 +++ protocol/x/vault/keeper/keeper_test.go | 16 ++ protocol/x/vault/keeper/msg_server.go | 17 ++ protocol/x/vault/keeper/msg_server_test.go | 26 ++ protocol/x/vault/module.go | 143 ++++++++++ protocol/x/vault/types/codec.go | 19 ++ protocol/x/vault/types/expected_keepers.go | 1 + protocol/x/vault/types/genesis.go | 12 + protocol/x/vault/types/genesis.pb.go | 263 ++++++++++++++++++ protocol/x/vault/types/keys.go | 10 + protocol/x/vault/types/query.pb.go | 81 ++++++ protocol/x/vault/types/tx.pb.go | 80 ++++++ 33 files changed, 1012 insertions(+), 112 deletions(-) create mode 100644 indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/genesis.ts create mode 100644 indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.rpc.Query.ts create mode 100644 indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts create mode 100644 indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts create mode 100644 proto/dydxprotocol/vault/genesis.proto create mode 100644 proto/dydxprotocol/vault/query.proto create mode 100644 proto/dydxprotocol/vault/tx.proto create mode 100644 protocol/x/vault/client/cli/query.go create mode 100644 protocol/x/vault/client/cli/tx.go create mode 100644 protocol/x/vault/genesis.go create mode 100644 protocol/x/vault/keeper/grpc_query.go create mode 100644 protocol/x/vault/keeper/keeper.go create mode 100644 protocol/x/vault/keeper/keeper_test.go create mode 100644 protocol/x/vault/keeper/msg_server.go create mode 100644 protocol/x/vault/keeper/msg_server_test.go create mode 100644 protocol/x/vault/module.go create mode 100644 protocol/x/vault/types/codec.go create mode 100644 protocol/x/vault/types/expected_keepers.go create mode 100644 protocol/x/vault/types/genesis.go create mode 100644 protocol/x/vault/types/genesis.pb.go create mode 100644 protocol/x/vault/types/keys.go create mode 100644 protocol/x/vault/types/query.pb.go create mode 100644 protocol/x/vault/types/tx.pb.go diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts index 66e00ab551..5d00767e2b 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts @@ -87,72 +87,76 @@ import * as _90 from "./subaccounts/genesis"; import * as _91 from "./subaccounts/perpetual_position"; import * as _92 from "./subaccounts/query"; import * as _93 from "./subaccounts/subaccount"; -import * as _94 from "./vest/genesis"; -import * as _95 from "./vest/query"; -import * as _96 from "./vest/tx"; -import * as _97 from "./vest/vest_entry"; -import * as _105 from "./assets/query.lcd"; -import * as _106 from "./blocktime/query.lcd"; -import * as _107 from "./bridge/query.lcd"; -import * as _108 from "./clob/query.lcd"; -import * as _109 from "./delaymsg/query.lcd"; -import * as _110 from "./epochs/query.lcd"; -import * as _111 from "./feetiers/query.lcd"; -import * as _112 from "./perpetuals/query.lcd"; -import * as _113 from "./prices/query.lcd"; -import * as _114 from "./ratelimit/query.lcd"; -import * as _115 from "./rewards/query.lcd"; -import * as _116 from "./stats/query.lcd"; -import * as _117 from "./subaccounts/query.lcd"; -import * as _118 from "./vest/query.lcd"; -import * as _119 from "./assets/query.rpc.Query"; -import * as _120 from "./blocktime/query.rpc.Query"; -import * as _121 from "./bridge/query.rpc.Query"; -import * as _122 from "./clob/query.rpc.Query"; -import * as _123 from "./delaymsg/query.rpc.Query"; -import * as _124 from "./epochs/query.rpc.Query"; -import * as _125 from "./feetiers/query.rpc.Query"; -import * as _126 from "./govplus/query.rpc.Query"; -import * as _127 from "./perpetuals/query.rpc.Query"; -import * as _128 from "./prices/query.rpc.Query"; -import * as _129 from "./ratelimit/query.rpc.Query"; -import * as _130 from "./rewards/query.rpc.Query"; -import * as _131 from "./sending/query.rpc.Query"; -import * as _132 from "./stats/query.rpc.Query"; -import * as _133 from "./subaccounts/query.rpc.Query"; -import * as _134 from "./vest/query.rpc.Query"; -import * as _135 from "./blocktime/tx.rpc.msg"; -import * as _136 from "./bridge/tx.rpc.msg"; -import * as _137 from "./clob/tx.rpc.msg"; -import * as _138 from "./delaymsg/tx.rpc.msg"; -import * as _139 from "./feetiers/tx.rpc.msg"; -import * as _140 from "./govplus/tx.rpc.msg"; -import * as _141 from "./perpetuals/tx.rpc.msg"; -import * as _142 from "./prices/tx.rpc.msg"; -import * as _143 from "./ratelimit/tx.rpc.msg"; -import * as _144 from "./rewards/tx.rpc.msg"; -import * as _145 from "./sending/tx.rpc.msg"; -import * as _146 from "./stats/tx.rpc.msg"; -import * as _147 from "./vest/tx.rpc.msg"; -import * as _148 from "./lcd"; -import * as _149 from "./rpc.query"; -import * as _150 from "./rpc.tx"; +import * as _94 from "./vault/genesis"; +import * as _95 from "./vault/query"; +import * as _96 from "./vault/tx"; +import * as _97 from "./vest/genesis"; +import * as _98 from "./vest/query"; +import * as _99 from "./vest/tx"; +import * as _100 from "./vest/vest_entry"; +import * as _108 from "./assets/query.lcd"; +import * as _109 from "./blocktime/query.lcd"; +import * as _110 from "./bridge/query.lcd"; +import * as _111 from "./clob/query.lcd"; +import * as _112 from "./delaymsg/query.lcd"; +import * as _113 from "./epochs/query.lcd"; +import * as _114 from "./feetiers/query.lcd"; +import * as _115 from "./perpetuals/query.lcd"; +import * as _116 from "./prices/query.lcd"; +import * as _117 from "./ratelimit/query.lcd"; +import * as _118 from "./rewards/query.lcd"; +import * as _119 from "./stats/query.lcd"; +import * as _120 from "./subaccounts/query.lcd"; +import * as _121 from "./vest/query.lcd"; +import * as _122 from "./assets/query.rpc.Query"; +import * as _123 from "./blocktime/query.rpc.Query"; +import * as _124 from "./bridge/query.rpc.Query"; +import * as _125 from "./clob/query.rpc.Query"; +import * as _126 from "./delaymsg/query.rpc.Query"; +import * as _127 from "./epochs/query.rpc.Query"; +import * as _128 from "./feetiers/query.rpc.Query"; +import * as _129 from "./govplus/query.rpc.Query"; +import * as _130 from "./perpetuals/query.rpc.Query"; +import * as _131 from "./prices/query.rpc.Query"; +import * as _132 from "./ratelimit/query.rpc.Query"; +import * as _133 from "./rewards/query.rpc.Query"; +import * as _134 from "./sending/query.rpc.Query"; +import * as _135 from "./stats/query.rpc.Query"; +import * as _136 from "./subaccounts/query.rpc.Query"; +import * as _137 from "./vault/query.rpc.Query"; +import * as _138 from "./vest/query.rpc.Query"; +import * as _139 from "./blocktime/tx.rpc.msg"; +import * as _140 from "./bridge/tx.rpc.msg"; +import * as _141 from "./clob/tx.rpc.msg"; +import * as _142 from "./delaymsg/tx.rpc.msg"; +import * as _143 from "./feetiers/tx.rpc.msg"; +import * as _144 from "./govplus/tx.rpc.msg"; +import * as _145 from "./perpetuals/tx.rpc.msg"; +import * as _146 from "./prices/tx.rpc.msg"; +import * as _147 from "./ratelimit/tx.rpc.msg"; +import * as _148 from "./rewards/tx.rpc.msg"; +import * as _149 from "./sending/tx.rpc.msg"; +import * as _150 from "./stats/tx.rpc.msg"; +import * as _151 from "./vest/tx.rpc.msg"; +import * as _152 from "./lcd"; +import * as _153 from "./rpc.query"; +import * as _154 from "./rpc.tx"; export namespace dydxprotocol { export const assets = { ..._5, ..._6, ..._7, ..._8, - ..._105, - ..._119 + ..._108, + ..._122 }; export const blocktime = { ..._9, ..._10, ..._11, ..._12, ..._13, - ..._106, - ..._120, - ..._135 + ..._109, + ..._123, + ..._139 }; export const bridge = { ..._14, ..._15, @@ -160,9 +164,9 @@ export namespace dydxprotocol { ..._17, ..._18, ..._19, - ..._107, - ..._121, - ..._136 + ..._110, + ..._124, + ..._140 }; export const clob = { ..._20, ..._21, @@ -178,9 +182,9 @@ export namespace dydxprotocol { ..._31, ..._32, ..._33, - ..._108, - ..._122, - ..._137 + ..._111, + ..._125, + ..._141 }; export namespace daemons { export const bridge = { ..._34 @@ -195,29 +199,29 @@ export namespace dydxprotocol { ..._39, ..._40, ..._41, - ..._109, - ..._123, - ..._138 + ..._112, + ..._126, + ..._142 }; export const epochs = { ..._42, ..._43, ..._44, - ..._110, - ..._124 + ..._113, + ..._127 }; export const feetiers = { ..._45, ..._46, ..._47, ..._48, - ..._111, - ..._125, - ..._139 + ..._114, + ..._128, + ..._143 }; export const govplus = { ..._49, ..._50, ..._51, - ..._126, - ..._140 + ..._129, + ..._144 }; export namespace indexer { export const events = { ..._52 @@ -243,71 +247,76 @@ export namespace dydxprotocol { ..._62, ..._63, ..._64, - ..._112, - ..._127, - ..._141 + ..._115, + ..._130, + ..._145 }; export const prices = { ..._65, ..._66, ..._67, ..._68, ..._69, - ..._113, - ..._128, - ..._142 + ..._116, + ..._131, + ..._146 }; export const ratelimit = { ..._70, ..._71, ..._72, ..._73, ..._74, - ..._114, - ..._129, - ..._143 + ..._117, + ..._132, + ..._147 }; export const rewards = { ..._75, ..._76, ..._77, ..._78, ..._79, - ..._115, - ..._130, - ..._144 + ..._118, + ..._133, + ..._148 }; export const sending = { ..._80, ..._81, ..._82, ..._83, - ..._131, - ..._145 + ..._134, + ..._149 }; export const stats = { ..._84, ..._85, ..._86, ..._87, ..._88, - ..._116, - ..._132, - ..._146 + ..._119, + ..._135, + ..._150 }; export const subaccounts = { ..._89, ..._90, ..._91, ..._92, ..._93, - ..._117, - ..._133 + ..._120, + ..._136 }; - export const vest = { ..._94, + export const vault = { ..._94, ..._95, ..._96, - ..._97, - ..._118, - ..._134, - ..._147 + ..._137 }; - export const ClientFactory = { ..._148, - ..._149, - ..._150 + export const vest = { ..._97, + ..._98, + ..._99, + ..._100, + ..._121, + ..._138, + ..._151 + }; + export const ClientFactory = { ..._152, + ..._153, + ..._154 }; } \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/rpc.query.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/rpc.query.ts index 8660a20d09..4c2d8a0de7 100644 --- a/indexer/packages/v4-protos/src/codegen/dydxprotocol/rpc.query.ts +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/rpc.query.ts @@ -24,6 +24,7 @@ export const createRPCQueryClient = async ({ sending: (await import("./sending/query.rpc.Query")).createRpcQueryExtension(client), stats: (await import("./stats/query.rpc.Query")).createRpcQueryExtension(client), subaccounts: (await import("./subaccounts/query.rpc.Query")).createRpcQueryExtension(client), + vault: (await import("./vault/query.rpc.Query")).createRpcQueryExtension(client), vest: (await import("./vest/query.rpc.Query")).createRpcQueryExtension(client) } }; diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/genesis.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/genesis.ts new file mode 100644 index 0000000000..9cf3de2b6d --- /dev/null +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/genesis.ts @@ -0,0 +1,42 @@ +import * as _m0 from "protobufjs/minimal"; +import { DeepPartial } from "../../helpers"; +/** GenesisState defines `x/vault`'s genesis state. */ + +export interface GenesisState {} +/** GenesisState defines `x/vault`'s genesis state. */ + +export interface GenesisStateSDKType {} + +function createBaseGenesisState(): GenesisState { + return {}; +} + +export const GenesisState = { + encode(_: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGenesisState(); + + while (reader.pos < end) { + const tag = reader.uint32(); + + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + + return message; + }, + + fromPartial(_: DeepPartial): GenesisState { + const message = createBaseGenesisState(); + return message; + } + +}; \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.rpc.Query.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.rpc.Query.ts new file mode 100644 index 0000000000..ab81adee85 --- /dev/null +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.rpc.Query.ts @@ -0,0 +1,18 @@ +import { Rpc } from "../../helpers"; +import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; +/** Query defines the gRPC querier service. */ + +export interface Query {} +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + + constructor(rpc: Rpc) { + this.rpc = rpc; + } + +} +export const createRpcQueryExtension = (base: QueryClient) => { + const rpc = createProtobufRpcClient(base); + const queryService = new QueryClientImpl(rpc); + return {}; +}; \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts new file mode 100644 index 0000000000..693da49fc4 --- /dev/null +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/query.ts @@ -0,0 +1 @@ +export {} \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts new file mode 100644 index 0000000000..693da49fc4 --- /dev/null +++ b/indexer/packages/v4-protos/src/codegen/dydxprotocol/vault/tx.ts @@ -0,0 +1 @@ +export {} \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts b/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts index 00726066d7..ac7a691883 100644 --- a/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts +++ b/indexer/packages/v4-protos/src/codegen/gogoproto/bundle.ts @@ -1,3 +1,3 @@ -import * as _98 from "./gogo"; -export const gogoproto = { ..._98 +import * as _101 from "./gogo"; +export const gogoproto = { ..._101 }; \ No newline at end of file diff --git a/indexer/packages/v4-protos/src/codegen/google/bundle.ts b/indexer/packages/v4-protos/src/codegen/google/bundle.ts index dcfe2ea382..3312f4c5c1 100644 --- a/indexer/packages/v4-protos/src/codegen/google/bundle.ts +++ b/indexer/packages/v4-protos/src/codegen/google/bundle.ts @@ -1,16 +1,16 @@ -import * as _99 from "./api/annotations"; -import * as _100 from "./api/http"; -import * as _101 from "./protobuf/descriptor"; -import * as _102 from "./protobuf/duration"; -import * as _103 from "./protobuf/timestamp"; -import * as _104 from "./protobuf/any"; +import * as _102 from "./api/annotations"; +import * as _103 from "./api/http"; +import * as _104 from "./protobuf/descriptor"; +import * as _105 from "./protobuf/duration"; +import * as _106 from "./protobuf/timestamp"; +import * as _107 from "./protobuf/any"; export namespace google { - export const api = { ..._99, - ..._100 + export const api = { ..._102, + ..._103 }; - export const protobuf = { ..._101, - ..._102, - ..._103, - ..._104 + export const protobuf = { ..._104, + ..._105, + ..._106, + ..._107 }; } \ No newline at end of file diff --git a/proto/dydxprotocol/vault/genesis.proto b/proto/dydxprotocol/vault/genesis.proto new file mode 100644 index 0000000000..f0341f243c --- /dev/null +++ b/proto/dydxprotocol/vault/genesis.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; +package dydxprotocol.vault; + +option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/vault/types"; + +// GenesisState defines `x/vault`'s genesis state. +message GenesisState {} diff --git a/proto/dydxprotocol/vault/query.proto b/proto/dydxprotocol/vault/query.proto new file mode 100644 index 0000000000..4c47f5531f --- /dev/null +++ b/proto/dydxprotocol/vault/query.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; +package dydxprotocol.vault; + +option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/vault/types"; + +// Query defines the gRPC querier service. +service Query {} diff --git a/proto/dydxprotocol/vault/tx.proto b/proto/dydxprotocol/vault/tx.proto new file mode 100644 index 0000000000..d6afd1bdbd --- /dev/null +++ b/proto/dydxprotocol/vault/tx.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; +package dydxprotocol.vault; + +option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/vault/types"; + +// Msg defines the Msg service. +service Msg {} diff --git a/protocol/app/app.go b/protocol/app/app.go index b737375fdb..6f8fcc0a26 100644 --- a/protocol/app/app.go +++ b/protocol/app/app.go @@ -173,6 +173,9 @@ import ( subaccountsmodule "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts" subaccountsmodulekeeper "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/keeper" satypes "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types" + vaultmodule "github.com/dydxprotocol/v4-chain/protocol/x/vault" + vaultmodulekeeper "github.com/dydxprotocol/v4-chain/protocol/x/vault/keeper" + vaultmoduletypes "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" vestmodule "github.com/dydxprotocol/v4-chain/protocol/x/vest" vestmodulekeeper "github.com/dydxprotocol/v4-chain/protocol/x/vest/keeper" vestmoduletypes "github.com/dydxprotocol/v4-chain/protocol/x/vest/types" @@ -294,6 +297,8 @@ type App struct { SendingKeeper sendingmodulekeeper.Keeper EpochsKeeper epochsmodulekeeper.Keeper + + VaultKeeper vaultmodulekeeper.Keeper // this line is used by starport scaffolding # stargate/app/keeperDeclaration ModuleManager *module.Manager @@ -397,6 +402,7 @@ func New( delaymsgmoduletypes.StoreKey, epochsmoduletypes.StoreKey, govplusmoduletypes.StoreKey, + vaultmoduletypes.StoreKey, ) keys[authtypes.StoreKey] = keys[authtypes.StoreKey].WithLocking() tkeys := storetypes.NewTransientStoreKeys( @@ -1034,6 +1040,16 @@ func New( ) govPlusModule := govplusmodule.NewAppModule(appCodec, app.GovPlusKeeper) + app.VaultKeeper = *vaultmodulekeeper.NewKeeper( + appCodec, + keys[vaultmoduletypes.StoreKey], + []string{ + lib.GovModuleAddress.String(), + delaymsgmoduletypes.ModuleAddress.String(), + }, + ) + vaultModule := vaultmodule.NewAppModule(appCodec, app.VaultKeeper) + /**** Module Options ****/ // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment @@ -1101,6 +1117,7 @@ func New( delayMsgModule, epochsModule, rateLimitModule, + vaultModule, ) app.ModuleManager.SetOrderPreBlockers( @@ -1145,6 +1162,7 @@ func New( sendingmoduletypes.ModuleName, govplusmoduletypes.ModuleName, delaymsgmoduletypes.ModuleName, + vaultmoduletypes.ModuleName, ) app.ModuleManager.SetOrderPrepareCheckStaters( @@ -1184,6 +1202,7 @@ func New( epochsmoduletypes.ModuleName, govplusmoduletypes.ModuleName, delaymsgmoduletypes.ModuleName, + vaultmoduletypes.ModuleName, authz.ModuleName, // No-op. blocktimemoduletypes.ModuleName, // Must be last ) @@ -1227,6 +1246,7 @@ func New( sendingmoduletypes.ModuleName, govplusmoduletypes.ModuleName, delaymsgmoduletypes.ModuleName, + vaultmoduletypes.ModuleName, authz.ModuleName, ) @@ -1266,6 +1286,7 @@ func New( sendingmoduletypes.ModuleName, govplusmoduletypes.ModuleName, delaymsgmoduletypes.ModuleName, + vaultmoduletypes.ModuleName, authz.ModuleName, // Auth must be migrated after staking. diff --git a/protocol/app/app_test.go b/protocol/app/app_test.go index d466ebee22..352ab0f2f7 100644 --- a/protocol/app/app_test.go +++ b/protocol/app/app_test.go @@ -47,6 +47,7 @@ import ( sendingmodule "github.com/dydxprotocol/v4-chain/protocol/x/sending" statsmodule "github.com/dydxprotocol/v4-chain/protocol/x/stats" subaccountsmodule "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts" + vaultmodule "github.com/dydxprotocol/v4-chain/protocol/x/vault" vestmodule "github.com/dydxprotocol/v4-chain/protocol/x/vest" "github.com/stretchr/testify/require" "gopkg.in/typ.v4/slices" @@ -220,6 +221,7 @@ func TestModuleBasics(t *testing.T) { delaymsgmodule.AppModuleBasic{}, epochsmodule.AppModuleBasic{}, ratelimitmodule.AppModuleBasic{}, + vaultmodule.AppModuleBasic{}, ) app := testapp.DefaultTestApp(nil) diff --git a/protocol/app/testdata/default_genesis_state.json b/protocol/app/testdata/default_genesis_state.json index 4a521b1e5c..1b30955b02 100644 --- a/protocol/app/testdata/default_genesis_state.json +++ b/protocol/app/testdata/default_genesis_state.json @@ -454,6 +454,7 @@ "total_escrowed": [] }, "upgrade": {}, + "vault": {}, "vest": { "vest_entries": [ { diff --git a/protocol/scripts/genesis/sample_pregenesis.json b/protocol/scripts/genesis/sample_pregenesis.json index 7caf67d599..57b6375850 100644 --- a/protocol/scripts/genesis/sample_pregenesis.json +++ b/protocol/scripts/genesis/sample_pregenesis.json @@ -1796,6 +1796,7 @@ "total_escrowed": [] }, "upgrade": {}, + "vault": {}, "vest": { "vest_entries": [ { diff --git a/protocol/testing/containertest/preupgrade_genesis.json b/protocol/testing/containertest/preupgrade_genesis.json index 94c28efbdc..7c7947bb47 100644 --- a/protocol/testing/containertest/preupgrade_genesis.json +++ b/protocol/testing/containertest/preupgrade_genesis.json @@ -2243,6 +2243,7 @@ "total_escrowed": [] }, "upgrade": {}, + "vault": {}, "vest": { "vest_entries": [ { diff --git a/protocol/testutil/constants/genesis.go b/protocol/testutil/constants/genesis.go index 994a9706a7..d8b1ca8209 100644 --- a/protocol/testutil/constants/genesis.go +++ b/protocol/testutil/constants/genesis.go @@ -1498,6 +1498,7 @@ const GenesisState = `{ "port_id": "transfer" }, "upgrade": {}, + "vault": {}, "vest": { "vest_entries": [ { diff --git a/protocol/x/vault/client/cli/query.go b/protocol/x/vault/client/cli/query.go new file mode 100644 index 0000000000..d55ce14426 --- /dev/null +++ b/protocol/x/vault/client/cli/query.go @@ -0,0 +1,24 @@ +package cli + +import ( + "fmt" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" +) + +// GetQueryCmd returns the cli query commands for this module. +func GetQueryCmd(queryRoute string) *cobra.Command { + // Group x/vault 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, + } + + return cmd +} diff --git a/protocol/x/vault/client/cli/tx.go b/protocol/x/vault/client/cli/tx.go new file mode 100644 index 0000000000..156bfb8544 --- /dev/null +++ b/protocol/x/vault/client/cli/tx.go @@ -0,0 +1,22 @@ +package cli + +import ( + "fmt" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/dydxprotocol/v4-chain/protocol/x/vault/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/protocol/x/vault/genesis.go b/protocol/x/vault/genesis.go new file mode 100644 index 0000000000..4ed3e49bea --- /dev/null +++ b/protocol/x/vault/genesis.go @@ -0,0 +1,16 @@ +package vault + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dydxprotocol/v4-chain/protocol/x/vault/keeper" + "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" +) + +// InitGenesis initializes the module's state from a provided genesis state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { +} + +// ExportGenesis returns the module's exported genesis. +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + return &types.GenesisState{} +} diff --git a/protocol/x/vault/keeper/grpc_query.go b/protocol/x/vault/keeper/grpc_query.go new file mode 100644 index 0000000000..2b8ac9afcf --- /dev/null +++ b/protocol/x/vault/keeper/grpc_query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" +) + +var _ types.QueryServer = Keeper{} diff --git a/protocol/x/vault/keeper/keeper.go b/protocol/x/vault/keeper/keeper.go new file mode 100644 index 0000000000..319158f723 --- /dev/null +++ b/protocol/x/vault/keeper/keeper.go @@ -0,0 +1,43 @@ +package keeper + +import ( + "fmt" + + "cosmossdk.io/log" + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/dydxprotocol/v4-chain/protocol/lib" + "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + authorities map[string]struct{} + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey storetypes.StoreKey, + authorities []string, +) *Keeper { + return &Keeper{ + cdc: cdc, + storeKey: storeKey, + authorities: lib.UniqueSliceToSet(authorities), + } +} + +func (k Keeper) HasAuthority(authority string) bool { + _, ok := k.authorities[authority] + return ok +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With(log.ModuleKey, fmt.Sprintf("x/%s", types.ModuleName)) +} + +func (k Keeper) InitializeForGenesis(ctx sdk.Context) {} diff --git a/protocol/x/vault/keeper/keeper_test.go b/protocol/x/vault/keeper/keeper_test.go new file mode 100644 index 0000000000..9c3c803630 --- /dev/null +++ b/protocol/x/vault/keeper/keeper_test.go @@ -0,0 +1,16 @@ +package keeper_test + +import ( + "testing" + + testapp "github.com/dydxprotocol/v4-chain/protocol/testutil/app" + "github.com/stretchr/testify/require" +) + +func TestLogger(t *testing.T) { + tApp := testapp.NewTestAppBuilder(t).Build() + ctx := tApp.InitChain() + + logger := tApp.App.VaultKeeper.Logger(ctx) + require.NotNil(t, logger) +} diff --git a/protocol/x/vault/keeper/msg_server.go b/protocol/x/vault/keeper/msg_server.go new file mode 100644 index 0000000000..a53e319e75 --- /dev/null +++ b/protocol/x/vault/keeper/msg_server.go @@ -0,0 +1,17 @@ +package keeper + +import ( + "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} diff --git a/protocol/x/vault/keeper/msg_server_test.go b/protocol/x/vault/keeper/msg_server_test.go new file mode 100644 index 0000000000..a49577ab61 --- /dev/null +++ b/protocol/x/vault/keeper/msg_server_test.go @@ -0,0 +1,26 @@ +package keeper_test + +import ( + "context" + "testing" + + testapp "github.com/dydxprotocol/v4-chain/protocol/testutil/app" + "github.com/dydxprotocol/v4-chain/protocol/x/vault/keeper" + "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" + "github.com/stretchr/testify/require" +) + +func setupMsgServer(t *testing.T) (keeper.Keeper, types.MsgServer, context.Context) { + tApp := testapp.NewTestAppBuilder(t).Build() + ctx := tApp.InitChain() + k := tApp.App.VaultKeeper + + return k, keeper.NewMsgServerImpl(k), ctx +} + +func TestMsgServer(t *testing.T) { + k, ms, ctx := setupMsgServer(t) + require.NotNil(t, k) + require.NotNil(t, ms) + require.NotNil(t, ctx) +} diff --git a/protocol/x/vault/module.go b/protocol/x/vault/module.go new file mode 100644 index 0000000000..bf1c9e1d1b --- /dev/null +++ b/protocol/x/vault/module.go @@ -0,0 +1,143 @@ +package vault + +import ( + "encoding/json" + "fmt" + + "cosmossdk.io/core/appmodule" + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + "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/dydxprotocol/v4-chain/protocol/x/vault/client/cli" + "github.com/dydxprotocol/v4-chain/protocol/x/vault/keeper" + "github.com/dydxprotocol/v4-chain/protocol/x/vault/types" +) + +var ( + _ module.AppModuleBasic = AppModuleBasic{} + _ module.HasGenesisBasics = AppModuleBasic{} + + _ appmodule.AppModule = AppModule{} + _ module.HasConsensusVersion = AppModule{} + _ module.HasGenesis = AppModule{} + _ module.HasServices = 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, config 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() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {} + +// 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 +// ---------------------------------------------------------------------------- + +// 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, + } +} + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() {} + +// IsOnePerModuleType is a marker function just indicates that this is a one-per-module type. +func (am AppModule) IsOnePerModuleType() {} + +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// 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) { + var genState types.GenesisState + // Initialize global index to index in genesis state. + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) +} + +// 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 1 } diff --git a/protocol/x/vault/types/codec.go b/protocol/x/vault/types/codec.go new file mode 100644 index 0000000000..b68229b0d6 --- /dev/null +++ b/protocol/x/vault/types/codec.go @@ -0,0 +1,19 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" + "github.com/dydxprotocol/v4-chain/protocol/app/module" +) + +func RegisterCodec(cdc *codec.LegacyAmino) {} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(module.InterfaceRegistry) +) diff --git a/protocol/x/vault/types/expected_keepers.go b/protocol/x/vault/types/expected_keepers.go new file mode 100644 index 0000000000..ab1254f4c2 --- /dev/null +++ b/protocol/x/vault/types/expected_keepers.go @@ -0,0 +1 @@ +package types diff --git a/protocol/x/vault/types/genesis.go b/protocol/x/vault/types/genesis.go new file mode 100644 index 0000000000..09583a5f2e --- /dev/null +++ b/protocol/x/vault/types/genesis.go @@ -0,0 +1,12 @@ +package types + +// DefaultGenesis returns the default stats genesis state. +func DefaultGenesis() *GenesisState { + return &GenesisState{} +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + return nil +} diff --git a/protocol/x/vault/types/genesis.pb.go b/protocol/x/vault/types/genesis.pb.go new file mode 100644 index 0000000000..eec0857795 --- /dev/null +++ b/protocol/x/vault/types/genesis.pb.go @@ -0,0 +1,263 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dydxprotocol/vault/genesis.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines `x/vault`'s genesis state. +type GenesisState struct { +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_4be4a747b209e41c, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func init() { + proto.RegisterType((*GenesisState)(nil), "dydxprotocol.vault.GenesisState") +} + +func init() { proto.RegisterFile("dydxprotocol/vault/genesis.proto", fileDescriptor_4be4a747b209e41c) } + +var fileDescriptor_4be4a747b209e41c = []byte{ + // 140 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xa9, 0x4c, 0xa9, + 0x28, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0xce, 0xcf, 0xd1, 0x2f, 0x4b, 0x2c, 0xcd, 0x29, 0xd1, 0x4f, + 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x03, 0x0b, 0x0b, 0x09, 0x21, 0xab, 0xd0, 0x03, 0xab, + 0x50, 0xe2, 0xe3, 0xe2, 0x71, 0x87, 0x28, 0x0a, 0x2e, 0x49, 0x2c, 0x49, 0x75, 0x0a, 0x3c, 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, 0xf3, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, + 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x54, 0xab, 0x4c, 0x74, 0x93, 0x33, 0x12, 0x33, 0xf3, 0xf4, 0xe1, + 0x22, 0x15, 0x50, 0xeb, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0xe2, 0xc6, 0x80, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x44, 0xfe, 0x11, 0x7d, 0xa1, 0x00, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/protocol/x/vault/types/keys.go b/protocol/x/vault/types/keys.go new file mode 100644 index 0000000000..7e130df0e9 --- /dev/null +++ b/protocol/x/vault/types/keys.go @@ -0,0 +1,10 @@ +package types + +// Module name and store keys +const ( + // ModuleName defines the module name + ModuleName = "vault" + + // StoreKey defines the primary module store key + StoreKey = ModuleName +) diff --git a/protocol/x/vault/types/query.pb.go b/protocol/x/vault/types/query.pb.go new file mode 100644 index 0000000000..c29c39cd30 --- /dev/null +++ b/protocol/x/vault/types/query.pb.go @@ -0,0 +1,81 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dydxprotocol/vault/query.proto + +package types + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +func init() { proto.RegisterFile("dydxprotocol/vault/query.proto", fileDescriptor_478fb8dc0ff21ea6) } + +var fileDescriptor_478fb8dc0ff21ea6 = []byte{ + // 132 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0xa9, 0x4c, 0xa9, + 0x28, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0xce, 0xcf, 0xd1, 0x2f, 0x4b, 0x2c, 0xcd, 0x29, 0xd1, 0x2f, + 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x03, 0x0b, 0x0a, 0x09, 0x21, 0xcb, 0xeb, 0x81, 0xe5, 0x8d, 0xd8, + 0xb9, 0x58, 0x03, 0x41, 0x4a, 0x9c, 0x02, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, + 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, + 0x21, 0xca, 0x3c, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xd5, 0x06, + 0x13, 0xdd, 0xe4, 0x8c, 0xc4, 0xcc, 0x3c, 0x7d, 0xb8, 0x48, 0x05, 0xd4, 0xd6, 0x92, 0xca, 0x82, + 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0xb8, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xf0, 0xd6, 0x1e, 0xab, + 0x98, 0x00, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +// QueryServer is the server API for Query service. +type QueryServer interface { +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "dydxprotocol.vault.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "dydxprotocol/vault/query.proto", +} diff --git a/protocol/x/vault/types/tx.pb.go b/protocol/x/vault/types/tx.pb.go new file mode 100644 index 0000000000..ce1c55128a --- /dev/null +++ b/protocol/x/vault/types/tx.pb.go @@ -0,0 +1,80 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dydxprotocol/vault/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +func init() { proto.RegisterFile("dydxprotocol/vault/tx.proto", fileDescriptor_ced574c6017ce006) } + +var fileDescriptor_ced574c6017ce006 = []byte{ + // 128 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4e, 0xa9, 0x4c, 0xa9, + 0x28, 0x28, 0xca, 0x2f, 0xc9, 0x4f, 0xce, 0xcf, 0xd1, 0x2f, 0x4b, 0x2c, 0xcd, 0x29, 0xd1, 0x2f, + 0xa9, 0xd0, 0x03, 0x8b, 0x08, 0x09, 0x21, 0x4b, 0xea, 0x81, 0x25, 0x8d, 0x58, 0xb9, 0x98, 0x7d, + 0x8b, 0xd3, 0x9d, 0x02, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, + 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x3c, + 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xd5, 0x70, 0x13, 0xdd, 0xe4, + 0x8c, 0xc4, 0xcc, 0x3c, 0x7d, 0xb8, 0x48, 0x05, 0xcc, 0xc2, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, + 0xb0, 0xb8, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x2f, 0x7f, 0xc8, 0xf1, 0x93, 0x00, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "dydxprotocol.vault.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "dydxprotocol/vault/tx.proto", +}