Skip to content
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

Merged
merged 2 commits into from
Jan 17, 2018
Merged

Conversation

axic
Copy link
Member

@axic axic commented Jan 16, 2018

No description provided.

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);
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member Author

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.

Copy link
Member Author

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());
Copy link
Collaborator

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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. .resize(0) === .clear().
  2. 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>();
Copy link
Collaborator

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);
Copy link
Collaborator

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")) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be getReturnDataSize.

@axic axic changed the title EEI: implement returnDataSize and returnDataCopy EEI: implement getReturnDataSize and returnDataCopy Jan 17, 2018
@axic axic merged commit 220bcac into master Jan 17, 2018
@axic axic removed the in progress label Jan 17, 2018
@axic axic deleted the eei-returndata branch January 17, 2018 12:32
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants