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

wasm server download via env #2064

Merged
merged 2 commits into from
Oct 30, 2023
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 .changelog/unreleased/improvements/2064-wasm-download.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Define the wasm download endpoint via environemnt variable.
([\#2064](https://github.com/anoma/namada/pull/2064))
13 changes: 10 additions & 3 deletions apps/src/lib/wasm_loader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ pub enum Error {
#[serde(transparent)]
pub struct Checksums(pub HashMap<String, String>);

const S3_URL: &str = "https://namada-wasm-master.s3.eu-west-1.amazonaws.com";
/// Github URL prefix of released Namada network configs
pub const ENV_VAR_WASM_SERVER: &str = "NAMADA_NETWORK_CONFIGS_SERVER";
const DEFAULT_WASM_SERVER: &str = "https://artifacts.heliax.click/namada-wasm";

impl Checksums {
/// Read WASM checksums from the given path
Expand Down Expand Up @@ -101,6 +103,11 @@ impl Checksums {
}
}

fn wasm_url_prefix(wasm_name: &str) -> String {
std::env::var(ENV_VAR_WASM_SERVER)
.unwrap_or_else(|_| format!("{DEFAULT_WASM_SERVER}/{wasm_name}"))
}

/// Download all the pre-built wasms, or if they're already downloaded, verify
/// their checksums.
pub async fn pre_fetch_wasm(wasm_directory: impl AsRef<Path>) {
Expand Down Expand Up @@ -180,7 +187,7 @@ pub async fn pre_fetch_wasm(wasm_directory: impl AsRef<Path>) {
}
}

let url = format!("{}/{}", S3_URL, full_name);
let url = wasm_url_prefix(&full_name);
match download_wasm(url).await {
Ok(bytes) => {
if let Err(e) =
Expand Down Expand Up @@ -224,7 +231,7 @@ pub async fn pre_fetch_wasm(wasm_directory: impl AsRef<Path>) {
}
}

let url = format!("{}/{}", S3_URL, full_name);
let url = wasm_url_prefix(&full_name);
match download_wasm(url).await {
Ok(bytes) => {
if let Err(e) =
Expand Down
Loading