Websocket Relay
February 20, 2024 ยท View on GitHub
Description
An example application that connects to a homestar-runtime node
over a websocket connection in order to run static Wasm-based, image
processing workflows that chain inputs and outputs using
inlined promises.
This application demonstrates:
- workflows built using the @fission-codes/homestar client library
- websocket notifications of UCAN Invocation Receipts sent
between a web client and a
homestarrunner using @fission-codes/homestar - instantaneous replay of previously run, cached executions
- fetching content (the original static image) over IPFS through a local blockstore
- the WIT + IPLD interpreter for
Wasm(time) embedded execution within a
homestarrunner
Install
Nix
If you're using our Nix file, you get these installs for free.
Manual
To get started, please install:
- Rust, unless you're running
homestaras a binary - Node & NPM
- Kubo IPFS
Usage
-
Run
cargo runto start the runtime and an IPFS daemon as a background process. This runtime includes ANSI-coded logging by default. -
In a separate terminal window, run
npm install --prefix relay-appto install dependencies andnpm run --prefix relay-app devto start the relay web application (UI) onhttp://localhost:5173/by default. -
Press the play buttons on the UI to run workflows. Follow along with this video for more information.
https://www.loom.com/share/b0f882adc2ea45709d1f3031b5e61e92?sid=29cb403e-c666-4753-82f5-e35bbb710151
Following along with the video, once you're up and running on localhost,
you'll see two workflows with several tasks. You can click on the stack icon on
the top right hand corner to inspect the source of the workflows.
Running the first workflow completes a number of image-processing tasks, i.e.
crop -> rotate90 -> blur, submitting the rendered output to each
subsequent task.
The second workflow executes crop -> rotate90 as well, and then something
new: grayscale. As demonstrated, the first two task executions can be skipped
if they've been previously run.
Tips & Common Issues
-
On macOS, for example, a simple homebrew install would install everything you need:
brew install rust npm ipfs. -
Running
homestarusingcargo runrequires a minimum Rust version of1.75.0. If you've got an older version of rust, update it withrustup update. -
You do not have to start Kubo (IPFS) on your own. The example will do this for you, and use
examples/websocket-relay/tmp/.ipfsas a local blockstore. Feel free to discard it when you don't need it. -
If you're already running an IPFS instance, for example IPFS Desktop, the application will check for it and not start a new, local one. However, the application expects a default IPFS host and port. The expected IPFS
hostandportcan be updated in thehomestarnetwork settings:[node] [node.network.ipfs] host = "127.0.0.1" port = 5001 -
We have officially packaged homestar binaries using brew, so
brew install fission-codes/fission/homestarwill install mostly everything you need, includingipfs. You will still neednpmto run this example, and you'll have to manuallyipfs addthesynthcat.pngandexample_test.wasmfiles located in this directory. Then, from this folder, you can run the example like this:homestar start --db homestar.dbAfterward, run
npm install --prefix relay-appto install dependencies andnpm run --prefix relay-app devto start the relay web application (UI) onhttp://localhost:5173/by default.