-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[WIP] Struct encoder #2433
[WIP] Struct encoder #2433
Conversation
values[i]["i"] = to_string(i); | ||
values[i]["headPos"] = to_string(headPos); | ||
headPos += _targetTypes[i]->calldataEncodedSize(); | ||
string encodingFuctionName = _givenTypes[i]->identifier() + "_TO_" + _targetTypes[i]->identifier(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function uses lowercase _to_
. Actually this isn't even used, wouldn't a list suffice?
Please rebase to use Whiskers 😉 |
cf1a667
to
705053a
Compare
Only fails 105 out of 422 end to end test! :-) |
Down to 69 |
@@ -180,6 +181,14 @@ void CompilerUtils::encodeToMemory( | |||
t = t->mobileType()->interfaceType(_encodeAsLibraryTypes)->encodingType(); | |||
} | |||
|
|||
if (_givenTypes.empty()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we merge this optimisation right now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optimizer (if not the peephole optimizer) will fix that, but yes, I can try to extract it.
@@ -311,7 +311,7 @@ void ContractCompiler::appendCalldataUnpacker(TypePointers const& _typeParameter | |||
{ | |||
// stack: v1 v2 ... v(k-1) base_offset current_offset | |||
TypePointer type = parameterType->decodingType(); | |||
solAssert(type, "No decoding type found."); | |||
solUnimplementedAssert(type, "No decoding type found."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps take this with the other change too (in general I like those specific solUnimplementedAssert
s better from a user's perspective).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this has to be an assert in current develop, I changed it to an unimplemented because of the new struct types.
Please rebase. |
a7e0193
to
dfd5aba
Compare
Down to 61 errors in SolidityEndToEndTests. |
By the way, an example encoder now looks as follows:
I.e. it has very detailed "convert" and "cleanup" calls which makes it very visible what happens and those can also probably be easily inlined. |
59! |
24! |
14! |
Only one failing test left, but this is due to the fact that we do not use Still, more test coverage is needed. |
Oh and it turns out, the storage-to-ABI-encoder is actually used, but it seems there are only few tests for it. |
test/ExecutionFramework.h
Outdated
@@ -287,7 +287,7 @@ class ExecutionFramework | |||
Address m_contractAddress; | |||
u256 m_blockNumber; | |||
u256 const m_gasPrice = 100 * szabo; | |||
u256 const m_gas = 100000000; | |||
u256 m_gas = 100000000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this modified?
Can you pull the tests which should succeed on the current encoder into a separate PR and merge them first? |
Currently, we can only reduce duplication if all encoders are handled in a single pass of the JULIA parser, because only then we can have different JULIA functions referencing themselves. This is only possible if the ABI encoder has a label we can jump to. This requires the following refactorings:
Each call to
encodeToMemory
has to be changed to an actual function call and for that, the return label has to be put onto the stack before the values to encode are put onto the stack.Furthermore, we have to have a way to reference a label in a piece of JULIA code from outside of that JULIA code and this also has to be possible before that code is even parsed.
I think the best solution to this problem is to provide a string as a hint to
AbstractAssembly::newLabelID
so that the EVM assembly can specially prepare some label ids to be linked properly.Depends on #1673 and #2704.