Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Refactor ABI encoder #1723
What I did
Refactor the ABI encoder/decoder so that the code is clearer and more extensible. This should make it easier to implement ABI-related features.
There's still a lot to do (ultimately I want to replace our entire calling convention and event generation code with abi_encode/abi_decode, for now it's just returndata with abi_encode) but it's at a good self-contained stage where we can review and move further work into another PR. Tote that abi_decode and lazy_abi_decode are unused right now but they will be useful in the future.
How I did it
See commit messages and inline comments
How to verify it
Description for the changelog
Refactor ABI encoder for return data.
Cute Animal Picture
leaf bytes are encoded as-is (+ padding), tuples with child bytes are encoded <ofst> <len> <data>.
make_return_stmt jumps out of the with statement, leaving the with variables on the stack (when they shouldn't be).
The idea is that in a lot of cases (e.g. decoding calldata), we don't actually need to copy the data from the abi-encoded buffer into a destination buffer, but instead we can "leave it where it is" and instead just generate loader statements for the data.
this is ready for a look over. there's still a lot to do (ultimately i want to replace our entire calling convention and event generation code with abi_encode/abi_decode and now it's just generating returndata with abi_encode) but it's at a good self-contained stage where we can review and move further work into another PR. note that
fubuloubu left a comment
Gave it a first pass. Overall, looks very promising.
I would like the use of more descriptive variable names in the codegen modules. Obviously needs a series of test cases. Also, if it's not too much trouble, add typing to it.