-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: Settlement contract balances get cached too long #2093
Labels
bug
Something isn't working
E:3.1 Driver Colocation
See https://github.com/cowprotocol/pm/issues/14 for details
Comments
MartinquaXD
added
bug
Something isn't working
E:3.1 Driver Colocation
See https://github.com/cowprotocol/pm/issues/14 for details
labels
Nov 28, 2023
Thinking about this again, this may actually be blocking launch since it would lead to wrong or significantly less internalisations on the solver side (which has a big impact on gas costs on mainnet production) |
My suggestion would be to use CurrentBlockStream and update a fixed amount of recently used and invalidate remaining balances (so that they get fetched when queried) whenever a new block arrives. |
2 tasks
fleupold
added a commit
that referenced
this issue
Dec 4, 2023
# Description Addresses the bug that we currently fetch settlement buffer balances once per token and don't update them in between auctions, which can lead to solutions relying on outdate internal buffer balance information and thus incorrectly marking interactions as internalizable causing simulation to fail. # Changes - [ ] Add an e2e showcasing the problematic behavior - [ ] Spawn a task when creating a new token fetcher, which on arrival of new blocks update the token balances of all cached tokens. This approach is a bit wasteful, as token balances only really change when a settlement trading this token is included on-chain. However, getting that information in this component is non-trivial. Moreover, some tokens exhibit custom balance logic (e.g. rebasing tokens) which could update the contract balance even without a settlement taking place. If we deem this approach too inefficient, I would suggest we restrict the number of tokens we cache (using an LRU cache) and re-fetch all relevant information (including decimals and symbol) in case of a cache miss. If we don't want to lose caching of decimals and symbols for some tokens, I'd suggest splitting the fetcher into two components, one for static information, and one more `RecentBlockCache` like component for the settlement balances. Let me know what you think. ## How to test Added an end to end test which fails without the changes in `driver::infra::tokens` ## Related Issues Fixes #2093
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Something isn't working
E:3.1 Driver Colocation
See https://github.com/cowprotocol/pm/issues/14 for details
Problem
For some solvers the driver has to provide some metadata (symbol, decimals, settlement contract balance).
This is already cached (nice) but at least the settlement contract balance should be updated on every new block.
Impact
We are reporting outdated token balances which can affect internal buffer trading optimizations.
Expected behaviour
The balance of every token in the balance should be the value at the current block when building the auction in the driver.
The text was updated successfully, but these errors were encountered: