Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 4 additions & 2 deletions pkgs/id/crates/id-worlds/src/world_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
//! trap.
//!
//! Unlike Wasm, the guarantee is the OS sandbox, not an import-free format:
//! native modules are admin-installed and opt-in (`--world-native`), and are
//! never offered for peer download.
//! native modules are admin-installed and opt-in (`--world-native`).
//! A native module stays downloadable by join-capability holders like any
//! active module: download is not install (install needs an admin token
//! plus a native-enabled server), and guest code cannot invoke a download.

use std::io::{Read, Write};
use std::os::fd::OwnedFd;
Expand Down
16 changes: 11 additions & 5 deletions pkgs/id/crates/id-worlds/src/world_session/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,8 +722,11 @@ impl WorldService {
}
}

// Native workers are never offered for peer download: only the Wasm
// tier gets pinned in the blob store.
// Native workers are not pinned in the blob store the way the Wasm
// tier is; a native module is still downloadable by
// join-capability holders via the module-directory fallback in
// `module_bytes` — download is not install (install needs an
// admin token plus a native-enabled server).
let blobs = self.blobs.as_ref().ok_or(InstallError::Disabled)?.clone();
let pin = (!is_native).then(|| {
blobs
Expand Down Expand Up @@ -904,7 +907,9 @@ impl WorldService {
}

/// Read the currently pinned module artifact for peer download.
/// The caller must already have authenticated as a world participant.
/// The caller must already have authenticated as a world participant
/// (a join-capability holder); guest program code cannot invoke a
/// download — only session frames can.
///
/// Falls back to the module directory when there is no blob pin to
/// serve from. A read-only replica clears its blob store so module
Expand Down Expand Up @@ -959,8 +964,9 @@ impl WorldService {
.parse()
.map_err(|_| InstallError::InvalidUpload)?;
// Wasm installs are pinned in the blob store; native installs are
// saved only in the module directory (they are never offered for
// peer download), so a stored native module is read from there.
// saved only in the module directory and served from there for
// join-capability-holder downloads (download is not install:
// install needs an admin token plus a native-enabled server),
if let Some(blobs) = self.blobs.as_ref()
&& let Ok(bytes) = blobs.blobs().get_bytes(hash).await
&& bytes.len() <= MAX_WORLD_MODULE_BYTES
Expand Down