From da9be67fa527d7be984b2b1729f6a993e19c7232 Mon Sep 17 00:00:00 2001 From: sukantoraymond Date: Tue, 3 Dec 2024 10:16:06 -0500 Subject: [PATCH 01/10] fix add validator (#2387) --- cmd/blockchaincmd/add_validator.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/blockchaincmd/add_validator.go b/cmd/blockchaincmd/add_validator.go index ada28db60..cb45f755b 100644 --- a/cmd/blockchaincmd/add_validator.go +++ b/cmd/blockchaincmd/add_validator.go @@ -151,6 +151,10 @@ func addValidator(_ *cobra.Command, args []string) error { network = models.ConvertClusterToNetwork(network) } + if sc.Networks[network.Name()].ClusterName != "" { + clusterNameFlagValue = sc.Networks[network.Name()].ClusterName + } + fee := network.GenesisParams().TxFeeConfig.StaticFeeConfig.AddSubnetValidatorFee kc, err := keychain.GetKeychainFromCmdLineFlags( app, From 78b21fd1d1cf484f2ff9d1f3e4932cff76be375a Mon Sep 17 00:00:00 2001 From: felipemadero Date: Tue, 3 Dec 2024 12:38:34 -0300 Subject: [PATCH 02/10] lint (#2389) --- cmd/blockchaincmd/deploy.go | 16 +++- cmd/interchaincmd/relayercmd/deploy.go | 12 +-- cmd/interchaincmd/relayercmd/start.go | 6 +- cmd/interchaincmd/relayercmd/stop.go | 4 +- cmd/networkcmd/start.go | 2 +- cmd/nodecmd/create_gcp.go | 2 +- cmd/nodecmd/wiz.go | 46 ++++++------ internal/mocks/binary_checker.go | 2 +- internal/mocks/downloader.go | 20 ++--- internal/mocks/installer.go | 2 +- internal/mocks/network.go | 2 +- internal/mocks/plugin_binary_downloader.go | 2 +- internal/mocks/process_checker.go | 2 +- internal/mocks/prompter.go | 74 +++++++++++++++---- internal/mocks/publisher.go | 2 +- pkg/application/app.go | 28 +++---- pkg/application/downloader.go | 25 ++++--- pkg/binutils/avago.go | 1 + pkg/binutils/release.go | 11 ++- pkg/binutils/subnet_evm.go | 1 + pkg/constants/constants.go | 33 +++++---- pkg/docker/compose.go | 2 +- pkg/docker/ssh.go | 4 +- .../templates/awmrelayer.docker-compose.yml | 2 +- pkg/models/clusters_config.go | 4 +- pkg/models/node_config.go | 2 +- pkg/node/helper.go | 1 + pkg/node/node.go | 4 +- pkg/ssh/ssh.go | 24 +++--- pkg/teleporter/relayer.go | 33 +++++++-- pkg/teleporter/teleporter.go | 4 +- pkg/utils/common.go | 14 ++++ pkg/vm/evm_prompts.go | 2 + 33 files changed, 248 insertions(+), 141 deletions(-) diff --git a/cmd/blockchaincmd/deploy.go b/cmd/blockchaincmd/deploy.go index a5db0b932..4233a0543 100644 --- a/cmd/blockchaincmd/deploy.go +++ b/cmd/blockchaincmd/deploy.go @@ -159,8 +159,18 @@ so you can take your locally tested Subnet and deploy it on Fuji or Mainnet.`, cmd.Flags().BoolVar(&icmSpec.SkipICMDeploy, "skip-local-teleporter", false, "skip automatic teleporter deploy on local networks [to be deprecated]") cmd.Flags().BoolVar(&icmSpec.SkipICMDeploy, "skip-teleporter-deploy", false, "skip automatic teleporter deploy") cmd.Flags().BoolVar(&icmSpec.SkipRelayerDeploy, skipRelayerFlagName, false, "skip relayer deploy") - cmd.Flags().StringVar(&icmSpec.ICMVersion, "teleporter-version", "latest", "teleporter version to deploy") - cmd.Flags().StringVar(&icmSpec.RelayerVersion, "relayer-version", "latest", "relayer version to deploy") + cmd.Flags().StringVar( + &icmSpec.ICMVersion, + "teleporter-version", + constants.LatestReleaseVersionTag, + "teleporter version to deploy", + ) + cmd.Flags().StringVar( + &icmSpec.RelayerVersion, + "relayer-version", + constants.LatestPreReleaseVersionTag, + "relayer version to deploy", + ) cmd.Flags().StringVar(&icmSpec.RelayerBinPath, "relayer-path", "", "relayer binary to use") cmd.Flags().StringVar(&icmSpec.RelayerLogLevel, "relayer-log-level", "info", "log level to be used for relayer logs") cmd.Flags().Float64Var(&relayerAmount, "relayer-amount", 0, "automatically fund relayer fee payments with the given amount") @@ -1120,7 +1130,7 @@ func deployBlockchain(cmd *cobra.Command, args []string) error { Amount: relayerAmount, } if network.Kind == models.Local || useLocalMachine { - deployRelayerFlags.Key = constants.AWMRelayerKeyName + deployRelayerFlags.Key = constants.ICMRelayerKeyName deployRelayerFlags.Amount = constants.DefaultRelayerAmount deployRelayerFlags.BlockchainFundingKey = constants.ICMKeyName } diff --git a/cmd/interchaincmd/relayercmd/deploy.go b/cmd/interchaincmd/relayercmd/deploy.go index 4f2861296..148afc512 100644 --- a/cmd/interchaincmd/relayercmd/deploy.go +++ b/cmd/interchaincmd/relayercmd/deploy.go @@ -409,17 +409,17 @@ func CallDeploy(_ []string, flags DeployFlags, network models.Network) error { configPath := app.GetLocalRelayerConfigPath(network.Kind, localNetworkRootDir) logPath := app.GetLocalRelayerLogPath(network.Kind) - metricsPort := constants.RemoteAWMRelayerMetricsPort + metricsPort := constants.RemoteICMRelayerMetricsPort if !deployToRemote { switch network.Kind { case models.Local: - metricsPort = constants.LocalNetworkLocalAWMRelayerMetricsPort + metricsPort = constants.LocalNetworkLocalICMRelayerMetricsPort case models.Devnet: - metricsPort = constants.DevnetLocalAWMRelayerMetricsPort + metricsPort = constants.DevnetLocalICMRelayerMetricsPort case models.EtnaDevnet: - metricsPort = constants.EtnaDevnetLocalAWMRelayerMetricsPort + metricsPort = constants.EtnaDevnetLocalICMRelayerMetricsPort case models.Fuji: - metricsPort = constants.FujiLocalAWMRelayerMetricsPort + metricsPort = constants.FujiLocalICMRelayerMetricsPort } } @@ -466,7 +466,7 @@ func CallDeploy(_ []string, flags DeployFlags, network models.Network) error { binPath, err := teleporter.DeployRelayer( flags.Version, flags.BinPath, - app.GetAWMRelayerBinDir(), + app.GetICMRelayerBinDir(), configPath, logPath, runFilePath, diff --git a/cmd/interchaincmd/relayercmd/start.go b/cmd/interchaincmd/relayercmd/start.go index e50acb275..f7ce28a73 100644 --- a/cmd/interchaincmd/relayercmd/start.go +++ b/cmd/interchaincmd/relayercmd/start.go @@ -58,11 +58,11 @@ func start(_ *cobra.Command, _ []string) error { } switch { case network.ClusterName != "": - host, err := node.GetAWMRelayerHost(app, network.ClusterName) + host, err := node.GetICMRelayerHost(app, network.ClusterName) if err != nil { return err } - if err := ssh.RunSSHStartAWMRelayerService(host); err != nil { + if err := ssh.RunSSHStartICMRelayerService(host); err != nil { return err } ux.Logger.GreenCheckmarkToUser("Remote AWM Relayer on %s successfully started", host.GetCloudID()) @@ -95,7 +95,7 @@ func start(_ *cobra.Command, _ []string) error { } else if binPath, err := teleporter.DeployRelayer( "latest", binPath, - app.GetAWMRelayerBinDir(), + app.GetICMRelayerBinDir(), relayerConfigPath, app.GetLocalRelayerLogPath(network.Kind), app.GetLocalRelayerRunPath(network.Kind), diff --git a/cmd/interchaincmd/relayercmd/stop.go b/cmd/interchaincmd/relayercmd/stop.go index dcaf54887..389120562 100644 --- a/cmd/interchaincmd/relayercmd/stop.go +++ b/cmd/interchaincmd/relayercmd/stop.go @@ -50,11 +50,11 @@ func stop(_ *cobra.Command, _ []string) error { } switch { case network.ClusterName != "": - host, err := node.GetAWMRelayerHost(app, network.ClusterName) + host, err := node.GetICMRelayerHost(app, network.ClusterName) if err != nil { return err } - if err := ssh.RunSSHStopAWMRelayerService(host); err != nil { + if err := ssh.RunSSHStopICMRelayerService(host); err != nil { return err } ux.Logger.GreenCheckmarkToUser("Remote AWM Relayer on %s successfully stopped", host.GetCloudID()) diff --git a/cmd/networkcmd/start.go b/cmd/networkcmd/start.go index 57b680c44..42bce8efc 100644 --- a/cmd/networkcmd/start.go +++ b/cmd/networkcmd/start.go @@ -200,7 +200,7 @@ func Start(flags StartFlags, printEndpoints bool) error { if relayerBinPath, err := teleporter.DeployRelayer( "latest", relayerBinPath, - app.GetAWMRelayerBinDir(), + app.GetICMRelayerBinDir(), relayerConfigPath, app.GetLocalRelayerLogPath(models.Local), app.GetLocalRelayerRunPath(models.Local), diff --git a/cmd/nodecmd/create_gcp.go b/cmd/nodecmd/create_gcp.go index b67e92d92..cd69c205e 100644 --- a/cmd/nodecmd/create_gcp.go +++ b/cmd/nodecmd/create_gcp.go @@ -414,7 +414,7 @@ func grantAccessToPublicIPViaFirewall(gcpClient *gcpAPI.GcpCloud, projectName st return nil } -func setGCPAWMRelayerSecurityGroupRule(awmRelayerHost *models.Host) error { +func setGCPICMRelayerSecurityGroupRule(awmRelayerHost *models.Host) error { gcpClient, _, _, _, projectName, err := getGCPConfig(true) if err != nil { return err diff --git a/cmd/nodecmd/wiz.go b/cmd/nodecmd/wiz.go index cf928c219..f5316a2e0 100644 --- a/cmd/nodecmd/wiz.go +++ b/cmd/nodecmd/wiz.go @@ -319,12 +319,12 @@ func wiz(cmd *cobra.Command, args []string) error { var awmRelayerHost *models.Host if sc.TeleporterReady && sc.RunRelayer && isEVMGenesis { // get or set AWM Relayer host and configure/stop service - awmRelayerHost, err = node.GetAWMRelayerHost(app, clusterName) + awmRelayerHost, err = node.GetICMRelayerHost(app, clusterName) if err != nil { return err } if awmRelayerHost == nil { - awmRelayerHost, err = chooseAWMRelayerHost(clusterName) + awmRelayerHost, err = chooseICMRelayerHost(clusterName) if err != nil { return err } @@ -333,16 +333,16 @@ func wiz(cmd *cobra.Command, args []string) error { if err != nil { return err } - if err := setAWMRelayerHost(awmRelayerHost, relayerVersion); err != nil { + if err := setICMRelayerHost(awmRelayerHost, relayerVersion); err != nil { return err } - if err := setAWMRelayerSecurityGroupRule(clusterName, awmRelayerHost); err != nil { + if err := setICMRelayerSecurityGroupRule(clusterName, awmRelayerHost); err != nil { return err } } else { ux.Logger.PrintToUser("") ux.Logger.PrintToUser(logging.Green.Wrap("Stopping AWM Relayer Service")) - if err := ssh.RunSSHStopAWMRelayerService(awmRelayerHost); err != nil { + if err := ssh.RunSSHStopICMRelayerService(awmRelayerHost); err != nil { return err } } @@ -414,10 +414,10 @@ func wiz(cmd *cobra.Command, args []string) error { ux.Logger.PrintToUser("") ux.Logger.PrintToUser(logging.Green.Wrap("Starting AWM Relayer Service")) ux.Logger.PrintToUser("") - if err := updateAWMRelayerFunds(network, sc, blockchainID); err != nil { + if err := updateICMRelayerFunds(network, sc, blockchainID); err != nil { return err } - if err := updateAWMRelayerHostConfig(network, awmRelayerHost, subnetName); err != nil { + if err := updateICMRelayerHostConfig(network, awmRelayerHost, subnetName); err != nil { return err } } @@ -507,7 +507,7 @@ func updateProposerVMs( return teleporter.SetProposerVM(app, network, "C", "") } -func setAWMRelayerHost(host *models.Host, relayerVersion string) error { +func setICMRelayerHost(host *models.Host, relayerVersion string) error { cloudID := host.GetCloudID() ux.Logger.PrintToUser("") ux.Logger.PrintToUser("configuring AWM Relayer on host %s", cloudID) @@ -515,25 +515,25 @@ func setAWMRelayerHost(host *models.Host, relayerVersion string) error { if err != nil { return err } - if err := ssh.ComposeSSHSetupAWMRelayer(host, relayerVersion); err != nil { + if err := ssh.ComposeSSHSetupICMRelayer(host, relayerVersion); err != nil { return err } - nodeConfig.IsAWMRelayer = true + nodeConfig.IsICMRelayer = true return app.CreateNodeCloudConfigFile(cloudID, &nodeConfig) } -func updateAWMRelayerHostConfig(network models.Network, host *models.Host, blockchainName string) error { +func updateICMRelayerHostConfig(network models.Network, host *models.Host, blockchainName string) error { ux.Logger.PrintToUser("setting AWM Relayer on host %s to relay blockchain %s", host.GetCloudID(), blockchainName) if err := addBlockchainToRelayerConf(network, host.GetCloudID(), blockchainName); err != nil { return err } - if err := ssh.RunSSHUploadNodeAWMRelayerConfig(host, app.GetNodeInstanceDirPath(host.GetCloudID())); err != nil { + if err := ssh.RunSSHUploadNodeICMRelayerConfig(host, app.GetNodeInstanceDirPath(host.GetCloudID())); err != nil { return err } - return ssh.RunSSHStartAWMRelayerService(host) + return ssh.RunSSHStartICMRelayerService(host) } -func chooseAWMRelayerHost(clusterName string) (*models.Host, error) { +func chooseICMRelayerHost(clusterName string) (*models.Host, error) { // first look up for separate monitoring host monitoringInventoryFile := app.GetMonitoringInventoryDir(clusterName) if utils.FileExists(monitoringInventoryFile) { @@ -560,8 +560,8 @@ func chooseAWMRelayerHost(clusterName string) (*models.Host, error) { return nil, fmt.Errorf("no hosts found on cluster") } -func updateAWMRelayerFunds(network models.Network, sc models.Sidecar, blockchainID ids.ID) error { - relayerKey, err := app.GetKey(constants.AWMRelayerKeyName, network, true) +func updateICMRelayerFunds(network models.Network, sc models.Sidecar, blockchainID ids.ID) error { + relayerKey, err := app.GetKey(constants.ICMRelayerKeyName, network, true) if err != nil { return err } @@ -827,7 +827,7 @@ func filterHosts(hosts []*models.Host, nodes []string) ([]*models.Host, error) { return filteredHosts, nil } -func setAWMRelayerSecurityGroupRule(clusterName string, awmRelayerHost *models.Host) error { +func setICMRelayerSecurityGroupRule(clusterName string, awmRelayerHost *models.Host) error { clusterConfig, err := app.GetClusterConfig(clusterName) if err != nil { return err @@ -874,7 +874,7 @@ func setAWMRelayerSecurityGroupRule(clusterName string, awmRelayerHost *models.H } } if hasGCPNodes { - if err := setGCPAWMRelayerSecurityGroupRule(awmRelayerHost); err != nil { + if err := setGCPICMRelayerSecurityGroupRule(awmRelayerHost); err != nil { return err } } @@ -960,15 +960,15 @@ func setUpSubnetLogging(clusterName, subnetName string) error { } func addBlockchainToRelayerConf(network models.Network, cloudNodeID string, blockchainName string) error { - relayerAddress, relayerPrivateKey, err := teleporter.GetRelayerKeyInfo(app.GetKeyPath(constants.AWMRelayerKeyName)) + relayerAddress, relayerPrivateKey, err := teleporter.GetRelayerKeyInfo(app.GetKeyPath(constants.ICMRelayerKeyName)) if err != nil { return err } - storageBasePath := constants.AWMRelayerDockerDir + storageBasePath := constants.ICMRelayerDockerDir configBasePath := app.GetNodeInstanceDirPath(cloudNodeID) - configPath := app.GetAWMRelayerServiceConfigPath(configBasePath) + configPath := app.GetICMRelayerServiceConfigPath(configBasePath) if err := os.MkdirAll(filepath.Dir(configPath), constants.DefaultPerms755); err != nil { return err } @@ -977,8 +977,8 @@ func addBlockchainToRelayerConf(network models.Network, cloudNodeID string, bloc if err := teleporter.CreateBaseRelayerConfigIfMissing( configPath, logging.Info.LowerString(), - app.GetAWMRelayerServiceStorageDir(storageBasePath), - constants.RemoteAWMRelayerMetricsPort, + app.GetICMRelayerServiceStorageDir(storageBasePath), + constants.RemoteICMRelayerMetricsPort, network, ); err != nil { return err diff --git a/internal/mocks/binary_checker.go b/internal/mocks/binary_checker.go index 6ae2837c5..ec21488b8 100644 --- a/internal/mocks/binary_checker.go +++ b/internal/mocks/binary_checker.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks diff --git a/internal/mocks/downloader.go b/internal/mocks/downloader.go index c554f6de6..7f74b7d2f 100644 --- a/internal/mocks/downloader.go +++ b/internal/mocks/downloader.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -69,9 +69,9 @@ func (_m *Downloader) GetAllReleasesForRepo(org string, repo string) ([]string, return r0, r1 } -// GetLatestPreReleaseVersion provides a mock function with given fields: org, repo -func (_m *Downloader) GetLatestPreReleaseVersion(org string, repo string) (string, error) { - ret := _m.Called(org, repo) +// GetLatestPreReleaseVersion provides a mock function with given fields: org, repo, kind +func (_m *Downloader) GetLatestPreReleaseVersion(org string, repo string, kind string) (string, error) { + ret := _m.Called(org, repo, kind) if len(ret) == 0 { panic("no return value specified for GetLatestPreReleaseVersion") @@ -79,17 +79,17 @@ func (_m *Downloader) GetLatestPreReleaseVersion(org string, repo string) (strin var r0 string var r1 error - if rf, ok := ret.Get(0).(func(string, string) (string, error)); ok { - return rf(org, repo) + if rf, ok := ret.Get(0).(func(string, string, string) (string, error)); ok { + return rf(org, repo, kind) } - if rf, ok := ret.Get(0).(func(string, string) string); ok { - r0 = rf(org, repo) + if rf, ok := ret.Get(0).(func(string, string, string) string); ok { + r0 = rf(org, repo, kind) } else { r0 = ret.Get(0).(string) } - if rf, ok := ret.Get(1).(func(string, string) error); ok { - r1 = rf(org, repo) + if rf, ok := ret.Get(1).(func(string, string, string) error); ok { + r1 = rf(org, repo, kind) } else { r1 = ret.Error(1) } diff --git a/internal/mocks/installer.go b/internal/mocks/installer.go index 02e15e2ba..5fa59ad64 100644 --- a/internal/mocks/installer.go +++ b/internal/mocks/installer.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks diff --git a/internal/mocks/network.go b/internal/mocks/network.go index d4e8f7446..56ce44811 100644 --- a/internal/mocks/network.go +++ b/internal/mocks/network.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks diff --git a/internal/mocks/plugin_binary_downloader.go b/internal/mocks/plugin_binary_downloader.go index 20a73b022..1972dbd49 100644 --- a/internal/mocks/plugin_binary_downloader.go +++ b/internal/mocks/plugin_binary_downloader.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks diff --git a/internal/mocks/process_checker.go b/internal/mocks/process_checker.go index 06b752ee1..c013c731b 100644 --- a/internal/mocks/process_checker.go +++ b/internal/mocks/process_checker.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks diff --git a/internal/mocks/prompter.go b/internal/mocks/prompter.go index 6281cbc90..5588d0483 100644 --- a/internal/mocks/prompter.go +++ b/internal/mocks/prompter.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks @@ -112,6 +112,34 @@ func (_m *Prompter) CaptureDate(promptStr string) (time.Time, error) { return r0, r1 } +// CaptureDuration provides a mock function with given fields: promptStr +func (_m *Prompter) CaptureDuration(promptStr string) (time.Duration, error) { + ret := _m.Called(promptStr) + + if len(ret) == 0 { + panic("no return value specified for CaptureDuration") + } + + var r0 time.Duration + var r1 error + if rf, ok := ret.Get(0).(func(string) (time.Duration, error)); ok { + return rf(promptStr) + } + if rf, ok := ret.Get(0).(func(string) time.Duration); ok { + r0 = rf(promptStr) + } else { + r0 = ret.Get(0).(time.Duration) + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(promptStr) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // CaptureEmail provides a mock function with given fields: promptStr func (_m *Prompter) CaptureEmail(promptStr string) (string, error) { ret := _m.Called(promptStr) @@ -140,6 +168,34 @@ func (_m *Prompter) CaptureEmail(promptStr string) (string, error) { return r0, r1 } +// CaptureEtnaDuration provides a mock function with given fields: promptStr +func (_m *Prompter) CaptureEtnaDuration(promptStr string) (time.Duration, error) { + ret := _m.Called(promptStr) + + if len(ret) == 0 { + panic("no return value specified for CaptureEtnaDuration") + } + + var r0 time.Duration + var r1 error + if rf, ok := ret.Get(0).(func(string) (time.Duration, error)); ok { + return rf(promptStr) + } + if rf, ok := ret.Get(0).(func(string) time.Duration); ok { + r0 = rf(promptStr) + } else { + r0 = ret.Get(0).(time.Duration) + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(promptStr) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // CaptureExistingFilepath provides a mock function with given fields: promptStr func (_m *Prompter) CaptureExistingFilepath(promptStr string) (string, error) { ret := _m.Called(promptStr) @@ -313,7 +369,7 @@ func (_m *Prompter) CaptureID(promptStr string) (ids.ID, error) { } // CaptureIndex provides a mock function with given fields: promptStr, options -func (_m *Prompter) CaptureIndex(promptStr string, options []any) (int, error) { +func (_m *Prompter) CaptureIndex(promptStr string, options []interface{}) (int, error) { ret := _m.Called(promptStr, options) if len(ret) == 0 { @@ -322,16 +378,16 @@ func (_m *Prompter) CaptureIndex(promptStr string, options []any) (int, error) { var r0 int var r1 error - if rf, ok := ret.Get(0).(func(string, []any) (int, error)); ok { + if rf, ok := ret.Get(0).(func(string, []interface{}) (int, error)); ok { return rf(promptStr, options) } - if rf, ok := ret.Get(0).(func(string, []any) int); ok { + if rf, ok := ret.Get(0).(func(string, []interface{}) int); ok { r0 = rf(promptStr, options) } else { r0 = ret.Get(0).(int) } - if rf, ok := ret.Get(1).(func(string, []any) error); ok { + if rf, ok := ret.Get(1).(func(string, []interface{}) error); ok { r1 = rf(promptStr, options) } else { r1 = ret.Error(1) @@ -452,14 +508,6 @@ func (_m *Prompter) CaptureMainnetDuration(promptStr string) (time.Duration, err return r0, r1 } -func (_m *Prompter) CaptureEtnaDuration(promptStr string) (time.Duration, error) { - return _m.CaptureMainnetDuration(promptStr) -} - -func (_m *Prompter) CaptureDuration(promptStr string) (time.Duration, error) { - return _m.CaptureMainnetDuration(promptStr) -} - // CaptureNewFilepath provides a mock function with given fields: promptStr func (_m *Prompter) CaptureNewFilepath(promptStr string) (string, error) { ret := _m.Called(promptStr) diff --git a/internal/mocks/publisher.go b/internal/mocks/publisher.go index 9b4a6d866..45d6028a6 100644 --- a/internal/mocks/publisher.go +++ b/internal/mocks/publisher.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.46.3. DO NOT EDIT. +// Code generated by mockery v2.43.2. DO NOT EDIT. package mocks diff --git a/pkg/application/app.go b/pkg/application/app.go index 1fc3c61fe..22248427f 100644 --- a/pkg/application/app.go +++ b/pkg/application/app.go @@ -121,8 +121,8 @@ func (app *Avalanche) GetTeleporterBinDir() string { return filepath.Join(app.baseDir, constants.AvalancheCliBinDir, constants.TeleporterInstallDir) } -func (app *Avalanche) GetAWMRelayerBinDir() string { - return filepath.Join(app.baseDir, constants.AvalancheCliBinDir, constants.AWMRelayerInstallDir) +func (app *Avalanche) GetICMRelayerBinDir() string { + return filepath.Join(app.baseDir, constants.AvalancheCliBinDir, constants.ICMRelayerInstallDir) } func (app *Avalanche) GetLocalRelayerDir(networkKind models.NetworkKind) string { @@ -131,37 +131,37 @@ func (app *Avalanche) GetLocalRelayerDir(networkKind models.NetworkKind) string } func (app *Avalanche) GetLocalRelayerStorageDir(networkKind models.NetworkKind) string { - return filepath.Join(app.GetLocalRelayerDir(networkKind), constants.AWMRelayerStorageDir) + return filepath.Join(app.GetLocalRelayerDir(networkKind), constants.ICMRelayerStorageDir) } func (app *Avalanche) GetLocalRelayerConfigPath(networkKind models.NetworkKind, localNetworkRootDir string) string { if localNetworkRootDir != "" { - return filepath.Join(localNetworkRootDir, constants.AWMRelayerConfigFilename) + return filepath.Join(localNetworkRootDir, constants.ICMRelayerConfigFilename) } - return filepath.Join(app.GetLocalRelayerDir(networkKind), constants.AWMRelayerConfigFilename) + return filepath.Join(app.GetLocalRelayerDir(networkKind), constants.ICMRelayerConfigFilename) } func (app *Avalanche) GetLocalRelayerLogPath(networkKind models.NetworkKind) string { - return filepath.Join(app.GetLocalRelayerDir(networkKind), constants.AWMRelayerLogFilename) + return filepath.Join(app.GetLocalRelayerDir(networkKind), constants.ICMRelayerLogFilename) } func (app *Avalanche) GetLocalRelayerRunPath(networkKind models.NetworkKind) string { - return filepath.Join(app.GetLocalRelayerDir(networkKind), constants.AWMRelayerRunFilename) + return filepath.Join(app.GetLocalRelayerDir(networkKind), constants.ICMRelayerRunFilename) } -func (app *Avalanche) GetAWMRelayerServiceDir(baseDir string) string { - return filepath.Join(app.GetServicesDir(baseDir), constants.AWMRelayerInstallDir) +func (app *Avalanche) GetICMRelayerServiceDir(baseDir string) string { + return filepath.Join(app.GetServicesDir(baseDir), constants.ICMRelayerInstallDir) } -func (app *Avalanche) GetAWMRelayerServiceConfigPath(baseDir string) string { - return filepath.Join(app.GetAWMRelayerServiceDir(baseDir), constants.AWMRelayerConfigFilename) +func (app *Avalanche) GetICMRelayerServiceConfigPath(baseDir string) string { + return filepath.Join(app.GetICMRelayerServiceDir(baseDir), constants.ICMRelayerConfigFilename) } -func (app *Avalanche) GetAWMRelayerServiceStorageDir(baseDir string) string { +func (app *Avalanche) GetICMRelayerServiceStorageDir(baseDir string) string { if baseDir != "" { - return filepath.Join(baseDir, constants.AWMRelayerStorageDir) + return filepath.Join(baseDir, constants.ICMRelayerStorageDir) } - return filepath.Join(app.GetAWMRelayerServiceDir(""), constants.AWMRelayerStorageDir) + return filepath.Join(app.GetICMRelayerServiceDir(""), constants.ICMRelayerStorageDir) } func (app *Avalanche) GetSubnetEVMBinDir() string { diff --git a/pkg/application/downloader.go b/pkg/application/downloader.go index e9a2ad24f..fc41d0bcf 100644 --- a/pkg/application/downloader.go +++ b/pkg/application/downloader.go @@ -12,7 +12,7 @@ import ( "strings" "github.com/ava-labs/avalanche-cli/pkg/constants" - "golang.org/x/mod/semver" + "github.com/ava-labs/avalanche-cli/pkg/utils" ) const githubVersionTagName = "tag_name" @@ -23,7 +23,7 @@ const githubVersionTagName = "tag_name" type Downloader interface { Download(url string) ([]byte, error) GetLatestReleaseVersion(releaseURL string) (string, error) - GetLatestPreReleaseVersion(org, repo string) (string, error) + GetLatestPreReleaseVersion(org, repo, kind string) (string, error) GetAllReleasesForRepo(org, repo string) ([]string, error) } @@ -47,7 +47,7 @@ func (downloader) Download(url string) ([]byte, error) { } // GetLatestPreReleaseVersion returns the latest available pre release version from github -func (d downloader) GetLatestPreReleaseVersion(org, repo string) (string, error) { +func (d downloader) GetLatestPreReleaseVersion(org, repo, kind string) (string, error) { releases, err := d.GetAllReleasesForRepo(org, repo) if err != nil { return "", err @@ -55,7 +55,15 @@ func (d downloader) GetLatestPreReleaseVersion(org, repo string) (string, error) if len(releases) == 0 { return "", fmt.Errorf("no releases found for org %s repo %s", org, repo) } - return releases[0], nil + if kind == "" { + return releases[0], nil + } + for _, release := range releases { + if strings.HasPrefix(release, kind) { + return release, nil + } + } + return "", fmt.Errorf("no releases found for org %s repo %s kind %s", org, repo, kind) } func (d downloader) GetAllReleasesForRepo(org, repo string) ([]string, error) { @@ -80,7 +88,7 @@ func (d downloader) GetAllReleasesForRepo(org, repo string) ([]string, error) { releases := make([]string, len(releaseArr)) for i, r := range releaseArr { version := r[githubVersionTagName].(string) - if !semver.IsValid(version) { + if !utils.IsValidSemanticVersion(version) { return nil, fmt.Errorf("invalid version string: %s", version) } releases[i] = version @@ -130,12 +138,7 @@ func (d downloader) GetLatestReleaseVersion(releaseURL string) (string, error) { } version := jsonStr[githubVersionTagName].(string) - if !semver.IsValid(version) { - // remove "app" part, just in case (eg icm-relayer/v1.5.1) - versionParts := strings.Split(version, "/") - if len(versionParts) == 2 && semver.IsValid(versionParts[1]) { - return version, nil - } + if !utils.IsValidSemanticVersion(version) { return "", fmt.Errorf("invalid version string: %s", version) } diff --git a/pkg/binutils/avago.go b/pkg/binutils/avago.go index f9b0a692a..6cbc6f266 100644 --- a/pkg/binutils/avago.go +++ b/pkg/binutils/avago.go @@ -21,6 +21,7 @@ func SetupAvalanchego(app *application.Avalanche, avagoVersion string) (string, avalanchegoBinPrefix, constants.AvaLabsOrg, constants.AvalancheGoRepoName, + "", downloader, installer, ) diff --git a/pkg/binutils/release.go b/pkg/binutils/release.go index e094294ef..317ae32ff 100644 --- a/pkg/binutils/release.go +++ b/pkg/binutils/release.go @@ -9,9 +9,10 @@ import ( "strings" "github.com/ava-labs/avalanche-cli/pkg/application" + "github.com/ava-labs/avalanche-cli/pkg/utils" "github.com/ava-labs/avalanche-cli/pkg/ux" + "go.uber.org/zap" - "golang.org/x/mod/semver" ) func installBinaryWithVersion( @@ -60,9 +61,10 @@ func InstallBinary( version string, baseBinDir string, installDir string, - binPrefix, - org, + binPrefix string, + org string, repo string, + kind string, downloader GithubDownloader, installer Installer, ) (string, string, error) { @@ -83,11 +85,12 @@ func InstallBinary( version, err = app.Downloader.GetLatestPreReleaseVersion( org, repo, + kind, ) if err != nil { return "", "", err } - case !semver.IsValid(version): + case !utils.IsValidSemanticVersion(version): return "", "", fmt.Errorf( "invalid version string. Must be semantic version ex: v1.7.14: %s", version) } diff --git a/pkg/binutils/subnet_evm.go b/pkg/binutils/subnet_evm.go index 6b8ee525b..f02c6ec78 100644 --- a/pkg/binutils/subnet_evm.go +++ b/pkg/binutils/subnet_evm.go @@ -25,6 +25,7 @@ func SetupSubnetEVM(app *application.Avalanche, subnetEVMVersion string) (string subnetEVMBinPrefix, constants.AvaLabsOrg, constants.SubnetEVMRepoName, + "", downloader, installer, ) diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index 2a8f10283..4028c9d18 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -215,7 +215,8 @@ const ( SubnetEVMRepoName = "subnet-evm" CliRepoName = "avalanche-cli" TeleporterRepoName = "teleporter" - AWMRelayerRepoName = "awm-relayer" + ICMServicesRepoName = "icm-services" + ICMRelayerKind = "icm-relayer" SubnetEVMReleaseURL = "https://github.com/ava-labs/subnet-evm/releases/download/%s/%s" SubnetEVMArchive = "subnet-evm_%s_linux_amd64.tar.gz" CloudNodeConfigBasePath = "/home/ubuntu/.avalanchego/" @@ -235,30 +236,30 @@ const ( IPAddressSuffix = "/32" AvalancheGoInstallDir = "avalanchego" SubnetEVMInstallDir = "subnet-evm" - AWMRelayerInstallDir = "awm-relayer" + ICMRelayerInstallDir = "icm-relayer" TeleporterInstallDir = "teleporter" - AWMRelayerBin = "awm-relayer" + ICMRelayerBin = "icm-relayer" LocalRelayerDir = "local-relayer" - AWMRelayerConfigFilename = "awm-relayer-config.json" - AWMRelayerStorageDir = "awm-relayer-storage" - AWMRelayerLogFilename = "awm-relayer.log" - AWMRelayerRunFilename = "awm-relayer-process.json" - AWMRelayerDockerDir = "/.awm-relayer" + ICMRelayerConfigFilename = "icm-relayer-config.json" + ICMRelayerStorageDir = "icm-relayer-storage" + ICMRelayerLogFilename = "icm-relayer.log" + ICMRelayerRunFilename = "icm-relayer-process.json" + ICMRelayerDockerDir = "/.icm-relayer" - AWMRelayerSnapshotConfsDir = "relayer-confs" + ICMRelayerSnapshotConfsDir = "relayer-confs" ICMKeyName = "cli-teleporter-deployer" - AWMRelayerKeyName = "cli-awm-relayer" + ICMRelayerKeyName = "cli-awm-relayer" DefaultRelayerAmount = float64(10) // to not interfere with other node services - RemoteAWMRelayerMetricsPort = 9091 + RemoteICMRelayerMetricsPort = 9091 // enables having many local relayers - LocalNetworkLocalAWMRelayerMetricsPort = 9092 - DevnetLocalAWMRelayerMetricsPort = 9093 - EtnaDevnetLocalAWMRelayerMetricsPort = 9094 - FujiLocalAWMRelayerMetricsPort = 9095 + LocalNetworkLocalICMRelayerMetricsPort = 9092 + DevnetLocalICMRelayerMetricsPort = 9093 + EtnaDevnetLocalICMRelayerMetricsPort = 9094 + FujiLocalICMRelayerMetricsPort = 9095 DevnetFlagsProposerVMUseCurrentHeight = true @@ -341,7 +342,7 @@ const ( APIRole = "API" ValidatorRole = "Validator" MonitorRole = "Monitor" - AWMRelayerRole = "Relayer" + ICMRelayerRole = "Relayer" LoadTestRole = "LoadTest" DefaultWalletCreationTimeout = 5 * time.Second diff --git a/pkg/docker/compose.go b/pkg/docker/compose.go index b246044dd..ecd5f28f8 100644 --- a/pkg/docker/compose.go +++ b/pkg/docker/compose.go @@ -23,7 +23,7 @@ type DockerComposeInputs struct { WithMonitoring bool WithAvalanchego bool AvalanchegoVersion string - AWMRelayerVersion string + ICMRelayerVersion string E2E bool E2EIP string E2ESuffix string diff --git a/pkg/docker/ssh.go b/pkg/docker/ssh.go index aab8a089c..dcc8ce727 100644 --- a/pkg/docker/ssh.go +++ b/pkg/docker/ssh.go @@ -168,12 +168,12 @@ func ComposeSSHSetupMonitoring(host *models.Host) error { DockerComposeInputs{}) } -func ComposeSSHSetupAWMRelayer(host *models.Host, relayerVersion string) error { +func ComposeSSHSetupICMRelayer(host *models.Host, relayerVersion string) error { return ComposeOverSSH("Setup AWM Relayer", host, constants.SSHScriptTimeout, "templates/awmrelayer.docker-compose.yml", DockerComposeInputs{ - AWMRelayerVersion: relayerVersion, + ICMRelayerVersion: relayerVersion, }) } diff --git a/pkg/docker/templates/awmrelayer.docker-compose.yml b/pkg/docker/templates/awmrelayer.docker-compose.yml index f992b1139..2b6650c2e 100644 --- a/pkg/docker/templates/awmrelayer.docker-compose.yml +++ b/pkg/docker/templates/awmrelayer.docker-compose.yml @@ -1,7 +1,7 @@ name: avalanche-cli services: awm-relayer: - image: avaplatform/awm-relayer:{{ .AWMRelayerVersion }} + image: avaplatform/awm-relayer:{{ .ICMRelayerVersion }} container_name: awm-relayer restart: unless-stopped user: "1000:1000" # ubuntu user diff --git a/pkg/models/clusters_config.go b/pkg/models/clusters_config.go index 02d5b11b2..3913cb880 100644 --- a/pkg/models/clusters_config.go +++ b/pkg/models/clusters_config.go @@ -84,8 +84,8 @@ func (cc *ClusterConfig) GetHostRoles(nodeConf NodeConfig) []string { if nodeConf.IsMonitor { roles = append(roles, constants.MonitorRole) } - if nodeConf.IsAWMRelayer { - roles = append(roles, constants.AWMRelayerRole) + if nodeConf.IsICMRelayer { + roles = append(roles, constants.ICMRelayerRole) } return roles } diff --git a/pkg/models/node_config.go b/pkg/models/node_config.go index 2fb030da2..56b2499b7 100644 --- a/pkg/models/node_config.go +++ b/pkg/models/node_config.go @@ -13,6 +13,6 @@ type NodeConfig struct { CloudService string // which cloud service node is hosted on (AWS / GCP) UseStaticIP bool // node has a static IP association IsMonitor bool // node has a monitoring dashboard - IsAWMRelayer bool // node has an AWM relayer service + IsICMRelayer bool // node has an ICM relayer service IsLoadTest bool // node is used to host load test } diff --git a/pkg/node/helper.go b/pkg/node/helper.go index 8e29d6722..5214ac4ac 100644 --- a/pkg/node/helper.go +++ b/pkg/node/helper.go @@ -329,6 +329,7 @@ func GetAvalancheGoVersion(app *application.Avalanche, avagoVersion AvalancheGoV latestPreReleaseVersion, err := app.Downloader.GetLatestPreReleaseVersion( constants.AvaLabsOrg, constants.AvalancheGoRepoName, + "", ) if err != nil { return "", err diff --git a/pkg/node/node.go b/pkg/node/node.go index de21b32ed..9d25f87ac 100644 --- a/pkg/node/node.go +++ b/pkg/node/node.go @@ -30,7 +30,7 @@ func GetHostWithCloudID(app *application.Avalanche, clusterName string, cloudID return nil, nil } -func GetAWMRelayerHost(app *application.Avalanche, clusterName string) (*models.Host, error) { +func GetICMRelayerHost(app *application.Avalanche, clusterName string) (*models.Host, error) { clusterConfig, err := app.GetClusterConfig(clusterName) if err != nil { return nil, err @@ -39,7 +39,7 @@ func GetAWMRelayerHost(app *application.Avalanche, clusterName string) (*models. for _, cloudID := range clusterConfig.GetCloudIDs() { if nodeConfig, err := app.LoadClusterNodeConfig(cloudID); err != nil { return nil, err - } else if nodeConfig.IsAWMRelayer { + } else if nodeConfig.IsICMRelayer { relayerCloudID = nodeConfig.NodeID } } diff --git a/pkg/ssh/ssh.go b/pkg/ssh/ssh.go index 9bc74bfa6..60260ca2f 100644 --- a/pkg/ssh/ssh.go +++ b/pkg/ssh/ssh.go @@ -159,21 +159,21 @@ func RunSSHRestartNode(host *models.Host) error { return docker.RestartDockerComposeService(host, remoteComposeFile, avagoService, constants.SSHLongRunningScriptTimeout) } -// ComposeSSHSetupAWMRelayer used docker compose to setup AWM Relayer -func ComposeSSHSetupAWMRelayer(host *models.Host, relayerVersion string) error { - if err := docker.ComposeSSHSetupAWMRelayer(host, relayerVersion); err != nil { +// ComposeSSHSetupICMRelayer used docker compose to setup AWM Relayer +func ComposeSSHSetupICMRelayer(host *models.Host, relayerVersion string) error { + if err := docker.ComposeSSHSetupICMRelayer(host, relayerVersion); err != nil { return err } return docker.StartDockerComposeService(host, utils.GetRemoteComposeFile(), "awm-relayer", constants.SSHLongRunningScriptTimeout) } -// RunSSHStartAWMRelayerService runs script to start an AWM Relayer Service -func RunSSHStartAWMRelayerService(host *models.Host) error { +// RunSSHStartICMRelayerService runs script to start an AWM Relayer Service +func RunSSHStartICMRelayerService(host *models.Host) error { return docker.StartDockerComposeService(host, utils.GetRemoteComposeFile(), "awm-relayer", constants.SSHLongRunningScriptTimeout) } -// RunSSHStopAWMRelayerService runs script to start an AWM Relayer Service -func RunSSHStopAWMRelayerService(host *models.Host) error { +// RunSSHStopICMRelayerService runs script to start an AWM Relayer Service +func RunSSHStopICMRelayerService(host *models.Host) error { return docker.StopDockerComposeService(host, utils.GetRemoteComposeFile(), "awm-relayer", constants.SSHLongRunningScriptTimeout) } @@ -402,14 +402,14 @@ func RunSSHDownloadNodePrometheusConfig(host *models.Host, nodeInstanceDirPath s ) } -func RunSSHUploadNodeAWMRelayerConfig(host *models.Host, nodeInstanceDirPath string) error { - cloudAWMRelayerConfigDir := filepath.Join(constants.CloudNodeCLIConfigBasePath, constants.ServicesDir, constants.AWMRelayerInstallDir) - if err := host.MkdirAll(cloudAWMRelayerConfigDir, constants.SSHDirOpsTimeout); err != nil { +func RunSSHUploadNodeICMRelayerConfig(host *models.Host, nodeInstanceDirPath string) error { + cloudICMRelayerConfigDir := filepath.Join(constants.CloudNodeCLIConfigBasePath, constants.ServicesDir, constants.ICMRelayerInstallDir) + if err := host.MkdirAll(cloudICMRelayerConfigDir, constants.SSHDirOpsTimeout); err != nil { return err } return host.Upload( - filepath.Join(nodeInstanceDirPath, constants.ServicesDir, constants.AWMRelayerInstallDir, constants.AWMRelayerConfigFilename), - filepath.Join(cloudAWMRelayerConfigDir, constants.AWMRelayerConfigFilename), + filepath.Join(nodeInstanceDirPath, constants.ServicesDir, constants.ICMRelayerInstallDir, constants.ICMRelayerConfigFilename), + filepath.Join(cloudICMRelayerConfigDir, constants.ICMRelayerConfigFilename), constants.SSHFileOpsTimeout, ) } diff --git a/pkg/teleporter/relayer.go b/pkg/teleporter/relayer.go index 77c7ddb12..2aeab5d85 100644 --- a/pkg/teleporter/relayer.go +++ b/pkg/teleporter/relayer.go @@ -224,11 +224,27 @@ func saveRelayerRunFile(runFilePath string, pid int) error { func GetLatestRelayerReleaseVersion() (string, error) { downloader := application.NewDownloader() - return downloader.GetLatestReleaseVersion(binutils.GetGithubLatestReleaseURL(constants.AvaLabsOrg, constants.AWMRelayerRepoName)) + return downloader.GetLatestReleaseVersion(binutils.GetGithubLatestReleaseURL(constants.AvaLabsOrg, constants.ICMServicesRepoName)) +} + +func GetLatestRelayerPreReleaseVersion() (string, error) { + downloader := application.NewDownloader() + return downloader.GetLatestPreReleaseVersion( + constants.AvaLabsOrg, + constants.ICMServicesRepoName, + constants.ICMRelayerKind, + ) } func InstallRelayer(binDir, version string) (string, error) { - if version == "" || version == "latest" { + if version == "" || version == constants.LatestPreReleaseVersionTag { + var err error + version, err = GetLatestRelayerPreReleaseVersion() + if err != nil { + return "", err + } + } + if version == constants.LatestReleaseVersionTag { var err error version, err = GetLatestRelayerReleaseVersion() if err != nil { @@ -236,8 +252,15 @@ func InstallRelayer(binDir, version string) (string, error) { } } ux.Logger.PrintToUser("Relayer version %s", version) + if version == "" || version == "latest" { + var err error + version, err = GetLatestRelayerReleaseVersion() + if err != nil { + return "", err + } + } versionBinDir := filepath.Join(binDir, version) - binPath := filepath.Join(versionBinDir, constants.AWMRelayerBin) + binPath := filepath.Join(versionBinDir, constants.ICMRelayerBin) if utils.IsExecutable(binPath) { return binPath, nil } @@ -308,9 +331,9 @@ func getRelayerURL(version string) (string, error) { version = splittedVersion[1] trimmedVersion := strings.TrimPrefix(version, "v") return fmt.Sprintf( - "https://github.com/%s/%s/releases/download/awm-relayer%%2F%s/awm-relayer_%s_%s_%s.tar.gz", + "https://github.com/%s/%s/releases/download/icm-relayer%%2F%s/icm-relayer_%s_%s_%s.tar.gz", constants.AvaLabsOrg, - constants.AWMRelayerRepoName, + constants.ICMServicesRepoName, version, trimmedVersion, goos, diff --git a/pkg/teleporter/teleporter.go b/pkg/teleporter/teleporter.go index c4d73481b..306846c17 100644 --- a/pkg/teleporter/teleporter.go +++ b/pkg/teleporter/teleporter.go @@ -411,7 +411,7 @@ func DeployAndFundRelayer( return false, "", "", err } // get relayer address - relayerAddress, _, err := GetRelayerKeyInfo(app.GetKeyPath(constants.AWMRelayerKeyName)) + relayerAddress, _, err := GetRelayerKeyInfo(app.GetKeyPath(constants.ICMRelayerKeyName)) if err != nil { return false, "", "", err } @@ -471,7 +471,7 @@ func GetInfo( if err != nil { return nil, err } - ti.RelayerAddress, _, err = GetRelayerKeyInfo(app.GetKeyPath(constants.AWMRelayerKeyName)) + ti.RelayerAddress, _, err = GetRelayerKeyInfo(app.GetKeyPath(constants.ICMRelayerKeyName)) if err != nil { return nil, err } diff --git a/pkg/utils/common.go b/pkg/utils/common.go index 2ca53b546..169d6e76d 100644 --- a/pkg/utils/common.go +++ b/pkg/utils/common.go @@ -30,8 +30,10 @@ import ( "github.com/ava-labs/avalanchego/vms/platformvm" "github.com/ava-labs/avalanchego/vms/platformvm/txs" "github.com/ava-labs/subnet-evm/core" + "github.com/aws/aws-sdk-go-v2/service/ec2/types" "golang.org/x/exp/slices" + "golang.org/x/mod/semver" ) func SetupRealtimeCLIOutput( @@ -558,3 +560,15 @@ func LogLevelToEmoji(logLevel string) (string, error) { } return levelEmoji, nil } + +func IsValidSemanticVersion(version string) bool { + if !semver.IsValid(version) { + // remove tool part, just in case (eg icm-relayer/v1.5.1) + versionParts := strings.Split(version, "/") + if len(versionParts) == 2 && semver.IsValid(versionParts[1]) { + return true + } + return false + } + return true +} diff --git a/pkg/vm/evm_prompts.go b/pkg/vm/evm_prompts.go index fcfafb2a5..2da6b43c3 100644 --- a/pkg/vm/evm_prompts.go +++ b/pkg/vm/evm_prompts.go @@ -893,6 +893,7 @@ func PromptVMVersion( return app.Downloader.GetLatestPreReleaseVersion( constants.AvaLabsOrg, repoName, + "", ) case "": return promptUserForVMVersion(app, repoName) @@ -922,6 +923,7 @@ func promptUserForVMVersion( latestPreReleaseVersion, err = app.Downloader.GetLatestPreReleaseVersion( constants.AvaLabsOrg, repoName, + "", ) if err != nil { return "", err From 5d715b8ffff8712e176bbb0ebf6c282f3579a331 Mon Sep 17 00:00:00 2001 From: felipemadero Date: Tue, 3 Dec 2024 13:23:52 -0300 Subject: [PATCH 03/10] use blockchain timestamp to calculate expiry (#2391) --- cmd/blockchaincmd/add_validator.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd/blockchaincmd/add_validator.go b/cmd/blockchaincmd/add_validator.go index cb45f755b..c090a7cf8 100644 --- a/cmd/blockchaincmd/add_validator.go +++ b/cmd/blockchaincmd/add_validator.go @@ -245,7 +245,11 @@ func CallAddValidator( return fmt.Errorf("failure parsing BLS info: %w", err) } - expiry := uint64(time.Now().Add(constants.DefaultValidationIDExpiryDuration).Unix()) + blockchainTimestamp, err := getBlockchainTimestamp(network) + if err != nil { + return fmt.Errorf("failed to get blockchain timestamp: %w", err) + } + expiry := uint64(blockchainTimestamp.Add(constants.DefaultValidationIDExpiryDuration).Unix()) chainSpec := contract.ChainSpec{ BlockchainName: blockchainName, @@ -593,7 +597,6 @@ func getMaxValidationTime(network models.Network, nodeID ids.NodeID, startTime t defer cancel() platformCli := platformvm.NewClient(network.Endpoint) vs, err := platformCli.GetCurrentValidators(ctx, avagoconstants.PrimaryNetworkID, nil) - cancel() if err != nil { return 0, err } @@ -605,6 +608,13 @@ func getMaxValidationTime(network models.Network, nodeID ids.NodeID, startTime t return 0, errors.New("nodeID not found in validator set: " + nodeID.String()) } +func getBlockchainTimestamp(network models.Network) (time.Time, error) { + ctx, cancel := utils.GetAPIContext() + defer cancel() + platformCli := platformvm.NewClient(network.Endpoint) + return platformCli.GetTimestamp(ctx) +} + func getTimeParameters(network models.Network, nodeID ids.NodeID, isValidator bool) (time.Time, time.Duration, error) { defaultStakingStartLeadTime := constants.StakingStartLeadTime if network.Kind == models.Devnet { From 9ad90b87d8d879759e3cd62e6af074e1a891f97d Mon Sep 17 00:00:00 2001 From: sukantoraymond Date: Tue, 3 Dec 2024 11:34:57 -0500 Subject: [PATCH 04/10] Change deploy num local nodes flags (#2386) * change deploy flags * use constants * fix lint --------- Signed-off-by: sukantoraymond --- cmd/blockchaincmd/deploy.go | 10 ++++++++- pkg/constants/constants.go | 21 ++++++++++--------- tests/e2e/testcases/subnet/sov/etna/suite.go | 2 -- tests/e2e/testcases/validatormanager/suite.go | 1 - 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/cmd/blockchaincmd/deploy.go b/cmd/blockchaincmd/deploy.go index 4233a0543..36faa293f 100644 --- a/cmd/blockchaincmd/deploy.go +++ b/cmd/blockchaincmd/deploy.go @@ -191,7 +191,7 @@ so you can take your locally tested Subnet and deploy it on Fuji or Mainnet.`, cmd.Flags().StringSliceVar(&aggregatorExtraEndpoints, "aggregator-extra-endpoints", nil, "endpoints for extra nodes that are needed in signature aggregation") cmd.Flags().BoolVar(&useLocalMachine, "use-local-machine", false, "use local machine as a blockchain validator") cmd.Flags().IntVar(&numBootstrapValidators, "num-bootstrap-validators", 0, "(only if --generate-node-id is true) number of bootstrap validators to set up in sovereign L1 validator)") - cmd.Flags().IntVar(&numLocalNodes, "num-local-nodes", 1, "number of nodes to be created on local machine") + cmd.Flags().IntVar(&numLocalNodes, "num-local-nodes", 0, "number of nodes to be created on local machine") cmd.Flags().StringVar(&changeOwnerAddress, "change-owner-address", "", "address that will receive change if node is no longer L1 validator") cmd.Flags().Uint64Var(&poSMinimumStakeAmount, "pos-minimum-stake-amount", 1, "minimum stake amount") @@ -625,6 +625,9 @@ func deployBlockchain(cmd *cobra.Command, args []string) error { network = models.ConvertClusterToNetwork(network) } } + if numLocalNodes > 0 { + useLocalMachine = true + } // ask user if we want to use local machine if cluster is not provided if network.Kind != models.Local && !useLocalMachine && clusterNameFlagValue == "" { ux.Logger.PrintToUser("You can use your local machine as a bootstrap validator on the blockchain") @@ -635,6 +638,11 @@ func deployBlockchain(cmd *cobra.Command, args []string) error { return err } } + // default number of local machine nodes to be 1 + // we set it here instead of at flag level so that we don't prompt if user wants to use local machine when they set numLocalNodes flag value + if useLocalMachine && numLocalNodes == 0 { + numLocalNodes = constants.DefaultNumberOfLocalMachineNodes + } // if no cluster provided - we create one with fmt.Sprintf("%s-local-node", blockchainName) name if useLocalMachine && clusterNameFlagValue == "" { // stop local avalanchego process so that we can generate new local cluster diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index 4028c9d18..102b665ce 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -335,16 +335,17 @@ const ( PluginDir = "plugins" LocalDir = "local" - MetricsNetwork = "network" - MultiSig = "multi-sig" - SkipUpdateFlag = "skip-update-check" - LastFileName = ".last_actions.json" - APIRole = "API" - ValidatorRole = "Validator" - MonitorRole = "Monitor" - ICMRelayerRole = "Relayer" - LoadTestRole = "LoadTest" - DefaultWalletCreationTimeout = 5 * time.Second + DefaultNumberOfLocalMachineNodes = 1 + MetricsNetwork = "network" + MultiSig = "multi-sig" + SkipUpdateFlag = "skip-update-check" + LastFileName = ".last_actions.json" + APIRole = "API" + ValidatorRole = "Validator" + MonitorRole = "Monitor" + ICMRelayerRole = "Relayer" + LoadTestRole = "LoadTest" + DefaultWalletCreationTimeout = 5 * time.Second DefaultConfirmTxTimeout = 20 * time.Second diff --git a/tests/e2e/testcases/subnet/sov/etna/suite.go b/tests/e2e/testcases/subnet/sov/etna/suite.go index 10e266ce4..d9f48a2df 100644 --- a/tests/e2e/testcases/subnet/sov/etna/suite.go +++ b/tests/e2e/testcases/subnet/sov/etna/suite.go @@ -102,7 +102,6 @@ func deployEtnaSubnetEtnaFlag() { "deploy", subnetName, "--etna-devnet", - "--use-local-machine", "--num-local-nodes=1", "--ewoq", "--change-owner-address", @@ -131,7 +130,6 @@ func deployEtnaSubnetEtnaFlagConvertOnly() { "deploy", subnetName, "--etna-devnet", - "--use-local-machine", "--num-local-nodes=1", "--convert-only", "--ewoq", diff --git a/tests/e2e/testcases/validatormanager/suite.go b/tests/e2e/testcases/validatormanager/suite.go index 9eaa2daf4..8555cdfba 100644 --- a/tests/e2e/testcases/validatormanager/suite.go +++ b/tests/e2e/testcases/validatormanager/suite.go @@ -83,7 +83,6 @@ func createSovereignSubnet() (string, string, error) { "deploy", subnetName, "--etna-devnet", - "--use-local-machine", "--num-local-nodes=1", "--ewoq", "--convert-only", From b3a056c8c143e4331624c67255484e1d2dee0462 Mon Sep 17 00:00:00 2001 From: sukantoraymond Date: Tue, 3 Dec 2024 11:49:05 -0500 Subject: [PATCH 05/10] change add validator balance error message (#2385) * change add validator balance error message * change err msg --- pkg/prompts/validations.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/prompts/validations.go b/pkg/prompts/validations.go index 8b13cdddf..baf7e0e2c 100644 --- a/pkg/prompts/validations.go +++ b/pkg/prompts/validations.go @@ -155,7 +155,7 @@ func validateValidatorBalanceFunc(availableBalance uint64) func(string) error { return fmt.Errorf("subnet validator balance must be at least 1 AVAX") } if val > availableBalance { - return fmt.Errorf("balance should be less than %d AVAX", availableBalance) + return fmt.Errorf("current balance of %d is not sufficient for subnet validator balance to be %d AVAX", availableBalance, val) } return nil } From ad9aa0c2ade75bf34c1f749535945cf828da4d5f Mon Sep 17 00:00:00 2001 From: sukantoraymond Date: Tue, 3 Dec 2024 16:00:36 -0500 Subject: [PATCH 06/10] Validate validator manager flag value (#2395) * update validator manager flag value * fix lint --- cmd/blockchaincmd/create.go | 31 +++++ tests/e2e/testcases/subnet/sov/etna/suite.go | 133 ++++++++++++++++++- 2 files changed, 163 insertions(+), 1 deletion(-) diff --git a/cmd/blockchaincmd/create.go b/cmd/blockchaincmd/create.go index a5e84f43d..1c330f424 100644 --- a/cmd/blockchaincmd/create.go +++ b/cmd/blockchaincmd/create.go @@ -12,6 +12,10 @@ import ( "strings" "unicode" + "github.com/ava-labs/avalanche-cli/pkg/key" + "github.com/ava-labs/avalanchego/utils/formatting/address" + "github.com/ethereum/go-ethereum/common" + "github.com/ava-labs/avalanche-cli/cmd/flags" "github.com/ava-labs/avalanche-cli/pkg/cobrautils" "github.com/ava-labs/avalanche-cli/pkg/constants" @@ -251,6 +255,12 @@ func createBlockchainConfig(cmd *cobra.Command, args []string) error { if vmType == models.SubnetEvm { if sovereign { + // if validatorManagerOwner flag is used, we get the C Chain address of the key used + if createFlags.validatorManagerOwner != "" { + if err = validateValidatorManagerOwnerFlag(createFlags.validatorManagerOwner); err != nil { + return err + } + } if createFlags.validatorManagerOwner == "" { createFlags.validatorManagerOwner, err = getValidatorContractManagerAddr() if err != nil { @@ -262,6 +272,9 @@ func createBlockchainConfig(cmd *cobra.Command, args []string) error { // use the validator manager owner as the transparent proxy contract owner unless specified via cmd flag if createFlags.proxyContractOwner != "" { + if err = validateValidatorManagerOwnerFlag(createFlags.proxyContractOwner); err != nil { + return err + } sc.ProxyContractOwner = createFlags.proxyContractOwner } else { sc.ProxyContractOwner = sc.ValidatorManagerOwner @@ -510,6 +523,24 @@ func sendMetrics(cmd *cobra.Command, repoName, blockchainName string) error { return nil } +func validateValidatorManagerOwnerFlag(input string) error { + // check that flag value is not P Chain or X Chain address + _, _, _, err := address.Parse(input) + if err == nil { + return fmt.Errorf("validator manager owner has to be EVM address (in 0x format)") + } + // if flag value is a key name, we get the C Chain address of the key and set it as the value of + // the validator manager address + if !common.IsHexAddress(input) { + k, err := key.LoadSoft(models.UndefinedNetwork.ID, app.GetKeyPath(input)) + if err != nil { + return err + } + createFlags.validatorManagerOwner = k.C() + } + return nil +} + func checkInvalidSubnetNames(name string) error { if name == "" { return errEmptyBlockchainName diff --git a/tests/e2e/testcases/subnet/sov/etna/suite.go b/tests/e2e/testcases/subnet/sov/etna/suite.go index d9f48a2df..4e71b6646 100644 --- a/tests/e2e/testcases/subnet/sov/etna/suite.go +++ b/tests/e2e/testcases/subnet/sov/etna/suite.go @@ -19,7 +19,6 @@ const ( CLIBinary = "./bin/avalanche" subnetName = "e2eSubnetTest" keyName = "ewoq" - avalancheGoPath = "--avalanchego-path" ewoqEVMAddress = "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC" ewoqPChainAddress = "P-custom18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p" testLocalNodeName = "e2eSubnetTest-local-node" @@ -67,6 +66,125 @@ func createEtnaSubnetEvmConfig(poa, pos bool) { gomega.Expect(exists).Should(gomega.BeTrue()) } +func createEtnaSubnetEvmConfigWithoutProxyOwner(poa, pos bool) { + // Check config does not already exist + exists, err := utils.SubnetConfigExists(subnetName) + gomega.Expect(err).Should(gomega.BeNil()) + gomega.Expect(exists).Should(gomega.BeFalse()) + + cmdArgs := []string{ + "blockchain", + "create", + subnetName, + "--evm", + "--validator-manager-owner", + ewoqEVMAddress, + "--production-defaults", + "--evm-chain-id=99999", + "--evm-token=TOK", + "--teleporter=false", + "--" + constants.SkipUpdateFlag, + } + if poa { + cmdArgs = append(cmdArgs, "--proof-of-authority") + } else if pos { + cmdArgs = append(cmdArgs, "--proof-of-stake") + } + + cmd := exec.Command(CLIBinary, cmdArgs...) + output, err := cmd.CombinedOutput() + fmt.Println(string(output)) + if err != nil { + fmt.Println(cmd.String()) + utils.PrintStdErr(err) + } + gomega.Expect(err).Should(gomega.BeNil()) + + // Config should now exist + exists, err = utils.SubnetConfigExists(subnetName) + gomega.Expect(err).Should(gomega.BeNil()) + gomega.Expect(exists).Should(gomega.BeTrue()) +} + +func createEtnaSubnetEvmConfigValidatorManagerFlagKeyname(poa, pos bool) { + // Check config does not already exist + exists, err := utils.SubnetConfigExists(subnetName) + gomega.Expect(err).Should(gomega.BeNil()) + gomega.Expect(exists).Should(gomega.BeFalse()) + + cmdArgs := []string{ + "blockchain", + "create", + subnetName, + "--evm", + "--validator-manager-owner", + "ewoq", + "--proxy-contract-owner", + "ewoq", + "--production-defaults", + "--evm-chain-id=99999", + "--evm-token=TOK", + "--teleporter=false", + "--" + constants.SkipUpdateFlag, + } + if poa { + cmdArgs = append(cmdArgs, "--proof-of-authority") + } else if pos { + cmdArgs = append(cmdArgs, "--proof-of-stake") + } + + cmd := exec.Command(CLIBinary, cmdArgs...) + output, err := cmd.CombinedOutput() + fmt.Println(string(output)) + if err != nil { + fmt.Println(cmd.String()) + utils.PrintStdErr(err) + } + gomega.Expect(err).Should(gomega.BeNil()) + + // Config should now exist + exists, err = utils.SubnetConfigExists(subnetName) + gomega.Expect(err).Should(gomega.BeNil()) + gomega.Expect(exists).Should(gomega.BeTrue()) +} + +func createEtnaSubnetEvmConfigValidatorManagerFlagPChain(poa, pos bool) { + // Check config does not already exist + exists, err := utils.SubnetConfigExists(subnetName) + gomega.Expect(err).Should(gomega.BeNil()) + gomega.Expect(exists).Should(gomega.BeFalse()) + + cmdArgs := []string{ + "blockchain", + "create", + subnetName, + "--evm", + "--validator-manager-owner", + "P-custom18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p", + "--proxy-contract-owner", + "P-custom18jma8ppw3nhx5r4ap8clazz0dps7rv5u9xde7p", + "--production-defaults", + "--evm-chain-id=99999", + "--evm-token=TOK", + "--teleporter=false", + "--" + constants.SkipUpdateFlag, + } + if poa { + cmdArgs = append(cmdArgs, "--proof-of-authority") + } else if pos { + cmdArgs = append(cmdArgs, "--proof-of-stake") + } + + cmd := exec.Command(CLIBinary, cmdArgs...) + output, err := cmd.CombinedOutput() + fmt.Println(string(output)) + if err != nil { + fmt.Println(cmd.String()) + utils.PrintStdErr(err) + } + gomega.Expect(err).ShouldNot(gomega.BeNil()) +} + func destroyLocalNode() { _, err := os.Stat(testLocalNodeName) if os.IsNotExist(err) { @@ -242,6 +360,19 @@ var _ = ginkgo.Describe("[Etna Subnet SOV]", func() { gomega.Expect(err).Should(gomega.BeNil()) commands.CleanNetwork() }) + + ginkgo.It("Test Create Etna POA Subnet Config With Key Name for Validator Manager Flag", func() { + createEtnaSubnetEvmConfigValidatorManagerFlagKeyname(true, false) + }) + + ginkgo.It("Test Create Etna POA Subnet Config With P Chain Address for Validator Manager Flag", func() { + createEtnaSubnetEvmConfigValidatorManagerFlagPChain(true, false) + }) + + ginkgo.It("Test Create Etna POA Subnet Config Without Proxy Owner Flag", func() { + createEtnaSubnetEvmConfigWithoutProxyOwner(true, false) + }) + ginkgo.It("Create Etna POA Subnet Config & Deploy the Subnet To Public Etna On Local Machine", func() { createEtnaSubnetEvmConfig(true, false) deployEtnaSubnetEtnaFlag() From a87959dd6b4324a92b1c16b330469bc6827ccb2d Mon Sep 17 00:00:00 2001 From: felipemadero Date: Tue, 3 Dec 2024 20:09:49 -0300 Subject: [PATCH 07/10] fix add validator issues (#2396) * fix add validator issues * lint --- cmd/blockchaincmd/add_validator.go | 6 +- pkg/validatormanager/registration.go | 155 ++++++++++++++++++--------- 2 files changed, 109 insertions(+), 52 deletions(-) diff --git a/cmd/blockchaincmd/add_validator.go b/cmd/blockchaincmd/add_validator.go index c090a7cf8..1a61c19ba 100644 --- a/cmd/blockchaincmd/add_validator.go +++ b/cmd/blockchaincmd/add_validator.go @@ -318,13 +318,13 @@ func CallAddValidator( if err != nil { return err } - balanceAVAX, err := promptValidatorBalance(availableBalance) + balance, err = promptValidatorBalance(availableBalance) if err != nil { return err } - // convert to nanoAVAX - balance = balanceAVAX * units.Avax } + // convert to nanoAVAX + balance *= units.Avax if remainingBalanceOwnerAddr == "" { remainingBalanceOwnerAddr, err = getKeyForChangeOwner(network) diff --git a/pkg/validatormanager/registration.go b/pkg/validatormanager/registration.go index d97f5525d..7a98f80a7 100644 --- a/pkg/validatormanager/registration.go +++ b/pkg/validatormanager/registration.go @@ -148,6 +148,7 @@ func PoAValidatorManagerInitializeValidatorRegistration( } func ValidatorManagerGetSubnetValidatorRegistrationMessage( + rpcURL string, network models.Network, aggregatorLogLevel logging.Level, aggregatorQuorumPercentage uint64, @@ -162,34 +163,62 @@ func ValidatorManagerGetSubnetValidatorRegistrationMessage( balanceOwners warpMessage.PChainOwner, disableOwners warpMessage.PChainOwner, weight uint64, + alreadyInitialized bool, ) (*warp.Message, ids.ID, error) { - addressedCallPayload, err := warpMessage.NewRegisterL1Validator( - subnetID, - nodeID, - blsPublicKey, - expiry, - balanceOwners, - disableOwners, - weight, + var ( + registerSubnetValidatorUnsignedMessage *warp.UnsignedMessage + validationID ids.ID + err error ) - if err != nil { - return nil, ids.Empty, err - } - validationID := addressedCallPayload.ValidationID() - registerSubnetValidatorAddressedCall, err := warpPayload.NewAddressedCall( - managerAddress.Bytes(), - addressedCallPayload.Bytes(), - ) - if err != nil { - return nil, ids.Empty, err - } - registerSubnetValidatorUnsignedMessage, err := warp.NewUnsignedMessage( - network.ID, - blockchainID, - registerSubnetValidatorAddressedCall.Bytes(), - ) - if err != nil { - return nil, ids.Empty, err + if alreadyInitialized { + validationID, err = GetRegisteredValidator( + rpcURL, + managerAddress, + nodeID, + ) + if err != nil { + return nil, ids.Empty, err + } + unsignedMessageBytes, err := GetRegistrationMessage( + rpcURL, + validationID, + ) + if err != nil { + return nil, ids.Empty, err + } + registerSubnetValidatorUnsignedMessage, err = warp.ParseUnsignedMessage(unsignedMessageBytes) + if err != nil { + return nil, ids.Empty, err + } + } else { + addressedCallPayload, err := warpMessage.NewRegisterL1Validator( + subnetID, + nodeID, + blsPublicKey, + expiry, + balanceOwners, + disableOwners, + weight, + ) + if err != nil { + return nil, ids.Empty, err + } + validationID = addressedCallPayload.ValidationID() + registerSubnetValidatorAddressedCall, err := warpPayload.NewAddressedCall( + managerAddress.Bytes(), + addressedCallPayload.Bytes(), + ) + if err != nil { + return nil, ids.Empty, err + } + registerSubnetValidatorUnsignedMessage, err = warp.NewUnsignedMessage( + network.ID, + blockchainID, + registerSubnetValidatorAddressedCall.Bytes(), + ) + if err != nil { + return nil, ids.Empty, err + } } signatureAggregator, err := interchain.NewSignatureAggregator( network, @@ -291,7 +320,7 @@ func ValidatorManagerGetPChainSubnetValidatorRegistrationWarpMessage( } var justificationBytes []byte if !registered { - justificationBytes, err = GetRegistrationMessage(rpcURL, validationID, subnetID) + justificationBytes, err = GetRegistrationJustification(rpcURL, validationID, subnetID) if err != nil { return nil, err } @@ -355,6 +384,7 @@ func InitValidatorRegistration( return nil, ids.Empty, err } managerAddress := common.HexToAddress(validatorManagerSDK.ProxyContractAddress) + alreadyInitialized := false if initWithPos { ux.Logger.PrintLineSeparator() ux.Logger.PrintToUser("Initializing a validator registration with PoS validator manager") @@ -379,6 +409,7 @@ func InitValidatorRegistration( return nil, ids.Empty, evm.TransactionError(tx, err, "failure initializing validator registration") } ux.Logger.PrintToUser("the validator registration was already initialized. Proceeding to the next step") + alreadyInitialized = true } } else { managerAddress = common.HexToAddress(validatorManagerSDK.ProxyContractAddress) @@ -398,6 +429,7 @@ func InitValidatorRegistration( return nil, ids.Empty, evm.TransactionError(tx, err, "failure initializing validator registration") } ux.Logger.PrintToUser("the validator registration was already initialized. Proceeding to the next step") + alreadyInitialized = true } } aggregatorLogLevel, err := logging.ToLevel(aggregatorLogLevelStr) @@ -419,6 +451,7 @@ func InitValidatorRegistration( ux.Logger.PrintToUser(fmt.Sprintf("Validator weight: %d", weight)) return ValidatorManagerGetSubnetValidatorRegistrationMessage( + rpcURL, network, aggregatorLogLevel, 0, @@ -433,6 +466,7 @@ func InitValidatorRegistration( balanceOwners, disableOwners, weight, + alreadyInitialized, ) } @@ -494,23 +528,7 @@ func FinishValidatorRegistration( func GetRegistrationMessage( rpcURL string, validationID ids.ID, - subnetID ids.ID, ) ([]byte, error) { - const numBootstrapValidatorsToSearch = 100 - for validationIndex := uint32(0); validationIndex < numBootstrapValidatorsToSearch; validationIndex++ { - bootstrapValidationID := subnetID.Append(validationIndex) - if bootstrapValidationID == validationID { - justification := platformvm.L1ValidatorRegistrationJustification{ - Preimage: &platformvm.L1ValidatorRegistrationJustification_ConvertSubnetToL1TxData{ - ConvertSubnetToL1TxData: &platformvm.SubnetIDIndex{ - SubnetId: subnetID[:], - Index: validationIndex, - }, - }, - } - return proto.Marshal(&justification) - } - } client, err := evm.GetClient(rpcURL) if err != nil { return nil, err @@ -545,12 +563,7 @@ func GetRegistrationMessage( reg, err := warpMessage.ParseRegisterL1Validator(addressedCall.Payload) if err == nil { if reg.ValidationID() == validationID { - justification := platformvm.L1ValidatorRegistrationJustification{ - Preimage: &platformvm.L1ValidatorRegistrationJustification_RegisterL1ValidatorMessage{ - RegisterL1ValidatorMessage: addressedCall.Payload, - }, - } - return proto.Marshal(&justification) + return msg.Bytes(), nil } } } @@ -559,3 +572,47 @@ func GetRegistrationMessage( } return nil, fmt.Errorf("validation id %s not found on warp events", validationID) } + +func GetRegistrationJustification( + rpcURL string, + validationID ids.ID, + subnetID ids.ID, +) ([]byte, error) { + const numBootstrapValidatorsToSearch = 100 + for validationIndex := uint32(0); validationIndex < numBootstrapValidatorsToSearch; validationIndex++ { + bootstrapValidationID := subnetID.Append(validationIndex) + if bootstrapValidationID == validationID { + justification := platformvm.L1ValidatorRegistrationJustification{ + Preimage: &platformvm.L1ValidatorRegistrationJustification_ConvertSubnetToL1TxData{ + ConvertSubnetToL1TxData: &platformvm.SubnetIDIndex{ + SubnetId: subnetID[:], + Index: validationIndex, + }, + }, + } + return proto.Marshal(&justification) + } + } + msg, err := GetRegistrationMessage( + rpcURL, + validationID, + ) + if err != nil { + return nil, err + } + parsed, err := warp.ParseUnsignedMessage(msg) + if err != nil { + return nil, err + } + payload := parsed.Payload + addressedCall, err := warpPayload.ParseAddressedCall(payload) + if err != nil { + return nil, err + } + justification := platformvm.L1ValidatorRegistrationJustification{ + Preimage: &platformvm.L1ValidatorRegistrationJustification_RegisterL1ValidatorMessage{ + RegisterL1ValidatorMessage: addressedCall.Payload, + }, + } + return proto.Marshal(&justification) +} From 6d679253706ae4dde560049b7f7746bf6a5697c5 Mon Sep 17 00:00:00 2001 From: sukantoraymond Date: Tue, 3 Dec 2024 18:40:26 -0500 Subject: [PATCH 08/10] remove unused constants (#2393) --- pkg/constants/constants.go | 61 +++++--------------------------------- sdk/constants/constants.go | 5 +--- 2 files changed, 9 insertions(+), 57 deletions(-) diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index 102b665ce..ff33ba5f4 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -38,9 +38,6 @@ const ( NodeCloudConfigFileName = "node_cloud_config.json" AnsibleDir = "ansible" AnsibleHostInventoryFileName = "hosts" - StopAWSNode = "stop-aws-node" - CreateAWSNode = "create-aws-node" - GetAWSNodeIP = "get-aws-node-ip" ClustersConfigFileName = "cluster_config.json" ClustersConfigVersion = "1" StakerCertFileName = "staker.crt" @@ -68,7 +65,6 @@ const ( SSHFileOpsTimeout = 100 * time.Second SSHPOSTTimeout = 10 * time.Second SSHSleepBetweenChecks = 1 * time.Second - SSHShell = "/bin/bash" AWSVolumeTypeGP3 = "gp3" AWSVolumeTypeIO1 = "io1" AWSVolumeTypeIO2 = "io2" @@ -84,10 +80,8 @@ const ( // TODO: remove after etna release is available FirstEtnaRPCVersion = 38 - PublicAccess HTTPAccess = true - PrivateAccess HTTPAccess = false - FujiAPIEndpoint = "https://api.avax-test.network" - MainnetAPIEndpoint = "https://api.avax.network" + FujiAPIEndpoint = "https://api.avax-test.network" + MainnetAPIEndpoint = "https://api.avax.network" // this depends on bootstrap snapshot LocalAPIEndpoint = "http://127.0.0.1:9650" @@ -103,27 +97,16 @@ const ( DefaultTokenSymbol = "TEST" - HealthCheckInterval = 100 * time.Millisecond - // it's unlikely anyone would want to name a snapshot `default` // but let's add some more entropy SnapshotsDirName = "snapshots" DefaultSnapshotName = "default-1654102509" - Cortina17Version = "v1.10.17" - Durango11Version = "v1.11.11" - Durango12Version = "v1.11.12" - - BootstrapSnapshotRawBranch = "https://github.com/ava-labs/avalanche-cli/raw/main/" - ExtraLocalNetworkDataFilename = "extra-local-network-data.json" CliInstallationURL = "https://raw.githubusercontent.com/ava-labs/avalanche-cli/main/scripts/install.sh" - ExpectedCliInstallErr = "resource temporarily unavailable" EIPLimitErr = "AddressLimitExceeded" - ErrCreatingAWSNode = "failed to create AWS Node" - ErrCreatingGCPNode = "failed to create GCP Node" ErrReleasingGCPStaticIP = "failed to release gcp static ip" KeyDir = "key" KeySuffix = ".pk" @@ -163,7 +146,6 @@ const ( GCPDefaultAuthKeyPath = "~/.config/gcloud/application_default_credentials.json" CertSuffix = "-kp.pem" AWSSecurityGroupSuffix = "-sg" - ExportSubnetSuffix = "-export.dat" SSHTCPPort = 22 AvalancheGoAPIPort = 9650 AvalancheGoP2PPort = 9651 @@ -171,24 +153,10 @@ const ( AvalancheGoLokiPort = 23101 CloudServerStorageSize = 1000 MonitoringCloudServerStorageSize = 50 - OutboundPort = 0 - // Set this one to true while testing changes that alter CLI execution on cloud nodes - // Disable it for releases to save cluster creation time - EnableSetupCLIFromSource = false - SetupCLIFromSourceBranch = "main" - BuildEnvGolangVersion = "1.22.1" - IsHealthyJSONFile = "isHealthy.json" - IsBootstrappedJSONFile = "isBootstrapped.json" - AvalancheGoVersionJSONFile = "avalancheGoVersion.json" - SubnetSyncJSONFile = "isSubnetSynced.json" - AnsibleInventoryDir = "inventories" - AnsibleTempInventoryDir = "temp_inventories" - AnsibleStatusDir = "status" - AnsibleInventoryFlag = "-i" - AnsibleExtraArgsIdentitiesOnlyFlag = "--ssh-extra-args='-o IdentitiesOnly=yes'" - AnsibleSSHShellParams = "-o IdentitiesOnly=yes -o StrictHostKeyChecking=no" - AnsibleSSHUseAgentParams = "-o StrictHostKeyChecking=no" - AnsibleExtraVarsFlag = "--extra-vars" + BuildEnvGolangVersion = "1.22.1" + AnsibleInventoryDir = "inventories" + AnsibleSSHShellParams = "-o IdentitiesOnly=yes -o StrictHostKeyChecking=no" + AnsibleSSHUseAgentParams = "-o StrictHostKeyChecking=no" ConfigAPMCredentialsFileKey = "credentials-file" ConfigAPMAdminAPIEndpointKey = "admin-api-endpoint" @@ -246,8 +214,6 @@ const ( ICMRelayerRunFilename = "icm-relayer-process.json" ICMRelayerDockerDir = "/.icm-relayer" - ICMRelayerSnapshotConfsDir = "relayer-confs" - ICMKeyName = "cli-teleporter-deployer" ICMRelayerKeyName = "cli-awm-relayer" DefaultRelayerAmount = float64(10) @@ -265,8 +231,6 @@ const ( SubnetEVMBin = "subnet-evm" - DefaultNodeRunURL = "http://127.0.0.1:9650" - APMDir = ".apm" APMLogName = "apm.log" DefaultAvaLabsPackage = "ava-labs/avalanche-plugins-core" @@ -321,10 +285,8 @@ const ( NotAvailableLabel = "Not available" BackendCmd = "avalanche-cli-backend" - AvalancheGoVersionUnknown = "n/a" - AvalancheGoCompatibilityVersionAdded = "v1.9.2" - AvalancheGoCompatibilityURL = "https://raw.githubusercontent.com/ava-labs/avalanchego/master/version/compatibility.json" - SubnetEVMRPCCompatibilityURL = "https://raw.githubusercontent.com/ava-labs/subnet-evm/master/compatibility.json" + AvalancheGoCompatibilityURL = "https://raw.githubusercontent.com/ava-labs/avalanchego/master/version/compatibility.json" + SubnetEVMRPCCompatibilityURL = "https://raw.githubusercontent.com/ava-labs/subnet-evm/master/compatibility.json" YesLabel = "Yes" NoLabel = "No" @@ -337,7 +299,6 @@ const ( DefaultNumberOfLocalMachineNodes = 1 MetricsNetwork = "network" - MultiSig = "multi-sig" SkipUpdateFlag = "skip-update-check" LastFileName = ".last_actions.json" APIRole = "API" @@ -345,9 +306,6 @@ const ( MonitorRole = "Monitor" ICMRelayerRole = "Relayer" LoadTestRole = "LoadTest" - DefaultWalletCreationTimeout = 5 * time.Second - - DefaultConfirmTxTimeout = 20 * time.Second PayTxsFeesMsg = "pay transaction fees" @@ -362,9 +320,6 @@ const ( E2EDebugAvalancheGoPath = "E2E_AVALANCHEGO_PATH" GitExtension = ".git" - // Docker - RemoteDockeSocketPath = "/var/run/docker.sock" - // Avalanche InterChain Token Transfer ICTTDir = "avalanche-interchain-token-transfer" ICTTURL = "https://github.com/ava-labs/avalanche-interchain-token-transfer" diff --git a/sdk/constants/constants.go b/sdk/constants/constants.go index 128abe30a..d985e24b1 100644 --- a/sdk/constants/constants.go +++ b/sdk/constants/constants.go @@ -9,9 +9,6 @@ const ( APIRequestTimeout = 30 * time.Second APIRequestLargeTimeout = 2 * time.Minute - RemoteHostUser = "ubuntu" - // node - CloudNodeCLIConfigBasePath = "/home/ubuntu/.avalanche-cli/" - WriteReadUserOnlyPerms = 0o600 + WriteReadUserOnlyPerms = 0o600 ) From d2319f8a21d87ea38c24ee751f121c222f522a61 Mon Sep 17 00:00:00 2001 From: Meaghan FitzGerald Date: Wed, 4 Dec 2024 11:28:10 -0500 Subject: [PATCH 09/10] Update feature_spec.md (#2390) Signed-off-by: Meaghan FitzGerald Co-authored-by: sukantoraymond --- .github/ISSUE_TEMPLATE/feature_spec.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/feature_spec.md b/.github/ISSUE_TEMPLATE/feature_spec.md index ec68012fb..f8d0f5a05 100644 --- a/.github/ISSUE_TEMPLATE/feature_spec.md +++ b/.github/ISSUE_TEMPLATE/feature_spec.md @@ -1,18 +1,20 @@ --- -name: Feature specification +name: Feature about: Discussion on design and implementation of new features for the Avalanche CLI. title: '' -labels: enhancement assignees: '' - --- -**Context and scope** -Include a short description of the context and scope of the suggested feature. -Include goals the change will accomplish if relevant. +## Goal + +### Assumptions and Scope + +## Example Usage + +### Requirements: + +### Current Limitations -**Discussion and alternatives** -Include a description of the changes to be made to the code along with alternatives that were considered. +### Nice to Have, but Not Required -**Open questions** -Questions that are still being discussed. +## Open Questions From b7753323af59789f4ce0bb02077b4afad204d168 Mon Sep 17 00:00:00 2001 From: sukantoraymond Date: Wed, 4 Dec 2024 11:44:51 -0500 Subject: [PATCH 10/10] version 1.8.0 (#2397) --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 359a5b952..afa2b3515 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.0 \ No newline at end of file +1.8.0 \ No newline at end of file