Change enabled gating to available for currencies and assets in wrappers & friends#2183
Change enabled gating to available for currencies and assets in wrappers & friends#2183gloriousCode wants to merge 7 commits intothrasher-corp:masterfrom
Conversation
Changes enabled gating and pushes it to `/engine` Some areas such as subscription generation still require enabled to not blow out websockets when undesired Updates websocketroutine_manager to move ticker processing to exchange websockets
There was a problem hiding this comment.
Code Review
This pull request is a significant refactoring that changes the gating for many data retrieval functions from checking for "enabled" currencies and assets to "available". This makes the system more flexible for querying data. The PR also includes important fixes for data races in engine/exchange_manager and engine/sync_manager, and refactors ticker processing to be more modular.
My review focuses on the correctness and potential side effects of these widespread changes. While most changes look good and are consistent with the PR's goal, I've identified a potential issue where CancelAllOrders in several exchange wrappers now iterates over all available pairs instead of enabled pairs. This could lead to unexpected behavior and a high volume of API requests. This seems to contradict the PR's description that write operations should remain strict.
| case asset.CoinMarginedFutures: | ||
| if req.Pair.IsEmpty() { | ||
| enabledPairs, err := e.GetEnabledPairs(asset.CoinMarginedFutures) | ||
| availablePairs, err := e.GetAvailablePairs(asset.CoinMarginedFutures) |
There was a problem hiding this comment.
This change from GetEnabledPairs to GetAvailablePairs means that calling CancelAllOrders for an asset will now attempt to cancel orders for all pairs available on the exchange, not just the ones enabled in the user's configuration. This could be unexpected and lead to a large number of API requests, potentially causing rate limiting. The PR description states that write operations should remain strict ('for enabled only'). Should this use GetEnabledPairs instead?
| availablePairs, err := e.GetAvailablePairs(asset.CoinMarginedFutures) | |
| availablePairs, err := e.GetEnabledPairs(asset.CoinMarginedFutures) |
| case asset.USDTMarginedFutures: | ||
| if req.Pair.IsEmpty() { | ||
| enabledPairs, err := e.GetEnabledPairs(asset.USDTMarginedFutures) | ||
| availablePairs, err := e.GetAvailablePairs(asset.USDTMarginedFutures) |
There was a problem hiding this comment.
This change from GetEnabledPairs to GetAvailablePairs means that calling CancelAllOrders for an asset will now attempt to cancel orders for all pairs available on the exchange, not just the ones enabled in the user's configuration. This could be unexpected and lead to a large number of API requests, potentially causing rate limiting. The PR description states that write operations should remain strict ('for enabled only'). Should this use GetEnabledPairs instead?
| availablePairs, err := e.GetAvailablePairs(asset.USDTMarginedFutures) | |
| availablePairs, err := e.GetEnabledPairs(asset.USDTMarginedFutures) |
|
|
||
| var allOrders []OrderData | ||
| currs, err := e.GetEnabledPairs(asset.Spot) | ||
| currs, err := e.GetAvailablePairs(asset.Spot) |
There was a problem hiding this comment.
This change from GetEnabledPairs to GetAvailablePairs means that calling CancelAllOrders will now attempt to cancel orders for all pairs available on the exchange, not just the ones enabled in the user's configuration. This could be unexpected and lead to a large number of API requests, potentially causing rate limiting. The PR description states that write operations should remain strict ('for enabled only'). Should this use GetEnabledPairs instead?
| currs, err := e.GetAvailablePairs(asset.Spot) | |
| currs, err := e.GetEnabledPairs(asset.Spot) |
| switch orderCancellation.AssetType { | ||
| case asset.Spot: | ||
| enabledPairs, err := e.GetEnabledPairs(asset.Spot) | ||
| availablePairs, err := e.GetAvailablePairs(asset.Spot) |
There was a problem hiding this comment.
This change from GetEnabledPairs to GetAvailablePairs means that calling CancelAllOrders for an asset will now attempt to cancel orders for all pairs available on the exchange, not just the ones enabled in the user's configuration. This could be unexpected and lead to a large number of API requests, potentially causing rate limiting. The PR description states that write operations should remain strict ('for enabled only'). Should this use GetEnabledPairs instead?
| availablePairs, err := e.GetAvailablePairs(asset.Spot) | |
| availablePairs, err := e.GetEnabledPairs(asset.Spot) |
| // getAllOpenOrderID returns all open orders by currency pairs | ||
| func (e *Exchange) getAllOpenOrderID(ctx context.Context) (map[string][]string, error) { | ||
| allPairs, err := e.GetEnabledPairs(asset.Spot) | ||
| allPairs, err := e.GetAvailablePairs(asset.Spot) |
There was a problem hiding this comment.
This change from GetEnabledPairs to GetAvailablePairs means that getAllOpenOrderID (and by extension CancelAllOrders) will now operate on all pairs available on the exchange, not just the ones enabled in the user's configuration. This could be unexpected and lead to a large number of API requests, potentially causing rate limiting. The PR description states that write operations should remain strict ('for enabled only'). Should this use GetEnabledPairs instead?
| allPairs, err := e.GetAvailablePairs(asset.Spot) | |
| allPairs, err := e.GetEnabledPairs(asset.Spot) |
| } | ||
|
|
||
| enabledPairs, err := e.GetEnabledPairs(asset.Spot) | ||
| availablePairs, err := e.GetAvailablePairs(asset.Spot) |
There was a problem hiding this comment.
This change from GetEnabledPairs to GetAvailablePairs means that calling CancelAllOrders will now attempt to cancel orders for all pairs available on the exchange, not just the ones enabled in the user's configuration. This could be unexpected and lead to a large number of API requests, potentially causing rate limiting. The PR description states that write operations should remain strict ('for enabled only'). Should this use GetEnabledPairs instead?
| availablePairs, err := e.GetAvailablePairs(asset.Spot) | |
| availablePairs, err := e.GetEnabledPairs(asset.Spot) |
| } | ||
| if len(req.Pairs) == 0 { | ||
| allPairs, err := e.GetEnabledPairs(asset.Spot) | ||
| allPairs, err := e.GetAvailablePairs(asset.Spot) |
There was a problem hiding this comment.
This change from GetEnabledPairs to GetAvailablePairs means that calling GetActiveOrders without specifying pairs will now fetch orders for all pairs available on the exchange, not just the ones enabled in the user's configuration. While this is a 'get' request, it could still result in a large number of API requests. Is this the intended behavior?
|
@codex please review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e74f6a9c53
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if b.Config.CurrencyPairs.IsAssetAvailable(a) == nil { | ||
| enabledAsset = true |
There was a problem hiding this comment.
Preserve disabled-asset state when applying config pairs
In SetConfigPairs, enabledAsset is now derived from Config.CurrencyPairs.IsAssetAvailable(a) while iterating assetTypes := Config.CurrencyPairs.GetAssetTypes(false), so this condition is always true for every configured asset. As a result, SetAssetEnabled(a, enabledAsset) re-enables assets that were intentionally disabled in config, which breaks asset-level disablement after bootstrap/reload.
Useful? React with 👍 / 👎.
| case []ticker.Price: | ||
| if !m.syncer.IsRunning() { | ||
| return nil | ||
| } |
There was a problem hiding this comment.
Keep ticker cache updates for websocket ticker batches
The websocket routine no longer runs ticker.ProcessTicker for incoming *ticker.Price/[]ticker.Price, and now only performs sync bookkeeping here. That regression affects feeds that still emit raw ticker structs without pre-processing (notably GateIO option/futures websocket handlers), so those websocket ticker updates no longer refresh the global ticker cache and downstream GetTicker consumers can observe stale values.
Useful? React with 👍 / 👎.
PR Description
This is a more thorough version of #2159. If this is to be done, its to be done in a single PR with minimal changes.
Changes
ClassificationErrorbecause it should gowebsocketroutine_manager.goto spend less time processingWhat stays
Type of change