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

Handle gas allocation robustly #168

Open
JakeOShannessy opened this issue Jun 14, 2019 · 3 comments
Open

Handle gas allocation robustly #168

JakeOShannessy opened this issue Jun 14, 2019 · 3 comments
Labels
S-blocked Status: marked as blocked ❌ on something else such as an RFC or other implementation work. T-ewasm Target system: Ethereum Wasm

Comments

@JakeOShannessy
Copy link
Contributor

As part of a syscall (or any call) we usually pass the value of the GAS call, which is equivalent to allowing the called contract to use as much of the remaining gas as it needs. When performing a CALL in EVM this was quite easy, as the GAS call was the last instruction executed before performing the call. When comping to WASM this isn't quite as simple, as we can't guarantee that it is the final instruction called.

Currently, there are a few instances of GAS - SomeValue to allow some leftover gas to complete other instructions. This is not a robust way to do this and we should find alternatives.

@Latrasis Latrasis added S-blocked Status: marked as blocked ❌ on something else such as an RFC or other implementation work. T-ewasm Target system: Ethereum Wasm labels Jun 14, 2019
@JakeOShannessy
Copy link
Contributor Author

I have a solution for this. We can use the same mechanism as cap9_syscall_low and introduce cap9_maxgas_call_code and the like. In the same way we can control the exact instructions deployed and make sure that exactly all the remaining gas is used.

@Latrasis
Copy link
Member

Latrasis commented Jun 21, 2019

I have a solution for this. We can use the same mechanism as cap9_syscall_low and introduce cap9_maxgas_call_code and the like. In the same way we can control the exact instructions deployed and make sure that exactly all the remaining gas is used.

Would this still be feasible for validation?

@JakeOShannessy
Copy link
Contributor Author

In that particular case it's only for the kernel, so we don't have to run it through the validation code.

For procedures we have defined syscalls in such a way that handles this already, we just have to make sure the values are correct, which I failed to do in #178 it seems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-blocked Status: marked as blocked ❌ on something else such as an RFC or other implementation work. T-ewasm Target system: Ethereum Wasm
Projects
None yet
Development

No branches or pull requests

2 participants