-
Notifications
You must be signed in to change notification settings - Fork 152
Make metrics based bad order detection order specific #4021
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
github unfortunately marks this whole file as new when it actually was actually just moved and modified slightly. The new parts are:
- added
last_seen_at - added
spawn_gc_task(and the associated unit test)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The refactoring/renaming should probably be separated from the logic changes to avoid this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This diff is much better https://www.diffchecker.com/iMNVcpf7/
jmg-duarte
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
Moved bad_token and bad_order detection as submodules to common The public facing api (Quality and the Detector) now reside inside of it. Then its submodules are Also removed the hand rolled current_unix_timestamp() in favour of now_in_epoch_seconds() |
|
I am now left wondering how should the configuration struct be called. It's currently named |
Suggestions:
|
We now have 2 detectors that live in different modules. Can we simply split their configs or do they share some config params? |
They could be split into two if there was not the common hardcoded token statuses: Here is the overall struct, I'll call it "DetectorConfig" to avoid confusion It could be split into 2 configs with the remaining field: I am inclined to leave it as-is, keeping the name as The Competition strategy uses the detector on an per-order basis to ask if it is unsupported. The underlying mechanism makes a decision based either on the token itself or on the specific order, which might be considered an implementation detail. Thus the Let's keep it as is and move forward with the PR. |
| account = "{account}" | ||
| merge-solutions = {merge_solutions} | ||
| quote-using-limit-orders = {quote_using_limit_orders} | ||
| enable-simulation-bad-token-detection = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this config still relevant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the simulation-bad-token-detection retains its previous name: https://github.com/cowprotocol/services/pull/4021/changes/BASE..1cdb7f81f9a4c2607acab68c108c39acd5307638#diff-892459cd473d2f4681aa36029b2d7967cac7604c93c0f780cb917dd597fd1719R839-R840
|
Thanks for the reviews. I will wait for @MartinquaXD to provide his thoughts as he is the original author and merge only then. |
MartinquaXD
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks alright to me. I like the discussion about proper naming and where to move stuff.
One more nit from my side: detector is a very generic name for the module. risk_detector would give the reader at least some information on what it's supposed to be.
BTW GH doesn't let me approve my own PR.
|
I'll change the detector naming to risk_detector and merge |
Description
Currently the bad token detection assumes that we are perfectly able to detect "broken" orders and only orders that trade specific tokens that a particular solver is not able to handle cause problems. However this assumption does not work well with the increasing complexity of new order types that can suddenly start failing for any number of reasons.
The most prominent recent example were flashloan orders where the EIP 1271 signature verified correctly but transferring the tokens into the settlement contract failed because the user's Aave debt position was not healthy enough.
Our current logic caused a lot of collateral damage because such orders could cause many reasonable tokens to be flagged as unsupported although the tokens themselves were perfectly fine and only that particular order was problematic.
Changes
To address this this PR change the metrics based detection mechanism to only flag on an order by order basis instead flagging all orders trading specific tokens. The change itself is relatively simple (collect metrics keyed by
Uidinstead of token`) but came with a few related changes:bad_token_detectionis now incorrect in most (but not all!) cases so many things were renamedHow to test
UidRelated issues
Fixes #4019