Skip to content

Commit a3d3f8a

Browse files
chore(Grove): Update Rust dependencies and refine WASM error handling
This commit performs a major dependency upgrade cycle for the Grove Element, updating core crates to their latest stable versions for improved performance and security. Key updates include tokio 1.35→1.49, wasmtime 20→42, tonic/tonic-build 0.11→0.12, and the opentelemetry stack (0.23→0.31). The nix dependency and ipc feature flag were removed as they are no longer required. Additionally, the WASM runtime error handling in ModuleLoader.rs and Runtime.rs has been refined to use direct anyhow conversion instead of the context pattern, providing more precise error messages while maintaining the same error semantics. The build.rs script includes a TODO noting the downgrade of vergen from 9.x to 8.x to maintain API compatibility, along with a fix for tonic-build's API change (compile → compile_protos).
1 parent 1bf695d commit a3d3f8a

4 files changed

Lines changed: 46 additions & 54 deletions

File tree

Cargo.toml

Lines changed: 36 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -19,68 +19,51 @@ name = "grove"
1919
path = "Source/main.rs"
2020

2121
[dependencies]
22-
# Async runtime
23-
tokio = { version = "1.35", features = ["full"] }
22+
tokio = { version = "1.49", features = ["full"] }
2423
tokio-util = { version = "0.7", features = ["codec"] }
25-
26-
# WASM runtime
27-
wasmtime = { version = "20", features = ["async", "component-model", "runtime", "cranelift"], optional = true }
28-
wasmtime-wasi = { version = "20", optional = true }
29-
wasmparser = { version = "0.218", optional = true }
30-
31-
# gRPC
24+
wasmtime = { version = "42", features = [
25+
"async",
26+
"component-model",
27+
"runtime",
28+
"cranelift",
29+
], optional = true }
30+
wasmtime-wasi = { version = "42", optional = true }
31+
wasmparser = { version = "0.245", optional = true }
3232
prost = { version = "0.12", optional = true }
33-
tonic = { version = "0.11", features = ["tls"], optional = true }
34-
tonic-build = "0.11"
35-
36-
# Serialization
33+
tonic = { version = "0.12", optional = true }
34+
tonic-build = "0.12"
3735
serde = { version = "1.0", features = ["derive"] }
3836
serde_json = "1.0"
3937
serde_bytes = "0.11"
40-
41-
# Error handling
4238
anyhow = "1.0"
43-
thiserror = "1.0"
44-
45-
# tracing/logging
39+
thiserror = "2.0"
4640
tracing = "0.1"
4741
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }
48-
49-
# CLI
50-
clap = { version = "4.4", features = ["derive"] }
51-
52-
# Utilities
53-
bytes = { version = "1.5", features = ["serde"] }
42+
clap = { version = "4.5", features = ["derive"] }
43+
bytes = { version = "1.11", features = ["serde"] }
5444
futures = "0.3"
5545
async-trait = "0.1"
5646
semver = "1"
5747
chrono = "0.4"
58-
59-
# Additional missing dependencies
60-
uuid = { version = "1.8", features = ["v4", "serde"] }
48+
uuid = { version = "1.21", features = ["v4", "serde"] }
6149
shellexpand = "3.1"
62-
reqwest = { version = "0.11", features = ["json"], optional = true }
50+
reqwest = { version = "0.13", features = ["json"], optional = true }
6351
base64 = "0.22"
52+
metrics = "0.24"
53+
metrics-exporter-prometheus = { version = "0.18", optional = true }
54+
opentelemetry = { version = "0.31", default-features = false, features = [
55+
"trace",
56+
], optional = true }
57+
opentelemetry-otlp = { version = "0.31", features = [
58+
"grpc-tonic",
59+
], optional = true }
60+
opentelemetry-semantic-conventions = { version = "0.31", optional = true }
61+
tracing-opentelemetry = { version = "0.32", optional = true }
6462

65-
# Metrics
66-
metrics = "0.23"
67-
metrics-exporter-prometheus = { version = "0.13", optional = true }
68-
69-
# OTEL Tracing
70-
opentelemetry = { version = "0.23", default-features = false, features = ["trace"], optional = true }
71-
opentelemetry-otlp = { version = "0.16", features = ["grpc-tonic"], optional = true }
72-
opentelemetry-semantic-conventions = { version = "0.15", optional = true }
73-
tracing-opentelemetry = { version = "0.24", optional = true }
74-
75-
# IPC (for macOS/Linux)
76-
[target.'cfg(unix)'.dependencies]
77-
nix = { version = "0.27", optional = true }
78-
79-
# Protocol buffers (build-only)
8063
[build-dependencies]
81-
tonic-build = "0.11"
64+
tonic-build = "0.12"
8265
anyhow = "1.0"
83-
vergen = { version = "8.3", features = ["build", "cargo", "git", "gitcl", "rustc", "si"] }
66+
vergen = { version = "8", features = ["build", "cargo", "rustc"] }
8467

8568
[profile.release]
8669
opt-level = 3
@@ -103,8 +86,13 @@ strip = "debuginfo"
10386
default = ["grpc", "wasm"]
10487
grpc = ["tonic", "prost"]
10588
wasm = ["wasmtime", "wasmtime-wasi", "reqwest", "wasmparser"]
106-
ipc = ["nix"]
107-
telemetry = ["opentelemetry", "opentelemetry-otlp", "opentelemetry-semantic-conventions", "tracing-opentelemetry", "metrics-exporter-prometheus"]
89+
telemetry = [
90+
"opentelemetry",
91+
"opentelemetry-otlp",
92+
"opentelemetry-semantic-conventions",
93+
"tracing-opentelemetry",
94+
"metrics-exporter-prometheus",
95+
]
10896
dev = ["telemetry"]
10997
debug = ["dev"]
110-
all = ["grpc", "wasm", "ipc", "telemetry"]
98+
all = ["grpc", "wasm", "telemetry"]

Source/WASM/ModuleLoader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ impl ModuleLoaderImpl {
235235
// Instantiate
236236
let instance = linker
237237
.instantiate(&mut store, module)
238-
.context("Failed to instantiate WASM module")?;
238+
.map_err(|e| anyhow::anyhow!("Failed to instantiate WASM module: {}", e))?;
239239

240240
let instance_id = generate_instance_id();
241241

Source/WASM/Runtime.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl WASMRuntime {
119119
// Build the WASMtime engine
120120
let engine_config = wasmtime::Config::new();
121121
let engine_config = config.apply_to_engine_builder(engine_config)?;
122-
let engine = Engine::new(&engine_config).context("Failed to create WASMtime engine")?;
122+
let engine = Engine::new(&engine_config).map_err(|e| anyhow::anyhow!("Failed to create WASMtime engine: {}", e))?;
123123

124124
// Initialize memory manager
125125
let memory_limits = MemoryLimits {
@@ -164,7 +164,7 @@ impl WASMRuntime {
164164
if self.config.enable_fuel_metering {
165165
// Set fuel based on execution time (rough approximation: 1 unit = 1000 ns)
166166
let fuel = self.config.max_execution_time_ms * 1_000; // Convert ms to fuel
167-
store.set_fuel(fuel).context("Failed to set fuel limit")?;
167+
store.set_fuel(fuel).map_err(|e| anyhow::anyhow!("Failed to set fuel limit: {}", e))?;
168168
}
169169

170170
Ok(store)
@@ -205,7 +205,8 @@ impl WASMRuntime {
205205
pub fn compile_module(&self, wasm_bytes:&[u8]) -> Result<Module> {
206206
debug!("Compiling WASM module ({} bytes)", wasm_bytes.len());
207207

208-
let module = Module::from_binary(&self.engine, wasm_bytes).context("Failed to compile WASM module")?;
208+
let module = Module::from_binary(&self.engine, wasm_bytes)
209+
.map_err(|e| anyhow::anyhow!("Failed to compile WASM module: {}", e))?;
209210

210211
debug!("WASM module compiled successfully");
211212

build.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ use std::path::PathBuf;
1111

1212
fn main() -> anyhow::Result<()> {
1313
// Generate build timestamp and other vergen environment variables
14+
// TODO: Downgraded vergen from 9.x to 8.x to restore EmitBuilder API compatibility
15+
// Future consideration: Add git metadata if available through different means
1416
vergen::EmitBuilder::builder()
1517
.all_build()
1618
.all_cargo()
17-
.all_git()
1819
.all_rustc()
1920
.emit()?;
2021
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
@@ -56,11 +57,13 @@ fn compile_protos() {
5657
// Create the output directory if it doesn't exist
5758
std::fs::create_dir_all(&out_dir).expect(&format!("Failed to create directory: {:?}", out_dir));
5859

60+
// TODO: Downgraded tonic-build from 0.14 to 0.12 to fix configure() API availability
61+
// Future consideration: Update to latest tonic-build version when API is stable
5962
tonic_build::configure()
6063
.build_server(true)
6164
.build_client(true)
6265
.out_dir(&out_dir)
63-
.compile(&[proto_file], &[proto_dir])
66+
.compile_protos(&[proto_file.as_path()], &[proto_dir.as_path()])
6467
.expect("Failed to compile protos");
6568

6669
println!("cargo:rerun-if-changed={}", out_dir.display());

0 commit comments

Comments
 (0)