-
Notifications
You must be signed in to change notification settings - Fork 142
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
feat: fvm-wasm-instrument stack limiter and gas #494
Conversation
This looks like the correct approach, but do we need to do any pre-validation first? |
3cab1fa
to
0e5d64c
Compare
Depends on filecoin-project/fvm-wasm-instrument#3 |
28d64ed
to
7ca7a63
Compare
2528ed8
to
7774b8e
Compare
597dde3
to
8dca7b7
Compare
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.
partial review
244b69b
to
905edf3
Compare
c5b660b
to
5c108f3
Compare
Related ffi PR: filecoin-project/filecoin-ffi#273 |
b28b727
to
1e06f7b
Compare
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.
nits, but the logic LGTM.
@@ -55,23 +104,20 @@ pub fn default_wasmtime_config() -> wasmtime::Config { | |||
// > not enabled by default. | |||
c.cranelift_nan_canonicalization(true); | |||
|
|||
// c.cranelift_opt_level(Speed); ? | |||
// Set to something much higher than the instrumented limiter. | |||
c.max_wasm_stack(64 << 20).unwrap(); |
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.
TODO: make sure this doesn't force us to allocate 64MiB per container.
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 this just a backstop? Why do we need it? I guess because it can't be disabled entirely?
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, the default is 512k
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.
As far as I can tell wasm execution uses the native stack - when this is set to a high value the out_of_stack test will fail with:
thread 'out_of_stack' has overflowed its stack
fatal runtime error: stack overflow
Given that, I don't think we're allocating here
let out = syscall(ctx $(, $t)*).into(); | ||
|
||
let result = match out { |
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.
I think we can re-combine these lines now.
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.
(We'll split them again if we merge #465.)
let (mut memory, mut data) = memory_and_data(&mut caller)?; | ||
let ctx = Context{kernel: &mut data.kernel, memory: &mut memory}; | ||
let result = match syscall(ctx $(, $t)*).into()? { | ||
Ok(_) => { | ||
let out = syscall(ctx $(, $t)*).into(); | ||
|
||
let result = match out { | ||
Ok(Ok(_)) => { | ||
log::trace!("syscall {}::{}: ok", module, name); | ||
data.last_error = None; | ||
0 | ||
Ok(0) | ||
}, | ||
Err(err) => { | ||
Ok(Err(err)) => { | ||
let code = err.1; | ||
log::trace!("syscall {}::{}: fail ({})", module, name, code as u32); | ||
data.last_error = Some(backtrace::Cause::new(module, name, err)); | ||
code as u32 | ||
Ok(code as u32) | ||
}, | ||
Err(e) => Err(e.into()), | ||
}; |
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.
I would consider wrapping all of this in a closure (and immediately calling it) to make trapping errors a bit easier.
(NetworkVersion::V14, actors_v6::BUNDLE_CAR), | ||
(NetworkVersion::V15, actors_v7::BUNDLE_CAR), | ||
(NetworkVersion::V16, actors_v7::BUNDLE_CAR), // todo bad hack |
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 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.
I guess this is because we still don't have a release for v8.
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, the integration test runner needs a bundle to load, even if we don't use any actor code. Ideally we could run integration tests without actor bundles - that would also make those tests run much faster.
Co-authored-by: raulk <raul@protocol.ai> Co-authored-by: Steven Allen <steven@stebalien.com>
95d1f37
to
ea08252
Compare
No description provided.