-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add A Balance Override Detector #3
Conversation
d7805e8
to
fc868c8
Compare
Let me summarise the strategy in my own words to see if I get it fully. This strategy generates a new unknown address as a test token In that case this strategy should be sufficient for faking balances for tokens with:
However, all of this still leaves me with a question about your example test. USDC is proxy contract that is verified on etherscan and your test suggests that the balances mapping is stored in the 10th storage slot. Wouldn't that mean the balances are stored in the wrapper proxy contract and not the implementation? Given that the proxy is verified on etherscan shouldn't we see the relevant variables there? |
Summary is correct.
The proxy contract does a This is important for proxy upgrades - if it were not a You essentially need to look at the implementation code (which AFAIU is also verified on Etherscan) to manually figure out the storage slot. |
This PR is a follow up to #3 in that it adds configuration and glue code for enabling the automatic token balance override detection introduced in the aforementioned PR. An E2E test was modified to include balance override tests for both configured and auto-detected tokens.
This PR is a follow up to #3 in that it adds configuration and glue code for enabling the automatic token balance override detection introduced in the aforementioned PR. An E2E test was modified to include balance override tests for both configured and auto-detected tokens.
fc868c8
to
6cf73ec
Compare
This PR is a follow up to #3 in that it adds configuration and glue code for enabling the automatic token balance override detection introduced in the aforementioned PR. An E2E test was modified to include balance override tests for both configured and auto-detected tokens.
723758d
to
83ae3bb
Compare
6cf73ec
to
0e32024
Compare
This PR is a follow up to #3 in that it adds configuration and glue code for enabling the automatic token balance override detection introduced in the aforementioned PR. An E2E test was modified to include balance override tests for both configured and auto-detected tokens.
This PR adds a balance override detector for quote verification. This allows The current implementation strategy is quite simple - just try a bunch of different slots and see which one works. For now, the number of slots to try is hardcoded at 25, but this can be configurable in the future. The component is marked with `#[allow(dead_code)]` as it isn't being used anywhere, In the interest of keeping the PR size down, I will add all of the glue code to make it used in a follow up (which will also test whether or not the detector works as expected). In the meantime, I did some local testing to check that it works with tokens for which I know the mapping slot on Ethereum Mainnet (test not included in the PR).
83ae3bb
to
f7fcfff
Compare
0e32024
to
df8f9ba
Compare
This PR is a follow up to #3 in that it adds configuration and glue code for enabling the automatic token balance override detection introduced in the aforementioned PR. An E2E test was modified to include balance override tests for both configured and auto-detected tokens.
This PR is a follow up to #3 in that it adds configuration and glue code for enabling the automatic token balance override detection introduced in the aforementioned PR. An E2E test was modified to include balance override tests for both configured and auto-detected tokens.
Superseded by cowprotocol#3148 |
This PR is a follow up to #3 in that it adds configuration and glue code for enabling the automatic token balance override detection introduced in the aforementioned PR. An E2E test was modified to include balance override tests for both configured and auto-detected tokens.
This PR is a follow up to #3 in that it adds configuration and glue code for enabling the automatic token balance override detection introduced in the aforementioned PR. An E2E test was modified to include balance override tests for both configured and auto-detected tokens.
Description
This PR adds a balance override detector for quote verification. This allows tokens to automatically support balance overrides without automatic configurations.
Changes
A new (but as of yet) unused component is added that can detect balance override strategies for tokens. The current implementation strategy is quite simple - just try a bunch of different slots and see which one works. For now, the number of slots to try is hard-coded at 25, but this can trivially be changed to be configurable in the future.
The component is marked with
#[allow(dead_code)]
as it isn't being used anywhere, In the interest of keeping the PR size down, I will add all of the glue code to make it used in a follow up (which will also test whether or not the detector works as expected).How to Test
In the meantime, I did some local testing to check that it works with tokens for which I know the mapping slot on Ethereum Mainnet (test not included in the PR):
This test successfully passes!