-
Notifications
You must be signed in to change notification settings - Fork 85
EVM: Implement reverts correctly #864
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
Conversation
7a1228b
to
da1cc9f
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## next #864 +/- ##
==========================================
- Coverage 87.32% 87.31% -0.02%
==========================================
Files 125 125
Lines 22784 22896 +112
==========================================
+ Hits 19897 19991 +94
- Misses 2887 2905 +18
|
A::invoke_method(self, method_num, params) | ||
})) | ||
.unwrap_or_else(|panic| { | ||
if self.actor_exit.borrow().is_some() { |
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.
Let's instead embed the exit inside the error, and cast with https://doc.rust-lang.org/std/any/trait.Any.html#method.downcast. That way, we can't accidentally swallow up a real panic.
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.
Basically, we can use panic to "throw" the exit value.
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.
Does this even make sense here?
We set the exit and immediately panic, which lands here; any other panic will be resumed. So the mentioned condition is not really possible, and it is nicer to the eye in tests since cargo will still report these panics at runtime in the console.
Now, if this was prod code, i would definitely consider the fancy way.
Here, i dont think it adds anything but complexity, really.
Having said all that, if you feel overly strongly about that and insist, i will abide.
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.
Eh, you're right. There's little benefit.
precompiles::Precompiles::call_precompile(system.rt, dst, input_data) | ||
.map_err(|_| StatusCode::PrecompileFailure)? | ||
match precompiles::Precompiles::call_precompile(system.rt, dst, input_data) | ||
.map_err(|_| StatusCode::PrecompileFailure) |
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.
This will need to be re-done when merging with #861, since there are cases where we want to return to a status code error and others where we have a precompile error
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.
Sure, i'll leave that up to you.
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.
Well, it has already been merged.
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.
Yeah i noticed. I will rebase and we can discuss what do here when we are happy with the rest.
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.
ok, merged, very little to do here other than resolve the conflict.
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.
LGTM!
@@ -634,7 +639,7 @@ pub fn trampoline<C: ActorCode>(params: u32) -> u32 { | |||
let mut rt = FvmRuntime::default(); | |||
// Invoke the method, aborting if the actor returns an errored exit code. | |||
let ret = C::invoke_method(&mut rt, method, ¶ms) | |||
.unwrap_or_else(|err| fvm::vm::abort(err.exit_code().value(), Some(err.msg()))); | |||
.unwrap_or_else(|err| fvm::vm::exit(err.exit_code().value(), err.data(), Some(err.msg()))); |
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.
nice catch!
nested call revert should go in integration test, really
9c4e443
to
3f91e75
Compare
rebased on next to merge the precompile/callactor work and did a very minor dedup simplification in 3f91e75. |
Adjust implementation so that
TBD:
Notes:
reverts for direct invocations are tested with a unit test; reverts in nested invocations are tested with the callvariants test in the integration test suite.