@@ -581,73 +581,76 @@ func deployBlockchain(cmd *cobra.Command, args []string) error {
581581 deployBalance := uint64 (deployBalanceAVAX * float64 (units .Avax ))
582582 // whether user has created Avalanche Nodes when blockchain deploy command is called
583583 if sidecar .Sovereign {
584- if changeOwnerAddress == "" {
585- // use provided key as change owner unless already set
586- if pAddr , err := kc .PChainFormattedStrAddresses (); err == nil && len (pAddr ) > 0 {
587- changeOwnerAddress = pAddr [0 ]
588- ux .Logger .PrintToUser ("Using [%s] to be set as a change owner for leftover AVAX" , changeOwnerAddress )
589- }
590- }
591- if ! generateNodeID {
592- if cancel , err := StartLocalMachine (
593- network ,
594- sidecar ,
595- blockchainName ,
596- deployBalance ,
597- availableBalance ,
598- httpPorts ,
599- stakingPorts ,
600- ); err != nil {
601- return err
602- } else if cancel {
603- return nil
604- }
605- }
606- switch {
607- case len (bootstrapEndpoints ) > 0 :
584+ if len (bootstrapValidators ) == 0 {
608585 if changeOwnerAddress == "" {
609- changeOwnerAddress , err = blockchain .GetKeyForChangeOwner (app , network )
610- if err != nil {
611- return err
586+ // use provided key as change owner unless already set
587+ if pAddr , err := kc .PChainFormattedStrAddresses (); err == nil && len (pAddr ) > 0 {
588+ changeOwnerAddress = pAddr [0 ]
589+ ux .Logger .PrintToUser ("Using [%s] to be set as a change owner for leftover AVAX" , changeOwnerAddress )
612590 }
613591 }
614- for _ , endpoint := range bootstrapEndpoints {
615- infoClient := info .NewClient (endpoint )
616- ctx , cancel := utils .GetAPILargeContext ()
617- defer cancel ()
618- nodeID , proofOfPossession , err := infoClient .GetNodeID (ctx )
619- if err != nil {
592+ if ! generateNodeID {
593+ if cancel , err := StartLocalMachine (
594+ network ,
595+ sidecar ,
596+ blockchainName ,
597+ deployBalance ,
598+ availableBalance ,
599+ httpPorts ,
600+ stakingPorts ,
601+ cmd ,
602+ ); err != nil {
620603 return err
604+ } else if cancel {
605+ return nil
621606 }
622- publicKey = "0x" + hex .EncodeToString (proofOfPossession .PublicKey [:])
623- pop = "0x" + hex .EncodeToString (proofOfPossession .ProofOfPossession [:])
624-
625- bootstrapValidators = append (bootstrapValidators , models.SubnetValidator {
626- NodeID : nodeID .String (),
627- Weight : constants .BootstrapValidatorWeight ,
628- Balance : deployBalance ,
629- BLSPublicKey : publicKey ,
630- BLSProofOfPossession : pop ,
631- ChangeOwnerAddr : changeOwnerAddress ,
632- })
633- }
634- case clusterNameFlagValue != "" :
635- // for remote clusters we don't need to ask for bootstrap validators and can read it from filesystem
636- bootstrapValidators , err = getClusterBootstrapValidators (clusterNameFlagValue , network , deployBalance )
637- if err != nil {
638- return fmt .Errorf ("error getting bootstrap validators from cluster %s: %w" , clusterNameFlagValue , err )
639607 }
608+ switch {
609+ case len (bootstrapEndpoints ) > 0 :
610+ if changeOwnerAddress == "" {
611+ changeOwnerAddress , err = blockchain .GetKeyForChangeOwner (app , network )
612+ if err != nil {
613+ return err
614+ }
615+ }
616+ for _ , endpoint := range bootstrapEndpoints {
617+ infoClient := info .NewClient (endpoint )
618+ ctx , cancel := utils .GetAPILargeContext ()
619+ defer cancel ()
620+ nodeID , proofOfPossession , err := infoClient .GetNodeID (ctx )
621+ if err != nil {
622+ return err
623+ }
624+ publicKey = "0x" + hex .EncodeToString (proofOfPossession .PublicKey [:])
625+ pop = "0x" + hex .EncodeToString (proofOfPossession .ProofOfPossession [:])
626+
627+ bootstrapValidators = append (bootstrapValidators , models.SubnetValidator {
628+ NodeID : nodeID .String (),
629+ Weight : constants .BootstrapValidatorWeight ,
630+ Balance : deployBalance ,
631+ BLSPublicKey : publicKey ,
632+ BLSProofOfPossession : pop ,
633+ ChangeOwnerAddr : changeOwnerAddress ,
634+ })
635+ }
636+ case clusterNameFlagValue != "" :
637+ // for remote clusters we don't need to ask for bootstrap validators and can read it from filesystem
638+ bootstrapValidators , err = getClusterBootstrapValidators (clusterNameFlagValue , network , deployBalance )
639+ if err != nil {
640+ return fmt .Errorf ("error getting bootstrap validators from cluster %s: %w" , clusterNameFlagValue , err )
641+ }
640642
641- default :
642- bootstrapValidators , err = promptBootstrapValidators (
643- network ,
644- changeOwnerAddress ,
645- numBootstrapValidators ,
646- deployBalance ,
647- availableBalance ,
648- )
649- if err != nil {
650- return err
643+ default :
644+ bootstrapValidators , err = promptBootstrapValidators (
645+ network ,
646+ changeOwnerAddress ,
647+ numBootstrapValidators ,
648+ deployBalance ,
649+ availableBalance ,
650+ )
651+ if err != nil {
652+ return err
653+ }
651654 }
652655 }
653656 } else if network .Kind == models .Local {
0 commit comments