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

Integrate local machine into subnet deploy #2235

Closed
wants to merge 14 commits into from

Conversation

sukantoraymond
Copy link
Collaborator

@sukantoraymond sukantoraymond commented Oct 10, 2024

Why this should be merged

Integrates using local machine as bootstrap validator into subnet deploy command.

How this works

// create the local node connected to etna
go run main.go node local start --etna-devnet --avalanchego-path <AVALANCHEGO_PATH>

// create a blockchain conf
go run main.go blockchain create

// create subnet+blockchain+convert on the blokchain
go run main.go blockchain deploy --cluster

How this was tested

./bin/avalanche subnet deploy will have to achieve L1 set up with local machine as sole bootstrap validator in Etna Devnet

How is this documented

NA

@sukantoraymond sukantoraymond requested a review from a team as a code owner October 10, 2024 23:18
@sukantoraymond sukantoraymond changed the base branch from main to node-create-local October 10, 2024 23:19
aggregatorExtraPeerEndpoints, err := GetAggregatorExtraPeerEndpoints(network)

// TODO: replace wait below wiht check for healhty in local machine
time.Sleep(70 * time.Second)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will have to change this

}

if useLocalMachine {
bootstrapEndpoints = []string{"http://127.0.0.1:9650"}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might be tricky to assume this endpoint as port can be not 9650 but rather dynamic
cc @felipemadero

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should ask user for the endpoint and not yes/no for local machine.
we can hint that it can be 127.0.0.1:9650 for the local machine

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now. After the previous question, a Start should be made and from that, the endpoint
can be obtained from the anr itself, not need to assume anything.
This is not related to the flag useLocalMachine. This relates to the local cluster that exists previous
to the deploy. The best way should be to check the network, which should be a local cluster,
in that case take the endpoint from anr.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably for another PR. Make an issue for this and keep current static assignment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if exists, err := CheckClusterExists(app, clusterName); err != nil || !exists {
return nil, fmt.Errorf("cluster %q not found", clusterName)
}
clustersConfig, err := app.LoadClustersConfig()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use

clusterConfig, err := app.GetClusterConfig(clusterName)
	if err != nil {
		return err
	}
	```
	and
	`clusterConfig.Nodes` instead

)

var errIllegalNameCharacter = errors.New(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix format

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just copying from refactoring part.

ux.Logger.PrintToUser("You can use your local machine as a bootstrap validator on the blockchain")
ux.Logger.PrintToUser("This means that you don't have to to set up a remote server on a cloud service (e.g. AWS / GCP) to be a validator on the blockchain.")

useLocalMachine, err := app.Prompt.CaptureYesNo("Do you want to use your local machine as a bootstrap validator?")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flag to avoid question for this and just proceed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

@@ -464,6 +466,18 @@ func deployBlockchain(cmd *cobra.Command, args []string) error {
return PrintSubnetInfo(blockchainName, true)
}

ux.Logger.PrintToUser("You can use your local machine as a bootstrap validator on the blockchain")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also this to be guarded by a flag

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

@@ -464,6 +466,18 @@ func deployBlockchain(cmd *cobra.Command, args []string) error {
return PrintSubnetInfo(blockchainName, true)
}

ux.Logger.PrintToUser("You can use your local machine as a bootstrap validator on the blockchain")
ux.Logger.PrintToUser("This means that you don't have to to set up a remote server on a cloud service (e.g. AWS / GCP) to be a validator on the blockchain.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably we want to explain more here? like this is temporary bootstrap validator

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not temporary if user wants to leave it the node indefinitely as validator

}

if useLocalMachine {
bootstrapEndpoints = []string{"http://127.0.0.1:9650"}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now. After the previous question, a Start should be made and from that, the endpoint
can be obtained from the anr itself, not need to assume anything.
This is not related to the flag useLocalMachine. This relates to the local cluster that exists previous
to the deploy. The best way should be to check the network, which should be a local cluster,
in that case take the endpoint from anr.

}

if useLocalMachine {
bootstrapEndpoints = []string{"http://127.0.0.1:9650"}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably for another PR. Make an issue for this and keep current static assignment.

chainSpec,
)
if err != nil {
clusterName, err := node.GetClusterNameFromList(app)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cluster name to be taken from the input network itself IMO

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which should be a cluster

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

models.Networks has ClusterName

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to do it when integrating local node start

@@ -415,14 +416,17 @@ func localStopNode(_ *cobra.Command, _ []string) error {
func localDestroyNode(_ *cobra.Command, args []string) error {
clusterName := args[0]

localStopNode(nil, nil)
if err := localStopNode(nil, nil); err != nil {
return fmt.Errorf("failed to destroy local node: %w", err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node can be already stopped. for the moment on ignore the error or verify is the node is already stopped,
we want to continue removing all the directorioes that is the reason the error is ignored

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just need to make sure this passes lint. removed err

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

}
ux.Logger.GreenCheckmarkToUser("%s successfully tracking %s", clusterName, blockchainName)
return nil
return node.TrackSubnetWithLocalMachine(app, clusterName, blockchainName)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure it is the moment to move this to node pgk. we keep a part of logic here and a part in node.
also, maybe node is not the final dest package.

@@ -0,0 +1,298 @@
// Copyright (C) 2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package node
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is for another PR?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anyway, no problem keeping here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants