Optimizer: cap chain reads of competitor quotes with chain_read_min_secs (optimizer.json, default 600s) - #735
Merged
Merged
Conversation
…d_min_secs (optimizer.json, default 600), so a flapping feed can't spend the Helius budget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #734. That PR added a chain read of competitor quotes (
getProgramAccountsper managed direction, 10 Helius credits each, about 21 credits per read) after every re-seed. Only the reads triggered by an API disagreement were rate-limited.The risk: a re-seed can happen once per 60 s tick. If Helius drops the optimizer's websocket every minute (a throttled or flaky free key is exactly when that happens), the optimizer would do a chain read every minute: about 30k credits a day, over 1M a month from this read alone. That's the whole free tier, and the base miner's swap feed shares the same key.
The change:
chain_read_min_secs. That covers reads after a re-seed, reads triggered by an API disagreement, and retries.chain_read_min_secsis a newoptimizer.jsonkey, default 600, must be >= 0.Tests
test_a_feed_that_drops_every_minute_reads_the_chain_once_per_limit. Reconnects every tick for 16 minutes read the chain twice (at 0 and 10 minutes); with a configured 300 s limit, they read every 5 minutes.chain_read_min_secsand rejecting a negative value.pytest: full suite passes.