Skip to content

Commit f7a2b8b

Browse files
committed
fix(svm): pin rust toolchain for solana (#960)
* fix(svm): pin rust toolchain for solana Signed-off-by: Reinis Martinsons <reinis@umaproject.org> * fix: add local toolchain Signed-off-by: Reinis Martinsons <reinis@umaproject.org> * fix: add rustfmt to nightly Signed-off-by: Reinis Martinsons <reinis@umaproject.org> * fix: pin nightly in lint scripts Signed-off-by: Reinis Martinsons <reinis@umaproject.org> --------- Signed-off-by: Reinis Martinsons <reinis@umaproject.org>
1 parent 71e990b commit f7a2b8b

File tree

5 files changed

+46
-8
lines changed

5 files changed

+46
-8
lines changed

.github/workflows/pr.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ jobs:
2828
- name: Install Cargo toolchain
2929
uses: actions-rs/toolchain@v1
3030
with:
31-
toolchain: nightly
31+
toolchain: nightly-2025-04-01
3232
profile: minimal
3333
components: rustc
3434
- name: Install packages
35-
run: yarn install --frozen-lockfile && rustup component add --toolchain nightly-x86_64-unknown-linux-gnu rustfmt
35+
run: yarn install --frozen-lockfile && rustup component add --toolchain nightly-2025-04-01-x86_64-unknown-linux-gnu rustfmt
3636
- name: Lint js
3737
shell: bash
3838
run: yarn lint-js
@@ -69,7 +69,7 @@ jobs:
6969
- name: Install Cargo toolchain
7070
uses: actions-rs/toolchain@v1
7171
with:
72-
toolchain: stable
72+
toolchain: nightly-2025-04-01
7373
profile: minimal
7474
components: rustc
7575
- name: Cache Cargo dependencies

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,25 @@
2222
"lint": "yarn lint-solidity && yarn lint-js && yarn lint-rust",
2323
"lint-solidity": "yarn solhint ./contracts/**/*.sol",
2424
"lint-js": "yarn prettier --list-different **/*.js **/*.ts",
25-
"lint-rust": "cargo +nightly fmt --all -- --check && cargo clippy",
26-
"lint-fix": "yarn prettier --write **/*.js **/*.ts ./programs/**/*.rs ./contracts**/*.sol && cargo +nightly fmt --all && cargo clippy",
25+
"lint-rust": "cargo +nightly-2025-04-01 fmt --all -- --check && cargo clippy",
26+
"lint-fix": "yarn prettier --write **/*.js **/*.ts ./programs/**/*.rs ./contracts**/*.sol && cargo +nightly-2025-04-01 fmt --all && cargo clippy",
2727
"clean-fast": "for dir in node_modules cache cache-zk artifacts artifacts-zk dist typechain; do mv \"${dir}\" \"_${dir}\"; rm -rf \"_${dir}\" &; done",
2828
"clean": "rm -rf node_modules cache cache-zk artifacts artifacts-zk dist typechain",
2929
"generate-svm-assets": "sh ./scripts/generate-svm-assets.sh && yarn generate-svm-clients",
3030
"generate-svm-clients": "yarn ts-node ./scripts/svm/utils/generate-svm-clients.ts && yarn ts-node ./scripts/svm/utils/rename-clients-imports.ts",
3131
"build-evm": "hardhat compile",
32-
"build-svm": "echo 'Generating IDLs...' && anchor build > /dev/null 2>&1 || true && anchor run generateExternalTypes && anchor build",
32+
"build-svm": "echo 'Generating IDLs...' && yarn anchor-build > /dev/null 2>&1 || true && anchor run generateExternalTypes && yarn anchor-build",
3333
"build-ts": "rm -rf ./dist && tsc && rsync -a --include '*/' --include '*.d.ts' --exclude '*' ./typechain ./dist/",
3434
"copy-idl": "mkdir -p dist/src/svm/assets/idl && cp src/svm/assets/idl/*.json dist/src/svm/assets/idl/",
3535
"build": "yarn build-evm && yarn build-svm && yarn generate-svm-assets && yarn build-ts && yarn copy-idl",
3636
"test-evm": "IS_TEST=true hardhat test",
37-
"test-svm": "anchor test -- --features test",
37+
"test-svm": "sh ./scripts/anchor-test.sh",
3838
"test": "yarn test-evm && yarn test-svm",
3939
"test:report-gas": "IS_TEST=true REPORT_GAS=true hardhat test",
4040
"generate-evm-assets": "rm -rf typechain && TYPECHAIN=ethers yarn hardhat typechain",
4141
"prepublish": "yarn build && hardhat export --export-all ./cache/massExport.json && ts-node ./scripts/processHardhatExport.ts && prettier --write ./deployments/deployments.json && yarn generate-evm-assets",
42-
"pre-commit-hook": "sh scripts/preCommitHook.sh"
42+
"pre-commit-hook": "sh scripts/preCommitHook.sh",
43+
"anchor-build": "sh ./scripts/anchor-build.sh"
4344
},
4445
"dependencies": {
4546
"@across-protocol/constants": "^3.1.46",

rust-toolchain.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[toolchain]
2+
channel = "nightly-2025-04-01"

scripts/anchor-build.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
echo "🔨 Building anchor programs (no IDL)..."
4+
anchor build --no-idl
5+
6+
echo "📦 Generating IDLs (using nightly)..."
7+
8+
for program in programs/*; do
9+
[ -d "$program" ] || continue
10+
11+
dir_name=$(basename "$program")
12+
program_name=$(echo "$dir_name" | tr '-' '_')
13+
14+
echo "→ IDL for $program_name"
15+
RUSTUP_TOOLCHAIN="nightly-2025-04-01" anchor idl build -p "$dir_name" -o "target/idl/$program_name.json" -t "target/types/$program_name.ts"
16+
done

scripts/anchor-test.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
echo "🔨 Building anchor programs (with test feature, no IDL)..."
4+
anchor build --no-idl -- --features test
5+
6+
echo "📦 Generating IDLs (using nightly)..."
7+
8+
for program in programs/*; do
9+
[ -d "$program" ] || continue
10+
11+
dir_name=$(basename "$program")
12+
program_name=$(echo "$dir_name" | tr '-' '_')
13+
14+
echo "→ IDL for $program_name"
15+
RUSTUP_TOOLCHAIN="nightly-2025-04-01" anchor idl build -p "$dir_name" -o "target/idl/$program_name.json" -t "target/types/$program_name.ts"
16+
done
17+
18+
echo "🧪 Running anchor tests..."
19+
anchor test --skip-build

0 commit comments

Comments
 (0)