The /rust directory contains the full backend code that is compiled into the saito-js npm bundle. If you want to modify this Rust-level consensus code locally, you will need to follow the instructions on this page. These allow your machine to compile the full software stack locally, and use your locally-compiled code instead of the pre-compiled wasm bundle published by the project.
Once you have installed and compiled the software successfully for the first time, you can skip this step and "re-compile" at any time by running npm run linklocal. This is useful if you want to make changes to the backend code and then immediately recompile and see them in action.
Navigate to the cloned directory and run the bootstrap script to prepare your environment. The script will work for Mac or Linux, auto-detecting the appropriate bootstrap script based on your environment. Select YES when asked if you want to "Build Project":
cd rust/scripts
bash bootstrap.sh
If you want to run the Saito Rust client, you can now do so using the following, which enables debug logging:
RUST_LOG=debug cargo run
If you are using a Mac, please see our instructions on installing WASM compiler for Mac. Otherwise:
cd saito-wasm
cargo install wasm-pack
npm install
npm run build
git clone https://github.com/saitotech/saito
cd <repo>/rust/scripts
./dev_setup.sh
Provide any expected inputs and wait till the script completes. Script will install all the required software, compile the code and locally link the npm packages.
cd <repo>/node/
npm install
npm link saito-js
npm run compile
Now the node js server can be started with the locally linked saito-js package.
cd <repo>/rust/saito-wasm
npm install
npm run build
npm link # this will setup saito-wasm to be locally linked by other projects
cd <repo>/rust/saito-js
npm install
npm link saito-wasm # this is linking previously built saito-wasm into saito-js project
npm run build
cd dist
npm link # this will setup saito-js to be locally linked by other projects
Now link the local saito-js as in aboe step 3.
Local links will stay there until npm install is called. So you don't need to run npm link saito-js everytime you compile but only when you run npm install.
Once you do any rust changes, below is the procedure to compile wasm code. (Assuming saito-wasm and saito-js are locally linked)
cd <repo>/rust/saito-wasm
npm run build
cd <repo>/rust/saito-js
npm run build
cd <repo>/node/
npm link saito-js
npm run compile #or equivalent
npm start
Once you test everything in the local environment. If you need to publish new npms with the changes, all you have to do is below steps.