feat(cli): add --artifacts-path flag to override .so program location#573
Conversation
Allow overriding the default `target/deploy` path for .so artifacts with `--artifacts-path`. This enables loading debug-compiled programs during local development (e.g. `surfpool start --artifacts-path ./target/deploy/debug`). The flag conflicts with `--network` to prevent deploying debug builds to mainnet/devnet/testnet. Threads artifacts_path through framework detection, .so existence checks, in-memory template generation (bin_path injection), and the file watcher.
Allow overriding the default target/deploy path for .so program artifacts. Deployment always targets the local surfnet regardless of --network or --rpc-url, so no conflicts are needed.
|
Hmm, I just ran |
The change dates back to anza-xyz/agave#9263 . What you observe is most probably because you use cargo-build-sbf from stable. However with agave 4.x the path for debug builds is changed to |
|
@MicaiahReid - is it possible that you have a look on this one again? |
5419677 to
2129ad9
Compare
@procdump I was able to get this tested, it looks good to me! One question - it looks like the debug build also generates a new keypair / program id. Should this artifacts-path also be updating the keypair used for the deployment? Something like let bin_path = format!("{}/{}.so", artifacts.trim_end_matches('/'), program_name);
let keypair_path = format!("{}/{}-keypair.json", artifacts.trim_end_matches('/'), program_name);
// Pass bin_path as the 4th argument (program_name, keypair_path, idl_path, bin_path)
let old = format!("program = {}(\"{}\") ", get_program_fn, program_name);
let new = format!(
"program = {}(\"{}\", \"{}\", null, \"{}\") ",
get_program_fn, program_name, keypair_path, bin_path
); |
819431a to
2286c77
Compare
When --artifacts-path is set, use the keypair from the same directory as the .so instead of defaulting to target/deploy/. cargo build-sbf outputs both files to the same location.
2286c77 to
7346dbc
Compare
@MicaiahReid - Good point. I've fixed it as you suggest 7346dbc. |
Summary
cargo-build-sbf --debugemits artifacts intarget/deploy/debugon purpose to prevent accidental deployments on mainnet so in that sense:--artifacts-pathCLI flag to support loading debug-compiled.soprograms (e.g.surfpool start --artifacts-path ./target/deploy/debug)artifacts_paththrough framework detection,.soexistence checks, in-memory template generation, and the--watchfile watcherWhile working on this PR I've unearthed a calculation overflow bug in
txtx-addon-network-svm(details in the PR): solana-foundation/txtx#399