Skip to content

Commit

Permalink
lavavisor binary name changed (#772)
Browse files Browse the repository at this point in the history
  • Loading branch information
candostyavuz authored Sep 7, 2023
1 parent 78d87b5 commit a06b72b
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 44 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions cmd/lavad/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
36 changes: 18 additions & 18 deletions cmd/lava-visor/README.md → cmd/lavavisor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ 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`
- `--auto-download`
- `--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/<version-tag>/`.
3. Using the acquired version, it searches for the corresponding protocol binary in `.lavavisor/upgrades/<version-tag>/`.
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/<version-tag>/` and the protocol binary in the system path.
7. Establishes a symbolic link between the fetched binary in `.lavavisor/upgrades/<version-tag>/` 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.
Expand All @@ -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"]`
Expand All @@ -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/<new-version-tag>/` 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/<new-version-tag>/` 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
Expand Down
File renamed without changes.
18 changes: 9 additions & 9 deletions ecosystem/lavavisor/cmd/create-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
},
}
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions ecosystem/lavavisor/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions ecosystem/lavavisor/pkg/process/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -64,23 +64,23 @@ 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 {
return utils.LavaFormatError("unable to create or clean config.yml", err)
}
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)
Expand Down

0 comments on commit a06b72b

Please sign in to comment.