-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor balance override detection (#3239)
# Description With #3238 merged it now becomes apparent why we have such a poor quote verification ratio on arbitrum. All bridged tokens store their `balances` mapping at storage slot 51. # Changes To avoid having to merge another PR every time we find an important token that requires a deeper probing depth I made the probing depth controllable via a CLI parameter. While I was at it I did the same for the token cache size (should have been like that from the start given that the change was trivial with the given architecture). Making the probing depth runtime dependent made using static variables a lot more annoying. Instead I created an `Inner` struct which contains all the static data so now it can be initialized once at runtime without more exotic types like `LazyLock` or `OnceLock`. As long as we ensure that only 1 instance of `Detector` gets created this would be equivalent in terms of memory usage and performance. I also refactored the logic that constructs the strategy list. It should now be dead simple to see what's going on and how to extend it. First we hardcode a list of known non-variable storage slots and afterwards we probe the first N slots starting from known entry points. This is currently just the 0th slot but could theoretically be extended with other relevant slots. Even if it doesn't get extended I think the refactor still makes the code easier. ## How to test e2e tests and units tests still work also added another unit test for a bridged token on arbitrum
- Loading branch information
1 parent
395d605
commit df6306c
Showing
2 changed files
with
126 additions
and
64 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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