Skip to content

Commit

Permalink
Remove pricefeed config toml entirely. (#627)
Browse files Browse the repository at this point in the history
clemire authored Oct 17, 2023
1 parent f4da098 commit 5be62c0
Showing 27 changed files with 133 additions and 572 deletions.
5 changes: 2 additions & 3 deletions protocol/app/app.go
Original file line number Diff line number Diff line change
@@ -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{},
)
28 changes: 0 additions & 28 deletions protocol/cmd/dydxprotocold/cmd/init.go

This file was deleted.

1 change: 0 additions & 1 deletion protocol/cmd/dydxprotocold/main.go
Original file line number Diff line number Diff line change
@@ -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)
124 changes: 0 additions & 124 deletions protocol/daemons/configs/default_pricefeed_exchange_config.go

This file was deleted.

243 changes: 0 additions & 243 deletions protocol/daemons/configs/default_pricefeed_exchange_config_test.go

This file was deleted.

6 changes: 0 additions & 6 deletions protocol/daemons/configs/test_data/broken_test.toml

This file was deleted.

4 changes: 0 additions & 4 deletions protocol/daemons/configs/test_data/missingvals_test.toml

This file was deleted.

5 changes: 0 additions & 5 deletions protocol/daemons/configs/test_data/valid_test.toml

This file was deleted.

6 changes: 0 additions & 6 deletions protocol/daemons/configs/test_data/wrongvaltype_test.toml

This file was deleted.

3 changes: 0 additions & 3 deletions protocol/daemons/constants/pricefeed.go
Original file line number Diff line number Diff line change
@@ -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"
)
28 changes: 14 additions & 14 deletions protocol/daemons/pricefeed/client/client.go
Original file line number Diff line number Diff line change
@@ -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)
}
4 changes: 2 additions & 2 deletions protocol/daemons/pricefeed/client/client_integration_test.go
Original file line number Diff line number Diff line change
@@ -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{},
)
36 changes: 18 additions & 18 deletions protocol/daemons/pricefeed/client/client_test.go
Original file line number Diff line number Diff line change
@@ -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,15 +136,15 @@ 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
expectedError error
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,25 +168,25 @@ 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,
expectCloseGrpcConnection: true,
},
"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,27 +199,27 @@ 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(
nil,
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{},
)
Original file line number Diff line number Diff line change
@@ -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: {
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
@@ -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,
36 changes: 18 additions & 18 deletions protocol/daemons/pricefeed/client/price_fetcher/price_fetcher.go
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
@@ -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,
8 changes: 4 additions & 4 deletions protocol/daemons/pricefeed/client/sub_task_runner.go
Original file line number Diff line number Diff line change
@@ -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,
Original file line number Diff line number Diff line change
@@ -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"`
}
1 change: 0 additions & 1 deletion protocol/go.mod
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions protocol/go.sum
Original file line number Diff line number Diff line change
@@ -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=
5 changes: 0 additions & 5 deletions protocol/testing/containertest/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

This file was deleted.

2 changes: 1 addition & 1 deletion protocol/testing/genesis.sh
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions protocol/testutil/constants/pricefeed.go
Original file line number Diff line number Diff line change
@@ -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,
7 changes: 1 addition & 6 deletions protocol/x/prices/client/cli/prices_cli_test.go
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 5be62c0

Please sign in to comment.