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
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ updates:
update-types: ["version-update:semver-minor", "version-update:semver-major"]
# Add entries for excluded workspace members
- package-ecosystem: "cargo"
directory: "/src/wasm_runtime"
directory: "/src/hyperlight_wasm_runtime"
schedule:
interval: "daily"
time: "03:00"
Expand Down
15 changes: 0 additions & 15 deletions .github/workflows/CreateRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,6 @@ jobs:
uses: hyperlight-dev/ci-setup-workflow@v1.8.0
with:
rust-toolchain: "1.89"
- name: Verify vendor.tar
if: ${{ contains(github.ref, 'refs/heads/release/') }}
run: |
set -euxo pipefail
VENDOR1=$(mktemp -d)
VENDOR2=$(mktemp -d)
tar xf ./src/hyperlight_wasm/vendor.tar -C $VENDOR1
just make-vendor-tar
tar xf ./src/hyperlight_wasm/vendor.tar -C $VENDOR2
if ! git diff --no-index $VENDOR1 $VENDOR2; then
echo "vendor.tar is not up to date, please run 'just make-vendor-tar' and commit the changes"
exit 1
fi
git restore ./src/hyperlight_wasm/vendor.tar
shell: bash
- name: Package hyperlight-wasm crate
if: ${{ contains(github.ref, 'refs/heads/release/') }}
run: cargo package -p hyperlight-wasm
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/CreateReleaseBranch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,5 @@ jobs:
- name: Create Release Branch
run: |
git checkout -b release/${GITHUB_REF_NAME}
just make-vendor-tar
sed -i '/vendor.tar/d' ./src/hyperlight_wasm/.gitignore
git add ./src/hyperlight_wasm/vendor.tar
git add ./src/hyperlight_wasm/.gitignore
git config user.name hyperlight-wasm-ci
git config user.email github@users.noreply.github.com
git commit -s \
-m "Vendor dependencies for release ${GITHUB_REF_NAME}"
git push --set-upstream origin release/${GITHUB_REF_NAME}
shell: bash
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,6 @@ $RECYCLE.BIN/
**/include/libc/musl/**
**/include/flatbuffers/generated/**
**/include/flatcc/**
**/guest-toolchain
src/wasm_runtime/src/include

## Rust from https://github.com/github/gitignore/blob/main/Rust.gitignore

Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"id": "program",
"type": "promptString",
"default": "x64/debug/wasm_runtime",
"default": "x64/debug/hyperlight_wasm_runtime",
"description": "Path to the program to debug",
}
],
Expand Down
38 changes: 19 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = [ "src/hyperlight_wasm", "src/examples_common", "src/hyperlight_wasm_aot", "src/wasm_runtime", "src/hyperlight_wasm_macro" ]
members = [ "src/hyperlight_wasm", "src/examples_common", "src/hyperlight_wasm_aot", "src/hyperlight_wasm_runtime", "src/hyperlight_wasm_macro" ]
exclude = [ "src/rust_wasm_samples", "src/component_sample" ]
resolver = "2"

Expand All @@ -20,4 +20,4 @@ hyperlight-guest = { version = "0.12.0" }
hyperlight-guest-bin = { version = "0.12.0", features = [ "printf" ] }
hyperlight-host = { version = "0.12.0", default-features = false, features = ["executable_heap", "init-paging"] }
hyperlight-wasm-macro = { version = "0.12.0", path = "src/hyperlight_wasm_macro" }
wasm-runtime = { version = "0.12.0", path = "src/wasm_runtime" }
hyperlight-wasm-runtime = { version = "0.12.0", path = "src/hyperlight_wasm_runtime" }
17 changes: 4 additions & 13 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ wit-world-c := if os() == "windows" { "$env:WIT_WORLD=\"" + justfile_directory()

set windows-shell := ["pwsh.exe", "-NoLogo", "-Command"]

make-vendor-tar:
tar cf ./src/hyperlight_wasm/vendor.tar \
--owner=0 --group=0 \
--exclude-vcs-ignores \
-C ./src wasm_runtime hyperlight_wasm_macro

ensure-tools:
cargo install wasm-tools --locked --version 1.235.0
cargo install cargo-component --locked --version 0.21.1
Expand Down Expand Up @@ -66,32 +60,29 @@ check target=default-target:
cargo check --profile={{ if target == "debug" {"dev"} else { target } }}
cd src/rust_wasm_samples && cargo check --profile={{ if target == "debug" {"dev"} else { target } }}
cd src/component_sample && cargo check --profile={{ if target == "debug" {"dev"} else { target } }}
cd src/wasm_runtime && cargo hyperlight check --profile={{ if target == "debug" {"dev"} else { target } }}
cd src/hyperlight_wasm_runtime && cargo hyperlight check --profile={{ if target == "debug" {"dev"} else { target } }}
cd src/hyperlight_wasm_macro && cargo check --profile={{ if target == "debug" {"dev"} else { target } }}

fmt-check:
rustup toolchain install nightly -c rustfmt && cargo +nightly fmt -v --all -- --check
cd src/rust_wasm_samples && rustup toolchain install nightly -c rustfmt && cargo +nightly fmt -v --all -- --check
cd src/component_sample && rustup toolchain install nightly -c rustfmt && cargo +nightly fmt -v --all -- --check
cd src/wasm_runtime && rustup toolchain install nightly -c rustfmt && cargo +nightly fmt -v --all -- --check
cd src/hyperlight_wasm_runtime && rustup toolchain install nightly -c rustfmt && cargo +nightly fmt -v --all -- --check
cd src/hyperlight_wasm_macro && rustup toolchain install nightly -c rustfmt && cargo +nightly fmt -v --all -- --check

fmt:
rustup toolchain install nightly -c rustfmt
cargo +nightly fmt --all
cd src/rust_wasm_samples && cargo +nightly fmt -v --all
cd src/component_sample && cargo +nightly fmt -v --all
cd src/wasm_runtime && cargo +nightly fmt -v --all
cd src/hyperlight_wasm_runtime && cargo +nightly fmt -v --all
cd src/hyperlight_wasm_macro && cargo +nightly fmt -v --all

export CC_x86_64_unknown_none:= if os() == "windows" { justfile_directory() / "src/wasm_runtime/guest-toolchain/clang" } else { "" }
export AR_x86_64_unknown_none:= if os() == "windows" { "llvm-ar" } else { "" }

clippy target=default-target: (check target)
cargo clippy --profile={{ if target == "debug" {"dev"} else { target } }} --all-targets --all-features -- -D warnings
cd src/rust_wasm_samples && cargo clippy --profile={{ if target == "debug" {"dev"} else { target } }} --all-targets --all-features -- -D warnings
cd src/component_sample && cargo clippy --profile={{ if target == "debug" {"dev"} else { target } }} --all-targets --all-features -- -D warnings
cd src/wasm_runtime && cargo hyperlight clippy --profile={{ if target == "debug" {"dev"} else { target } }} --all-targets --all-features -- -D warnings
cd src/hyperlight_wasm_runtime && cargo hyperlight clippy --profile={{ if target == "debug" {"dev"} else { target } }} --all-targets --all-features -- -D warnings
cd src/hyperlight_wasm_macro && cargo clippy --profile={{ if target == "debug" {"dev"} else { target } }} --all-targets --all-features -- -D warnings

# TESTING
Expand Down
2 changes: 1 addition & 1 deletion RustDev.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ but has no Wasm runtime loaded. Once it has been transitioned to a `WasmSandbox`

### More about `WasmSandbox`

The `WasmSandbox` represents a sandbox state that is not completely ready for use. While it does have the `wasm_runtime` guest binary loaded into it (see [Rust.md](./Rust.md) for more details on this guest binary), and the Wasm runtime initialised, it is missing a user's WebAssembly module code. The 'WasmSandbox' type is an intermediate state that is designed to be cached in a host to avoid having to pay the cost of loading the `wasm_runtime` guest binary and initializing the Wasm runtime each time a new user code module is loaded.
The `WasmSandbox` represents a sandbox state that is not completely ready for use. While it does have the `hyperlight-wasm-runtime` guest binary loaded into it (see [Rust.md](./Rust.md) for more details on this guest binary), and the Wasm runtime initialised, it is missing a user's WebAssembly module code. The 'WasmSandbox' type is an intermediate state that is designed to be cached in a host to avoid having to pay the cost of loading the `hyperlight-wasm-runtime` guest binary and initializing the Wasm runtime each time a new user code module is loaded.

Loading user code is the final initialization step necessary to have a ready-to-use sandbox, so moving from the `WasmSandbox` state to the `LoadedWasmSandbox` state requires specifying what user code to load. See the "State transitions" section below for details on making this state transition.

Expand Down
2 changes: 1 addition & 1 deletion docs/wasm-modules-debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ After you attach, you can set breakpoints, step through the code, and inspect va
{
"id": "program",
"type": "promptString",
"default": "x64/debug/wasm_runtime",
"default": "x64/debug/hyperlight_wasm_runtime",
"description": "Path to the program to debug"
},
],
Expand Down
2 changes: 1 addition & 1 deletion src/hyperlight_wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ log = "0.4"
cfg-if = "1"
metrics = "0.24.3"
env_logger = "0.11.9"
wasm-runtime.workspace = true
hyperlight-wasm-runtime.workspace = true

[target.'cfg(windows)'.dependencies]
windows = { version = "0.62", features = ["Win32_System_Threading"] }
Expand Down
48 changes: 24 additions & 24 deletions src/hyperlight_wasm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ limitations under the License.

// build.rs

// The purpose of this build script is to embed the wasm_runtime binary as a resource in the hyperlight-wasm binary.
// This is done by reading the wasm_runtime binary into a static byte array named WASM_RUNTIME.
// this build script writes the code to do that to a file named wasm_runtime_resource.rs in the OUT_DIR.
// The purpose of this build script is to embed the hyperlight-wasm-runtime binary as a resource in the hyperlight-wasm binary.
// This is done by reading the hyperlight-wasm-runtime binary into a static byte array named WASM_RUNTIME.
// this build script writes the code to do that to a file named built.rs in the OUT_DIR.
// this file is included in lib.rs.
// The wasm_runtime binary is expected to be in the x64/{config} directory.
// The hyperlight-wasm-runtime binary is expected to be in the x64/{config} directory.

use std::fs::OpenOptions;
use std::io::Write;
Expand Down Expand Up @@ -50,8 +50,8 @@ fn get_wasm_runtime_manifest_path() -> PathBuf {
// "packages": [
// ...,
// {
// "name": "wasm-runtime",
// "manifest_path": "/path/to/wasm-runtime/Cargo.toml",
// "name": "hyperlight-wasm-runtime",
// "manifest_path": "/path/to/hyperlight-wasm-runtime/Cargo.toml",
// ...
// },
// ...
Expand All @@ -74,14 +74,14 @@ fn get_wasm_runtime_manifest_path() -> PathBuf {
let metadata: CargoMetadata =
serde_json::from_slice(&output.stdout).expect("Failed to parse cargo metadata");

// find the package entry for wasm-runtime and get its manifest_path
let wasm_runtime = metadata
// find the package entry for hyperlight-wasm-runtime and get its manifest_path
let hyperlight_wasm_runtime = metadata
.packages
.into_iter()
.find(|pkg| pkg.name == "wasm-runtime")
.expect("wasm-runtime crate not found in cargo metadata");
.find(|pkg| pkg.name == "hyperlight-wasm-runtime")
.expect("hyperlight-wasm-runtime crate not found in cargo metadata");

wasm_runtime.manifest_path
hyperlight_wasm_runtime.manifest_path
}

fn find_target_dir() -> PathBuf {
Expand Down Expand Up @@ -121,7 +121,7 @@ fn build_wasm_runtime() -> PathBuf {
let runtime_dir = manifest_path.parent().unwrap();

if !runtime_dir.exists() {
panic!("missing wasm_runtime in-tree dependency");
panic!("missing hyperlight-wasm-runtime in-tree dependency");
}

println!("cargo::rerun-if-changed={}", runtime_dir.display());
Expand Down Expand Up @@ -156,25 +156,25 @@ fn build_wasm_runtime() -> PathBuf {
}

cmd.status()
.unwrap_or_else(|e| panic!("could not run cargo build wasm_runtime: {e:?}"));
.unwrap_or_else(|e| panic!("could not run cargo build hyperlight-wasm-runtime: {e:?}"));

let resource = target_dir
.join("x86_64-hyperlight-none")
.join(profile)
.join("wasm_runtime");
.join("hyperlight-wasm-runtime");

if let Ok(path) = resource.canonicalize() {
if std::env::var("CARGO_FEATURE_GDB").is_ok() {
println!(
"cargo:warning=Wasm runtime guest binary at: {}",
"cargo:warning=Hyperlight wasm runtime guest binary at: {}",
path.display()
);
}

path
} else {
panic!(
"could not find wasm_runtime after building it (expected {:?})",
"could not find hyperlight-wasm-runtime after building it (expected {:?})",
resource
)
}
Expand All @@ -192,13 +192,13 @@ fn main() -> Result<()> {

fs::write(dest_path, contents).unwrap();

// get the wasmtime version number from the wasm_runtime metadata
// get the wasmtime version number from the hyperlight-wasm-runtime metadata

let wasm_runtime_bytes = fs::read(&wasm_runtime_resource).unwrap();
let elf = goblin::elf::Elf::parse(&wasm_runtime_bytes).unwrap();

// the wasm_runtime binary has a section named .note_hyperlight_metadata that contains the wasmtime version number
// this section is added to the wasm_runtime binary by the build.rs script in the wasm_runtime crate
// the hyperlight-wasm-runtime binary has a section named .note_hyperlight_metadata that contains the wasmtime version number
// this section is added to the hyperlight-wasm-runtime binary by the build.rs script in the hyperlight-wasm-runtime crate
let section_name = ".note_hyperlight_metadata";
let wasmtime_version_number = if let Some(header) = elf.section_headers.iter().find(|hdr| {
if let Some(name) = elf.shdr_strtab.get_at(hdr.sh_name) {
Expand All @@ -218,13 +218,13 @@ fn main() -> Result<()> {
std::str::from_utf8(metadata_bytes).unwrap()
}
} else {
panic!(".note_hyperlight_metadata section not found in wasm_runtime binary");
panic!(".note_hyperlight_metadata section not found in hyperlight-wasm-runtime binary");
};

// write the build information to the built.rs file
write_built_file()?;

// open the built.rs file and append the details of the wasm_runtime file
// open the built.rs file and append the details of the hyperlight-wasm-runtime file
let built_path = Path::new(&out_dir).join("built.rs");
let mut file = OpenOptions::new()
.create(false)
Expand Down Expand Up @@ -254,9 +254,9 @@ fn main() -> Result<()> {
writeln!(file, "{}", wasm_runtime_size).unwrap();
writeln!(file, "{}", wasm_runtime_wasmtime_version).unwrap();

// Calculate the blake3 hash of the wasm_runtime file and write it to the wasm_runtime_resource.rs file so we can include it in the binary
let wasm_runtime = fs::read(wasm_runtime_resource).unwrap();
let hash = blake3::hash(&wasm_runtime);
// Calculate the blake3 hash of the hyperlight-wasm-runtime file and write it to the wasm_runtime_resource.rs file so we can include it in the binary
let hyperlight_wasm_runtime = fs::read(wasm_runtime_resource).unwrap();
let hash = blake3::hash(&hyperlight_wasm_runtime);
let hash_str = format!("static WASM_RUNTIME_BLAKE3_HASH: &str = \"{}\";", hash);

writeln!(file, "{}", hash_str).unwrap();
Expand Down
Loading