diff --git a/protocol/app/app.go b/protocol/app/app.go index aa16a8313f..0fb90246aa 100644 --- a/protocol/app/app.go +++ b/protocol/app/app.go @@ -107,7 +107,6 @@ import ( // Daemons bridgeclient "github.com/dydxprotocol/v4-chain/protocol/daemons/bridge/client" - "github.com/dydxprotocol/v4-chain/protocol/daemons/configs" daemonflags "github.com/dydxprotocol/v4-chain/protocol/daemons/flags" liquidationclient "github.com/dydxprotocol/v4-chain/protocol/daemons/liquidation/client" metricsclient "github.com/dydxprotocol/v4-chain/protocol/daemons/metrics/client" @@ -598,7 +597,7 @@ func New( // Non-validating full-nodes have no need to run the price daemon. if !appFlags.NonValidatingFullNode && daemonFlags.Price.Enabled { - exchangeStartupConfig := configs.ReadExchangeStartupConfigFile(homePath) + exchangeQueryConfig := constants.StaticExchangeQueryConfig app.Server.ExpectPricefeedDaemon(daemonservertypes.MaximumAcceptableUpdateDelay(daemonFlags.Price.LoopDelayMs)) // Start pricefeed client for sending prices for the pricefeed server to consume. These prices // are retrieved via third-party APIs like Binance and then are encoded in-memory and @@ -611,7 +610,7 @@ func New( appFlags, logger, &daemontypes.GrpcClientImpl{}, - exchangeStartupConfig, + exchangeQueryConfig, constants.StaticExchangeDetails, &pricefeedclient.SubTaskRunnerImpl{}, ) diff --git a/protocol/cmd/dydxprotocold/cmd/init.go b/protocol/cmd/dydxprotocold/cmd/init.go deleted file mode 100644 index 570d4f44ff..0000000000 --- a/protocol/cmd/dydxprotocold/cmd/init.go +++ /dev/null @@ -1,28 +0,0 @@ -package cmd - -import ( - "os" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/dydxprotocol/v4-chain/protocol/daemons/configs" - "github.com/spf13/cobra" -) - -// AddInitCmdPostRunE adds a PostRunE to the `init` subcommand. -func AddInitCmdPostRunE(rootCmd *cobra.Command) { - // Fetch init subcommand. - initCmd, _, err := rootCmd.Find([]string{"init"}) - if err != nil { - os.Exit(1) - } - - // Add PostRun to configure required setups after `init`. - initCmd.PostRunE = func(cmd *cobra.Command, args []string) error { - // Get home directory. - clientCtx := client.GetClientContextFromCmd(cmd) - - // Add default pricefeed exchange config toml file if it does not exist. - configs.WriteDefaultPricefeedExchangeToml(clientCtx.HomeDir) - return nil - } -} diff --git a/protocol/cmd/dydxprotocold/main.go b/protocol/cmd/dydxprotocold/main.go index 697bc47fe2..9a065941ec 100644 --- a/protocol/cmd/dydxprotocold/main.go +++ b/protocol/cmd/dydxprotocold/main.go @@ -16,7 +16,6 @@ func main() { rootCmd := cmd.NewRootCmd(option) cmd.AddTendermintSubcommands(rootCmd) - cmd.AddInitCmdPostRunE(rootCmd) if err := svrcmd.Execute(rootCmd, app.AppDaemonName, app.DefaultNodeHome); err != nil { os.Exit(1) diff --git a/protocol/daemons/configs/default_pricefeed_exchange_config.go b/protocol/daemons/configs/default_pricefeed_exchange_config.go deleted file mode 100644 index cc521bc86a..0000000000 --- a/protocol/daemons/configs/default_pricefeed_exchange_config.go +++ /dev/null @@ -1,124 +0,0 @@ -package configs - -import ( - "bytes" - "fmt" - "os" - "path/filepath" - "text/template" - - tmos "github.com/cometbft/cometbft/libs/os" - daemonconstants "github.com/dydxprotocol/v4-chain/protocol/daemons/constants" - "github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/constants" - "github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/types" - "github.com/pelletier/go-toml" -) - -// Note: any changes to the comments/variables/mapstructure must be reflected in the appropriate -// struct in daemons/pricefeed/client/static_exchange_startup_config.go. -const ( - defaultTomlTemplate = `# This is a TOML config file. - # StaticExchangeStartupConfig represents the mapping of exchanges to the parameters for - # querying from them. - # - # ExchangeId - Unique string identifying an exchange. - # - # IntervalMs - Delays between sending API requests to get exchange market prices - cannot be 0. - # - # TimeoutMs - Max time to wait on an API call to an exchange - cannot be 0. - # - # MaxQueries - Max api calls to get market prices for an exchange to make in a task-loop - - # cannot be 0. For multi-market API exchanges, the behavior will default to 1.{{ range $exchangeId, $element := .}} - [[exchanges]] - ExchangeId = "{{$element.ExchangeId}}" - IntervalMs = {{$element.IntervalMs}} - TimeoutMs = {{$element.TimeoutMs}} - MaxQueries = {{$element.MaxQueries}}{{end}} -` -) - -// GenerateDefaultExchangeTomlString creates the toml file string containing the default configs -// for querying each exchange. -func GenerateDefaultExchangeTomlString() bytes.Buffer { - // Create the template for turning each `parsableExchangeStartupConfig` into a toml map config in - // a stringified toml file. - template, err := template.New("").Parse(defaultTomlTemplate) - // Panic if failure occurs when parsing the template. - if err != nil { - panic(err) - } - - // Encode toml string into `defaultExchangeToml` and return if successful. Otherwise, panic. - var defaultExchangeToml bytes.Buffer - err = template.Execute(&defaultExchangeToml, constants.StaticExchangeStartupConfig) - if err != nil { - panic(err) - } - return defaultExchangeToml -} - -// WriteDefaultPricefeedExchangeToml reads in the toml string for the pricefeed client and -// writes said string to the config folder as a toml file if the config file does not exist. -func WriteDefaultPricefeedExchangeToml(homeDir string) { - // Write file into config folder if file does not exist. - configFilePath := getConfigFilePath(homeDir) - if !tmos.FileExists(configFilePath) { - buffer := GenerateDefaultExchangeTomlString() - tmos.MustWriteFile(configFilePath, buffer.Bytes(), 0644) - } -} - -// ReadExchangeStartupConfigFile gets a mapping of `exchangeIds` to `ExchangeStartupConfigs` -// where `ExchangeStartupConfig` for querying exchanges for market prices comes from parsing a TOML -// file in the config directory. -// NOTE: if the config file is not found for the price-daemon, return the static exchange startup -// config. -func ReadExchangeStartupConfigFile(homeDir string) map[types.ExchangeId]*types.ExchangeStartupConfig { - // Read file for exchange startup configurations. - tomlFile, err := os.ReadFile(getConfigFilePath(homeDir)) - if err != nil { - panic(err) - } - - // Unmarshal `tomlFile` into `exchanges` for `exchangeStartupConfigMap`. - exchanges := map[string][]types.ExchangeStartupConfig{} - if err = toml.Unmarshal(tomlFile, &exchanges); err != nil { - panic(err) - } - - // Populate configs for exchanges. - exchangeStartupConfigMap := make(map[types.ExchangeId]*types.ExchangeStartupConfig, len(exchanges)) - for _, exchange := range exchanges["exchanges"] { - // Zero is an invalid configuration value for all parameters. This could also point to the - // configuration file being setup wrong with one or more exchange parameters unset. - if exchange.IntervalMs == 0 || - exchange.TimeoutMs == 0 || - exchange.MaxQueries == 0 { - panic( - fmt.Errorf( - "One or more startup config values are unset or are set to zero for exchange with id: '%v'", - exchange.ExchangeId, - ), - ) - } - - // Insert Key-Value pair into `exchangeStartupConfigMap`. - exchangeStartupConfigMap[exchange.ExchangeId] = &types.ExchangeStartupConfig{ - ExchangeId: exchange.ExchangeId, - IntervalMs: exchange.IntervalMs, - TimeoutMs: exchange.TimeoutMs, - MaxQueries: exchange.MaxQueries, - } - } - - return exchangeStartupConfigMap -} - -// getConfigFilePath returns the path to the pricefeed exchange config file. -func getConfigFilePath(homeDir string) string { - return filepath.Join( - homeDir, - "config", - daemonconstants.PricefeedExchangeConfigFileName, - ) -} diff --git a/protocol/daemons/configs/default_pricefeed_exchange_config_test.go b/protocol/daemons/configs/default_pricefeed_exchange_config_test.go deleted file mode 100644 index e397b284b5..0000000000 --- a/protocol/daemons/configs/default_pricefeed_exchange_config_test.go +++ /dev/null @@ -1,243 +0,0 @@ -package configs_test - -import ( - "bytes" - "errors" - "fmt" - "os" - "path/filepath" - "testing" - - "github.com/dydxprotocol/v4-chain/protocol/daemons/configs" - "github.com/dydxprotocol/v4-chain/protocol/daemons/constants" - pfconstants "github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/constants" - "github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/constants/exchange_common" - "github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/types" - - tmos "github.com/cometbft/cometbft/libs/os" - "github.com/stretchr/testify/require" -) - -var ( - binanceId = exchange_common.EXCHANGE_ID_BINANCE - filePath = fmt.Sprintf("config/%v", constants.PricefeedExchangeConfigFileName) -) - -const ( - tomlString = `# This is a TOML config file. - # StaticExchangeStartupConfig represents the mapping of exchanges to the parameters for - # querying from them. - # - # ExchangeId - Unique string identifying an exchange. - # - # IntervalMs - Delays between sending API requests to get exchange market prices - cannot be 0. - # - # TimeoutMs - Max time to wait on an API call to an exchange - cannot be 0. - # - # MaxQueries - Max api calls to get market prices for an exchange to make in a task-loop - - # cannot be 0. For multi-market API exchanges, the behavior will default to 1. - [[exchanges]] - ExchangeId = "Binance" - IntervalMs = 2500 - TimeoutMs = 3000 - MaxQueries = 1 - [[exchanges]] - ExchangeId = "BinanceUS" - IntervalMs = 2500 - TimeoutMs = 3000 - MaxQueries = 1 - [[exchanges]] - ExchangeId = "Bitfinex" - IntervalMs = 2500 - TimeoutMs = 3000 - MaxQueries = 1 - [[exchanges]] - ExchangeId = "Bitstamp" - IntervalMs = 2000 - TimeoutMs = 3000 - MaxQueries = 1 - [[exchanges]] - ExchangeId = "Bybit" - IntervalMs = 2000 - TimeoutMs = 3000 - MaxQueries = 1 - [[exchanges]] - ExchangeId = "CoinbasePro" - IntervalMs = 2000 - TimeoutMs = 3000 - MaxQueries = 3 - [[exchanges]] - ExchangeId = "CryptoCom" - IntervalMs = 2000 - TimeoutMs = 3000 - MaxQueries = 1 - [[exchanges]] - ExchangeId = "Gate" - IntervalMs = 2000 - TimeoutMs = 3000 - MaxQueries = 1 - [[exchanges]] - ExchangeId = "Huobi" - IntervalMs = 2000 - TimeoutMs = 3000 - MaxQueries = 1 - [[exchanges]] - ExchangeId = "Kraken" - IntervalMs = 2000 - TimeoutMs = 3000 - MaxQueries = 1 - [[exchanges]] - ExchangeId = "Kucoin" - IntervalMs = 2000 - TimeoutMs = 3000 - MaxQueries = 1 - [[exchanges]] - ExchangeId = "Mexc" - IntervalMs = 2000 - TimeoutMs = 3000 - MaxQueries = 1 - [[exchanges]] - ExchangeId = "Okx" - IntervalMs = 2000 - TimeoutMs = 3000 - MaxQueries = 1 - [[exchanges]] - ExchangeId = "TestVolatileExchange" - IntervalMs = 2000 - TimeoutMs = 3000 - MaxQueries = 3 -` -) - -func TestGenerateDefaultExchangeTomlString(t *testing.T) { - defaultConfigStringBuffer := configs.GenerateDefaultExchangeTomlString() - require.Equal( - t, - tomlString, - defaultConfigStringBuffer.String(), - ) -} - -func TestWriteDefaultPricefeedExchangeToml(t *testing.T) { - err := os.Mkdir("config", 0700) - require.NoError(t, err) - configs.WriteDefaultPricefeedExchangeToml("") - - buffer, err := os.ReadFile(filePath) - require.NoError(t, err) - - require.Equal(t, tomlString, string(buffer[:])) - os.RemoveAll("config") -} - -func TestWriteDefaultPricefeedExchangeToml_FileExists(t *testing.T) { - helloWorld := "Hello World" - - err := os.Mkdir("config", 0700) - require.NoError(t, err) - - tmos.MustWriteFile(filePath, bytes.NewBuffer([]byte(helloWorld)).Bytes(), 0644) - configs.WriteDefaultPricefeedExchangeToml("") - - buffer, err := os.ReadFile(filePath) - require.NoError(t, err) - - require.Equal(t, helloWorld, string(buffer[:])) - os.RemoveAll("config") -} - -func TestReadExchangeStartupConfigFile(t *testing.T) { - pwd, _ := os.Getwd() - - tests := map[string]struct { - // parameters - exchangeConfigSourcePath string - doNotWriteFile bool - - // expectations - expectedExchangeId types.ExchangeId - expectedIntervalMsExchange uint32 - expectedTimeoutMsExchange uint32 - expectedMaxQueries uint32 - expectedPanic error - }{ - "valid": { - exchangeConfigSourcePath: "test_data/valid_test.toml", - expectedExchangeId: binanceId, - expectedIntervalMsExchange: pfconstants.StaticExchangeStartupConfig[binanceId].IntervalMs, - expectedTimeoutMsExchange: pfconstants.StaticExchangeStartupConfig[binanceId].TimeoutMs, - expectedMaxQueries: pfconstants.StaticExchangeStartupConfig[binanceId].MaxQueries, - }, - "config file cannot be found": { - exchangeConfigSourcePath: "test_data/notexisting_test.toml", - doNotWriteFile: true, - expectedPanic: fmt.Errorf( - "open %s%s: no such file or directory", - pwd+"/config/", - constants.PricefeedExchangeConfigFileName, - ), - }, - "config file cannot be umarshalled": { - exchangeConfigSourcePath: "test_data/broken_test.toml", - expectedPanic: errors.New("(1, 12): was expecting token [[, but got unclosed table array key instead"), - }, - "config file has malformed values": { - exchangeConfigSourcePath: "test_data/missingvals_test.toml", - expectedPanic: errors.New( - "One or more startup config values are unset or are set to zero for exchange with id: 'BinanceUS'", - ), - }, - "config file has incorrect values": { - exchangeConfigSourcePath: "test_data/wrongvaltype_test.toml", - expectedPanic: errors.New( - "(3, 1): Can't convert a(string) to uint32", - ), - }, - } - - for name, tc := range tests { - t.Run(name, func(t *testing.T) { - if !tc.doNotWriteFile { - err := os.Mkdir("config", 0700) - require.NoError(t, err) - - file, err := os.Open(tc.exchangeConfigSourcePath) - require.NoError(t, err) - - config, err := os.Create(filepath.Join("config", constants.PricefeedExchangeConfigFileName)) - require.NoError(t, err) - _, err = config.ReadFrom(file) - require.NoError(t, err) - } - - if tc.expectedPanic != nil { - require.PanicsWithError( - t, - tc.expectedPanic.Error(), - func() { configs.ReadExchangeStartupConfigFile(pwd) }, - ) - - os.RemoveAll("config") - return - } - - exchangeStartupConfigMap := configs.ReadExchangeStartupConfigFile(pwd) - - require.Equal( - t, - &types.ExchangeStartupConfig{ - ExchangeId: tc.expectedExchangeId, - IntervalMs: tc.expectedIntervalMsExchange, - TimeoutMs: tc.expectedTimeoutMsExchange, - MaxQueries: tc.expectedMaxQueries, - }, - exchangeStartupConfigMap[tc.expectedExchangeId], - ) - - os.RemoveAll("config") - }) - } - - // In case tests fail and the path was never removed. - os.RemoveAll("config") -} diff --git a/protocol/daemons/configs/test_data/broken_test.toml b/protocol/daemons/configs/test_data/broken_test.toml deleted file mode 100644 index b7f29458e7..0000000000 --- a/protocol/daemons/configs/test_data/broken_test.toml +++ /dev/null @@ -1,6 +0,0 @@ -[[exchanges] -ExchangeId = "BinanceUS" -IntervalMs = 4_250 -TimeoutMs = 3_000 -MaxQueries = 1 -MaxBufferSize = 10 diff --git a/protocol/daemons/configs/test_data/missingvals_test.toml b/protocol/daemons/configs/test_data/missingvals_test.toml deleted file mode 100644 index eaf52e63b8..0000000000 --- a/protocol/daemons/configs/test_data/missingvals_test.toml +++ /dev/null @@ -1,4 +0,0 @@ -[[exchanges]] -ExchangeId = "BinanceUS" -IntervalMs = 4_250 -TimeoutMs = 3_000 diff --git a/protocol/daemons/configs/test_data/valid_test.toml b/protocol/daemons/configs/test_data/valid_test.toml deleted file mode 100644 index 3d2cafc027..0000000000 --- a/protocol/daemons/configs/test_data/valid_test.toml +++ /dev/null @@ -1,5 +0,0 @@ -[[exchanges]] -ExchangeId = "Binance" -IntervalMs = 2_500 -TimeoutMs = 3_000 -MaxQueries = 1 diff --git a/protocol/daemons/configs/test_data/wrongvaltype_test.toml b/protocol/daemons/configs/test_data/wrongvaltype_test.toml deleted file mode 100644 index fd076b4b0d..0000000000 --- a/protocol/daemons/configs/test_data/wrongvaltype_test.toml +++ /dev/null @@ -1,6 +0,0 @@ -[[exchanges]] -ExchangeId = "BinanceUS" -IntervalMs = "a" -TimeoutMs = 3_000 -MaxQueries = 1 -MaxBufferSize = 10 diff --git a/protocol/daemons/constants/pricefeed.go b/protocol/daemons/constants/pricefeed.go index e253129aca..575547ad82 100644 --- a/protocol/daemons/constants/pricefeed.go +++ b/protocol/daemons/constants/pricefeed.go @@ -3,7 +3,4 @@ package constants const ( // DefaultPrice is the default value for `Price` field in `UpdateMarketPricesRequest`. DefaultPrice = 0 - - // PricefeedExchangeConfigFileName names the config file containing the exchange startup config. - PricefeedExchangeConfigFileName = "pricefeed_exchange_config.toml" ) diff --git a/protocol/daemons/pricefeed/client/client.go b/protocol/daemons/pricefeed/client/client.go index a0860c92ff..28a76f5103 100644 --- a/protocol/daemons/pricefeed/client/client.go +++ b/protocol/daemons/pricefeed/client/client.go @@ -100,7 +100,7 @@ func (c *Client) Stop() { // B) periodically sends the most recent prices to a gRPC server // C) periodically queries the prices module for the latest market/exchange configuration and then updates // the shared, in-memory datastore with the latest configuration. -// The exchangeIdToStartupConfig map dictates which exchanges the pricefeed client queries against. +// The exchangeIdToQueryConfig map dictates which exchanges the pricefeed client queries against. // For all exchanges included in this map, the pricefeed client expects an exchangeQueryDetails and an // initialExchangeMarketConfig object to be defined in the parameter maps. To initialize an exchange with // zero markets, pass in an initialExchangeMarketConfig object with an empty map of market tickers for that @@ -118,7 +118,7 @@ func (c *Client) start(ctx context.Context, appFlags appflags.Flags, logger log.Logger, grpcClient daemontypes.GrpcClient, - exchangeIdToStartupConfig map[types.ExchangeId]*types.ExchangeStartupConfig, + exchangeIdToQueryConfig map[types.ExchangeId]*types.ExchangeQueryConfig, exchangeIdToExchangeDetails map[types.ExchangeId]types.ExchangeQueryDetails, subTaskRunner SubTaskRunner, ) (err error) { @@ -151,15 +151,15 @@ func (c *Client) start(ctx context.Context, // 2. Validate daemon configuration. if err := validateDaemonConfiguration( - exchangeIdToStartupConfig, + exchangeIdToQueryConfig, exchangeIdToExchangeDetails, ); err != nil { return err } // Let the canonical list of exchange feeds be the keys of the map of exchange feed ids to startup configs. - canonicalExchangeIds := make([]types.ExchangeId, 0, len(exchangeIdToStartupConfig)) - for exchangeId := range exchangeIdToStartupConfig { + canonicalExchangeIds := make([]types.ExchangeId, 0, len(exchangeIdToQueryConfig)) + for exchangeId := range exchangeIdToQueryConfig { canonicalExchangeIds = append(canonicalExchangeIds, exchangeId) } @@ -175,10 +175,10 @@ func (c *Client) start(ctx context.Context, // 4. Start PriceEncoder and PriceFetcher per exchange. timeProvider := &libtime.TimeProviderImpl{} - for _exchangeId := range exchangeIdToStartupConfig { + for _exchangeId := range exchangeIdToQueryConfig { // Assign these within the loop to avoid unexpected values being passed to the goroutines. exchangeId := _exchangeId - exchangeConfig := exchangeIdToStartupConfig[exchangeId] + exchangeConfig := exchangeIdToQueryConfig[exchangeId] // Expect an ExchangeQueryDetails to exist for each supported exchange feed id. exchangeDetails, exists := exchangeIdToExchangeDetails[exchangeId] @@ -270,7 +270,7 @@ func StartNewClient( appFlags appflags.Flags, logger log.Logger, grpcClient daemontypes.GrpcClient, - exchangeIdToStartupConfig map[types.ExchangeId]*types.ExchangeStartupConfig, + exchangeIdToQueryConfig map[types.ExchangeId]*types.ExchangeQueryConfig, exchangeIdToExchangeDetails map[types.ExchangeId]types.ExchangeQueryDetails, subTaskRunner SubTaskRunner, ) (client *Client) { @@ -290,7 +290,7 @@ func StartNewClient( appFlags, logger.With(sdklog.ModuleKey, constants.PricefeedDaemonModuleName), grpcClient, - exchangeIdToStartupConfig, + exchangeIdToQueryConfig, exchangeIdToExchangeDetails, subTaskRunner, ) @@ -303,21 +303,21 @@ func StartNewClient( } // validateDaemonConfiguration validates the daemon configuration. -// The list of exchanges used as keys for the exchangeIdToStartupConfig defines the exchanges used +// The list of exchanges used as keys for the exchangeIdToQueryConfig defines the exchanges used // by the daemon. // The daemon configuration is valid iff: // 1) The exchangeIdToExchangeDetails map has an entry for each exchange. // 2) The static exchange names map has an entry for each exchange, and each name is unique. func validateDaemonConfiguration( - exchangeIdToStartupConfig map[types.ExchangeId]*types.ExchangeStartupConfig, + exchangeIdToQueryConfig map[types.ExchangeId]*types.ExchangeQueryConfig, exchangeIdToExchangeDetails map[types.ExchangeId]types.ExchangeQueryDetails, ) ( err error, ) { - // Loop through all exchanges, which are defined by the exchangeIdToStartupConfig map, + // Loop through all exchanges, which are defined by the exchangeIdToQueryConfig map, // and validate all ids are unique and have a corresponding ExchangeQueryDetails. - exchangeIds := make(map[string]struct{}, len(exchangeIdToStartupConfig)) - for exchangeId := range exchangeIdToStartupConfig { + exchangeIds := make(map[string]struct{}, len(exchangeIdToQueryConfig)) + for exchangeId := range exchangeIdToQueryConfig { if _, exists := exchangeIds[exchangeId]; exists { return fmt.Errorf("duplicate exchange id '%v' found for exchangeIds", exchangeId) } diff --git a/protocol/daemons/pricefeed/client/client_integration_test.go b/protocol/daemons/pricefeed/client/client_integration_test.go index ddcbe2ba02..551452e0d9 100644 --- a/protocol/daemons/pricefeed/client/client_integration_test.go +++ b/protocol/daemons/pricefeed/client/client_integration_test.go @@ -50,7 +50,7 @@ var ( // Initialize the daemon client with Bitfinex and TestExchange exchanges. Shorten intervals for testing // since we're using a mock exchange server on localhost with no rate limits. - testExchangeStartupConfigs = map[types.ExchangeId]*types.ExchangeStartupConfig{ + testExchangeQueryConfigs = map[types.ExchangeId]*types.ExchangeQueryConfig{ exchange_common.EXCHANGE_ID_TEST_EXCHANGE: { ExchangeId: exchange_common.EXCHANGE_ID_TEST_EXCHANGE, IntervalMs: 100, @@ -326,7 +326,7 @@ func (s *PriceDaemonIntegrationTestSuite) startClient() { s.appFlags, log.TestingLogger(), &daemontypes.GrpcClientImpl{}, - testExchangeStartupConfigs, + testExchangeQueryConfigs, testExchangeToQueryDetails, &client.SubTaskRunnerImpl{}, ) diff --git a/protocol/daemons/pricefeed/client/client_test.go b/protocol/daemons/pricefeed/client/client_test.go index c0ffd7ca65..ca000d2ca1 100644 --- a/protocol/daemons/pricefeed/client/client_test.go +++ b/protocol/daemons/pricefeed/client/client_test.go @@ -86,7 +86,7 @@ func (f *FakeSubTaskRunner) StartPriceFetcher( ticker *time.Ticker, stop <-chan bool, configs types.PricefeedMutableMarketConfigs, - exchangeStartupConfig types.ExchangeStartupConfig, + exchangeQueryConfig types.ExchangeQueryConfig, exchangeDetails types.ExchangeQueryDetails, queryHandler handler.ExchangeQueryHandler, logger log.Logger, @@ -121,9 +121,9 @@ const ( ) var ( - validExchangeId = constants.ExchangeId1 - closeConnectionFailsError = errors.New(closeConnectionFailsErrorMsg) - testExchangeStartupConfigLength = len(constants.TestExchangeStartupConfigs) + validExchangeId = constants.ExchangeId1 + closeConnectionFailsError = errors.New(closeConnectionFailsErrorMsg) + testExchangeQueryConfigLength = len(constants.TestExchangeQueryConfigs) ) func TestFixedBufferSize(t *testing.T) { @@ -136,7 +136,7 @@ func TestStart_InvalidConfig(t *testing.T) { mockGrpcClient *mocks.GrpcClient initialMarketConfig map[types.MarketId]*types.MutableMarketConfig initialExchangeMarketConfig map[types.ExchangeId]*types.MutableExchangeMarketConfig - exchangeIdToStartupConfig map[types.ExchangeId]*types.ExchangeStartupConfig + exchangeIdToQueryConfig map[types.ExchangeId]*types.ExchangeQueryConfig exchangeIdToExchangeDetails map[types.ExchangeId]types.ExchangeQueryDetails // expectations @@ -144,7 +144,7 @@ func TestStart_InvalidConfig(t *testing.T) { expectGrpcConnection bool expectCloseTcpConnection bool expectCloseGrpcConnection bool - // This should equal the length of the `exchangeIdToStartupConfig` passed into + // This should equal the length of the `exchangeIdToQueryConfig` passed into // `client.Start`. expectedNumExchangeTasks int }{ @@ -168,16 +168,16 @@ func TestStart_InvalidConfig(t *testing.T) { }, "Valid: 2 exchanges": { mockGrpcClient: grpc_util.GenerateMockGrpcClientWithOptionalGrpcConnectionErrors(nil, nil, true), - exchangeIdToStartupConfig: constants.TestExchangeStartupConfigs, + exchangeIdToQueryConfig: constants.TestExchangeQueryConfigs, exchangeIdToExchangeDetails: constants.TestExchangeIdToExchangeQueryDetails, expectGrpcConnection: true, expectCloseTcpConnection: true, expectCloseGrpcConnection: true, - expectedNumExchangeTasks: testExchangeStartupConfigLength, + expectedNumExchangeTasks: testExchangeQueryConfigLength, }, - "Invalid: empty exchange startup config": { + "Invalid: empty exchange query config": { mockGrpcClient: grpc_util.GenerateMockGrpcClientWithOptionalGrpcConnectionErrors(nil, nil, true), - exchangeIdToStartupConfig: map[types.ExchangeId]*types.ExchangeStartupConfig{}, + exchangeIdToQueryConfig: map[types.ExchangeId]*types.ExchangeQueryConfig{}, expectedError: errors.New("exchangeIds must not be empty"), expectGrpcConnection: true, expectCloseTcpConnection: true, @@ -185,8 +185,8 @@ func TestStart_InvalidConfig(t *testing.T) { }, "Invalid: missing exchange query details": { mockGrpcClient: grpc_util.GenerateMockGrpcClientWithOptionalGrpcConnectionErrors(nil, nil, true), - exchangeIdToStartupConfig: map[string]*types.ExchangeStartupConfig{ - validExchangeId: constants.TestExchangeStartupConfigs[validExchangeId], + exchangeIdToQueryConfig: map[string]*types.ExchangeQueryConfig{ + validExchangeId: constants.TestExchangeQueryConfigs[validExchangeId], }, expectedError: fmt.Errorf("no exchange details exists for exchangeId: %v", validExchangeId), expectGrpcConnection: true, @@ -199,13 +199,13 @@ func TestStart_InvalidConfig(t *testing.T) { closeConnectionFailsError, true, ), - exchangeIdToStartupConfig: constants.TestExchangeStartupConfigs, + exchangeIdToQueryConfig: constants.TestExchangeQueryConfigs, exchangeIdToExchangeDetails: constants.TestExchangeIdToExchangeQueryDetails, expectedError: closeConnectionFailsError, expectGrpcConnection: true, expectCloseTcpConnection: true, expectCloseGrpcConnection: true, - expectedNumExchangeTasks: testExchangeStartupConfigLength, + expectedNumExchangeTasks: testExchangeQueryConfigLength, }, "Invalid: grpc close connection fails with good inputs": { mockGrpcClient: grpc_util.GenerateMockGrpcClientWithOptionalGrpcConnectionErrors( @@ -213,13 +213,13 @@ func TestStart_InvalidConfig(t *testing.T) { closeConnectionFailsError, true, ), - exchangeIdToStartupConfig: constants.TestExchangeStartupConfigs, + exchangeIdToQueryConfig: constants.TestExchangeQueryConfigs, exchangeIdToExchangeDetails: constants.TestExchangeIdToExchangeQueryDetails, expectedError: closeConnectionFailsError, expectGrpcConnection: true, expectCloseTcpConnection: true, expectCloseGrpcConnection: true, - expectedNumExchangeTasks: testExchangeStartupConfigLength, + expectedNumExchangeTasks: testExchangeQueryConfigLength, }, } for name, tc := range tests { @@ -242,7 +242,7 @@ func TestStart_InvalidConfig(t *testing.T) { appflags.GetFlagValuesFromOptions(appoptions.GetDefaultTestAppOptions("", nil)), log.NewNopLogger(), tc.mockGrpcClient, - tc.exchangeIdToStartupConfig, + tc.exchangeIdToQueryConfig, tc.exchangeIdToExchangeDetails, &faketaskRunner, ) @@ -335,7 +335,7 @@ func TestStop(t *testing.T) { appFlags, log.NewNopLogger(), &daemontypes.GrpcClientImpl{}, - constants.TestExchangeStartupConfigs, + constants.TestExchangeQueryConfigs, constants.TestExchangeIdToExchangeQueryDetails, &SubTaskRunnerImpl{}, ) diff --git a/protocol/daemons/pricefeed/client/constants/static_exchange_startup_config.go b/protocol/daemons/pricefeed/client/constants/static_exchange_query_config.go similarity index 98% rename from protocol/daemons/pricefeed/client/constants/static_exchange_startup_config.go rename to protocol/daemons/pricefeed/client/constants/static_exchange_query_config.go index c2d6ebced3..cf1a89747e 100644 --- a/protocol/daemons/pricefeed/client/constants/static_exchange_startup_config.go +++ b/protocol/daemons/pricefeed/client/constants/static_exchange_query_config.go @@ -19,7 +19,7 @@ const ( ) var ( - StaticExchangeStartupConfig = map[types.ExchangeId]*types.ExchangeStartupConfig{ + StaticExchangeQueryConfig = map[types.ExchangeId]*types.ExchangeQueryConfig{ // See above for rate limiting information of Binance. // https://binance-docs.github.io/apidocs/spot/en/#24hr-ticker-price-change-statistics exchange_common.EXCHANGE_ID_BINANCE: { diff --git a/protocol/daemons/pricefeed/client/constants/static_exchange_startup_config_test.go b/protocol/daemons/pricefeed/client/constants/static_exchange_query_config_test.go similarity index 80% rename from protocol/daemons/pricefeed/client/constants/static_exchange_startup_config_test.go rename to protocol/daemons/pricefeed/client/constants/static_exchange_query_config_test.go index ce05709062..55011e5b60 100644 --- a/protocol/daemons/pricefeed/client/constants/static_exchange_startup_config_test.go +++ b/protocol/daemons/pricefeed/client/constants/static_exchange_query_config_test.go @@ -9,18 +9,18 @@ import ( "github.com/stretchr/testify/require" ) -func TestStaticExchangeStartupConfigCache(t *testing.T) { +func TestStaticExchangeQueryConfigCache(t *testing.T) { tests := map[string]struct { // parameters exchangeId types.ExchangeId // expectations - expectedValue *types.ExchangeStartupConfig + expectedValue *types.ExchangeQueryConfig expectedFound bool }{ "Get BINANCE exchangeDetails": { exchangeId: exchange_common.EXCHANGE_ID_BINANCE, - expectedValue: &types.ExchangeStartupConfig{ + expectedValue: &types.ExchangeQueryConfig{ ExchangeId: exchange_common.EXCHANGE_ID_BINANCE, IntervalMs: 2_500, TimeoutMs: 3_000, @@ -30,7 +30,7 @@ func TestStaticExchangeStartupConfigCache(t *testing.T) { }, "Get BINANCEUS exchangeDetails": { exchangeId: exchange_common.EXCHANGE_ID_BINANCE_US, - expectedValue: &types.ExchangeStartupConfig{ + expectedValue: &types.ExchangeQueryConfig{ ExchangeId: exchange_common.EXCHANGE_ID_BINANCE_US, IntervalMs: 2_500, TimeoutMs: 3_000, @@ -40,7 +40,7 @@ func TestStaticExchangeStartupConfigCache(t *testing.T) { }, "Get BITFINEX exchangeDetails": { exchangeId: exchange_common.EXCHANGE_ID_BITFINEX, - expectedValue: &types.ExchangeStartupConfig{ + expectedValue: &types.ExchangeQueryConfig{ ExchangeId: exchange_common.EXCHANGE_ID_BITFINEX, IntervalMs: 2_500, TimeoutMs: 3_000, @@ -50,7 +50,7 @@ func TestStaticExchangeStartupConfigCache(t *testing.T) { }, "Get Kraken exchangeDetails": { exchangeId: exchange_common.EXCHANGE_ID_KRAKEN, - expectedValue: &types.ExchangeStartupConfig{ + expectedValue: &types.ExchangeQueryConfig{ ExchangeId: exchange_common.EXCHANGE_ID_KRAKEN, IntervalMs: 2_000, TimeoutMs: 3_000, @@ -60,7 +60,7 @@ func TestStaticExchangeStartupConfigCache(t *testing.T) { }, "Get GATE exchangeDetails": { exchangeId: exchange_common.EXCHANGE_ID_GATE, - expectedValue: &types.ExchangeStartupConfig{ + expectedValue: &types.ExchangeQueryConfig{ ExchangeId: exchange_common.EXCHANGE_ID_GATE, IntervalMs: 2_000, TimeoutMs: 3_000, @@ -70,7 +70,7 @@ func TestStaticExchangeStartupConfigCache(t *testing.T) { }, "Get Bitstamp exchangeDetails": { exchangeId: exchange_common.EXCHANGE_ID_BITSTAMP, - expectedValue: &types.ExchangeStartupConfig{ + expectedValue: &types.ExchangeQueryConfig{ ExchangeId: exchange_common.EXCHANGE_ID_BITSTAMP, IntervalMs: 2_000, TimeoutMs: 3_000, @@ -80,7 +80,7 @@ func TestStaticExchangeStartupConfigCache(t *testing.T) { }, "Get Bybit exchangeDetails": { exchangeId: exchange_common.EXCHANGE_ID_BYBIT, - expectedValue: &types.ExchangeStartupConfig{ + expectedValue: &types.ExchangeQueryConfig{ ExchangeId: exchange_common.EXCHANGE_ID_BYBIT, IntervalMs: 2_000, TimeoutMs: 3_000, @@ -90,7 +90,7 @@ func TestStaticExchangeStartupConfigCache(t *testing.T) { }, "Get CryptoCom exchangeDetails": { exchangeId: exchange_common.EXCHANGE_ID_CRYPTO_COM, - expectedValue: &types.ExchangeStartupConfig{ + expectedValue: &types.ExchangeQueryConfig{ ExchangeId: exchange_common.EXCHANGE_ID_CRYPTO_COM, IntervalMs: 2_000, TimeoutMs: 3_000, @@ -100,7 +100,7 @@ func TestStaticExchangeStartupConfigCache(t *testing.T) { }, "Get Huobi exchangeDetails": { exchangeId: exchange_common.EXCHANGE_ID_HUOBI, - expectedValue: &types.ExchangeStartupConfig{ + expectedValue: &types.ExchangeQueryConfig{ ExchangeId: exchange_common.EXCHANGE_ID_HUOBI, IntervalMs: 2_000, TimeoutMs: 3_000, @@ -110,7 +110,7 @@ func TestStaticExchangeStartupConfigCache(t *testing.T) { }, "Get Kucoin exchangeDetails": { exchangeId: exchange_common.EXCHANGE_ID_KUCOIN, - expectedValue: &types.ExchangeStartupConfig{ + expectedValue: &types.ExchangeQueryConfig{ ExchangeId: exchange_common.EXCHANGE_ID_KUCOIN, IntervalMs: 2_000, TimeoutMs: 3_000, @@ -120,7 +120,7 @@ func TestStaticExchangeStartupConfigCache(t *testing.T) { }, "Get Okx exchangeDetails": { exchangeId: exchange_common.EXCHANGE_ID_OKX, - expectedValue: &types.ExchangeStartupConfig{ + expectedValue: &types.ExchangeQueryConfig{ ExchangeId: exchange_common.EXCHANGE_ID_OKX, IntervalMs: 2_000, TimeoutMs: 3_000, @@ -130,7 +130,7 @@ func TestStaticExchangeStartupConfigCache(t *testing.T) { }, "Get Mexc exchangeDetails": { exchangeId: exchange_common.EXCHANGE_ID_MEXC, - expectedValue: &types.ExchangeStartupConfig{ + expectedValue: &types.ExchangeQueryConfig{ ExchangeId: exchange_common.EXCHANGE_ID_MEXC, IntervalMs: 2_000, TimeoutMs: 3_000, @@ -140,7 +140,7 @@ func TestStaticExchangeStartupConfigCache(t *testing.T) { }, "Get CoinbasePro exchangeDetails": { exchangeId: exchange_common.EXCHANGE_ID_COINBASE_PRO, - expectedValue: &types.ExchangeStartupConfig{ + expectedValue: &types.ExchangeQueryConfig{ ExchangeId: exchange_common.EXCHANGE_ID_COINBASE_PRO, IntervalMs: 2_000, TimeoutMs: 3_000, @@ -156,13 +156,13 @@ func TestStaticExchangeStartupConfigCache(t *testing.T) { for name, tc := range tests { t.Run(name, func(t *testing.T) { - value, ok := constants.StaticExchangeStartupConfig[tc.exchangeId] + value, ok := constants.StaticExchangeQueryConfig[tc.exchangeId] require.Equal(t, tc.expectedValue, value) require.Equal(t, ok, tc.expectedFound) }) } } -func TestStaticExchangeStartupConfigCacheLength(t *testing.T) { - require.Len(t, constants.StaticExchangeStartupConfig, 14) +func TestStaticExchangeQueryConfigCacheLength(t *testing.T) { + require.Len(t, constants.StaticExchangeQueryConfig, 14) } diff --git a/protocol/daemons/pricefeed/client/price_fetcher/mutable_state_test.go b/protocol/daemons/pricefeed/client/price_fetcher/mutable_state_test.go index ae84c08ba2..4f840db19e 100644 --- a/protocol/daemons/pricefeed/client/price_fetcher/mutable_state_test.go +++ b/protocol/daemons/pricefeed/client/price_fetcher/mutable_state_test.go @@ -11,7 +11,7 @@ import ( func TestGetNextNMarkets(t *testing.T) { pf, err := NewPriceFetcher( - constants.Exchange1_2MaxQueries_StartupConfig, + constants.Exchange1_2MaxQueries_QueryConfig, types.ExchangeQueryDetails{}, &constants.Exchange1_3Markets_MutableExchangeMarketConfig, constants.MutableMarketConfigs_3Markets, @@ -41,7 +41,7 @@ func TestGetNextNMarkets(t *testing.T) { func TestGetMarketIds(t *testing.T) { pf, err := NewPriceFetcher( - constants.Exchange1_2MaxQueries_StartupConfig, + constants.Exchange1_2MaxQueries_QueryConfig, types.ExchangeQueryDetails{}, &constants.Exchange1_3Markets_MutableExchangeMarketConfig, constants.MutableMarketConfigs_3Markets, @@ -57,7 +57,7 @@ func TestGetMarketIds(t *testing.T) { func TestGetMarketExponents(t *testing.T) { pf, err := NewPriceFetcher( - constants.Exchange1_2MaxQueries_StartupConfig, + constants.Exchange1_2MaxQueries_QueryConfig, types.ExchangeQueryDetails{}, &constants.Exchange1_3Markets_MutableExchangeMarketConfig, constants.MutableMarketConfigs_3Markets, @@ -76,7 +76,7 @@ func TestGetMarketExponents(t *testing.T) { func TestGetMutableExchangeConfig(t *testing.T) { pf, err := NewPriceFetcher( - constants.Exchange1_2MaxQueries_StartupConfig, + constants.Exchange1_2MaxQueries_QueryConfig, types.ExchangeQueryDetails{}, &constants.Exchange1_3Markets_MutableExchangeMarketConfig, constants.MutableMarketConfigs_3Markets, @@ -96,7 +96,7 @@ func TestGetMutableExchangeConfig(t *testing.T) { // set from mutable state and that it uses copies of all identical data structures. func TestGetTaskLoopDefinition(t *testing.T) { pf, err := NewPriceFetcher( - constants.Exchange1_2MaxQueries_StartupConfig, + constants.Exchange1_2MaxQueries_QueryConfig, types.ExchangeQueryDetails{}, &constants.Exchange1_3Markets_MutableExchangeMarketConfig, constants.MutableMarketConfigs_3Markets, diff --git a/protocol/daemons/pricefeed/client/price_fetcher/price_fetcher.go b/protocol/daemons/pricefeed/client/price_fetcher/price_fetcher.go index 18b4dc5911..8a8377b4dd 100644 --- a/protocol/daemons/pricefeed/client/price_fetcher/price_fetcher.go +++ b/protocol/daemons/pricefeed/client/price_fetcher/price_fetcher.go @@ -28,11 +28,11 @@ type PriceFetcherSubtaskResponse struct { // PriceFetcher fetches prices from an exchange by making a query based on the // `exchangeConfig` specifications and then encodes the price or any associated error. type PriceFetcher struct { - exchangeStartupConfig types.ExchangeStartupConfig - exchangeDetails types.ExchangeQueryDetails - queryHandler handler.ExchangeQueryHandler - logger log.Logger - bCh chan<- *PriceFetcherSubtaskResponse + exchangeQueryConfig types.ExchangeQueryConfig + exchangeDetails types.ExchangeQueryDetails + queryHandler handler.ExchangeQueryHandler + logger log.Logger + bCh chan<- *PriceFetcherSubtaskResponse // mutableState contains all mutable state on the price fetcher is consolidated into a single object with access // and update protected by a mutex. @@ -43,7 +43,7 @@ type PriceFetcher struct { // queries to an exchange and encodes the responses or related errors into the shared buffered // channel `bCh`. func NewPriceFetcher( - exchangeStartupConfig types.ExchangeStartupConfig, + exchangeQueryConfig types.ExchangeQueryConfig, exchangeDetails types.ExchangeQueryDetails, mutableExchangeConfig *types.MutableExchangeMarketConfig, mutableMarketConfigs []*types.MutableMarketConfig, @@ -59,16 +59,16 @@ func NewPriceFetcher( constants.SubmoduleLogKey, constants.PriceFetcherSubmoduleName, constants.ExchangeIdLogKey, - exchangeStartupConfig.ExchangeId, + exchangeQueryConfig.ExchangeId, ) pf := &PriceFetcher{ - exchangeStartupConfig: exchangeStartupConfig, - exchangeDetails: exchangeDetails, - queryHandler: queryHandler, - logger: pfLogger, - bCh: bCh, - mutableState: &mutableState{}, + exchangeQueryConfig: exchangeQueryConfig, + exchangeDetails: exchangeDetails, + queryHandler: queryHandler, + logger: pfLogger, + bCh: bCh, + mutableState: &mutableState{}, } // This will instantiate the price fetcher's mutable state. @@ -83,7 +83,7 @@ func NewPriceFetcher( // GetExchangeId returns the exchange id for the exchange queried by the price fetcher. // This method is added to support the MutableExchangeConfigUpdater interface. func (p *PriceFetcher) GetExchangeId() types.ExchangeId { - return p.exchangeStartupConfig.ExchangeId + return p.exchangeQueryConfig.ExchangeId } // UpdateMutableExchangeConfig updates the price fetcher with the most current copy of the exchange config, as @@ -94,7 +94,7 @@ func (p *PriceFetcher) UpdateMutableExchangeConfig( newMarketConfigs []*types.MutableMarketConfig, ) error { // 1. Validate new config. - if newConfig.Id != p.exchangeStartupConfig.ExchangeId { + if newConfig.Id != p.exchangeQueryConfig.ExchangeId { return fmt.Errorf("PriceFetcher.UpdateMutableExchangeConfig: exchange id mismatch") } @@ -147,7 +147,7 @@ func (p *PriceFetcher) getNumQueriesPerTaskLoop() int { return 1 } return lib.Min( - int(p.exchangeStartupConfig.MaxQueries), + int(p.exchangeQueryConfig.MaxQueries), len(p.mutableState.GetMarketIds()), ) } @@ -195,7 +195,7 @@ func (pf *PriceFetcher) runSubTask( marketIds []types.MarketId, taskLoopDefinition *taskLoopDefinition, ) { - exchangeId := pf.exchangeStartupConfig.ExchangeId + exchangeId := pf.exchangeQueryConfig.ExchangeId // Measure total latency for subtask to run for one API call and creating a context with timeout. defer metrics.ModuleMeasureSinceWithLabels( @@ -211,7 +211,7 @@ func (pf *PriceFetcher) runSubTask( ctxWithTimeout, cancelFunc := context.WithTimeout( context.Background(), - time.Duration(pf.exchangeStartupConfig.TimeoutMs)*time.Millisecond, + time.Duration(pf.exchangeQueryConfig.TimeoutMs)*time.Millisecond, ) defer cancelFunc() diff --git a/protocol/daemons/pricefeed/client/price_fetcher/price_fetcher_test.go b/protocol/daemons/pricefeed/client/price_fetcher/price_fetcher_test.go index 3ddf504299..5d0556a4fa 100644 --- a/protocol/daemons/pricefeed/client/price_fetcher/price_fetcher_test.go +++ b/protocol/daemons/pricefeed/client/price_fetcher/price_fetcher_test.go @@ -32,7 +32,7 @@ var ( func TestRunTaskLoop(t *testing.T) { tests := map[string]struct { // parameters - startupConfig types.ExchangeStartupConfig + queryConfig types.ExchangeQueryConfig queryDetails types.ExchangeQueryDetails mutableExchangeConfig types.MutableExchangeMarketConfig mutableMarketConfigs []*types.MutableMarketConfig @@ -41,13 +41,13 @@ func TestRunTaskLoop(t *testing.T) { expectedMarketIdsCalled []types.MarketId }{ "No markets": { - startupConfig: constants.Exchange1_0MaxQueries_StartupConfig, + queryConfig: constants.Exchange1_0MaxQueries_QueryConfig, queryDetails: constants.SingleMarketExchangeQueryDetails, mutableExchangeConfig: constants.Exchange1_NoMarkets_MutableExchangeMarketConfig, mutableMarketConfigs: constants.MutableMarketConfigs_0Markets, }, "Num markets equals max query markets where there is only 1 market": { - startupConfig: constants.Exchange1_1MaxQueries_StartupConfig, + queryConfig: constants.Exchange1_1MaxQueries_QueryConfig, queryDetails: constants.SingleMarketExchangeQueryDetails, mutableExchangeConfig: constants.Exchange1_1Markets_MutableExchangeMarketConfig, mutableMarketConfigs: constants.MutableMarketConfigs_1Markets, @@ -57,7 +57,7 @@ func TestRunTaskLoop(t *testing.T) { }, }, "Num markets < max query markets": { - startupConfig: constants.Exchange1_2MaxQueries_StartupConfig, + queryConfig: constants.Exchange1_2MaxQueries_QueryConfig, queryDetails: constants.SingleMarketExchangeQueryDetails, mutableExchangeConfig: constants.Exchange1_1Markets_MutableExchangeMarketConfig, mutableMarketConfigs: constants.MutableMarketConfigs_1Markets, @@ -67,7 +67,7 @@ func TestRunTaskLoop(t *testing.T) { }, }, "Num markets equals max query markets": { - startupConfig: constants.Exchange1_2MaxQueries_StartupConfig, + queryConfig: constants.Exchange1_2MaxQueries_QueryConfig, queryDetails: constants.SingleMarketExchangeQueryDetails, mutableExchangeConfig: constants.Exchange1_2Markets_MutableExchangeMarketConfig, mutableMarketConfigs: constants.MutableMarketConfigs_2Markets, @@ -79,7 +79,7 @@ func TestRunTaskLoop(t *testing.T) { }, }, "Multi-market, 2 markets": { - startupConfig: constants.Exchange1_1MaxQueries_StartupConfig, + queryConfig: constants.Exchange1_1MaxQueries_QueryConfig, queryDetails: constants.MultiMarketExchangeQueryDetails, mutableExchangeConfig: constants.Exchange1_2Markets_MutableExchangeMarketConfig, mutableMarketConfigs: constants.MutableMarketConfigs_2Markets, @@ -91,7 +91,7 @@ func TestRunTaskLoop(t *testing.T) { }, }, "Num markets greater than max query markets": { - startupConfig: constants.Exchange1_2MaxQueries_StartupConfig, + queryConfig: constants.Exchange1_2MaxQueries_QueryConfig, queryDetails: constants.SingleMarketExchangeQueryDetails, mutableExchangeConfig: constants.Exchange1_3Markets_MutableExchangeMarketConfig, mutableMarketConfigs: constants.MutableMarketConfigs_3Markets, @@ -103,7 +103,7 @@ func TestRunTaskLoop(t *testing.T) { }, }, "Multi-market, 5 markets": { - startupConfig: constants.Exchange1_1MaxQueries_StartupConfig, + queryConfig: constants.Exchange1_1MaxQueries_QueryConfig, queryDetails: constants.MultiMarketExchangeQueryDetails, mutableExchangeConfig: constants.Exchange1_5Markets_MutableExchangeMarketConfig, mutableMarketConfigs: constants.MutableMarketConfigs_5Markets, @@ -130,7 +130,7 @@ func TestRunTaskLoop(t *testing.T) { queryHandler := generateMockExchangeQueryHandler() pf, err := NewPriceFetcher( - tc.startupConfig, + tc.queryConfig, tc.queryDetails, &tc.mutableExchangeConfig, tc.mutableMarketConfigs, @@ -194,7 +194,7 @@ func TestRunTaskLoop(t *testing.T) { // market ids for an exchange on every call. func TestGetTaskLoopDefinition_SingleMarketExchange(t *testing.T) { pf, err := NewPriceFetcher( - constants.Exchange1_2MaxQueries_StartupConfig, + constants.Exchange1_2MaxQueries_QueryConfig, constants.SingleMarketExchangeQueryDetails, &constants.Exchange1_3Markets_MutableExchangeMarketConfig, constants.MutableMarketConfigs_3Markets, @@ -232,7 +232,7 @@ func TestGetTaskLoopDefinition_SingleMarketExchange(t *testing.T) { // expected task loop definition for a multi-market exchange. func TestGetTaskLoopDefinition_MultiMarketExchange(t *testing.T) { pf, err := NewPriceFetcher( - constants.Exchange1_1MaxQueries_StartupConfig, + constants.Exchange1_1MaxQueries_QueryConfig, constants.MultiMarketExchangeQueryDetails, &constants.Exchange1_3Markets_MutableExchangeMarketConfig, constants.MutableMarketConfigs_3Markets, @@ -260,8 +260,8 @@ func TestGetTaskLoopDefinition_MultiMarketExchange(t *testing.T) { func TestUpdateMutableExchangeConfig_CorrectlyUpdatesTaskDefinition(t *testing.T) { tests := map[string]struct { // parameters - startupConfig types.ExchangeStartupConfig - queryDetails types.ExchangeQueryDetails + queryConfig types.ExchangeQueryConfig + queryDetails types.ExchangeQueryDetails initialMutableExchangeConfig types.MutableExchangeMarketConfig initialMarketConfig []*types.MutableMarketConfig @@ -276,7 +276,7 @@ func TestUpdateMutableExchangeConfig_CorrectlyUpdatesTaskDefinition(t *testing.T updateExpectedExponents map[types.MarketId]types.Exponent }{ "Multimarket: No markets to markets": { - startupConfig: constants.Exchange1_1MaxQueries_StartupConfig, + queryConfig: constants.Exchange1_1MaxQueries_QueryConfig, queryDetails: constants.MultiMarketExchangeQueryDetails, isMultiMarket: true, @@ -289,7 +289,7 @@ func TestUpdateMutableExchangeConfig_CorrectlyUpdatesTaskDefinition(t *testing.T updateExpectedExponents: constants.MutableMarketConfigs_3Markets_ExpectedExponents, }, "Multimarket: Add markets": { - startupConfig: constants.Exchange1_1MaxQueries_StartupConfig, + queryConfig: constants.Exchange1_1MaxQueries_QueryConfig, queryDetails: constants.MultiMarketExchangeQueryDetails, isMultiMarket: true, @@ -302,8 +302,8 @@ func TestUpdateMutableExchangeConfig_CorrectlyUpdatesTaskDefinition(t *testing.T updateExpectedExponents: constants.MutableMarketConfigs_5Markets_ExpectedExponents, }, "Single market: No markets to markets": { - startupConfig: constants.Exchange1_2MaxQueries_StartupConfig, - queryDetails: constants.SingleMarketExchangeQueryDetails, + queryConfig: constants.Exchange1_2MaxQueries_QueryConfig, + queryDetails: constants.SingleMarketExchangeQueryDetails, initialMutableExchangeConfig: constants.Exchange1_NoMarkets_MutableExchangeMarketConfig, initialMarketConfig: constants.MutableMarketConfigs_0Markets, @@ -314,8 +314,8 @@ func TestUpdateMutableExchangeConfig_CorrectlyUpdatesTaskDefinition(t *testing.T updateExpectedExponents: constants.MutableMarketConfigs_3Markets_ExpectedExponents, }, "Single market: Add markets": { - startupConfig: constants.Exchange1_2MaxQueries_StartupConfig, - queryDetails: constants.SingleMarketExchangeQueryDetails, + queryConfig: constants.Exchange1_2MaxQueries_QueryConfig, + queryDetails: constants.SingleMarketExchangeQueryDetails, initialMutableExchangeConfig: constants.Exchange1_3Markets_MutableExchangeMarketConfig, initialMarketConfig: constants.MutableMarketConfigs_3Markets, @@ -334,7 +334,7 @@ func TestUpdateMutableExchangeConfig_CorrectlyUpdatesTaskDefinition(t *testing.T queryHandler := generateMockExchangeQueryHandler() pf, err := NewPriceFetcher( - tc.startupConfig, + tc.queryConfig, tc.queryDetails, &tc.initialMutableExchangeConfig, tc.initialMarketConfig, @@ -352,7 +352,7 @@ func TestUpdateMutableExchangeConfig_CorrectlyUpdatesTaskDefinition(t *testing.T if tc.isMultiMarket || len(tc.initialMarketConfig) == 0 { require.Equal(t, tc.initialMutableExchangeConfig.GetMarketIds(), taskLoopDefinition.marketIds) } else { - numMarkets := lib.Min(len(tc.initialMarketConfig), int(tc.startupConfig.MaxQueries)) + numMarkets := lib.Min(len(tc.initialMarketConfig), int(tc.queryConfig.MaxQueries)) require.Len(t, taskLoopDefinition.marketIds, numMarkets) for i := 0; i < numMarkets; i++ { @@ -371,8 +371,8 @@ func TestUpdateMutableExchangeConfig_CorrectlyUpdatesTaskDefinition(t *testing.T if tc.isMultiMarket { require.Equal(t, tc.updateMutableExchangeConfig.GetMarketIds(), taskLoopDefinition.marketIds) } else { - numMarkets := lib.Min(len(tc.initialMarketConfig), int(tc.startupConfig.MaxQueries)) - require.Len(t, taskLoopDefinition.marketIds, int(tc.startupConfig.MaxQueries)) + numMarkets := lib.Min(len(tc.initialMarketConfig), int(tc.queryConfig.MaxQueries)) + require.Len(t, taskLoopDefinition.marketIds, int(tc.queryConfig.MaxQueries)) for i := 0; i < numMarkets; i++ { require.Equal(t, tc.updateMarketConfig[i].Id, taskLoopDefinition.marketIds[i]) @@ -388,8 +388,8 @@ func TestUpdateMutableExchangeConfig_CorrectlyUpdatesTaskDefinition(t *testing.T func TestUpdateMutableExchangeConfig_ProducesExpectedPrices(t *testing.T) { tests := map[string]struct { // parameters - startupConfig types.ExchangeStartupConfig - queryDetails types.ExchangeQueryDetails + queryConfig types.ExchangeQueryConfig + queryDetails types.ExchangeQueryDetails initialMutableExchangeConfig types.MutableExchangeMarketConfig initialMarketConfigs []*types.MutableMarketConfig @@ -404,7 +404,7 @@ func TestUpdateMutableExchangeConfig_ProducesExpectedPrices(t *testing.T) { expectedNumQueryCalls int }{ "Multimarket: No markets to markets": { - startupConfig: constants.Exchange1_1MaxQueries_StartupConfig, + queryConfig: constants.Exchange1_1MaxQueries_QueryConfig, queryDetails: constants.MultiMarketExchangeQueryDetails, isMultiMarket: true, @@ -427,7 +427,7 @@ func TestUpdateMutableExchangeConfig_ProducesExpectedPrices(t *testing.T) { expectedNumQueryCalls: 2, }, "Multimarket: Add markets": { - startupConfig: constants.Exchange1_1MaxQueries_StartupConfig, + queryConfig: constants.Exchange1_1MaxQueries_QueryConfig, queryDetails: constants.MultiMarketExchangeQueryDetails, isMultiMarket: true, @@ -460,8 +460,8 @@ func TestUpdateMutableExchangeConfig_ProducesExpectedPrices(t *testing.T) { expectedNumQueryCalls: 4, }, "Single market: No markets to markets": { - startupConfig: constants.Exchange1_2MaxQueries_StartupConfig, - queryDetails: constants.SingleMarketExchangeQueryDetails, + queryConfig: constants.Exchange1_2MaxQueries_QueryConfig, + queryDetails: constants.SingleMarketExchangeQueryDetails, initialMutableExchangeConfig: constants.Exchange1_NoMarkets_MutableExchangeMarketConfig, initialMarketConfigs: constants.MutableMarketConfigs_0Markets, @@ -479,8 +479,8 @@ func TestUpdateMutableExchangeConfig_ProducesExpectedPrices(t *testing.T) { expectedNumQueryCalls: 4, }, "Single market: Add markets": { - startupConfig: constants.Exchange1_2MaxQueries_StartupConfig, - queryDetails: constants.SingleMarketExchangeQueryDetails, + queryConfig: constants.Exchange1_2MaxQueries_QueryConfig, + queryDetails: constants.SingleMarketExchangeQueryDetails, initialMutableExchangeConfig: constants.Exchange1_3Markets_MutableExchangeMarketConfig, initialMarketConfigs: constants.MutableMarketConfigs_3Markets, @@ -508,7 +508,7 @@ func TestUpdateMutableExchangeConfig_ProducesExpectedPrices(t *testing.T) { bCh := newTestPriceFetcherBufferedChannel() queryHandler := generateMockExchangeQueryHandler() pf, err := NewPriceFetcher( - tc.startupConfig, + tc.queryConfig, tc.queryDetails, &tc.initialMutableExchangeConfig, tc.initialMarketConfigs, @@ -587,7 +587,7 @@ func TestUpdateMutableExchangeConfig_ProducesExpectedPrices(t *testing.T) { // For single market exchanges, the query handler should be called once per market per task loop. marketsPerInitialConfig := math.Min( len(tc.initialMarketConfigs), - int(tc.startupConfig.MaxQueries), + int(tc.queryConfig.MaxQueries), ) * 2 for i, marketId := range tc.expectedMarketIdsCalled { marketConfigs := tc.initialMarketConfigs @@ -608,7 +608,7 @@ func TestUpdateMutableExchangeConfig_ProducesExpectedPrices(t *testing.T) { func TestGetExchangeId(t *testing.T) { pf, err := NewPriceFetcher( - constants.Exchange1_1MaxQueries_StartupConfig, + constants.Exchange1_1MaxQueries_QueryConfig, constants.MultiMarketExchangeQueryDetails, &constants.Exchange1_3Markets_MutableExchangeMarketConfig, constants.MutableMarketConfigs_3Markets, @@ -617,7 +617,7 @@ func TestGetExchangeId(t *testing.T) { newTestPriceFetcherBufferedChannel(), ) require.NoError(t, err) - require.Equal(t, constants.Exchange1_1MaxQueries_StartupConfig.ExchangeId, pf.GetExchangeId()) + require.Equal(t, constants.Exchange1_1MaxQueries_QueryConfig.ExchangeId, pf.GetExchangeId()) } // Test runSubTask behavior with different query handler responses @@ -664,7 +664,7 @@ func TestRunSubTask_Mixed(t *testing.T) { for name, tc := range tests { t.Run(name, func(t *testing.T) { - exchangeStartupConfig := constants.Exchange1_1MaxQueries_StartupConfig + exchangeQueryConfig := constants.Exchange1_1MaxQueries_QueryConfig mutableExchangeMarketConfig := constants.Exchange1_1Markets_MutableExchangeMarketConfig mutableMarketConfigs := constants.MutableMarketConfigs_1Markets mockExchangeQueryHandler := &mocks.ExchangeQueryHandler{} @@ -685,7 +685,7 @@ func TestRunSubTask_Mixed(t *testing.T) { bCh := newTestPriceFetcherBufferedChannel() pf, err := NewPriceFetcher( - exchangeStartupConfig, + exchangeQueryConfig, constants.MultiMarketExchangeQueryDetails, &mutableExchangeMarketConfig, mutableMarketConfigs, diff --git a/protocol/daemons/pricefeed/client/sub_task_runner.go b/protocol/daemons/pricefeed/client/sub_task_runner.go index 1b9d85a8a5..b137bfcdc3 100644 --- a/protocol/daemons/pricefeed/client/sub_task_runner.go +++ b/protocol/daemons/pricefeed/client/sub_task_runner.go @@ -53,7 +53,7 @@ type SubTaskRunner interface { ticker *time.Ticker, stop <-chan bool, configs types.PricefeedMutableMarketConfigs, - exchangeStartupConfig types.ExchangeStartupConfig, + exchangeQueryConfig types.ExchangeQueryConfig, exchangeDetails types.ExchangeQueryDetails, queryHandler handler.ExchangeQueryHandler, logger log.Logger, @@ -153,13 +153,13 @@ func (s *SubTaskRunnerImpl) StartPriceFetcher( ticker *time.Ticker, stop <-chan bool, configs types.PricefeedMutableMarketConfigs, - exchangeStartupConfig types.ExchangeStartupConfig, + exchangeQueryConfig types.ExchangeQueryConfig, exchangeDetails types.ExchangeQueryDetails, queryHandler handler.ExchangeQueryHandler, logger log.Logger, bCh chan<- *price_fetcher.PriceFetcherSubtaskResponse, ) { - exchangeMarketConfig, err := configs.GetExchangeMarketConfigCopy(exchangeStartupConfig.ExchangeId) + exchangeMarketConfig, err := configs.GetExchangeMarketConfigCopy(exchangeQueryConfig.ExchangeId) if err != nil { panic(err) } @@ -171,7 +171,7 @@ func (s *SubTaskRunnerImpl) StartPriceFetcher( // Create PriceFetcher to begin querying with. priceFetcher, err := price_fetcher.NewPriceFetcher( - exchangeStartupConfig, + exchangeQueryConfig, exchangeDetails, exchangeMarketConfig, marketConfigs, diff --git a/protocol/daemons/pricefeed/client/types/exchange_startup_config.go b/protocol/daemons/pricefeed/client/types/exchange_query_config.go similarity index 60% rename from protocol/daemons/pricefeed/client/types/exchange_startup_config.go rename to protocol/daemons/pricefeed/client/types/exchange_query_config.go index 49c2f3ef33..30a3a9f8c5 100644 --- a/protocol/daemons/pricefeed/client/types/exchange_startup_config.go +++ b/protocol/daemons/pricefeed/client/types/exchange_query_config.go @@ -1,6 +1,6 @@ package types -// ExchangeStartupConfig contains configuration values for querying an exchange, passed in on startup. +// ExchangeQueryConfig contains configuration values for querying an exchange, passed in on startup. // The configuration values include // 1. `ExchangeId` // 2. `IntervalMs` delay between task-loops where each task-loop sends API requests to an exchange @@ -10,11 +10,11 @@ package types // // For single-market API exchanges, the price fetcher will send approximately // MaxQueries API responses into the exchange's buffered channel once every IntervalMs milliseconds. -// Note: the `ExchangeStartupConfig` will be used in the map of `{ exchangeId, `ExchangeStartupConfig` }` +// Note: the `ExchangeQueryConfig` will be used in the map of `{ exchangeId, `ExchangeQueryConfig` }` // that dictates how the pricefeed client queries for market prices. -type ExchangeStartupConfig struct { - ExchangeId ExchangeId - IntervalMs uint32 - TimeoutMs uint32 - MaxQueries uint32 +type ExchangeQueryConfig struct { + ExchangeId ExchangeId `json:"exchange_id"` + IntervalMs uint32 `json:"interval_ms"` + TimeoutMs uint32 `json:"timeout_ms"` + MaxQueries uint32 `json:"max_queries"` } diff --git a/protocol/go.mod b/protocol/go.mod index b3e0b605d6..fb835c9966 100644 --- a/protocol/go.mod +++ b/protocol/go.mod @@ -26,7 +26,6 @@ require ( github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/h2non/gock v1.2.0 github.com/ory/dockertest v3.3.5+incompatible - github.com/pelletier/go-toml v1.9.5 github.com/pkg/errors v0.9.1 github.com/rakyll/statik v0.1.7 github.com/spf13/cast v1.5.1 diff --git a/protocol/go.sum b/protocol/go.sum index 0890541aa1..00166e554f 100644 --- a/protocol/go.sum +++ b/protocol/go.sum @@ -1175,8 +1175,6 @@ github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0Mw github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= -github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= diff --git a/protocol/testing/containertest/Dockerfile b/protocol/testing/containertest/Dockerfile index 4e442d839d..52d95c3037 100644 --- a/protocol/testing/containertest/Dockerfile +++ b/protocol/testing/containertest/Dockerfile @@ -7,9 +7,4 @@ COPY ./testing/delaymsg_config /dydxprotocol/delaymsg_config RUN /dydxprotocol/containertest.sh -COPY ./testing/containertest/config/pricefeed_exchange_config.toml /dydxprotocol/chain/.alice/config/pricefeed_exchange_config.toml -COPY ./testing/containertest/config/pricefeed_exchange_config.toml /dydxprotocol/chain/.bob/config/pricefeed_exchange_config.toml -COPY ./testing/containertest/config/pricefeed_exchange_config.toml /dydxprotocol/chain/.carl/config/pricefeed_exchange_config.toml -COPY ./testing/containertest/config/pricefeed_exchange_config.toml /dydxprotocol/chain/.dave/config/pricefeed_exchange_config.toml - ENTRYPOINT ["dydxprotocold"] diff --git a/protocol/testing/containertest/config/pricefeed_exchange_config.toml b/protocol/testing/containertest/config/pricefeed_exchange_config.toml deleted file mode 100644 index 4966220300..0000000000 --- a/protocol/testing/containertest/config/pricefeed_exchange_config.toml +++ /dev/null @@ -1,5 +0,0 @@ -[[exchanges]] -ExchangeId = "TestExchange" -IntervalMs = 1000 -TimeoutMs = 1000 -MaxQueries = 33 diff --git a/protocol/testing/genesis.sh b/protocol/testing/genesis.sh index 815f6ac00d..bdd0019a2e 100755 --- a/protocol/testing/genesis.sh +++ b/protocol/testing/genesis.sh @@ -1492,7 +1492,7 @@ function update_genesis_use_test_exchange() { # All remaining markets can just use the LINK ticker so the daemon will start. All markets must have at least 1 # exchange. With only one exchange configured, there should not be enough prices to meet the minimum exchange # count, and these markets will not have index prices. - for market_idx in {3..33} + for market_idx in {3..34} do dasel put -t string -f "$GENESIS" ".app_state.prices.market_params.[$market_idx].exchange_config_json" -v "$link_exchange_config_json" done diff --git a/protocol/testutil/constants/pricefeed.go b/protocol/testutil/constants/pricefeed.go index d89d53f676..6198676491 100644 --- a/protocol/testutil/constants/pricefeed.go +++ b/protocol/testutil/constants/pricefeed.go @@ -353,22 +353,22 @@ var ( SingleMarketExchangeQueryDetails = daemonClientTypes.ExchangeQueryDetails{IsMultiMarket: false} MultiMarketExchangeQueryDetails = daemonClientTypes.ExchangeQueryDetails{IsMultiMarket: true} - // ExchangeStartupConfigs. - Exchange1_0MaxQueries_StartupConfig = daemonClientTypes.ExchangeStartupConfig{ + // ExchangeQueryConfigs. + Exchange1_0MaxQueries_QueryConfig = daemonClientTypes.ExchangeQueryConfig{ ExchangeId: ExchangeId1, IntervalMs: 100, TimeoutMs: 3_000, MaxQueries: 0, } - Exchange1_1MaxQueries_StartupConfig = daemonClientTypes.ExchangeStartupConfig{ + Exchange1_1MaxQueries_QueryConfig = daemonClientTypes.ExchangeQueryConfig{ ExchangeId: ExchangeId1, IntervalMs: 100, TimeoutMs: 3_000, MaxQueries: 1, } - Exchange1_2MaxQueries_StartupConfig = daemonClientTypes.ExchangeStartupConfig{ + Exchange1_2MaxQueries_QueryConfig = daemonClientTypes.ExchangeQueryConfig{ ExchangeId: ExchangeId1, IntervalMs: 100, TimeoutMs: 3_000, @@ -667,7 +667,7 @@ var ( MarketId11: MaticUsdExponent, } - TestExchangeStartupConfigs = map[string]*daemonClientTypes.ExchangeStartupConfig{ + TestExchangeQueryConfigs = map[string]*daemonClientTypes.ExchangeQueryConfig{ ExchangeId1: { ExchangeId: ExchangeId1, IntervalMs: 100, diff --git a/protocol/x/prices/client/cli/prices_cli_test.go b/protocol/x/prices/client/cli/prices_cli_test.go index a03c3c4912..b342c2be43 100644 --- a/protocol/x/prices/client/cli/prices_cli_test.go +++ b/protocol/x/prices/client/cli/prices_cli_test.go @@ -8,13 +8,11 @@ import ( "github.com/dydxprotocol/v4-chain/protocol/app/stoppable" "time" - "path/filepath" "testing" networktestutil "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/dydxprotocol/v4-chain/protocol/app" - "github.com/dydxprotocol/v4-chain/protocol/daemons/configs" daemonflags "github.com/dydxprotocol/v4-chain/protocol/daemons/flags" "github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client" "github.com/dydxprotocol/v4-chain/protocol/testutil/appoptions" @@ -96,14 +94,11 @@ func (s *PricesIntegrationTestSuite) SetupTest() { // Enable the Price daemon. appOptions.Set(daemonflags.FlagPriceDaemonEnabled, true) + appOptions.Set(daemonflags.FlagPriceDaemonLoopDelayMs, 1_000) // Make sure the daemon is using the correct GRPC address. appOptions.Set(appflags.GrpcAddress, testval.AppConfig.GRPC.Address) - homeDir := filepath.Join(testval.Dir, "simd") - configs.WriteDefaultPricefeedExchangeToml(homeDir) // must manually create config file. - appOptions.Set(daemonflags.FlagPriceDaemonLoopDelayMs, 1_000) - // Make sure all daemon-related services are properly stopped. s.T().Cleanup(func() { stoppable.StopServices(s.T(), testval.AppConfig.GRPC.Address)