@@ -228,7 +228,11 @@ async fn main() -> anyhow::Result<()> {
228228 . arg ( Arg :: with_name ( "cargo-args" )
229229 . multiple ( true )
230230 . last ( true )
231- . help ( "Arguments to pass to the underlying `cargo build-bpf` command" ) ) )
231+ . help ( "Arguments to pass to the underlying `cargo build-bpf` command" ) )
232+ . arg ( Arg :: with_name ( "skip-build" )
233+ . long ( "skip-build" )
234+ . help ( "Skip building and verification, only upload the PDA" )
235+ . takes_value ( false ) ) )
232236 . subcommand ( SubCommand :: with_name ( "close" )
233237 . about ( "Close the otter-verify PDA account associated with the given program ID" )
234238 . arg ( Arg :: with_name ( "program-id" )
@@ -346,6 +350,7 @@ async fn main() -> anyhow::Result<()> {
346350 Ok ( ( ) )
347351 }
348352 ( "verify-from-repo" , Some ( sub_m) ) => {
353+ let skip_build = sub_m. is_present ( "skip-build" ) ;
349354 let remote = sub_m. is_present ( "remote" ) ;
350355 let mount_path = sub_m. value_of ( "mount-path" ) . map ( |s| s. to_string ( ) ) . unwrap ( ) ;
351356 let repo_url = sub_m. value_of ( "repo-url" ) . map ( |s| s. to_string ( ) ) . unwrap ( ) ;
@@ -397,6 +402,7 @@ async fn main() -> anyhow::Result<()> {
397402 skip_prompt,
398403 path_to_keypair,
399404 compute_unit_price,
405+ skip_build,
400406 & mut container_id,
401407 & mut temp_dir,
402408 & check_signal,
@@ -945,6 +951,7 @@ pub async fn verify_from_repo(
945951 skip_prompt : bool ,
946952 path_to_keypair : Option < String > ,
947953 compute_unit_price : u64 ,
954+ skip_build : bool ,
948955 container_id_opt : & mut Option < String > ,
949956 temp_dir_opt : & mut Option < String > ,
950957 check_signal : & dyn Fn ( & mut Option < String > , & mut Option < String > ) ,
@@ -1183,51 +1190,60 @@ pub async fn verify_from_repo(
11831190 }
11841191 }
11851192
1186- let result = build_and_verify_repo (
1187- mount_path. to_str ( ) . unwrap ( ) . to_string ( ) ,
1188- base_image. clone ( ) ,
1189- bpf_flag,
1190- library_name. clone ( ) ,
1191- connection,
1192- program_id,
1193- cargo_args. clone ( ) ,
1194- container_id_opt,
1195- ) ;
1193+ // When skip_build is true, we skip the build and verify step but still do the upload
1194+ let result = if !skip_build {
1195+ build_and_verify_repo (
1196+ mount_path. to_str ( ) . unwrap ( ) . to_string ( ) ,
1197+ base_image. clone ( ) ,
1198+ bpf_flag,
1199+ library_name. clone ( ) ,
1200+ connection,
1201+ program_id,
1202+ cargo_args. clone ( ) ,
1203+ container_id_opt,
1204+ )
1205+ } else {
1206+ Ok ( ( "skipped" . to_string ( ) , "skipped" . to_string ( ) ) )
1207+ } ;
11961208
11971209 // Cleanup no matter the result
11981210 std:: process:: Command :: new ( "rm" )
11991211 . args ( [ "-rf" , & verify_dir] )
12001212 . output ( ) ?;
12011213
1202- // Compare hashes or return error
1203- if let Ok ( ( build_hash, program_hash) ) = result {
1204- println ! ( "Executable Program Hash from repo: {}" , build_hash) ;
1205- println ! ( "On-chain Program Hash: {}" , program_hash) ;
1214+ // Handle the result
1215+ match result {
1216+ Ok ( ( build_hash, program_hash) ) => {
1217+ if !skip_build {
1218+ println ! ( "Executable Program Hash from repo: {}" , build_hash) ;
1219+ println ! ( "On-chain Program Hash: {}" , program_hash) ;
1220+ }
12061221
1207- if build_hash == program_hash {
1208- println ! ( "Program hash matches ✅" ) ;
1209- let x = upload_program (
1210- repo_url,
1211- & commit_hash. clone ( ) ,
1212- args. iter ( ) . map ( |& s| s. into ( ) ) . collect ( ) ,
1213- program_id,
1214- connection,
1215- skip_prompt,
1216- path_to_keypair,
1217- compute_unit_price,
1218- )
1219- . await ;
1220- if x. is_err ( ) {
1221- println ! ( "Error uploading program: {:?}" , x) ;
1222- exit ( 1 ) ;
1222+ if skip_build || build_hash == program_hash {
1223+ if skip_build {
1224+ println ! ( "Skipping build and uploading program" ) ;
1225+ } else {
1226+ println ! ( "Program hash matches ✅" ) ;
1227+ }
1228+ upload_program (
1229+ repo_url,
1230+ & commit_hash. clone ( ) ,
1231+ args. iter ( ) . map ( |& s| s. into ( ) ) . collect ( ) ,
1232+ program_id,
1233+ connection,
1234+ skip_prompt,
1235+ path_to_keypair,
1236+ compute_unit_price,
1237+ )
1238+ . await
1239+ } else {
1240+ println ! ( "Program hashes do not match ❌" ) ;
1241+ println ! ( "Executable Program Hash from repo: {}" , build_hash) ;
1242+ println ! ( "On-chain Program Hash: {}" , program_hash) ;
1243+ Ok ( ( ) )
12231244 }
1224- } else {
1225- println ! ( "Program hashes do not match ❌" ) ;
12261245 }
1227-
1228- Ok ( ( ) )
1229- } else {
1230- Err ( anyhow ! ( "Error verifying program. {:?}" , result) )
1246+ Err ( e) => Err ( anyhow ! ( "Error verifying program: {:?}" , e) ) ,
12311247 }
12321248}
12331249
0 commit comments