-
Notifications
You must be signed in to change notification settings - Fork 293
[TKN-683] Add setup.sh script for local Whirlpools build
#1074
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
Conversation
yugure-orca
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice QoL improvement!
(1 comment about Rust version)
scripts/setup.sh
Outdated
| YARN_VERSION="4.6.0" | ||
| SOLANA_VERSION="v1.17.25" | ||
| ANCHOR_VERSION="v0.29.0" | ||
| RUST_VERSION_FOR_ANCHOR="1.76.0" # Required for building Anchor v0.29.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use 1.78.0 ?
yarn build should build everything. It uses 1.78.0 for contract build. (no need to switch default, we can use Rust 1.85.1 as default because package.json has the following setting)
https://github.com/orca-so/whirlpools/blob/main/programs/whirlpool/package.json#L5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Rust version in this line is specific to the installation of Anchor v0.29.0, and not the Whirlpools repo.
Background
I encountered an issue with using AVM to install v0.29.0.
Using Anchor's recommendation for installing Anchor:
cargo install --git https://github.com/coral-xyz/anchor avm --force
avm install 0.29.0
yields:
Error: Failed to install 0.29.0, is it a valid version?
So I decided to install Anchor v0.29.0 from source, but that would not compile with the latest version of Rust that comes with the default Rust installation, v1.90.0. Neither did it compile with v1.85.1. I tried multiple versions of Rust, and landed on v1.76 as a compatible version.
Testing your suggestions
That said, as a result of you review comment, I just tried v1.78 as well, and that works too. So, I believe we still need to switch the default right before building Anchor.
Furthermore, I tested the script without switching the default from v1.78.0 to v1.85.1 before trying yarn install and yarn build from the repo's root, and indeed the Whirlpool program builds, but building rust-tx-sender will fail with Error:
error: rustc 1.78.0 is not supported by the following packages:
[email protected] requires rustc 1.81
[email protected] requires rustc 1.80.0
[email protected] requires rustc 1.80.0
[email protected] requires rustc 1.80.0
[email protected] requires rustc 1.81
I'm happy to switch to another version of Rust instead of 1.85.1, but I believe we still need to switch the default at least twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow up
@wjthieme 's suggestion to use cargo install --git https://github.com/coral-xyz/anchor --tag v0.29.0 anchor-cli instead of my code works without switching the Rust version. So the only thing left to do was to add rustup default ${RUST_VERSION_FOR_PROJECT} right before building the project, with the version being v1.84.0, which is the same version that's used by the GitHub workflows.
(The default v1.90.0 seems to not be compatible with WASM compilation)
scripts/setup.sh
Outdated
| cd "$ANCHOR_TMP_DIR/anchor" | ||
| git checkout ${ANCHOR_VERSION} | ||
| cd cli | ||
| cargo build --release |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could do something like cargo install --git https://github.com/coral-xyz/anchor --tag v0.29.0 anchor-cli so you don't have to clone, build and link manually
| source "$NVM_DIR/nvm.sh" | ||
|
|
||
| echo "=== Installing Node.js ${NODE_VERSION} and Yarn (via Corepack) ===" | ||
| nvm install ${NODE_VERSION} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally hate nvm 🦗. I always just do brew install node@18 or something like that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This script runs on both Linux and Mac. Would you recommend installing Brew for Linux as well?
I went with nvm because it's the first pick in Node's installation documentation. And maybe not super important, but Brew does not fall under Node's 'Recommended (Official)' installations., but under 'Community (Unofficial)' installations.
Added a setup script to streamline development environment setup:
New Setup Script (
scripts/setup.sh):Updated Documentation: