-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
EEI: implement getReturnDataSize and returnDataCopy #80
Conversation
src/eei.cpp
Outdated
vector<uint8_t> result(call_result.output_data, call_result.output_data + call_result.output_size); | ||
result.resize(resultLength); | ||
storeMemory(result, 0, resultOffset, resultLength); | ||
lastReturnData.assign(call_result.output_data, call_result.output_data + call_result.output_size); |
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.
Is call not supposed to store output data at resultOffset anyway?
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.
There is no point doing that with returndata anymore. See ewasm/design#70
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.
But you are correct, perhaps I should separate these changes into two: supporting returndata and removing that option.
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.
Done, that will be a different PR.
src/eei.cpp
Outdated
@@ -401,6 +401,23 @@ namespace HeraVM { | |||
return Literal(); | |||
} | |||
|
|||
if (import->base == Name("returnDataSize")) { | |||
HERA_DEBUG << "returnDataSize\n"; | |||
return Literal((uint32_t)lastReturnData.size()); |
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.
Use static_cast
.
src/eei.cpp
Outdated
|
||
lastReturnData.assign(call_result.output_data, call_result.output_data + call_result.output_size); | ||
} else { | ||
lastReturnData.resize(0); |
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.
.resize(0)
===.clear()
.- You have to clear it unconditionally.
src/eei.h
Outdated
@@ -104,6 +104,7 @@ struct EthereumInterface : ShellExternalInterface { | |||
struct evm_context* context = nullptr; | |||
std::vector<uint8_t> const& code; | |||
struct evm_message const& msg; | |||
std::vector<uint8_t> lastReturnData = std::vector<uint8_t>(); |
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.
You need a default initializer only for "primitive" types.
@@ -475,6 +492,10 @@ namespace HeraVM { | |||
vector<uint8_t> result(call_result.output_data, call_result.output_data + call_result.output_size); | |||
result.resize(resultLength); | |||
storeMemory(result, 0, resultOffset, resultLength); | |||
|
|||
lastReturnData.assign(call_result.output_data, call_result.output_data + call_result.output_size); |
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 same goes for CREATE.
src/eei.cpp
Outdated
@@ -401,6 +401,23 @@ namespace HeraVM { | |||
return Literal(); | |||
} | |||
|
|||
if (import->base == Name("returnDataSize")) { |
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.
Should be getReturnDataSize
.
No description provided.