Skip to content

Commit

Permalink
Merge branch 'main' into change-deploy-flags
Browse files Browse the repository at this point in the history
Signed-off-by: sukantoraymond <[email protected]>
  • Loading branch information
sukantoraymond authored Dec 3, 2024
2 parents 024d630 + 5d715b8 commit 7118142
Show file tree
Hide file tree
Showing 34 changed files with 269 additions and 152 deletions.
14 changes: 12 additions & 2 deletions cmd/blockchaincmd/add_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand All @@ -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 {
Expand Down
16 changes: 13 additions & 3 deletions cmd/blockchaincmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -1128,7 +1138,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
}
Expand Down
12 changes: 6 additions & 6 deletions cmd/interchaincmd/relayercmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions cmd/interchaincmd/relayercmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions cmd/interchaincmd/relayercmd/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion cmd/networkcmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion cmd/nodecmd/create_gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 23 additions & 23 deletions cmd/nodecmd/wiz.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
}
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -507,33 +507,33 @@ 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)
nodeConfig, err := app.LoadClusterNodeConfig(cloudID)
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) {
Expand All @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/mocks/binary_checker.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions internal/mocks/downloader.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/mocks/installer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/mocks/network.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/mocks/plugin_binary_downloader.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/mocks/process_checker.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7118142

Please sign in to comment.