From d20beafd1f2ac0ab11726acc75a883b553d7e162 Mon Sep 17 00:00:00 2001 From: Jon C Date: Mon, 3 Mar 2025 21:04:25 +0100 Subject: [PATCH 1/3] tlv: Enable solana-pubkey feature, add testing #### Problem The tlv-account-resolution library currently fails to build `cargo check` because the `curve25519` feature is not enabled. #### Summary of changes Enable the feature. At the same time, add a CI step for running `cargo hack check --all-features` on the repo to catch this. --- .github/workflows/main.yml | 22 ++++++++++++++++++++++ package.json | 1 + scripts/rust/hack.mjs | 11 +++++++++++ tlv-account-resolution/Cargo.toml | 2 +- 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 scripts/rust/hack.mjs diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 63d4075c..b02023fd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -127,6 +127,28 @@ jobs: - name: Build run: pnpm ${{ matrix.library }}:build + hack_rust: + name: Check Powerset + runs-on: ubuntu-latest + steps: + - name: Git Checkout + uses: actions/checkout@v4 + + - name: Setup Environment + uses: ./.github/actions/setup + with: + rustfmt: true + cargo-cache-key: cargo-hack-check + cargo-cache-fallback-key: cargo-hack + + - name: Install cargo-hack + uses: taiki-e/cache-cargo-install-action@v2 + with: + tool: cargo-hack + + - name: Hack check + run: pnpm rust:hack + test_rust: name: Test Rust runs-on: ubuntu-latest diff --git a/package.json b/package.json index ad4a623b..d3f35725 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "template:upgrade": "zx ./scripts/upgrade-template.mjs", "rust:spellcheck": "cargo spellcheck --code 1", "rust:audit": "zx ./scripts/rust/audit.mjs", + "rust:hack": "zx ./scripts/rust/hack.mjs", "rust:semver": "cargo semver-checks" }, "devDependencies": { diff --git a/scripts/rust/hack.mjs b/scripts/rust/hack.mjs new file mode 100644 index 00000000..1342b80f --- /dev/null +++ b/scripts/rust/hack.mjs @@ -0,0 +1,11 @@ +#!/usr/bin/env zx +import 'zx/globals'; +import { + cliArguments, + getToolchainArgument, + popArgument, + workingDirectory, +} from '../utils.mjs'; + +const toolchain = getToolchainArgument('lint'); +await $`cargo ${toolchain} hack check --all-targets ${cliArguments()}`; diff --git a/tlv-account-resolution/Cargo.toml b/tlv-account-resolution/Cargo.toml index e41804fa..7bd55f43 100644 --- a/tlv-account-resolution/Cargo.toml +++ b/tlv-account-resolution/Cargo.toml @@ -21,7 +21,7 @@ solana-decode-error = "2.2.1" solana-instruction = { version = "2.2.1", features = ["std"] } solana-program-error = "2.2.1" solana-msg = "2.2.1" -solana-pubkey = "2.2.1" +solana-pubkey = { version = "2.2.1", features = ["curve25519"] } spl-discriminator = { version = "0.4.0", path = "../discriminator" } spl-program-error = { version = "0.6.0", path = "../program-error" } spl-pod = { version = "0.5.0", path = "../pod" } From 68688543099663af2ecc9606fea853f1ba491324 Mon Sep 17 00:00:00 2001 From: Jon C Date: Mon, 3 Mar 2025 21:12:09 +0100 Subject: [PATCH 2/3] Combine all toolchains into "nightly" --- .github/actions/setup/action.yml | 13 +++++++++++-- .github/workflows/main.yml | 2 +- Cargo.toml | 3 +-- scripts/ci/set-env.mjs | 3 +-- scripts/rust/format.mjs | 2 +- scripts/rust/hack.mjs | 9 ++------- scripts/rust/lint.mjs | 2 +- 7 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 34e39feb..f878470f 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -16,6 +16,9 @@ inputs: rustfmt: description: Install Rustfmt if `true`. Defaults to `false`. required: false + nightly-toolchain: + description: Install nightly toolchain if `true`. Defaults to `false`. + required: false solana: description: Install Solana if `true`. Defaults to `false`. required: false @@ -44,16 +47,22 @@ runs: if: ${{ inputs.rustfmt == 'true' }} uses: dtolnay/rust-toolchain@master with: - toolchain: ${{ env.TOOLCHAIN_FORMAT }} + toolchain: ${{ env.TOOLCHAIN_NIGHTLY }} components: rustfmt - name: Install Clippy if: ${{ inputs.clippy == 'true' }} uses: dtolnay/rust-toolchain@master with: - toolchain: ${{ env.TOOLCHAIN_LINT }} + toolchain: ${{ env.TOOLCHAIN_NIGHTLY }} components: clippy + - name: Install nightly toolchain + if: ${{ inputs.nightly-toolchain == 'true' }} + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.TOOLCHAIN_NIGHTLY }} + - name: Install Solana if: ${{ inputs.solana == 'true' }} uses: solana-program/actions/install-solana@v1 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b02023fd..25ae5fbf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -137,7 +137,7 @@ jobs: - name: Setup Environment uses: ./.github/actions/setup with: - rustfmt: true + nightly-toolchain: true cargo-cache-key: cargo-hack-check cargo-cache-fallback-key: cargo-hack diff --git a/Cargo.toml b/Cargo.toml index 0602ee30..e97c76cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,8 +15,7 @@ solana = "2.2.0" # Specify Rust toolchains for rustfmt, clippy, and build. # Any unprovided toolchains default to stable. [workspace.metadata.toolchains] -format = "nightly-2024-11-22" -lint = "nightly-2024-11-22" +nightly = "nightly-2024-11-22" [workspace.metadata.spellcheck] config = "scripts/spellcheck.toml" diff --git a/scripts/ci/set-env.mjs b/scripts/ci/set-env.mjs index 276d37bf..44f3b036 100644 --- a/scripts/ci/set-env.mjs +++ b/scripts/ci/set-env.mjs @@ -2,5 +2,4 @@ import { getSolanaVersion, getToolchain } from '../utils.mjs'; await $`echo "SOLANA_VERSION=${getSolanaVersion()}" >> $GITHUB_ENV`; -await $`echo "TOOLCHAIN_FORMAT=${getToolchain('format')}" >> $GITHUB_ENV`; -await $`echo "TOOLCHAIN_LINT=${getToolchain('lint')}" >> $GITHUB_ENV`; +await $`echo "TOOLCHAIN_NIGHTLY=${getToolchain('nightly')}" >> $GITHUB_ENV`; diff --git a/scripts/rust/format.mjs b/scripts/rust/format.mjs index 68dc98ca..7e24c575 100644 --- a/scripts/rust/format.mjs +++ b/scripts/rust/format.mjs @@ -12,7 +12,7 @@ const [folder, ...formatArgs] = cliArguments(); const fix = popArgument(formatArgs, '--fix'); const [cargoArgs, fmtArgs] = partitionArguments(formatArgs, '--'); -const toolchain = getToolchainArgument('format'); +const toolchain = getToolchainArgument('nightly'); const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml'); diff --git a/scripts/rust/hack.mjs b/scripts/rust/hack.mjs index 1342b80f..dbad72cd 100644 --- a/scripts/rust/hack.mjs +++ b/scripts/rust/hack.mjs @@ -1,11 +1,6 @@ #!/usr/bin/env zx import 'zx/globals'; -import { - cliArguments, - getToolchainArgument, - popArgument, - workingDirectory, -} from '../utils.mjs'; +import { cliArguments, getToolchainArgument } from '../utils.mjs'; -const toolchain = getToolchainArgument('lint'); +const toolchain = getToolchainArgument('nightly'); await $`cargo ${toolchain} hack check --all-targets ${cliArguments()}`; diff --git a/scripts/rust/lint.mjs b/scripts/rust/lint.mjs index 66777eb6..17be05a0 100644 --- a/scripts/rust/lint.mjs +++ b/scripts/rust/lint.mjs @@ -21,7 +21,7 @@ const lintArgs = [ ]; const fix = popArgument(lintArgs, '--fix'); -const toolchain = getToolchainArgument('lint'); +const toolchain = getToolchainArgument('nightly'); const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml'); From 3583d75676f91e861a50dafd430000de6f21d1f0 Mon Sep 17 00:00:00 2001 From: Jon C Date: Mon, 3 Mar 2025 21:15:21 +0100 Subject: [PATCH 3/3] Run with --feature-powerset --- scripts/rust/hack.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/rust/hack.mjs b/scripts/rust/hack.mjs index dbad72cd..2e90c7a2 100644 --- a/scripts/rust/hack.mjs +++ b/scripts/rust/hack.mjs @@ -3,4 +3,4 @@ import 'zx/globals'; import { cliArguments, getToolchainArgument } from '../utils.mjs'; const toolchain = getToolchainArgument('nightly'); -await $`cargo ${toolchain} hack check --all-targets ${cliArguments()}`; +await $`cargo ${toolchain} hack check --all-targets --feature-powerset ${cliArguments()}`;