Skip to content

Commit 5ab0fef

Browse files
custom vm path for devnet
1 parent a976b91 commit 5ab0fef

File tree

6 files changed

+46
-8
lines changed

6 files changed

+46
-8
lines changed

cmd/blockchaincmd/create.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ func CallCreate(
159159
customVMRepoURLParam string,
160160
customVMBranchParam string,
161161
customVMBuildScriptParam string,
162+
customVMPath string,
162163
) error {
163164
forceCreate = forceCreateParam
164165
genesisPath = genesisPathParam
@@ -174,6 +175,7 @@ func CallCreate(
174175
customVMRepoURL = customVMRepoURLParam
175176
customVMBranch = customVMBranchParam
176177
customVMBuildScript = customVMBuildScriptParam
178+
vmFile = customVMPath
177179
return createBlockchainConfig(cmd, []string{blockchainName})
178180
}
179181

cmd/nodecmd/wiz.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ var (
6363
customVMRepoURL string
6464
customVMBranch string
6565
customVMBuildScript string
66+
customVMPath string
6667
nodeConf string
6768
subnetConf string
6869
chainConf string
@@ -122,6 +123,7 @@ The node wiz command creates a devnet and deploys, sync and validate a subnet in
122123
cmd.Flags().StringVar(&customVMRepoURL, "custom-vm-repo-url", "", "custom vm repository url")
123124
cmd.Flags().StringVar(&customVMBranch, "custom-vm-branch", "", "custom vm branch or commit")
124125
cmd.Flags().StringVar(&customVMBuildScript, "custom-vm-build-script", "", "custom vm build-script")
126+
cmd.Flags().StringVar(&customVMPath, "custom-vm-branch", "", "custom vm branch or commit")
125127
cmd.Flags().StringVar(&customGrafanaDashboardPath, "add-grafana-dashboard", "", "path to additional grafana dashboard json file")
126128
cmd.Flags().StringVar(&nodeConf, "node-config", "", "path to avalanchego node configuration for subnet")
127129
cmd.Flags().StringVar(&subnetConf, "subnet-config", "", "path to the subnet configuration for subnet")
@@ -210,6 +212,7 @@ func wiz(cmd *cobra.Command, args []string) error {
210212
customVMRepoURL,
211213
customVMBranch,
212214
customVMBuildScript,
215+
customVMPath,
213216
); err != nil {
214217
return err
215218
}

pkg/models/sidecar.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type Sidecar struct {
4242
CustomVMRepoURL string
4343
CustomVMBranch string
4444
CustomVMBuildScript string
45+
CustomVMPath string
4546
// ICM related
4647
TeleporterReady bool
4748
TeleporterKey string

pkg/node/sync.go

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,26 @@ func prepareSubnetPlugin(app *application.Avalanche, hosts []*models.Host, block
6464
}
6565
wg := sync.WaitGroup{}
6666
wgResults := models.NodeResults{}
67-
for _, host := range hosts {
68-
wg.Add(1)
69-
go func(nodeResults *models.NodeResults, host *models.Host) {
70-
defer wg.Done()
71-
if err := ssh.RunSSHCreatePlugin(host, sc); err != nil {
72-
nodeResults.AddResult(host.NodeID, nil, err)
73-
}
74-
}(&wgResults, host)
67+
if sc.CustomVMRepoURL == "" && sc.CustomVMPath != "" {
68+
for _, host := range hosts {
69+
wg.Add(1)
70+
go func(nodeResults *models.NodeResults, host *models.Host) {
71+
defer wg.Done()
72+
if err := ssh.RunSSHCopyBinaryFile(host, sc); err != nil {
73+
nodeResults.AddResult(host.NodeID, nil, err)
74+
}
75+
}(&wgResults, host)
76+
}
77+
} else {
78+
for _, host := range hosts {
79+
wg.Add(1)
80+
go func(nodeResults *models.NodeResults, host *models.Host) {
81+
defer wg.Done()
82+
if err := ssh.RunSSHCreatePlugin(host, sc); err != nil {
83+
nodeResults.AddResult(host.NodeID, nil, err)
84+
}
85+
}(&wgResults, host)
86+
}
7587
}
7688
wg.Wait()
7789
if wgResults.HasErrors() {

pkg/ssh/ssh.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,23 @@ func RunSSHRenderAvalancheNodeConfig(
609609
return host.UploadBytes(nodeConf, remoteconfig.GetRemoteAvalancheNodeConfig(), constants.SSHFileOpsTimeout)
610610
}
611611

612+
func RunSSHCopyBinaryFile(host *models.Host, sc models.Sidecar) error {
613+
vmID, err := sc.GetVMID()
614+
if err != nil {
615+
return err
616+
}
617+
subnetVMBinaryPath := fmt.Sprintf(constants.CloudNodeSubnetEvmBinaryPath, vmID)
618+
ux.Logger.Info("Building Custom VM for %s to %s", host.NodeID, subnetVMBinaryPath)
619+
if err := host.Upload(
620+
sc.CustomVMPath,
621+
subnetVMBinaryPath,
622+
constants.SSHFileOpsTimeout,
623+
); err != nil {
624+
return err
625+
}
626+
return nil
627+
}
628+
612629
// RunSSHCreatePlugin runs script to create plugin
613630
func RunSSHCreatePlugin(host *models.Host, sc models.Sidecar) error {
614631
vmID, err := sc.GetVMID()

pkg/vm/create_custom.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ func CreateCustomSidecar(
9090

9191
sc.RPCVersion = rpcVersion
9292
sc.Sovereign = sovereign
93+
if vmPath != "" {
94+
sc.CustomVMPath = vmPath
95+
}
9396
return sc, nil
9497
}
9598

0 commit comments

Comments
 (0)