11use {
2- crate :: utils:: { dashboard, examples, nodes, ssh_deploy, svm_info} ,
2+ crate :: utils:: { dashboard, ebpf_deploy , examples, nodes, ssh_deploy, svm_info} ,
33 clparse:: parse_command_line,
44 solana_clap_utils:: input_validators:: normalize_to_url_if_moniker,
55 solana_client:: rpc_client:: RpcClient ,
@@ -16,7 +16,7 @@ fn pubkey_of_checked(matches: &clap::ArgMatches, name: &str) -> Option<solana_sd
1616}
1717
1818#[ cfg( feature = "remote-wallet" ) ]
19- use solana_remote_wallet:: remote_wallet:: RemoteWalletManager ;
19+ use { solana_remote_wallet:: remote_wallet:: RemoteWalletManager , std :: sync :: Arc } ;
2020pub mod clparse;
2121pub mod prelude;
2222pub mod utils;
@@ -53,8 +53,7 @@ impl From<webpki::Error> for WebPkiError {
5353async fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
5454 let app_matches = parse_command_line ( ) ;
5555 let Some ( ( sub_command, sub_matches) ) = app_matches. subcommand ( ) else {
56- eprintln ! ( "No subcommand provided" ) ;
57- exit ( 1 ) ;
56+ return Err ( "No subcommand provided" . into ( ) ) ;
5857 } ;
5958 let matches = sub_matches;
6059
@@ -66,6 +65,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
6665 }
6766
6867 #[ cfg( feature = "remote-wallet" ) ]
68+ #[ allow( unused_variables, unused_mut) ]
6969 let mut wallet_manager: Option < Arc < RemoteWalletManager > > = None ;
7070
7171 #[ cfg( not( feature = "remote-wallet" ) ) ]
@@ -86,11 +86,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
8686 . unwrap_or_else ( || cli_config. keypair_path . clone ( ) ) ;
8787
8888 // Create a signer directly from the keypair path
89- let signer =
90- solana_sdk:: signature:: read_keypair_file ( & keypair_path) . unwrap_or_else ( |err| {
91- eprintln ! ( "Error reading keypair file {}: {}" , keypair_path, err) ;
92- exit ( 1 ) ;
93- } ) ;
89+ let signer = match solana_sdk:: signature:: read_keypair_file ( & keypair_path) {
90+ Ok ( signer) => signer,
91+ Err ( err) => {
92+ return Err ( format ! ( "Error reading keypair file {}: {}" , keypair_path, err) . into ( ) ) ;
93+ }
94+ } ;
9495
9596 Config {
9697 json_rpc_url : normalize_to_url_if_moniker (
@@ -101,7 +102,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
101102 ) ,
102103 default_signer : Box :: new ( signer) ,
103104 // Count occurrences of the verbose flag to determine verbosity level
104- verbose : matches. get_count ( "verbose" ) as u8 ,
105+ verbose : matches. get_count ( "verbose" ) ,
105106 no_color,
106107 commitment_config : CommitmentConfig :: confirmed ( ) ,
107108 }
@@ -583,7 +584,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
583584 println ! ( "Solana validator node deployed successfully!" ) ;
584585 }
585586 "rpc" => {
586- let solana_sub_matches = solana_sub_matches;
587587 // Deploy a Solana RPC node with enhanced features
588588 let connection_str = solana_sub_matches
589589 . get_one :: < String > ( "connection" )
@@ -899,12 +899,90 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
899899 exit ( 1 ) ;
900900 }
901901 }
902+ "deploy" => {
903+ // Command to deploy eBPF binary to all SVM networks
904+ let binary_path = matches
905+ . get_one :: < String > ( "binary" )
906+ . map ( |s| s. as_str ( ) )
907+ . unwrap ( ) ;
908+ let program_id_path = matches
909+ . get_one :: < String > ( "program-id" )
910+ . map ( |s| s. as_str ( ) )
911+ . unwrap ( ) ;
912+ let owner_path = matches
913+ . get_one :: < String > ( "owner" )
914+ . map ( |s| s. as_str ( ) )
915+ . unwrap ( ) ;
916+ let fee_payer_path = matches
917+ . get_one :: < String > ( "fee" )
918+ . map ( |s| s. as_str ( ) )
919+ . unwrap ( ) ;
920+ let publish_idl = matches. get_flag ( "publish-idl" ) ;
921+ let idl_file_path = matches. get_one :: < String > ( "idl-file" ) . map ( |s| s. to_string ( ) ) ;
922+ let network_str = matches
923+ . get_one :: < String > ( "network" )
924+ . map ( |s| s. as_str ( ) )
925+ . unwrap_or ( "all" ) ;
926+ let json_output = matches. get_flag ( "json" ) ;
927+ let retry_attempts = matches
928+ . get_one :: < String > ( "retry-attempts" )
929+ . and_then ( |s| s. parse ( ) . ok ( ) )
930+ . unwrap_or ( 3 ) ;
931+ let confirm_large_binaries = matches. get_flag ( "confirm-large" ) ;
932+
933+ // Create deployment configuration
934+ let deploy_config = ebpf_deploy:: DeployConfig {
935+ binary_path : binary_path. to_string ( ) ,
936+ program_id_path : program_id_path. to_string ( ) ,
937+ owner_path : owner_path. to_string ( ) ,
938+ fee_payer_path : fee_payer_path. to_string ( ) ,
939+ publish_idl,
940+ idl_file_path,
941+ network_selection : network_str. to_string ( ) ,
942+ json_output,
943+ retry_attempts,
944+ confirm_large_binaries,
945+ } ;
946+
947+ println ! ( "🚀 OSVM eBPF Deployment Tool" ) ;
948+ println ! ( "============================" ) ;
949+ println ! ( "📁 Binary path: {binary_path}" ) ;
950+ println ! ( "🆔 Program ID: {program_id_path}" ) ;
951+ println ! ( "👤 Owner: {owner_path}" ) ;
952+ println ! ( "💰 Fee payer: {fee_payer_path}" ) ;
953+ println ! ( "📄 Publish IDL: {}" , if publish_idl { "yes" } else { "no" } ) ;
954+ println ! ( "🌐 Target network(s): {network_str}" ) ;
955+ println ! ( ) ;
956+
957+ // Execute deployment
958+ let results = ebpf_deploy:: deploy_to_all_networks (
959+ deploy_config. clone ( ) ,
960+ config. commitment_config ,
961+ )
962+ . await ;
963+
964+ // Display results using the new display function
965+ if let Err ( e) =
966+ ebpf_deploy:: display_deployment_results ( & results, deploy_config. json_output )
967+ {
968+ eprintln ! ( "Error displaying results: {}" , e) ;
969+ }
970+
971+ // Determine exit status
972+ let failure_count = results
973+ . iter ( )
974+ . filter ( |r| r. as_ref ( ) . map_or ( true , |d| !d. success ) )
975+ . count ( ) ;
976+
977+ if failure_count > 0 {
978+ return Err ( "Some deployments failed" . into ( ) ) ;
979+ }
980+ }
902981 "new_feature_command" => {
903982 println ! ( "Expected output for new feature" ) ;
904983 }
905984 cmd => {
906- eprintln ! ( "Unknown command: {}" , cmd) ;
907- exit ( 1 ) ;
985+ return Err ( format ! ( "Unknown command: {cmd}" ) . into ( ) ) ;
908986 }
909987 } ;
910988
@@ -919,7 +997,7 @@ mod test {
919997 #[ test]
920998 fn test_borsh ( ) {
921999 #[ repr( C ) ]
922- #[ derive( BorshSerialize , BorshDeserialize , PartialEq , Debug , Clone ) ]
1000+ #[ derive( BorshSerialize , BorshDeserialize , PartialEq , Eq , Debug , Clone ) ]
9231001 pub struct UpdateMetadataAccountArgs {
9241002 pub data : Option < String > ,
9251003 pub update_authority : Option < Pubkey > ,
0 commit comments