Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: skip binary installation when commits match #1135

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/binaries/binaries.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package binaries
import (
"github.com/spf13/cobra"

"github.com/dymensionxyz/roller/cmd/binaries/install"
"github.com/dymensionxyz/roller/cmd/binaries/versions"
)

func Cmd() *cobra.Command {
Expand All @@ -12,7 +12,8 @@ func Cmd() *cobra.Command {
Short: "Commands to manage roller dependencies",
}

cmd.AddCommand(install.Cmd())
// cmd.AddCommand(install.Cmd())
cmd.AddCommand(versions.Cmd())

return cmd
}
46 changes: 46 additions & 0 deletions cmd/binaries/versions/versions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package versions

import (
"fmt"

"github.com/spf13/cobra"

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

func Cmd() *cobra.Command {
versionCmd := &cobra.Command{
Use: "versions",
Short: "Print all binary versions",
Run: func(cmd *cobra.Command, args []string) {
dymdVersion, err := dependencies.GetCurrentCommit(consts.Executables.Dymension)
if err != nil {
fmt.Println("failed to get dymd version:", err)
return
}
fmt.Println("dymd version:", dymdVersion)
celestiaVersion, err := dependencies.GetCurrentCommit(consts.Executables.Celestia)
if err != nil {
fmt.Println("failed to get celestia version:", err)
return
}
fmt.Println("celestia version:", celestiaVersion)

relayerVersion, err := dependencies.GetCurrentCommit(consts.Executables.Relayer)
if err != nil {
fmt.Println("failed to get relayer version:", err)
return
}
fmt.Println("relayer version:", relayerVersion)

eibcVersion, err := dependencies.GetCurrentCommit(consts.Executables.Eibc)
if err != nil {
fmt.Println("failed to get eibc version:", err)
return
}
fmt.Println("eibc version:", eibcVersion)
},
}
return versionCmd
}
1 change: 1 addition & 0 deletions cmd/da-light-client/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func Cmd() *cobra.Command {
dep := dependencies.DefaultCelestiaNodeDependency()
err = dependencies.InstallBinaryFromRepo(
dep, dep.DependencyName,
true,
)
if err != nil {
pterm.Error.Println("failed to install binary: ", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/eibc/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func Cmd() *cobra.Command {
} else {
deps := dependencies.DefaultEibcClientPrebuiltDependencies()
for _, v := range deps {
err := dependencies.InstallBinaryFromRelease(v)
err := dependencies.InstallBinaryFromRelease(v, true)
if err != nil {
pterm.Error.Printfln("failed to install binary: %s", err)
return
Expand Down
37 changes: 14 additions & 23 deletions cmd/relayer/setup/setup.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package setup

import (
"context"
"fmt"
"os"
"slices"
"strconv"
"strings"
"time"

firebase "firebase.google.com/go"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
"google.golang.org/api/option"

initconfig "github.com/dymensionxyz/roller/cmd/config/init"
"github.com/dymensionxyz/roller/cmd/consts"
Expand Down Expand Up @@ -107,55 +104,49 @@ func Cmd() *cobra.Command {
pterm.Error.Println("failed to fetch rollapp information from hub: ", err)
return
}

err = genesis.DownloadGenesis(home, raResp.Rollapp.Metadata.GenesisUrl)
if err != nil {
pterm.Error.Println("failed to download genesis file: ", err)
return
}

as, err := genesis.GetGenesisAppState(home)
if err != nil {
pterm.Error.Println("failed to get genesis app state: ", err)
return
}
ctx := context.Background()
conf := &firebase.Config{ProjectID: "drs-metadata"}
app, err := firebase.NewApp(ctx, conf, option.WithoutAuthentication())
if err != nil {
pterm.Error.Printfln("failed to initialize firebase app: %v", err)
return
}
drsVersion := strconv.Itoa(as.RollappParams.Params.DrsVersion)

client, err := app.Firestore(ctx)
drsVersion := strconv.Itoa(as.RollappParams.Params.DrsVersion)
drsInfo, err := firebaseutils.GetLatestDrsVersionCommit(drsVersion)
if err != nil {
pterm.Error.Printfln("failed to create firestore client: %v", err)
pterm.Error.Println("failed to retrieve latest commit: ", err)
return
}
defer client.Close()

// Fetch DRS version information using the nested collection path
// Path format: versions/{version}/revisions/{revision}
drsInfo, err := firebaseutils.GetLatestDrsVersionCommit(drsVersion)
if err != nil {
pterm.Error.Println("failed to retrieve latest DRS version: ", err)
return
var raCommit string
switch strings.ToLower(raResp.Rollapp.VmType) {
case "evm":
raCommit = drsInfo.EvmCommit
case "wasm":
raCommit = drsInfo.WasmCommit
}

rbi := dependencies.NewRollappBinaryInfo(
raResp.Rollapp.GenesisInfo.Bech32Prefix,
drsInfo.Commit,
raCommit,
strings.ToLower(raResp.Rollapp.VmType),
)

raDep := dependencies.DefaultRollappDependency(rbi)
err = dependencies.InstallBinaryFromRepo(raDep, raDep.DependencyName)
err = dependencies.InstallBinaryFromRepo(raDep, raDep.DependencyName, false)
if err != nil {
pterm.Error.Printfln("failed to install binary: %s", err)
return
}

rlyDep := dependencies.DefaultRelayerPrebuiltDependencies()
err = dependencies.InstallBinaryFromRelease(rlyDep["rly"])
err = dependencies.InstallBinaryFromRelease(rlyDep["rly"], true)
if err != nil {
pterm.Error.Printfln("failed to install binary: %s", err)
return
Expand Down
26 changes: 17 additions & 9 deletions cmd/rollapp/drs/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ func Cmd() *cobra.Command {
return
}

if drsInfo.Commit[:6] == cv {
pterm.Info.Println("You are already using the latest version of DRS")
return
}

// if doesn't match, take latest as the reference
// download the latest, build into ~/.roller/tmp
raResp, err := rollapputils.GetMetadataFromChain(
rollerData.RollappID,
rollerData.HubData,
Expand All @@ -74,6 +67,21 @@ func Cmd() *cobra.Command {
return
}

var commit string
switch strings.ToLower(raResp.Rollapp.VmType) {
case "evm":
commit = drsInfo.EvmCommit
case "wasm":
commit = drsInfo.WasmCommit
}

if commit == cv {
pterm.Info.Println("You are already using the latest version of DRS")
return
}

// if doesn't match, take latest as the reference
// download the latest, build into ~/.roller/tmp
raNewBinDir, err := os.MkdirTemp(os.TempDir(), "rollapp-drs-update")
if err != nil {
pterm.Error.Println(
Expand All @@ -86,7 +94,7 @@ func Cmd() *cobra.Command {

rbi := dependencies.NewRollappBinaryInfo(
raResp.Rollapp.GenesisInfo.Bech32Prefix,
drsInfo.Commit,
commit,
strings.ToLower(raResp.Rollapp.VmType),
)

Expand All @@ -101,7 +109,7 @@ func Cmd() *cobra.Command {

pterm.Info.Println("starting update")
raDep.Binaries[0].BinaryDestination = tmpBinLocation
err = dependencies.InstallBinaryFromRepo(raDep, raDep.DependencyName)
err = dependencies.InstallBinaryFromRepo(raDep, raDep.DependencyName, true)
if err != nil {
pterm.Error.Println("failed to install rollapp binary: ", err)
return
Expand Down
39 changes: 14 additions & 25 deletions cmd/rollapp/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package initrollapp

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

Expand All @@ -16,7 +15,6 @@ import (
"github.com/dymensionxyz/roller/utils/config/scripts"
"github.com/dymensionxyz/roller/utils/config/tomlconfig"
"github.com/dymensionxyz/roller/utils/dependencies"
"github.com/dymensionxyz/roller/utils/dependencies/types"
"github.com/dymensionxyz/roller/utils/filesystem"
"github.com/dymensionxyz/roller/utils/keys"
"github.com/dymensionxyz/roller/utils/rollapp"
Expand Down Expand Up @@ -66,6 +64,13 @@ func Cmd() *cobra.Command {
}

if isRootExist {
dymdDep := dependencies.DefaultDymdDependency()
err = dependencies.InstallBinaryFromRelease(dymdDep, true)
if err != nil {
pterm.Error.Println("failed to install dymd: ", err)
return
}

shouldContinue, err := sequencer.CheckExistingSequencer(home)
if err != nil {
pterm.Error.Printf(
Expand Down Expand Up @@ -130,23 +135,9 @@ func Cmd() *cobra.Command {
// TODO: move to consts
// TODO(v2): move to roller config
if !shouldUseMockBackend && env != "custom" {
dymdBinaryOptions := types.Dependency{
DependencyName: "dymension",
RepositoryOwner: "dymensionxyz",
RepositoryName: "dymension",
RepositoryUrl: "https://github.com/artemijspavlovs/dymension",
Release: "v3.1.0-pg10",
Binaries: []types.BinaryPathPair{
{
Binary: "dymd",
BinaryDestination: consts.Executables.Dymension,
BuildCommand: exec.Command("make", "build"),
},
},
PersistFiles: []types.PersistFile{},
}
dymdBinaryOptions := dependencies.DefaultDymdDependency()
pterm.Info.Println("installing dependencies")
err = dependencies.InstallBinaryFromRelease(dymdBinaryOptions)
err = dependencies.InstallBinaryFromRelease(dymdBinaryOptions, true)
if err != nil {
pterm.Error.Println("failed to install dymd: ", err)
return
Expand Down Expand Up @@ -202,12 +193,10 @@ func Cmd() *cobra.Command {
},
}

if !shouldSkipBinaryInstallation {
_, _, err = dependencies.InstallBinaries(true, raRespMock)
if err != nil {
pterm.Error.Println("failed to install binaries: ", err)
return
}
_, _, err = dependencies.InstallBinaries(true, raRespMock)
if err != nil {
pterm.Error.Println("failed to install binaries: ", err)
return
}

err := runInit(
Expand All @@ -227,7 +216,7 @@ func Cmd() *cobra.Command {

if shouldSkipBinaryInstallation {
dymdDep := dependencies.DefaultDymdDependency()
err = dependencies.InstallBinaryFromRelease(dymdDep)
err = dependencies.InstallBinaryFromRelease(dymdDep, true)
if err != nil {
pterm.Error.Println("failed to install dymd: ", err)
return
Expand Down
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/spf13/cobra"

"github.com/dymensionxyz/roller/cmd/binaries"
blockexplorer "github.com/dymensionxyz/roller/cmd/block-explorer"
initconfig "github.com/dymensionxyz/roller/cmd/config/init"
da_light_client "github.com/dymensionxyz/roller/cmd/da-light-client"
Expand Down Expand Up @@ -40,6 +41,7 @@ func init() {
rootCmd.AddCommand(eibc.Cmd())
rootCmd.AddCommand(blockexplorer.Cmd())
rootCmd.AddCommand(version.Cmd())
rootCmd.AddCommand(binaries.Cmd())

initconfig.AddGlobalFlags(rootCmd)
}
25 changes: 23 additions & 2 deletions utils/dependencies/celestia.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import (
)

const (
DefaultCelestiaNodeVersion = "v0.20.2-mocha"
DefaultCelestiaAppVersion = "v2.3.1"
// 2dc9cce7b5dffc14fd4fe156d2aa9869318e0f68= "v0.20.2-mocha"
DefaultCelestiaNodeVersion = "2dc9cce7b5dffc14fd4fe156d2aa9869318e0f68"

// 5d6c695= "v3.0.0-mocha"
DefaultCelestiaAppVersion = "v3.0.0-mocha"
)

func DefaultCelestiaNodeDependency() types.Dependency {
Expand Down Expand Up @@ -39,3 +42,21 @@ func DefaultCelestiaNodeDependency() types.Dependency {
},
}
}

func DefaultCelestiaAppPrebuiltDependency() types.Dependency {
return types.Dependency{
DependencyName: "celestia-app",
RepositoryUrl: "https://github.com/celestiaorg/celestia-app",
Release: DefaultCelestiaAppVersion,
Binaries: []types.BinaryPathPair{
{
Binary: "celestia-appd",
BinaryDestination: consts.Executables.CelestiaApp,
BuildCommand: exec.Command(
"make",
"build",
),
},
},
}
}
Loading
Loading