Comments (7)
Started a WIP PR in #14, here are the vibes so far (from PR):
Still in the research phase, trying to find a way to detect output sizes but that's looking harder than I hoped.
It looks like modern solidity wraps most outputs through a chain of jumps that prepares the data. It's going to be quite hard to do this with a single-pass static analysis.
Older solidity (e.g. WETH contract with v0.4.x) does a simpler return macro per function window, those aren't hard to detect but extracting sizing reliably still seems hard.
Also I thought it'd be easier to detect address type outputs because they're 20 bytes rather than the usual 32, but I forgot that things get padded so it still ends up being 32 bytes.
I probably need to sleep on this in case there's other clever solutions but not looking great for single-pass static analysis right now. 😅
from whatsabi.
Updated the current state and challenges in the issue description, going to pass it around to some folks to see if anyone else has ideas. Feel free to re-share. :)
from whatsabi.
I just merged a branch which does more advanced static analysis into master, haven't done a release yet.
In some cases, it manages to successfully guess whether there are inputs or outputs (not super reliable, I'd say like... 60%?), but there have been major changes behind the scenes with how the static analysis works so we can do more advanced things moving forward.
Also we now have stateMutability
included in the ABI, which is reliable in detecting payable functions, but not reliable in distinguishing nonpayable vs view yet.
Would appreciate some testing and feedback before I do a proper release. :)
from whatsabi.
I'm assuming the RETURN
opcode with non-zero size will indicate if a function returns a value, but relying on that means we'd need to construct instruction ranges for each function (should be possible assuming the selector table yields back-to-back functions). [Update: This looks fine]
On the upside, that should be sufficient to give us the return size, which is often a good proxy for guessing what the type is (e.g. 160 bits -> probably address). [Update: This is false]
from whatsabi.
Using the dummy output value of [{type:"byte32"}]
seem to work to get at least a "readable" value for uint256
and address
types. string
, gets butchered and probably tuples etc. as well.
from whatsabi.
If a function returns a size that is larger than bytes32
, what's a good strategy for returning an undecoded type to fit it? Like say it's 32+16+32 = 80 bytes (but we don't know the layout, we just see 80 bytes). Naive approach feels like returning 32,32,16 (basically binpacking from largest to smallest). Is there something better we could do?
Or maybe it's better to just use string
type for anything >32?
from whatsabi.
Next release issue is here: #18
from whatsabi.
Related Issues (20)
- cli: bin/autoload.ts tool
- proxies: Load possible selectors from DiamondProxies HOT 2
- refactor: Add more types and make peer library agnostic HOT 3
- upstream: Add whatsabi support to Safe tx-builder app
- Invalid JSON output: keys and values missing double quotes HOT 3
- Add empty "name" keys to ABI results HOT 3
- Two bugs we encountered during our usage HOT 3
- Some proxies failed to resolve. HOT 2
- Publish generated documentation
- autoload: Behave on non-contract address
- Accuracy and speed results from EVMole benchmark HOT 2
- proxy: Resolve EIP-1967 transparent proxy with custom slot
- disasm: Add selectors-only escape hatch HOT 1
- bug test case: eth:0x000000000090d2b159528c290616CF919B24e1d9 HOT 2
- Pass an optional baseUrl or chainId to defaultWithApiKeys HOT 2
- Option to call etherscan's `getsourcecode` instead of `getabi` HOT 8
- Add an example env HOT 2
- disasm: Consider using evmole as an optional backend? HOT 16
- Some contracts return [0x00000001, 0x00000002] selectors HOT 1
- proxies: Load additional candidates from recent transactions? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from whatsabi.