-
Notifications
You must be signed in to change notification settings - Fork 93
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 #3148
Add A Balance Override Detector #3148
Conversation
# Description This PR adds a balance override detector for quote verification. This allows tokens to automatically support balance overrides without manual configurations. # Changes A new (but as of yet) unused component is added that can detect balance override strategies for tokens. The current implementation 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): ```rust async fn temporary_test() { let web3 = Arc::new(ethrpc::Web3::new(ethrpc::create_test_transport( "https://eth.llamarpc.com", ))); let detector = Detector::new(web3); let result = detector .detect(addr!("A0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48")) .await; println!("{result:?}"); assert!(matches!(result, Ok(Strategy::Mapping { slot }) if slot == U256::from(9_u8))); } ``` This test successfully passes!
Reposting @MartinquaXD's comment for additional context for others:
And my answer:
|
Description
This PR adds a balance override detector for quote verification. This allows tokens to automatically support balance overrides without manual configurations.
Changes
A new (but as of yet) unused component is added that can detect balance override strategies for tokens. The current implementation 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!