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

Switch to webc v3 by default #4874

Merged
merged 4 commits into from
Jun 20, 2024
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
2 changes: 2 additions & 0 deletions lib/backend-api/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,7 @@ type PackageDistribution {
webcSize: Int
webcSha256Hash: String
webcVersion: WebcVersion
webcManifest: JSONString
}

type PackageVersionFilesystem {
Expand Down Expand Up @@ -3046,6 +3047,7 @@ input RenameAppAliasInput {
"""Purges all cache for this app version"""
type PurgeCacheForAppVersionPayload {
appVersion: DeployAppVersion!
success: Boolean!
clientMutationId: String
}

Expand Down
1 change: 1 addition & 0 deletions lib/backend-api/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ mod queries {
pub size: Option<i32>,
pub pirita_size: Option<i32>,
pub webc_version: Option<WebcVersion>,
pub webc_manifest: Option<JSONString>,
}

#[derive(cynic::Enum, Clone, Copy, Debug)]
Expand Down
13 changes: 9 additions & 4 deletions lib/cli/src/commands/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,15 @@ impl Run {
wasmer_vm::set_stack_size(self.stack_size.unwrap());
}

// check for the preferred webc version
let preferred_webc_version = match std::env::var("WASMER_USE_WEBCV3") {
Ok(val) if ["1", "yes", "true"].contains(&val.as_str()) => webc::Version::V3,
_ => webc::Version::V2,
// Check for the preferred webc version.
// Default to v3.
let webc_version_var = std::env::var("WASMER_WEBC_VERSION");
let preferred_webc_version = match webc_version_var.as_deref() {
Ok("2") => webc::Version::V2,
Ok("3") | Err(_) => webc::Version::V3,
Ok(other) => {
bail!("unknown webc version: '{other}'");
}
};

let _guard = handle.enter();
Expand Down
6 changes: 4 additions & 2 deletions lib/cli/src/commands/run/wasi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ use wasmer_wasix::{
runtime::{
module_cache::{FileSystemCache, ModuleCache},
package_loader::{BuiltinPackageLoader, PackageLoader},
resolver::{FileSystemSource, InMemorySource, MultiSource, Source, WapmSource, WebSource},
resolver::{
BackendSource, FileSystemSource, InMemorySource, MultiSource, Source, WebSource,
},
task_manager::{
tokio::{RuntimeOrHandle, TokioTaskManager},
VirtualTaskManagerExt,
Expand Down Expand Up @@ -648,7 +650,7 @@ impl Wasi {

let graphql_endpoint = self.graphql_endpoint(env)?;
let cache_dir = env.cache_dir().join("queries");
let mut wapm_source = WapmSource::new(graphql_endpoint, Arc::clone(&client))
let mut wapm_source = BackendSource::new(graphql_endpoint, Arc::clone(&client))
.with_local_cache(cache_dir, WAPM_SOURCE_CACHE_TIMEOUT)
.with_preferred_webc_version(preferred_webc_version);
if let Some(token) = env
Expand Down
4 changes: 2 additions & 2 deletions lib/wasix/src/http/web_http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,15 @@ fn call_fetch(request: &web_sys::Request) -> JsFuture {
#[cfg(test)]
mod tests {
use super::*;
use crate::runtime::resolver::WapmSource;
use crate::runtime::resolver::BackendSource;

#[wasm_bindgen_test::wasm_bindgen_test]
async fn query_the_wasmer_registry_graphql_endpoint() {
let http_client = WebHttpClient::default();
let query = r#"{
"query": "{ info { defaultFrontend } }"
}"#;
let request = http::Request::post(WapmSource::WASMER_PROD_ENDPOINT)
let request = http::Request::post(BackendSource::WASMER_PROD_ENDPOINT)
.header(http::header::CONTENT_TYPE, "application/json")
.body(query)
.unwrap();
Expand Down
6 changes: 3 additions & 3 deletions lib/wasix/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::{
runtime::{
module_cache::{ModuleCache, ThreadLocalCache},
package_loader::{PackageLoader, UnsupportedPackageLoader},
resolver::{MultiSource, Source, WapmSource},
resolver::{BackendSource, MultiSource, Source},
},
SpawnError, WasiTtyState,
};
Expand Down Expand Up @@ -239,8 +239,8 @@ impl PluggableRuntime {

let mut source = MultiSource::new();
if let Some(client) = &http_client {
source.add_source(WapmSource::new(
WapmSource::WASMER_PROD_ENDPOINT.parse().unwrap(),
source.add_source(BackendSource::new(
BackendSource::WASMER_PROD_ENDPOINT.parse().unwrap(),
client.clone(),
));
}
Expand Down
Loading
Loading