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

feat: add verifiable option in deploy command #2705

Merged
merged 5 commits into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The minor version will be incremented upon a breaking change and the patch versi
### Features

- cli: Allow force `init` and `new` ([#2698](https://github.com/coral-xyz/anchor/pull/2698)).
- cli: Add verifiable option when `deploy` ([#2705](https://github.com/coral-xyz/anchor/pull/2705)).

### Fixes

Expand Down
10 changes: 8 additions & 2 deletions cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1257,10 +1257,16 @@ impl Program {
Ok(WithPath::new(file, path))
}

pub fn binary_path(&self) -> PathBuf {
pub fn binary_path(&self, verifiable: bool) -> PathBuf {
let path = if verifiable {
format!("target/verifiable/{}.so", self.lib_name)
} else {
format!("target/deploy/{}.so", self.lib_name)
};

std::env::current_dir()
.expect("Must have current dir")
.join(format!("target/deploy/{}.so", self.lib_name))
.join(path)
}
}

Expand Down
19 changes: 15 additions & 4 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ pub enum Command {
/// Keypair of the program (filepath) (requires program-name)
#[clap(long, requires = "program_name")]
program_keypair: Option<String>,
/// If true, deploy from path target/verifiable
#[clap(short, long)]
verifiable: bool,
},
/// Runs the deploy migration script.
Migrate,
Expand Down Expand Up @@ -676,7 +679,13 @@ fn process_command(opts: Opts) -> Result<()> {
Command::Deploy {
program_name,
program_keypair,
} => deploy(&opts.cfg_override, program_name, program_keypair),
verifiable,
} => deploy(
&opts.cfg_override,
program_name,
program_keypair,
verifiable,
),
Command::Expand {
program_name,
cargo_args,
Expand Down Expand Up @@ -3027,7 +3036,7 @@ fn test(
// In either case, skip the deploy if the user specifies.
let is_localnet = cfg.provider.cluster == Cluster::Localnet;
if (!is_localnet || skip_local_validator) && !skip_deploy {
deploy(cfg_override, None, None)?;
deploy(cfg_override, None, None, false)?;
}
let mut is_first_suite = true;
if cfg.scripts.get("test").is_some() {
Expand Down Expand Up @@ -3189,7 +3198,8 @@ fn validator_flags(

let mut flags = Vec::new();
for mut program in cfg.read_all_programs()? {
let binary_path = program.binary_path().display().to_string();
let verifiable = false;
let binary_path = program.binary_path(verifiable).display().to_string();

// Use the [programs.cluster] override and fallback to the keypair
// files if no override is given.
Expand Down Expand Up @@ -3559,6 +3569,7 @@ fn deploy(
cfg_override: &ConfigOverride,
program_name: Option<String>,
program_keypair: Option<String>,
verifiable: bool,
) -> Result<()> {
// Execute the code within the workspace
with_workspace(cfg_override, |cfg| {
Expand All @@ -3570,7 +3581,7 @@ fn deploy(
println!("Upgrade authority: {}", keypair);

for mut program in cfg.get_programs(program_name)? {
let binary_path = program.binary_path().display().to_string();
let binary_path = program.binary_path(verifiable).display().to_string();

println!("Deploying program {:?}...", program.lib_name);
println!("Program path: {}...", binary_path);
Expand Down
Loading