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

Built-in customizable deposit WASM #160

Merged
merged 8 commits into from
Jul 26, 2024

Conversation

koxu1996
Copy link
Contributor

Fixes #159 by:

  • including WASM bytes during compile time - still relying on previously used env PATH_TO_SESSION_BINARIES
  • adding optional argument that allow specifying custom WASM:
$ ./kairos-cli deposit --help

[cut]

  -s, --session-path <PATH>            Path to the custom WASM session code for deposit

@koxu1996 koxu1996 self-assigned this Jul 23, 2024
Comment on lines +7 to +19
let session_binaries_dir = env::var("PATH_TO_SESSION_BINARIES")
.expect("PATH_TO_SESSION_BINARIES environment variable is not set");

// Get the output directory set by Cargo.
let out_dir = env::var("OUT_DIR").expect("OUT_DIR not set");
let source_path = Path::new(&session_binaries_dir).join("deposit-session-optimized.wasm");
let dest_path = Path::new(&out_dir).join("deposit-session-optimized.wasm");

// Copy the file from the source to the destination
fs::copy(&source_path, dest_path).expect("Failed to copy WASM file");

// Print out a message to re-run this script if the source file changes.
println!("cargo:rerun-if-changed={}", source_path.display());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: This works, but I am not clear why we need to copy the wasm into OUT_DIR. Why not just include_bytes from PATH_TO_SESSION_BINARIES directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include_bytes!(env!("PATH_TO_SESSION_BINARIES")) would work too. However, I would like to extend build script to automatically discover and optimize WASMs (similar to this) so PATH_TO_SESSION_BINARIES can be avoided.

The whole project works great in Nix, but being able to just cargo build without bunch of extra env setup would be better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good

@marijanp marijanp merged commit f961a23 into main Jul 26, 2024
4 checks passed
@marijanp marijanp deleted the feature/built-in-customizable-deposit branch July 26, 2024 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Client relies on hardcoded path to deposit session
3 participants