Skip to content
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

Ape's proxy detection requires many calls #2465

Open
fubuloubu opened this issue Jan 10, 2025 · 5 comments
Open

Ape's proxy detection requires many calls #2465

fubuloubu opened this issue Jan 10, 2025 · 5 comments
Labels
category: bug Something isn't working

Comments

@fubuloubu
Copy link
Member

fubuloubu commented Jan 10, 2025

Description

Every time Ape does a call via ContractCache.instance_at, it will do proxy detection logic, which requires (I think?) 6 different calls to perform:
eth_getStorageAt
eth_getStorageAt
eth_getStorageAt
eth_getStorageAt
eth_call
eth_getCode (this one is heavy)

Suggestions

Suggestion would be to look at optimizing that proxy detection into a single batched RPC call (if available), and potentially find another way to perform whatever eth_getCode is needed for, since that's a pretty heavy call

@fubuloubu fubuloubu added the category: bug Something isn't working label Jan 10, 2025
Copy link

linear bot commented Jan 10, 2025

@antazoey
Copy link
Member

Getting rid of the eth_getCode may be tricky, as 12 proxy checks happen by looking at the code

@fubuloubu
Copy link
Member Author

Getting rid of the eth_getCode may be tricky, as 12 proxy checks happen by looking at the code

As long as it is one call for all of those checks we are good. Another thing I noticed is that there are several eth_call checks on top of that, which could be done with a multicall

@0xthedance
Copy link
Contributor

I think that it would be great to get rid of eth_getCode for 2 reasons:

  • While I find the skip proxy feature in feat: ability to skip proxy detection #2470 a great improvement, there may still be sometimes where it's not used, and the byte code, which could be anything (up to the max of 24k of EIP-170, I guess), is unnecessarily fetched.
  • As seen in PR test: tests for nine more proxies #2467 , it's sometimes unreliable, as the bytecode can change due to different compiler version or optimization runs.

In my opinion we should get rid of all those hardcoded chunks of bytecode and do the check based on the specs of the code (which ABI they implement, etc). Doing that with a batched RPC call seems a good improvement too.

If you agree with that approach, I would be happy to take a stab at it, get rid of those bytecodes, join RPC calls and fix the failing tests in the aforementioned PR.

@fubuloubu
Copy link
Member Author

Doing that with a batched RPC call seems a good improvement too.

Noting that batched RPC support is being tracked here (#2472), and may be a prerequisite of improving this.

Please feel free to leave some design suggestions in that issue for batched RPC support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants