Skip to content

Commit

Permalink
fix(block-explorer): improve block explorer reliability
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored and artemijspavlovs committed Sep 20, 2024
1 parent 4890bc7 commit b1132dc
Show file tree
Hide file tree
Showing 24 changed files with 522 additions and 379 deletions.
9 changes: 4 additions & 5 deletions .github/ISSUE_TEMPLATE/bug-report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,11 @@ body:
- type: textarea
id: logs
attributes:
label: Relevant log output
label: Log Files
description: >
Please copy and paste any relevant log(max 20 lines) output. This will
be automatically formatted into code, so no need for backticks. Or paste
gists, pastebins links here
render: Shell
Please Attach here any relevant log files.
placeholder: >
Please Attach here any relevant log files or log output.
- type: textarea
id: misc
attributes:
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## [1.7.1-alpha-rc01](https://github.com/dymensionxyz/roller/compare/v1.7.0-alpha-rc01...v1.7.1-alpha-rc01) (2024-09-18)


### Bug Fixes

* **da:** don't ask to override the existing da config ([#999](https://github.com/dymensionxyz/roller/issues/999)) ([eb7e31c](https://github.com/dymensionxyz/roller/commit/eb7e31cb8f1a019766f674e592c97f2aee71566d))
* display the relevant information based on node type ([8f82ffc](https://github.com/dymensionxyz/roller/commit/8f82ffc0db53bab38c186e29a9855e7828a40ed2))
* fix outputs that require node type ([4b218b8](https://github.com/dymensionxyz/roller/commit/4b218b858026c69558314c5d0395f5d762ea2ac0))
* **ui:** installation spinner shouldn't draw new lines ([62e25db](https://github.com/dymensionxyz/roller/commit/62e25dbe8b46981dec5ed50eaed7666663a4ad5c))
* **wasm:** add wasm vm type ([#1000](https://github.com/dymensionxyz/roller/issues/1000)) ([ce08f6d](https://github.com/dymensionxyz/roller/commit/ce08f6dc3f36e250fe01b8466c7261851d47bc8c))

## [1.7.0-alpha-rc01](https://github.com/dymensionxyz/roller/compare/v1.6.4-alpha-rc01...v1.7.0-alpha-rc01) (2024-09-18)


### Features

* **block-explorer:** add a command to tear down the block explorer setup ([#979](https://github.com/dymensionxyz/roller/issues/979)) ([4890bc7](https://github.com/dymensionxyz/roller/commit/4890bc7b1fb09070bb9abce362affb86fba3e7fd))


### Bug Fixes

* **block-explorer:** make the block-explorer creation more reliable ([#977](https://github.com/dymensionxyz/roller/issues/977)) ([fb69d9d](https://github.com/dymensionxyz/roller/commit/fb69d9d3fde392f13ae78ae58e39894f87b43e79))

## [1.6.4-alpha-rc01](https://github.com/dymensionxyz/roller/compare/v1.6.3-alpha-rc01...v1.6.4-alpha-rc01) (2024-09-18)


Expand Down
164 changes: 82 additions & 82 deletions cmd/binaries/install/install.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
package install

import (
"encoding/json"
"fmt"
"os/exec"
"strings"
"time"

"github.com/pterm/pterm"
"github.com/spf13/cobra"

"github.com/dymensionxyz/roller/cmd/consts"
"github.com/dymensionxyz/roller/utils/bash"
"github.com/dymensionxyz/roller/utils/dependencies"
"github.com/dymensionxyz/roller/utils/dependencies/types"
"github.com/dymensionxyz/roller/utils/rollapp"
)

func Cmd() *cobra.Command {
Expand All @@ -23,78 +13,88 @@ func Cmd() *cobra.Command {
Short: "Install necessary binaries for operating a RollApp node",
Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
// TODO: instead of relying on dymd binary, query the rpc for rollapp
envs := []string{"playground"}
env, _ := pterm.DefaultInteractiveSelect.
WithDefaultText("select the environment you want to initialize for").
WithOptions(envs).
Show()
hd := consts.Hubs[env]

var raID string
if len(args) != 0 {
raID = args[0]
} else {
raID, _ = pterm.DefaultInteractiveTextInput.WithDefaultText(
"provide RollApp ID you plan to run the nodes for",
).Show()
}

dymdBinaryOptions := types.Dependency{
Name: "dymension",
Repository: "https://github.com/artemijspavlovs/dymension",
Release: "v3.1.0-pg07",
Binaries: []types.BinaryPathPair{
{
Binary: "dymd",
BinaryDestination: consts.Executables.Dymension,
BuildCommand: exec.Command(
"make",
"build",
),
},
},
}
pterm.Info.Println("installing dependencies")
err := dependencies.InstallBinaryFromRelease(dymdBinaryOptions)
if err != nil {
pterm.Error.Println("failed to install dymd: ", err)
return
}

raID = strings.TrimSpace(raID)

getRaCmd := rollapp.GetRollappCmd(raID, hd)
var raResponse rollapp.ShowRollappResponse
out, err := bash.ExecCommandWithStdout(getRaCmd)
if err != nil {
pterm.Error.Println("failed to get rollapp: ", err)
return
}

err = json.Unmarshal(out.Bytes(), &raResponse)
if err != nil {
pterm.Error.Println("failed to unmarshal", err)
return
}

pterm.Info.Println("installing dependencies")
start := time.Now()
if raResponse.Rollapp.GenesisInfo.Bech32Prefix == "" {
pterm.Error.Println("no bech")
return
}
err = dependencies.InstallBinaries(
raResponse.Rollapp.GenesisInfo.Bech32Prefix,
false,
strings.ToLower(raResponse.Rollapp.VmType),
)
if err != nil {
pterm.Error.Println("failed to install binaries: ", err)
return
}
elapsed := time.Since(start)
fmt.Println("time elapsed: ", elapsed)
pterm.Info.Println("not implemented")
// home := cmd.Flag(utils.FlagNames.Home).Value.String()
//
// rollerData, err := tomlconfig.LoadRollerConfig(home)
// if err != nil {
// pterm.Error.Println("failed to load roller config file", err)
// return
// }
//
// // TODO: instead of relying on dymd binary, query the rpc for rollapp
// envs := []string{"playground"}
// env, _ := pterm.DefaultInteractiveSelect.
// WithDefaultText("select the environment you want to initialize for").
// WithOptions(envs).
// Show()
// hd := consts.Hubs[env]
//
// var raID string
// if len(args) != 0 {
// raID = args[0]
// } else {
// raID, _ = pterm.DefaultInteractiveTextInput.WithDefaultText(
// "provide RollApp ID you plan to run the nodes for",
// ).Show()
// }
//
// dymdBinaryOptions := types.Dependency{
// Name: "dymension",
// Repository: "https://github.com/artemijspavlovs/dymension",
// Release: "v3.1.0-pg07",
// Binaries: []types.BinaryPathPair{
// {
// Binary: "dymd",
// BinaryDestination: consts.Executables.Dymension,
// BuildCommand: exec.Command(
// "make",
// "build",
// ),
// },
// },
// }
// pterm.Info.Println("installing dependencies")
// err = dependencies.InstallBinaryFromRelease(dymdBinaryOptions)
// if err != nil {
// pterm.Error.Println("failed to install dymd: ", err)
// return
// }
//
// raID = strings.TrimSpace(raID)
//
// getRaCmd := rollapp.GetRollappCmd(raID, hd)
// var raResponse rollapp.ShowRollappResponse
// out, err := bash.ExecCommandWithStdout(getRaCmd)
// if err != nil {
// pterm.Error.Println("failed to get rollapp: ", err)
// return
// }
//
// err = json.Unmarshal(out.Bytes(), &raResponse)
// if err != nil {
// pterm.Error.Println("failed to unmarshal", err)
// return
// }
//
// pterm.Info.Println("installing dependencies")
// start := time.Now()
// if raResponse.Rollapp.GenesisInfo.Bech32Prefix == "" {
// pterm.Error.Println("no bech")
// return
// }
// err = dependencies.InstallBinaries(
// raResponse.Rollapp.GenesisInfo.Bech32Prefix,
// false,
// strings.ToLower(raResponse.Rollapp.VmType),
// rollerData,
// )
// if err != nil {
// pterm.Error.Println("failed to install binaries: ", err)
// return
// }
// elapsed := time.Since(start)
// fmt.Println("time elapsed: ", elapsed)
},
}

Expand Down
60 changes: 49 additions & 11 deletions cmd/block-explorer/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/dymensionxyz/roller/cmd/utils"
"github.com/dymensionxyz/roller/utils/blockexplorer"
"github.com/dymensionxyz/roller/utils/config/tomlconfig"
rollerfilesystemutils "github.com/dymensionxyz/roller/utils/filesystem"
"github.com/dymensionxyz/roller/utils/rollapp"
)

func Cmd() *cobra.Command {
Expand All @@ -23,43 +25,79 @@ func Cmd() *cobra.Command {
isFlagChanged := cmd.Flags().Changed("block-explorer-rpc-endpoint")
defaultBeRpcEndpoint, _ := cmd.Flags().GetString("block-explorer-rpc-endpoint")

hostAddress := "host.docker.internal"
if runtime.GOOS == "linux" {

Check failure on line 29 in cmd/block-explorer/run/run.go

View workflow job for this annotation

GitHub Actions / build

undefined: runtime

Check failure on line 29 in cmd/block-explorer/run/run.go

View workflow job for this annotation

GitHub Actions / lint

undefined: runtime) (typecheck)

Check failure on line 29 in cmd/block-explorer/run/run.go

View workflow job for this annotation

GitHub Actions / lint

undefined: runtime (typecheck)
hostAddress = "172.17.0.1" // Default Docker bridge network gateway
}
var raID string

var beRpcEndpoint string
if !isFlagChanged {
useDefaultEndpoint, _ := pterm.DefaultInteractiveConfirm.WithDefaultValue(false).
WithDefaultText(
fmt.Sprintf(
`'--block-explorer-rpc-endpoint' is not set,
would you like to continue with the default endpoint (%s)?'
press 'y' if you're running local node, press 'n' and provide the endpoint if you're running remote node`,
if you're running a rollapp locally, press 'y',
if you want to run block explorer for a rollapp on a different host, press 'n' and provide the endpoint and RollApp ID`,
defaultBeRpcEndpoint,
),
).
Show()
if useDefaultEndpoint {
beRpcEndpoint = defaultBeRpcEndpoint
beRpcEndpoint = fmt.Sprintf("http://%s:11100", hostAddress)

err := rollerfilesystemutils.UpdateHostsFile(
"127.0.0.1",
"host.docker.internal",
)
if err != nil {
pterm.Error.Println("failed to update hosts file", err)
return
}

rollerData, err := tomlconfig.LoadRollerConfig(home)
if err != nil {
pterm.Error.Println("failed to load roller config file", err)
return
}

raID = rollerData.RollappID
} else {
newBeRpcEndpoint, _ := pterm.DefaultInteractiveTextInput.Show()
newBeRpcEndpoint, _ := pterm.DefaultInteractiveTextInput.WithDefaultText(
"provide block explorer json rpc endpoint (running on port 11100 by default):",
).Show()
if newBeRpcEndpoint == "" {
pterm.Error.Println("invalid endpoint")
return
}

raIDInput, _ := pterm.DefaultInteractiveTextInput.WithDefaultText(
"provide a rollapp ID that you want to run the node for",
).Show()

_, err := rollapp.ValidateChainID(raIDInput)
if err != nil {
pterm.Error.Println("invalid rollapp ID", err)
}

raID = raIDInput

beRpcEndpoint = newBeRpcEndpoint
}
}

rollerData, err := tomlconfig.LoadRollerConfig(home)
if err != nil {
pterm.Error.Println("failed to load roller config file", err)
return
}

beChainConfigPath := filepath.Join(
home,
consts.ConfigDirName.BlockExplorer,
"config",
"chains.yaml",
)
beChainConfig := blockexplorer.GenerateChainsYAML(
rollerData.RollappID,
raID,
beRpcEndpoint,
)
err = blockexplorer.WriteChainsYAML(beChainConfigPath, beChainConfig)
err := blockexplorer.WriteChainsYAML(beChainConfigPath, beChainConfig)
if err != nil {
pterm.Error.Println("failed to generate block explorer config", err)
}
Expand Down
Loading

0 comments on commit b1132dc

Please sign in to comment.