shazow / whatsabi

Extract the ABI (and other metadata) from Ethereum bytecode, even without source code.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

proxies: Load additional candidates from recent transactions?

SonOfMosiah opened this issue · comments

Failed to get function selector from proxy: 0x54e3f31b

Nice, thank you! I'm going to be sprinting on these next week I think, but might get to it earlier.

Okay, had some time to investigate what's going on here: They have their own custom proxy, selectors are set in setImplementation but the selector gets stored in an internal mapping(bytes4 => address) internal selectorVsRouter and unlike DiamondProxy there is no array of registered selectors that we can enumerate.

Which is to say, aside from the ABI uploaded to Etherscan, there's no plain-RPC way to determine which selectors have been registered (unless we have an archival node then we could try to find all of the calls to setImplementation).

That is to say, I don't think whatsabi will be able to resolve these proxy selectors blind, but whatsabi should be capable of fetching the uploaded ABI.

Looks like the mistake is when whatsabi.autoload detects that there's a proxy, it goes into code-based detection rather than still checking if there's an ABI to fetch. (Are uploaded ABIs always include the proxy? I feel like they often don't? What's the correct behaviour here for autoload?)

Actually, the proxy selectors aren't in the ABI (since otherwise it would violate the verification).

So Etherscan must be grabbing selectors from recent transactions. I could add a helper for that, but not sure if it's a good idea for default behaviour?