Skip to content

Commit

Permalink
add node configs to local cluster (#2296)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemadero authored Oct 28, 2024
1 parent cf3d4a8 commit 2dfe5c5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/blockchaincmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,13 +532,22 @@ func deployBlockchain(cmd *cobra.Command, args []string) error {
}
}
network = models.NewNetworkFromCluster(network, clusterName)
nodeConfig := ""
if app.AvagoNodeConfigExists(blockchainName) {
nodeConfigBytes, err := os.ReadFile(app.GetAvagoNodeConfigPath(blockchainName))
if err != nil {
return err
}
nodeConfig = string(nodeConfigBytes)
}
// anrSettings, avagoVersionSettings, globalNetworkFlags are empty
if err = node.StartLocalNode(
app,
clusterName,
useEtnaDevnet,
avagoBinaryPath,
uint32(numLocalNodes),
nodeConfig,
anrSettings,
avagoVersionSettings,
globalNetworkFlags,
Expand Down
13 changes: 13 additions & 0 deletions cmd/nodecmd/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
package nodecmd

import (
"os"

"github.com/ava-labs/avalanche-cli/pkg/cobrautils"
"github.com/ava-labs/avalanche-cli/pkg/networkoptions"
"github.com/ava-labs/avalanche-cli/pkg/node"
Expand All @@ -22,6 +24,7 @@ var (
stakingCertKeyPath string
stakingSignerKeyPath string
numNodes uint32
nodeConfigPath string
)

// const snapshotName = "local_snapshot"
Expand Down Expand Up @@ -79,6 +82,7 @@ status by running avalanche node status local
cmd.Flags().StringVar(&stakingCertKeyPath, "staking-cert-key-path", "", "path to provided staking cert key for node")
cmd.Flags().StringVar(&stakingSignerKeyPath, "staking-signer-key-path", "", "path to provided staking signer key for node")
cmd.Flags().Uint32Var(&numNodes, "num-nodes", 1, "number of nodes to start")
cmd.Flags().StringVar(&nodeConfigPath, "node-config", "", "path to common avalanchego config settings for all nodes")
return cmd
}

Expand Down Expand Up @@ -139,12 +143,21 @@ func localStartNode(_ *cobra.Command, args []string) error {
UseLatestAvalanchegoReleaseVersion: useLatestAvalanchegoReleaseVersion,
UseAvalanchegoVersionFromSubnet: useAvalanchegoVersionFromSubnet,
}
nodeConfig := ""
if nodeConfigPath != "" {
nodeConfigBytes, err := os.ReadFile(nodeConfigPath)
if err != nil {
return err
}
nodeConfig = string(nodeConfigBytes)
}
return node.StartLocalNode(
app,
clusterName,
globalNetworkFlags.UseEtnaDevnet,
avalanchegoBinaryPath,
numNodes,
nodeConfig,
anrSettings,
avaGoVersionSetting,
globalNetworkFlags,
Expand Down
3 changes: 3 additions & 0 deletions pkg/node/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ func StartLocalNode(
useEtnaDevnet bool,
avalanchegoBinaryPath string,
numNodes uint32,
nodeConfig string,
anrSettings ANRSettings,
avaGoVersionSetting AvalancheGoVersionSettings,
globalNetworkFlags networkoptions.NetworkFlags,
Expand Down Expand Up @@ -207,6 +208,7 @@ func StartLocalNode(
client.WithReassignPortsIfUsed(true),
client.WithPluginDir(pluginDir),
client.WithSnapshotPath(rootDir),
client.WithGlobalNodeConfig(nodeConfig),
}
// load snapshot for existing network
if _, err := cli.LoadSnapshot(
Expand Down Expand Up @@ -298,6 +300,7 @@ func StartLocalNode(
client.WithPluginDir(pluginDir),
client.WithFreshStakingIds(true),
client.WithZeroIP(false),
client.WithGlobalNodeConfig(nodeConfig),
}
if anrSettings.GenesisPath != "" && utils.FileExists(anrSettings.GenesisPath) {
anrOpts = append(anrOpts, client.WithGenesisPath(anrSettings.GenesisPath))
Expand Down

0 comments on commit 2dfe5c5

Please sign in to comment.