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

Change subnet/blockchain creation order #1375

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

felipemadero
Copy link
Collaborator

@felipemadero felipemadero commented Jan 11, 2024

Closes #1279
With this, subnet deploy will create a subnet id on first execution, and create a blockchain on second execution. In the middle, it is expected for the user to add validators to the subnet. subnet deploy will check for that condition when creating the blockchain.

@@ -103,7 +101,10 @@ func syncSubnet(_ *cobra.Command, args []string) error {
return fmt.Errorf("node(s) %s failed to sync with subnet %s", untrackedNodes, subnetName)
}
ux.Logger.PrintToUser("Node(s) successfully started syncing with Subnet!")
ux.Logger.PrintToUser(fmt.Sprintf("Check node subnet syncing status with avalanche node status %s --subnet %s", clusterName, subnetName))
blockchainID := sc.Networks[network.Kind.String()].BlockchainID
Copy link
Collaborator

Choose a reason for hiding this comment

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

we need to check if sc.Networks[network.Kind.String()] is not nil before trying to access BlockchainID as it can crash

ux.Logger.PrintToUser(fmt.Sprintf("Check node subnet syncing status with avalanche node status %s --subnet %s", clusterName, subnetName))
blockchainID := sc.Networks[network.Kind.String()].BlockchainID
if blockchainID != ids.Empty {
ux.Logger.PrintToUser(fmt.Sprintf("Check node subnet syncing status with avalanche node status %s --subnet %s", clusterName, subnetName))
Copy link
Collaborator

Choose a reason for hiding this comment

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

fmt.Sprintf is not need as PrintToUser is a wrapper around Sprintf itself

}
return nil
return clustersConfig.Clusters[clusterName].Network, nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

check if clustersConfig.Clusters[clusterName] is not nil before accessing Network

if err != nil {
return nil, err
}
subnetID := sc.Networks[network.Kind.String()].SubnetID
Copy link
Collaborator

Choose a reason for hiding this comment

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

check if sc.Networks[network.Kind.String()] is not nil

}
nonValidators := []string{}
for i, nodeID := range nodeIDs {
isValidator, err := subnet.IsSubnetValidator(subnetID, nodeID, network)
Copy link
Collaborator

@arturrez arturrez Jan 17, 2024

Choose a reason for hiding this comment

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

suggestion: can be done in parallel to increase performance

ux.Logger.PrintToUser(" " + nonValidator)
}
ux.Logger.PrintToUser("")
return fmt.Errorf("failed to verify all nodes are subnet validators after %d seconds", uint32(timeout.Seconds()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

can it be replaced with return fmt.Errorf("failed to verify all nodes as subnet validators after %f seconds", timeout.Seconds())?

return err
}
if len(nonValidators) == 0 {
ux.Logger.PrintToUser("All nodes are subnet validators after %d seconds", uint32(time.Since(startTime).Seconds()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

can it be %f s or %0.2f?

fee += network.GenesisParams().CreateSubnetTxFee
fee = network.GenesisParams().CreateSubnetTxFee
} else {
fee = network.GenesisParams().CreateBlockchainTxFee
Copy link
Collaborator

@arturrez arturrez Jan 17, 2024

Choose a reason for hiding this comment

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

nit: can be simplified with

fee := network.GenesisParams().CreateBlockchainTxFee
if createSubnet {
		fee = network.GenesisParams().CreateSubnetTxFee
		}

Copy link
Collaborator

@arturrez arturrez left a comment

Choose a reason for hiding this comment

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

commented

@sukantoraymond
Copy link
Collaborator

Ok so seems that currently with this PR, user is expected to run the deploy command ONCE, call addValidator command, and then call deploy command again -> need to call 3 commands to deploy a subnet in public network.

I think it's better for user experience if we add prompts required for adding Validators in the deploy command so that we can deploy subnet in public network only with 1 command

@sukantoraymond
Copy link
Collaborator

Also are we changing the order here? Because seems that we are already creating subnet first and then creating blockchain anyways

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.

Avoid creating blockchains if subnet has no enough validators
3 participants