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

EVM-C: better error reporting in evm_call_fn #86

Closed
3 tasks done
axic opened this issue Aug 25, 2016 · 19 comments
Closed
3 tasks done

EVM-C: better error reporting in evm_call_fn #86

axic opened this issue Aug 25, 2016 · 19 comments
Assignees

Comments

@axic
Copy link
Member

axic commented Aug 25, 2016

We could consider how much of the evm_result / evm_result_code should/could be shared with evm_call_fn.

  • Check against EIP 5: Gas costs for return values EIPs#8.
  • Move the result_release() function to evm_result (as a pointer to function) to allow VM compositing and results from different VMs. It will work like C++ virtual destructor.
  • Use evm_result as the output of evm_call_fn().
@chfast chfast mentioned this issue Aug 25, 2016
12 tasks
@axic axic mentioned this issue Aug 28, 2016
2 tasks
@chfast
Copy link
Member

chfast commented Aug 28, 2016

I can propose to extend the return value of evm_call_fn to pair of result code and gas left. The output is passed differently so not point to having it there.

The error codes would be: "call depth limit reached", "insufficient funds" + codes we have in evm_result_code already.

However, I'm not convinced that would provide any addition value to the VM. What is the VM supposed to do with this error code? The user already knows about it because it provides it. Moreover, calls are in general a big mess, because it is not clear who (the VM or the user) is responsible to check which call preconditions.

@axic
Copy link
Member Author

axic commented Aug 31, 2016

I can propose to extend the return value of evm_call_fn to pair of result code and gas left.

I think this would be a good trade off as a start.

However, I'm not convinced that would provide any addition value to the VM. What is the VM supposed to do with this error code?

In eWASM it is possible to return these error codes back to the contract.

@chfast
Copy link
Member

chfast commented Sep 1, 2016

Can't you use output for passing errors?

@axic
Copy link
Member Author

axic commented Sep 1, 2016

I would rather not make it any more messy than it already is.

@chfast
Copy link
Member

chfast commented Sep 5, 2016

I was thinking a bit more about this issue.

How about returning evm_result and leaving output copy to the VM instead of the user / the API wrapper. That would be very consistent with the evm_execute.

However, there is one drawback: evm_result points external resources and they must be released. There is no problem if the evm_result comes from the same VM, but it can also be produced by other VM implementation.

@chfast
Copy link
Member

chfast commented Sep 14, 2016

I will need to proceed with this one now, because it turned out the current design might be not enough.

What do you think about putting the pointer to result_release() function in the evm_result struct itself. The releasing would look like:

evm_result result = ...
result.release(&result);

It will work like virtual destructor in C++.

@axic
Copy link
Member Author

axic commented Sep 14, 2016

@chfast should be fine.

Does it needs to be specific for call vs. tx and single release cannot be reused?

@chfast
Copy link
Member

chfast commented Sep 14, 2016

Single release will not work if you want to compose VMs. E.g. in one VM you have a call result coming from some other VM.

@axic
Copy link
Member Author

axic commented Sep 14, 2016

@chfast I see, it's fine having it in the struct.

@chfast
Copy link
Member

chfast commented Sep 28, 2016

How the evm_result should work for CREATE?

@chfast
Copy link
Member

chfast commented Sep 28, 2016

Returning evm_result should be perfect for ethereum/EIPs#8.

@axic
Copy link
Member Author

axic commented Oct 15, 2016

How the evm_result should work for CREATE?

This was added 5936db8.

@chfast is anything left to be done on this issue?

@chfast
Copy link
Member

chfast commented Oct 17, 2016

After this change Python gave up on this struct :). And there are a lots of issues in go. But last night I had an idea to split the CREATE to "code eval" and "create account" parts. It might work.

@axic
Copy link
Member Author

axic commented Oct 18, 2016

Are they having an issue with unions? Wouldn't a simple solution like removing the union and just having those 3 as members of the result struct work?

@chfast
Copy link
Member

chfast commented Oct 18, 2016

It would, but I'm trying to keep the structs within 64 bytes to fit in the cache line.

@axic
Copy link
Member Author

axic commented Oct 18, 2016

Since create_address is ultimately uint8_t bytes[20]; you could have a simple helper for consumers of evm.h to convert output_data to create_address.

@chfast
Copy link
Member

chfast commented Apr 26, 2017

I'm about to make the last change in the EVM-C by changing

int64_t evm_call_fn(struct evm_env* env, const struct evm_message* msg, uint8_t* output, size_t output_size);

to

void evm_call_fn(struct evm_result* result, struct evm_env* env, const struct evm_message* msg);

In case of CREATE, the host application should allocate 20 bytes of dynamic memory to pass the address of the created account.

But I need #112 first.

@chfast chfast self-assigned this Apr 26, 2017
@chfast chfast added the planned label Apr 26, 2017
@chfast
Copy link
Member

chfast commented May 22, 2017

This is addressed in #118.
But it creates a little weird combination of status codes (SUCCESS, FAILURE, REVERT) and output data. Sometimes output comes from EVM spec, sometimes it contains additional error message from an EVM implementation. So handling the result struct becomes tricky because you have to decide what kinds of outputs are for end users and what for EVM subcalls.

@axic
Copy link
Member Author

axic commented Aug 18, 2017

@chfast I think we could consider this finished now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants