@@ -455,8 +455,7 @@ func (n *Network) Bootstrap(ctx context.Context, log logging.Logger) error {
455455 }
456456
457457 // Don't restart the node during subnet creation since it will always be restarted afterwards.
458- uri := bootstrapNode .GetAccessibleURI ()
459- if err := n .CreateSubnets (ctx , log , uri , false /* restartRequired */ ); err != nil {
458+ if err := n .CreateSubnets (ctx , log , bootstrapNode , false /* restartRequired */ ); err != nil {
460459 return stacktrace .Wrap (err )
461460 }
462461
@@ -615,8 +614,9 @@ func (n *Network) GetSubnet(name string) *Subnet {
615614
616615// Ensure that each subnet on the network is created. If restartRequired is false, node restart
617616// to pick up configuration changes becomes the responsibility of the caller.
618- func (n * Network ) CreateSubnets (ctx context.Context , log logging.Logger , apiURI string , restartRequired bool ) error {
617+ func (n * Network ) CreateSubnets (ctx context.Context , log logging.Logger , apiNode * Node , restartRequired bool ) error {
619618 createdSubnets := make ([]* Subnet , 0 , len (n .Subnets ))
619+ apiURI := apiNode .GetAccessibleURI ()
620620 for _ , subnet := range n .Subnets {
621621 if len (subnet .ValidatorIDs ) == 0 {
622622 return stacktrace .Errorf ("subnet %s needs at least one validator" , subnet .SubnetID )
@@ -682,6 +682,8 @@ func (n *Network) CreateSubnets(ctx context.Context, log logging.Logger, apiURI
682682 reconfiguredNodes = append (reconfiguredNodes , node )
683683 }
684684
685+ // TODO(samliok): remove the restart required parameter, and check if subnet configuration requires
686+ // a restart instead.
685687 if restartRequired {
686688 log .Info ("restarting node(s) to enable them to track the new subnet(s)" )
687689
@@ -699,6 +701,9 @@ func (n *Network) CreateSubnets(ctx context.Context, log logging.Logger, apiURI
699701 if err := WaitForHealthyNodes (ctx , n .log , runningNodes ); err != nil {
700702 return stacktrace .Wrap (err )
701703 }
704+
705+ // since we have restarted nodes, refetch the api uri in case it changed
706+ apiURI = apiNode .GetAccessibleURI ()
702707 }
703708
704709 // Add validators for the subnet
0 commit comments