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

feat: when deserialization of module from filesystem cache fails, remove from cache #138

Merged
merged 15 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions crates/common/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ pub enum WasmErrorInner {
/// Wasmer failed to build a Module from wasm byte code.
/// With the feature `wasmer_sys` enabled, building a Module includes compiling the wasm.
ModuleBuild(String),
/// Wasmer failed to serialize a Module to bytes.
ModuleSerialize(String),
/// Wasmer failed to deserialize a Module from bytes.
ModuleDeserialize(String),
Copy link
Member Author

Choose a reason for hiding this comment

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

Additional error types for clarity

/// The host failed to call a function in the guest.
CallError(String),
/// Host attempted to interact with the module cache before it was initialized.
UninitializedSerializedModuleCache,
}

impl WasmErrorInner {
Expand All @@ -51,12 +53,12 @@ impl WasmErrorInner {
| Self::ErrorWhileError
// Bad memory is bad memory.
| Self::Memory
// Failing to build the wasmer Module means we cannot use it.
// Failing to build, serialize, or deserialize the wasmer Module means we cannot use it.
| Self::ModuleBuild(_)
| Self::ModuleSerialize(_)
| Self::ModuleDeserialize(_)
// This is ambiguous so best to treat as potentially corrupt.
| Self::CallError(_)
// We have no cache so cannot cache.
| Self::UninitializedSerializedModuleCache
=> true,
// (De)serialization simply means some input/output data was
// unrecognisable somehow, it doesn't corrupt the guest memory.
Expand Down
11 changes: 7 additions & 4 deletions crates/host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ version = "0.0.97"
authors = ["thedavidmeister", "[email protected]"]
edition = "2021"

[lib]
name = "holochain_wasmer_host"
crate-type = ["cdylib", "rlib"]
path = "src/lib.rs"

[dependencies]
wasmer = { version = "5.0.2", default-features = false }
wasmer-middlewares = { version = "5.0.2", optional = true }
Expand All @@ -20,10 +25,8 @@ bytes = "1"
hex = "0.4"
thiserror = "2"

[lib]
name = "holochain_wasmer_host"
crate-type = ["cdylib", "rlib"]
path = "src/lib.rs"
[dev-dependencies]
tempfile = "3.14.0"

[features]
default = ["error_as_host", "wasmer_sys_dev"]
Expand Down
Loading
Loading