Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
25 changes: 25 additions & 0 deletions bins/validator-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ async fn main() -> Result<()> {
fuel_limit: args.wasm_fuel_limit,
storage_host_config: wasm_runtime_interface::StorageHostConfig::default(),
storage_backend: std::sync::Arc::new(wasm_runtime_interface::InMemoryStorageBackend::new()),
chutes_api_key: None,
}) {
Ok(executor) => {
info!(
Expand Down Expand Up @@ -952,6 +953,30 @@ async fn handle_network_event(
"Received storage vote"
);
}
P2PMessage::ReviewAssignment(msg) => {
debug!(
submission_id = %msg.submission_id,
assigner = %msg.assigner.to_hex(),
assigned_count = msg.assigned_validators.len(),
"Received review assignment"
);
}
P2PMessage::ReviewDecline(msg) => {
debug!(
submission_id = %msg.submission_id,
validator = %msg.validator.to_hex(),
reason = %msg.reason,
"Received review decline"
);
}
P2PMessage::ReviewResult(msg) => {
debug!(
submission_id = %msg.submission_id,
validator = %msg.validator.to_hex(),
score = msg.score,
"Received review result"
);
}
},
NetworkEvent::PeerConnected(peer_id) => {
info!("Peer connected: {}", peer_id);
Expand Down
34 changes: 30 additions & 4 deletions bins/validator-node/src/wasm_executor.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
use anyhow::{Context, Result};
use bincode::Options;
use parking_lot::RwLock;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::Arc;
use std::time::Instant;
use tracing::{debug, info};

const MAX_EVALUATION_OUTPUT_SIZE: u64 = 64 * 1024 * 1024;
use wasm_runtime_interface::{
ConsensusPolicy, ExecPolicy, InMemoryStorageBackend, InstanceConfig, NetworkHostFunctions,
NetworkPolicy, RuntimeConfig, SandboxHostFunctions, SandboxPolicy, StorageBackend,
StorageHostConfig, TerminalPolicy, TimePolicy, WasmModule, WasmRuntime, WasmRuntimeError,
ConsensusPolicy, ExecPolicy, InMemoryStorageBackend, InstanceConfig, LlmPolicy,
NetworkHostFunctions, NetworkPolicy, RuntimeConfig, SandboxHostFunctions, SandboxPolicy,
StorageBackend, StorageHostConfig, TerminalPolicy, TimePolicy, WasmModule, WasmRuntime,
WasmRuntimeError,
};

#[derive(Clone, Debug, Serialize, Deserialize)]
Expand Down Expand Up @@ -65,6 +69,7 @@ pub struct WasmExecutorConfig {
pub fuel_limit: Option<u64>,
pub storage_host_config: StorageHostConfig,
pub storage_backend: Arc<dyn StorageBackend>,
pub chutes_api_key: Option<String>,
}

impl Default for WasmExecutorConfig {
Expand All @@ -76,6 +81,7 @@ impl Default for WasmExecutorConfig {
fuel_limit: None,
storage_host_config: StorageHostConfig::default(),
storage_backend: Arc::new(InMemoryStorageBackend::new()),
chutes_api_key: None,
}
}
}
Expand Down Expand Up @@ -186,6 +192,10 @@ impl WasmChallengeExecutor {
fixed_timestamp_ms: None,
consensus_policy: ConsensusPolicy::default(),
terminal_policy: TerminalPolicy::default(),
llm_policy: match &self.config.chutes_api_key {
Some(key) => LlmPolicy::with_api_key(key.clone()),
None => LlmPolicy::default(),
},
..Default::default()
};

Expand Down Expand Up @@ -229,7 +239,11 @@ impl WasmChallengeExecutor {
anyhow::anyhow!("Failed to read evaluation output from WASM memory: {}", e)
})?;

let output: EvaluationOutput = bincode::deserialize(&output_bytes)
let output: EvaluationOutput = bincode::DefaultOptions::new()
.with_limit(MAX_EVALUATION_OUTPUT_SIZE)
.with_fixint_encoding()
.allow_trailing_bytes()
.deserialize(&output_bytes)
.context("Failed to deserialize EvaluationOutput from WASM module")?;

let fuel_consumed = match (initial_fuel, instance.fuel_remaining()) {
Expand Down Expand Up @@ -309,6 +323,10 @@ impl WasmChallengeExecutor {
fixed_timestamp_ms: None,
consensus_policy: ConsensusPolicy::default(),
terminal_policy: TerminalPolicy::default(),
llm_policy: match &self.config.chutes_api_key {
Some(key) => LlmPolicy::with_api_key(key.clone()),
None => LlmPolicy::default(),
},
..Default::default()
};

Expand Down Expand Up @@ -419,6 +437,10 @@ impl WasmChallengeExecutor {
fixed_timestamp_ms: None,
consensus_policy: ConsensusPolicy::default(),
terminal_policy: TerminalPolicy::default(),
llm_policy: match &self.config.chutes_api_key {
Some(key) => LlmPolicy::with_api_key(key.clone()),
None => LlmPolicy::default(),
},
..Default::default()
};

Expand Down Expand Up @@ -498,6 +520,10 @@ impl WasmChallengeExecutor {
fixed_timestamp_ms: None,
consensus_policy: ConsensusPolicy::default(),
terminal_policy: TerminalPolicy::default(),
llm_policy: match &self.config.chutes_api_key {
Some(key) => LlmPolicy::with_api_key(key.clone()),
None => LlmPolicy::default(),
},
..Default::default()
};

Expand Down
Loading