From a06b72bb0253daf46403dfa636f329995c1a9a45 Mon Sep 17 00:00:00 2001 From: Can Dost Yavuz <82905251+candostyavuz@users.noreply.github.com> Date: Thu, 7 Sep 2023 15:32:43 +0300 Subject: [PATCH] lavavisor binary name changed (#772) --- .github/workflows/release.yml | 6 ++-- Makefile | 2 +- cmd/lavad/cmd/root.go | 6 ++-- cmd/{lava-visor => lavavisor}/README.md | 36 +++++++++++----------- cmd/{lava-visor => lavavisor}/main.go | 0 ecosystem/lavavisor/cmd/create-service.go | 18 +++++------ ecosystem/lavavisor/cmd/start.go | 6 ++-- ecosystem/lavavisor/pkg/process/fetcher.go | 14 ++++----- 8 files changed, 44 insertions(+), 44 deletions(-) rename cmd/{lava-visor => lavavisor}/README.md (70%) rename cmd/{lava-visor => lavavisor}/main.go (100%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aa87062f72..3999fb985a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -83,9 +83,9 @@ jobs: -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - -H "Content-Type: $(file -b --mime-type build/lava-visor)" \ - --data-binary @build/lava-visor \ - $(echo '${{ github.event.release.upload_url }}' | sed 's/{?name,label}/?name=lava-visor-${{ github.event.release.tag_name }}-linux-amd64/g') + -H "Content-Type: $(file -b --mime-type build/lavavisor)" \ + --data-binary @build/lavavisor \ + $(echo '${{ github.event.release.upload_url }}' | sed 's/{?name,label}/?name=lavavisor-${{ github.event.release.tag_name }}-linux-amd64/g') } delete_binary(){ diff --git a/Makefile b/Makefile index ec703455f0..c9a4f4f43b 100644 --- a/Makefile +++ b/Makefile @@ -223,7 +223,7 @@ ifeq (,$(findstring nostrip,$(LAVA_BUILD_OPTIONS))) BUILD_FLAGS += -trimpath endif -LAVA_ALL_BINARIES := lavad lavap lava-visor +LAVA_ALL_BINARIES := lavad lavap lavavisor # helper target/build functions diff --git a/cmd/lavad/cmd/root.go b/cmd/lavad/cmd/root.go index 988d06ea89..09ed36c2ea 100644 --- a/cmd/lavad/cmd/root.go +++ b/cmd/lavad/cmd/root.go @@ -161,9 +161,9 @@ func initLavaProtocolRootCmd( func NewLavaVisorRootCmd() *cobra.Command { version := "0.1.0" rootCmd := &cobra.Command{ - Use: "lava-visor", - Short: `lava-visor is a protocol upgrade manager for Lava protocol binaries.`, - Long: `lava-visor is a protocol upgrade manager designed to orchestrate and automate the process of protocol version upgrades.`, + Use: "lavavisor", + Short: `lavavisor is a protocol upgrade manager for Lava protocol binaries.`, + Long: `lavavisor is a protocol upgrade manager designed to orchestrate and automate the process of protocol version upgrades.`, Version: version, Run: func(cmd *cobra.Command, args []string) { if len(args) == 0 { diff --git a/cmd/lava-visor/README.md b/cmd/lavavisor/README.md similarity index 70% rename from cmd/lava-visor/README.md rename to cmd/lavavisor/README.md index f4b9a2cb9b..6065004f8a 100644 --- a/cmd/lava-visor/README.md +++ b/cmd/lavavisor/README.md @@ -9,7 +9,7 @@ Lavavisor is added as a `LAVA_ALL_BINARIES` parameter in the Makefile. Any scrip ## Usage ### Commands: -- **`lava-visor init`**: Initializes LavaVisor for operation. +- **`lavavisor init`**: Initializes LavaVisor for operation. **Optional Flags**: - `--directory` @@ -17,18 +17,18 @@ Lavavisor is added as a `LAVA_ALL_BINARIES` parameter in the Makefile. Any scrip - `--auto-start` **Example usage:** - `lava-visor init --auto-download --auto-start`` + `lavavisor init --auto-download --auto-start`` Prepares the local environment for the operation of LavaVisor. -Here are the operations that `lava-visor init` performs: +Here are the operations that `lavavisor init` performs: -1. Verifies the existence of the `./lava-visor` directory for LavaVisor operations. If absent, it establishes the directory structure. +1. Verifies the existence of the `./lavavisor` directory for LavaVisor operations. If absent, it establishes the directory structure. 2. Sends a request to the Lava Network, retrieving the minimum and target protocol versions. -3. Using the acquired version, it searches for the corresponding protocol binary in `.lava-visor/upgrades//`. +3. Using the acquired version, it searches for the corresponding protocol binary in `.lavavisor/upgrades//`. 4. If the binary isn't found at the target location, it tries to download the binary from GitHub using the fetched version (note: the `auto-download` flag must be enabled). 5. Validates the fetched binary. 6. Verifies if a `lavap` binary already exists in the system path. If not, it copies the fetched binary to the system path. -7. Establishes a symbolic link between the fetched binary in `.lava-visor/upgrades//` and the protocol binary in the system path. +7. Establishes a symbolic link between the fetched binary in `.lavavisor/upgrades//` and the protocol binary in the system path. ### Known Issue: Some older versions of `lavap` lack the `version` command, which LavaVisor employs to validate binary versions. When these older version binaries are downloaded using the auto-download option, LavaVisor will accept these binaries without signaling an error. However, when restarting LavaVisor with this binary, an error will be raised. This is because the binary validation will fail since the version command cannot be executed. @@ -37,7 +37,7 @@ Some older versions of `lavap` lack the `version` command, which LavaVisor emplo - Use the latest version of the protocol. - Set up the binaries manually. -- **`lava-visor create-service`**: Creates system files according to given consumer / provider config file and configuration flags. +- **`lavavisor create-service`**: Creates system files according to given consumer / provider config file and configuration flags. **Arguments**: `[service-type: "provider" or "consumer"]` @@ -52,38 +52,38 @@ Some older versions of `lavap` lack the `version` command, which LavaVisor emplo - `--directory` **Example usage:** - `lava-visor create-service consumer /home/ubuntu/config/consumer-ETH1.yml --geolocation 1 --from user1 --log_level info --keyring-backend test --chain-id lava --node http://127.0.0.1:26657` + `lavavisor create-service consumer /home/ubuntu/config/consumer-ETH1.yml --geolocation 1 --from user1 --log_level info --keyring-backend test --chain-id lava --node http://127.0.0.1:26657` - This command generates the service file in '.lava-visor/' directory so that consumer & provider processes can be started in a robust manner. Additionally, it creates a `./logs` directory, so that service logs can be easily accessed. Finally, it updates the `config.yml` file by appending the name of the service created by this command, allowing the created process to be read by the lava-visor start command. + This command generates the service file in '.lavavisor/' directory so that consumer & provider processes can be started in a robust manner. Additionally, it creates a `./logs` directory, so that service logs can be easily accessed. Finally, it updates the `config.yml` file by appending the name of the service created by this command, allowing the created process to be read by the lavavisor start command. -- **`lava-visor start`**: Starts provider/consumer processes given with linked binary and starts lava-visor version monitor. +- **`lavavisor start`**: Starts provider/consumer processes given with linked binary and starts lavavisor version monitor. **Optional Flags**: - `--directory` - `--auto-download` **Example usage:** - `lava-visor start --auto-download` + `lavavisor start --auto-download` This command reads the `config.yml` file to determine the list of services. Once identified, it starts each service using the linked binary. Concurrently, it also launches the LavaVisor version monitor. This monitor is designed to detect when an upgrade is necessary and will automatically carry out the upgrade process as soon as it's triggered. -Here are the operations that `lava-visor start` performs: +Here are the operations that `lavavisor start` performs: -1. Ensures the `.lava-visor` directory is present. +1. Ensures the `.lavavisor` directory is present. 2. Reads the `config.yml` to determine the list of services. Each service is then initiated using the binary linked by the `init` command. 3. Sets up state tracker parameters and registers its state tracker for protocol version updates. 4. Launches the version monitor as a separate go routine, which activates when the `updateTriggered` signal is set to true. 5. If an upgrade requirement is detected, the `updateTriggered` signal is enabled, prompting the version monitor to commence the auto-upgrade process. -6. Once the new binary is either retrieved from `.lava-visor/upgrades//` or downloaded from GitHub (note: `auto-download` must be active), a new link to the binary is established, and the system daemon is restarted. +6. Once the new binary is either retrieved from `.lavavisor/upgrades//` or downloaded from GitHub (note: `auto-download` must be active), a new link to the binary is established, and the system daemon is restarted. 7. After rebooting the provider and consumer processes, the version monitor resumes its monitoring for potential upgrade events. # Test -1. Run `lava-visor init --auto-download` → This will setup LavaVisor directory and link the protocol binary -2. Instead of creating service files manually, execute `lava-visor create-service` command to generate a the service files. -3. Validate `.lava-visor/services` folder created and with generated service files. +1. Run `lavavisor init --auto-download` → This will setup LavaVisor directory and link the protocol binary +2. Instead of creating service files manually, execute `lavavisor create-service` command to generate a the service files. +3. Validate `.lavavisor/services` folder created and with generated service files. 4. Validate `config.yml` is updated and includes all of the target service names. -5. Execute `lava-visor start`, and you should observe all services running. Additionally, the version monitor will begin validating versions. +5. Execute `lavavisor start`, and you should observe all services running. Additionally, the version monitor will begin validating versions. 6. Now we need to make an upgrade proposal by using `/gov` module, so that protocol version will change in the consensus and LavaVisor will detect & initiate auto-upgrade. Here is the script for sending version update proposal transaction (for Cosmos SDK v0.47.0): ```bash diff --git a/cmd/lava-visor/main.go b/cmd/lavavisor/main.go similarity index 100% rename from cmd/lava-visor/main.go rename to cmd/lavavisor/main.go diff --git a/ecosystem/lavavisor/cmd/create-service.go b/ecosystem/lavavisor/cmd/create-service.go index a1b156118b..a893c8e059 100644 --- a/ecosystem/lavavisor/cmd/create-service.go +++ b/ecosystem/lavavisor/cmd/create-service.go @@ -37,37 +37,37 @@ func CreateLavaVisorCreateServiceCobraCommand() *cobra.Command { Short: "generates service files for each provider/consumer in the config.yml.", Long: `The 'create-service' command generates system service files for provider and consumer processes. Once these service files are created, - the 'lava-visor start' command can utilize them to manage (enable, restart, and check the status of) + the 'lavavisor start' command can utilize them to manage (enable, restart, and check the status of) each service using the 'systemctl' command. After a service file is created, the name of the service is added to "config.yml" file inside Lavavisor directory.`, Args: cobra.ExactArgs(2), Example: `required flags: --geolocation | --from optional flags: --log-level | --node | --keyring-backend - lava-visor create-service provider ./config --geolocation 1 --from alice --log-level warn - lava-visor create-service consumer ./config --geolocation 1 --from bob --log-level info`, + lavavisor create-service provider ./config --geolocation 1 --from alice --log-level warn + lavavisor create-service consumer ./config --geolocation 1 --from bob --log-level info`, RunE: func(cmd *cobra.Command, args []string) error { // 1. read config.yml -> this will tell us what service files this command will create dir, _ := cmd.Flags().GetString("directory") - // Build path to ./lava-visor + // Build path to ./lavavisor lavavisorPath, err := processmanager.ValidateLavavisorDir(dir) if err != nil { return err } - // .lava-visor/ main services dir + // .lavavisor/ main services dir lavavisorServicesDir := lavavisorPath + "/services" err = os.MkdirAll(lavavisorServicesDir, 0o755) if err != nil { return utils.LavaFormatError("failed to create services directory", err) } - // .lava-visor/ service logs dir + // .lavavisor/ service logs dir lavavisorLogsDir := lavavisorServicesDir + "/logs" err = os.MkdirAll(lavavisorLogsDir, 0o755) if err != nil { return utils.LavaFormatError("failed to create service logs directory", err) } - // .lava-visor/ service config dir + // .lavavisor/ service config dir lavavisorServiceConfigDir := lavavisorServicesDir + "/service_configs" err = os.MkdirAll(lavavisorServiceConfigDir, 0o755) if err != nil { @@ -127,7 +127,7 @@ func CreateLavaVisorCreateServiceCobraCommand() *cobra.Command { if err != nil { return err } - // Write the name of the service into .lava-visor/config.yml + // Write the name of the service into .lavavisor/config.yml return WriteToConfigFile(lavavisorPath, serviceFileName) }, } @@ -171,7 +171,7 @@ func CreateServiceFile(serviceParams *ServiceParams) (string, error) { } else if serviceParams.ServiceType == "provider" { content += " ExecStart=" + workingDir + "lavap rpcprovider " } - content += ".lava-visor/services/service_configs/" + filepath.Base(serviceParams.ServiceConfigFile) + " --from " + serviceParams.FromUser + " --keyring-backend " + serviceParams.KeyringBackend + " --chain-id " + serviceParams.ChainID + " --geolocation " + fmt.Sprint(serviceParams.GeoLocation) + " --log_level " + serviceParams.LogLevel + " --node " + serviceParams.Node + "\n" + content += ".lavavisor/services/service_configs/" + filepath.Base(serviceParams.ServiceConfigFile) + " --from " + serviceParams.FromUser + " --keyring-backend " + serviceParams.KeyringBackend + " --chain-id " + serviceParams.ChainID + " --geolocation " + fmt.Sprint(serviceParams.GeoLocation) + " --log_level " + serviceParams.LogLevel + " --node " + serviceParams.Node + "\n" content += " User=ubuntu\n" content += " Restart=always\n" diff --git a/ecosystem/lavavisor/cmd/start.go b/ecosystem/lavavisor/cmd/start.go index 73704c8095..5a164077e4 100644 --- a/ecosystem/lavavisor/cmd/start.go +++ b/ecosystem/lavavisor/cmd/start.go @@ -64,9 +64,9 @@ func (lv *LavaVisor) Start(ctx context.Context, txFactory tx.Factory, clientCtx // Select most recent version set by init command (in the range of min-target version) selectedVersion, err := SelectMostRecentVersionFromDir(lavavisorPath, version) if err != nil { - utils.LavaFormatFatal("failed getting most recent version from .lava-visor dir", err) + utils.LavaFormatFatal("failed getting most recent version from .lavavisor dir", err) } - utils.LavaFormatInfo("Version check OK in '.lava-visor' directory.", utils.Attribute{Key: "Selected Version", Value: selectedVersion}) + utils.LavaFormatInfo("Version check OK in '.lavavisor' directory.", utils.Attribute{Key: "Selected Version", Value: selectedVersion}) // Initialize version monitor with selected most recent version versionMonitor := processmanager.NewVersionMonitor(selectedVersion, lavavisorPath, services, autoDownload) @@ -162,7 +162,7 @@ func LavavisorStart(cmd *cobra.Command) error { func SelectMostRecentVersionFromDir(lavavisorPath string, version *protocoltypes.Version) (selectedVersion string, err error) { upgradesDir := filepath.Join(lavavisorPath, "upgrades") - // List all directories under lava-visor/upgrades + // List all directories under lavavisor/upgrades dirs, err := os.ReadDir(upgradesDir) if err != nil { return "", err diff --git a/ecosystem/lavavisor/pkg/process/fetcher.go b/ecosystem/lavavisor/pkg/process/fetcher.go index fb28fd28fa..f3f8d8d0d2 100644 --- a/ecosystem/lavavisor/pkg/process/fetcher.go +++ b/ecosystem/lavavisor/pkg/process/fetcher.go @@ -34,14 +34,14 @@ func SetupLavavisorDir(dir string) (lavavisorPath string, err error) { if err != nil { return "", err } - // Check if ./lava-visor directory exists + // Check if ./lavavisor directory exists if _, err := os.Stat(lavavisorPath); os.IsNotExist(err) { // If not, create the directory err = setUpLavavisorDirectory(lavavisorPath) if err != nil { - return "", utils.LavaFormatError("unable to create .lava-visor/ directory", err) + return "", utils.LavaFormatError("unable to create .lavavisor/ directory", err) } - utils.LavaFormatInfo(".lava-visor/ folder successfully created", utils.Attribute{Key: "path:", Value: lavavisorPath}) + utils.LavaFormatInfo(".lavavisor/ folder successfully created", utils.Attribute{Key: "path:", Value: lavavisorPath}) } return lavavisorPath, nil } @@ -64,15 +64,15 @@ func buildLavavisorPath(dir string) (string, error) { return "", utils.LavaFormatError("unable to expand directory path", err) } // Build path to ./lavavisor - return filepath.Join(dir, ".lava-visor"), nil + return filepath.Join(dir, ".lavavisor"), nil } func setUpLavavisorDirectory(lavavisorPath string) error { err := os.MkdirAll(lavavisorPath, 0o755) if err != nil { - return utils.LavaFormatError("unable to create .lava-visor/ directory", err) + return utils.LavaFormatError("unable to create .lavavisor/ directory", err) } - // Create config.yml file inside .lava-visor and write placeholder text + // Create config.yml file inside .lavavisor and write placeholder text configPath := filepath.Join(lavavisorPath, "config.yml") configFile, err := os.Create(configPath) if err != nil { @@ -80,7 +80,7 @@ func setUpLavavisorDirectory(lavavisorPath string) error { } defer configFile.Close() // Close the file - // Create 'upgrades' directory inside .lava-visor + // Create 'upgrades' directory inside .lavavisor upgradesPath := filepath.Join(lavavisorPath, "upgrades") if _, err := os.Stat(upgradesPath); os.IsNotExist(err) { err = os.MkdirAll(upgradesPath, 0o755)