Skip to content
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

Rust cargo arguments not supported? #121

Open
yurushao opened this issue Jan 5, 2025 · 14 comments
Open

Rust cargo arguments not supported? #121

yurushao opened this issue Jan 5, 2025 · 14 comments

Comments

@yurushao
Copy link

yurushao commented Jan 5, 2025

Our mainnet program is built with cargo args:

 anchor build -- --features mainnet --tools-version v1.43

Tried to pass the args to solana-verify but it didn't work

$ solana-verify build -- --features mainnet
...
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
error: none of the selected packages contains these features: mainnet
Finished building program
Program Solana version: v1.18.23
Docker image Solana version: v1.18.23

Any advice on how to make it work? Thanks!

@ngundotra
Copy link
Collaborator

Hi! Do you mind sharing which version of solana-verify you are using?

@yurushao
Copy link
Author

yurushao commented Jan 6, 2025

Hi @ngundotra

$ solana-verify -V
solana-verify 0.4.0

@ngundotra
Copy link
Collaborator

@yurushao Can you provide a link to a github repo that you are trying to build? There is not enough information here for us to help debug

cc @Woody4618 for ideas on blind debugging here, just in case I'm missing something

@yurushao
Copy link
Author

yurushao commented Jan 6, 2025

Thank you. Appreciate your quick responses!

Our program code is here https://github.com/glamsystems/glam/tree/main/anchor

We build our mainnet program with this command:

anchor build -- --features mainnet --tools-version v1.43

@Woody4618
Copy link
Contributor

Looks like you are not putting the library name:
Can you please try:
solana-verify build --library-name glam -- --features mainnet

That works for me locally.

@yurushao
Copy link
Author

yurushao commented Jan 8, 2025

@Woody4618 Thank you so much! It works!

@yurushao yurushao closed this as completed Jan 8, 2025
@yurushao yurushao reopened this Jan 8, 2025
@yurushao
Copy link
Author

yurushao commented Jan 8, 2025

@Woody4618 Program was built and verified with --features mainnet. Thank you again for the help!

A follow-up question, any way to make --tools-version work? This is what I got with it:

➜  anchor git:(main) solana-verify build --library-name glam  -- --features mainnet --tools-version v1.43
Mounting path: /home/yurushao/code/glam/anchor
Found docker image for Solana version 1.18.23
Workdir: /build
Building program at /build//programs/glam/
Building manifest path: /build//programs/glam/Cargo.toml
No Docker resource limits are set.
You can set the SVB_DOCKER_MEMORY_LIMIT and SVB_DOCKER_CPU_LIMIT environment variables to limit Docker resources.
For example: SVB_DOCKER_MEMORY_LIMIT=2g SVB_DOCKER_CPU_LIMIT=2.
error: unexpected argument '--tools-version' found

Usage: cargo build --release --target [<TRIPLE>] --config <KEY=VALUE> --locked --manifest-path <PATH> --features <FEATURES>

For more information, try '--help'.
Finished building program
Program Solana version: v1.18.23
Docker image Solana version: v1.18.23
401500c5fb56231d9b7e413368eab4134d84ac29cc3c433d91e9c0431dc9854d

@LucasSte
Copy link

LucasSte commented Jan 8, 2025

The platform tools version are shipped with Solana CLI versions. If you update your CLI version to 2.0, you'll have tools version v1.42. CLI version 2.1 will have tools version v1.43.

--tools-version assumes you have the version already installed locally. If you don't have them yet, pass also the flag --force-tools-install.

@yurushao
Copy link
Author

Thank you very much for the clarification @LucasSte!

@0x0ece
Copy link

0x0ece commented Jan 12, 2025

The arguments after -- are passed to cargo build, not to cargo build-sbf [1]. So, --features is recognized but --tools-version (and fwiw --force-tools-install) are not.

If you guys want to support it, --tools-version should go before adding the --:
https://github.com/Ellipsis-Labs/solana-verifiable-build/blob/v0.4.0/src/main.rs#L1097-L1106

[1] Note that in the example at the very top, the cmd is anchor build, and anchor passes all arguments to cargo build-sbf, not to cargo build.

@yurushao yurushao reopened this Jan 14, 2025
@yurushao
Copy link
Author

yurushao commented Jan 14, 2025

Sorry had to re-open this issue again. I thought I could follow the advice from @LucasSte and @0x0ece to create a PR and make it work, but I got blocked.

Here's the PR for adding --tools-version support #126

I built the binary and ran it inside glam repo . As you can see --tools-version v1.43 was parsed correctly and printed, but cargo-build-sbf failed:

~/code/glam/anchor/ [main] /Users/yurushao/code/solana-verifiable-build/target/debug/solana-verify build --library-name glam  --tools-version v1.43
Mounting path: /Users/yurushao/code/glam/anchor
Found docker image for Solana version 1.18.23
...
tools_version_args: ["--force-tools-install", "--tools-version", "v1.43"]
thread 'main' panicked at sdk/cargo-build-sbf/src/main.rs:144:10:
called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
...

Any advice?

@LucasSte
Copy link

I tried reproducing the issue here with Solana v1.18.23, and I believe there is a bug in that version. Would you mind trying with the latest Solana CLI version?

@yurushao
Copy link
Author

Tested solana-program 1.18.11, 1.18.26, 2.0.0, 2.1.0, all got the same error.

@LucasSte
Copy link

solana-program is a Rust crate you include in your contract to use the Solana SDK. No version you choose will affect the cargo-build-sbf.

The Solana CLI is the set of tools you install locally (or inside Docker) to interact with the blockchain. It also comes with the compiler tools. This is how you install it: https://solana.com/docs/intro/installation#install-the-solana-cli

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants