From 05130c51837d239fe73db523dac2f3da4bc89e45 Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Sun, 24 Nov 2024 08:18:44 -0300 Subject: [PATCH] feat: spaceship faucet (#144) * faucet start * fix faucet. version * extract tarball * ssh faucet * faucet scripts * fix faucet target * fix faucet binary url * fix faucet start command * fix faucet. script * fix lgos * fix wrong faucet binary path * fix faucet script * add missing faucet flags * bump faucet version --- spaceship/cmd/chain.go | 336 ++++++++++++++++++ spaceship/cmd/cmd.go | 149 ++++++-- spaceship/cmd/debug/main.go | 59 ++- spaceship/cmd/faucet.go | 137 +++++++ spaceship/cmd/log.go | 78 ++++ spaceship/cmd/ssh.go | 274 +------------- spaceship/go.mod | 61 ++-- spaceship/go.sum | 132 ++++--- spaceship/main.go | 28 +- spaceship/pkg/faucet/faucet.go | 104 ++++++ spaceship/pkg/ssh/chain.go | 56 +++ spaceship/pkg/ssh/faucet.go | 49 +++ spaceship/pkg/ssh/file.go | 33 ++ spaceship/pkg/ssh/info.go | 49 +++ spaceship/pkg/ssh/log.go | 56 +-- spaceship/pkg/ssh/ssh.go | 222 +++--------- spaceship/pkg/ssh/upload.go | 31 +- spaceship/pkg/tarball/tarball.go | 13 +- .../templates/script/files/faucet.sh.plush | 77 ++++ spaceship/templates/script/files/run.sh.plush | 21 +- spaceship/templates/script/script.go | 17 +- 21 files changed, 1348 insertions(+), 634 deletions(-) create mode 100644 spaceship/cmd/chain.go create mode 100644 spaceship/cmd/faucet.go create mode 100644 spaceship/cmd/log.go create mode 100644 spaceship/pkg/faucet/faucet.go create mode 100644 spaceship/pkg/ssh/chain.go create mode 100644 spaceship/pkg/ssh/faucet.go create mode 100644 spaceship/pkg/ssh/file.go create mode 100644 spaceship/pkg/ssh/info.go create mode 100644 spaceship/templates/script/files/faucet.sh.plush diff --git a/spaceship/cmd/chain.go b/spaceship/cmd/chain.go new file mode 100644 index 00000000..7bf34d8a --- /dev/null +++ b/spaceship/cmd/chain.go @@ -0,0 +1,336 @@ +package cmd + +import ( + "context" + "fmt" + "os" + "path/filepath" + "strings" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/gookit/color" + ignitecmd "github.com/ignite/cli/v28/ignite/cmd" + config "github.com/ignite/cli/v28/ignite/config/chain" + "github.com/ignite/cli/v28/ignite/pkg/cliui" + "github.com/ignite/cli/v28/ignite/pkg/errors" + "github.com/ignite/cli/v28/ignite/services/plugin" + "github.com/schollz/progressbar/v3" + + "github.com/ignite/apps/spaceship/pkg/tarball" + "github.com/ignite/apps/spaceship/templates/script" +) + +// ExecuteSSHStatus executes the ssh status subcommand. +func ExecuteSSHStatus(ctx context.Context, cmd *plugin.ExecutedCommand, chain *plugin.ChainInfo) error { + session := cliui.New(cliui.StartSpinnerWithText(statusConnecting)) + defer session.End() + + c, err := executeSSH(cmd, chain) + if err != nil { + return err + } + defer c.Close() + + if !c.HasRunnerScript(ctx) { + return ErrServerNotInitialized + } + + chainStatus, err := c.Status(ctx) + if err != nil { + return err + } + _ = session.Println(chainStatus) + + flags := plugin.Flags(cmd.Flags) + faucet, _ := flags.GetBool(flagFaucet) + if faucet { + if !c.HasFaucetScript(ctx) { + return ErrServerNotInitialized + } + + stopStatus, err := c.FaucetStatus(ctx) + if err != nil { + return err + } + _ = session.Println(stopStatus) + } + return nil +} + +// ExecuteSSHRestart executes the ssh restart subcommand. +func ExecuteSSHRestart(ctx context.Context, cmd *plugin.ExecutedCommand, chain *plugin.ChainInfo) error { + session := cliui.New(cliui.StartSpinnerWithText(statusConnecting)) + defer session.End() + + c, err := executeSSH(cmd, chain) + if err != nil { + return err + } + defer c.Close() + + if !c.HasRunnerScript(ctx) { + return ErrServerNotInitialized + } + + chainRestart, err := c.Restart(ctx) + if err != nil { + return err + } + _ = session.Println(chainRestart) + + flags := plugin.Flags(cmd.Flags) + faucet, _ := flags.GetBool(flagFaucet) + if faucet { + if !c.HasFaucetScript(ctx) { + return ErrServerNotInitialized + } + + faucetPort, err := faucetPort(cmd.Flags) + if err != nil { + return err + } + + faucetRestart, err := c.FaucetRestart(ctx, faucetPort) + if err != nil { + return err + } + _ = session.Println(faucetRestart) + } + return nil +} + +// ExecuteSSHSStop executes the ssh stop subcommand. +func ExecuteSSHSStop(ctx context.Context, cmd *plugin.ExecutedCommand, chain *plugin.ChainInfo) error { + session := cliui.New(cliui.StartSpinnerWithText(statusConnecting)) + defer session.End() + + c, err := executeSSH(cmd, chain) + if err != nil { + return err + } + defer c.Close() + + if !c.HasRunnerScript(ctx) { + return ErrServerNotInitialized + } + + chainStop, err := c.Stop(ctx) + if err != nil { + return err + } + _ = session.Println(chainStop) + + flags := plugin.Flags(cmd.Flags) + faucet, _ := flags.GetBool(flagFaucet) + if faucet { + if !c.HasFaucetScript(ctx) { + return ErrServerNotInitialized + } + + faucetStop, err := c.FaucetStop(ctx) + if err != nil { + return err + } + _ = session.Println(faucetStop) + } + return nil +} + +// ExecuteSSHDeploy executes the ssh deploy subcommand. +func ExecuteSSHDeploy(ctx context.Context, cmd *plugin.ExecutedCommand, chain *plugin.ChainInfo) error { + session := cliui.New(cliui.StartSpinnerWithText(statusConnecting)) + defer session.End() + + flags := plugin.Flags(cmd.Flags) + + localDir, err := os.MkdirTemp(os.TempDir(), "spaceship") + if err != nil { + return err + } + defer func() { + _ = os.RemoveAll(localDir) + }() + + var ( + initChain, _ = flags.GetBool(flagInitChain) + faucet, _ = flags.GetBool(flagFaucet) + + localChainHome = filepath.Join(localDir, "home") + localBinOutput = filepath.Join(localDir, "bin") + ) + + c, err := executeSSH(cmd, chain) + if err != nil { + return err + } + defer c.Close() + + _ = session.Println(color.Yellow.Sprint("Building chain binary using Ignite:")) + + target, err := c.Target(ctx) + if err != nil { + return err + } + targetName := strings.ReplaceAll(target, ":", "_") + + // We are using the ignite chain build command to build the app. + igniteChainBuildCmd := ignitecmd.NewChainBuild() + igniteChainBuildCmd.SetArgs([]string{ + "-p", + chain.AppPath, + "-o", + localBinOutput, + "--release", + "--release.targets", + target, + "--verbose", + }) + if err := igniteChainBuildCmd.ExecuteContext(ctx); err != nil { + return err + } + + // Define a progress callback function. + bar := progressbar.DefaultBytes(1, "uploading") + progressCallback := func(bytesUploaded int64, totalBytes int64) error { + if bar.GetMax64() != totalBytes { + bar.ChangeMax64(totalBytes) + bar.Reset() + } + if err := bar.Set64(bytesUploaded); err != nil { + return err + } + if bytesUploaded == totalBytes { + if err := bar.Finish(); err != nil { + return err + } + } + return nil + } + + // Extract and upload the built binary. + var ( + binName = fmt.Sprintf("%sd", chain.ChainId) + localChainTarball = fmt.Sprintf( + "%s/%s_%s.tar.gz", + localBinOutput, + chain.ChainId, + targetName, + ) + ) + extracted, err := tarball.ExtractFile(ctx, localChainTarball, localBinOutput, binName) + if err != nil { + return err + } + if len(extracted) == 0 { + return errors.Errorf("zero files extracted from the tarball %s", localChainTarball) + } + + bar.Describe("Uploading chain binary") + chainBinPath, err := c.UploadBinary(extracted[0], progressCallback) + if err != nil { + return err + } + _ = session.Println() + _ = session.Println(color.Yellow.Sprintf("Chain binary uploaded to '%s'\n", chainBinPath)) + + bar.Describe("Uploading faucet binary") + faucetBin, err := c.UploadFaucetBinary(ctx, targetName, progressCallback) + if err != nil { + return err + } + _ = session.Println() + + home := c.Home() + if initChain || !c.HasGenesis(ctx) { + _ = session.Println(color.Yellow.Sprint("Initializing the chain home folder using Ignite:")) + + igniteChainInitCmd := ignitecmd.NewChainInit() + igniteChainInitCmd.SetArgs([]string{"-p", chain.AppPath, "--home", localChainHome}) + if err := igniteChainInitCmd.ExecuteContext(ctx); err != nil { + return err + } + + bar.Describe("Uploading chain home folder") + homeFiles, err := c.UploadHome(ctx, localChainHome, progressCallback) + if err != nil { + return err + } + _ = session.Println() + _ = session.Println(color.Yellow.Sprintf("Uploaded files: \n- %s\n", strings.Join(homeFiles, "\n- "))) + } + _ = session.Println() + + chainCfg, err := chainConfig(chain) + if err != nil { + return err + } + + denom := "token" + if len(chainCfg.Faucet.Coins) > 0 { + coin, err := sdk.ParseCoinNormalized(chainCfg.Faucet.Coins[0]) + if err != nil { + return err + } + denom = coin.Denom + } + + // Create the chain and faucet runner scripts. + scriptsDir := filepath.Join(localDir, "scripts") + if err := script.NewRunScripts( + c.Workspace(), + c.Log(), + home, + c.Bin(), + chainBinPath, + faucetBin, + *chainCfg.Faucet.Name, + denom, + scriptsDir, + ); err != nil { + return err + } + + bar.Describe("Uploading runner script") + if err := c.UploadScripts(ctx, scriptsDir, progressCallback); err != nil { + return err + } + + _ = session.Println(color.Yellow.Sprintf("Running chain %s", chain.ChainId)) + start, err := c.Start(ctx) + if err != nil { + return err + } + _ = session.Println("") + _ = session.Println(color.Blue.Sprint(start)) + + if faucet { + _ = session.Println(color.Yellow.Sprintf("Running chain %s faucet", chain.ChainId)) + faucetPort, err := faucetPort(cmd.Flags) + if err != nil { + return err + } + faucetStart, err := c.FaucetStart(ctx, faucetPort) + if err != nil { + return err + } + _ = session.Println("") + return session.Println(color.Blue.Sprint(faucetStart)) + } + return nil +} + +// chainConfig retrieves and parses the configuration for the given chain. +// It first attempts to load the config from chain's specified path, if unsuccessful, +// it attempts to locate and load the default config file. +func chainConfig(chain *plugin.ChainInfo) (*config.Config, error) { + cfg, err := config.ParseFile(chain.ConfigPath) + if err == nil { + return cfg, nil + } + + cfgPath, err := config.LocateDefault(chain.AppPath) + if err != nil { + return nil, err + } + return config.ParseFile(cfgPath) +} diff --git a/spaceship/cmd/cmd.go b/spaceship/cmd/cmd.go index 17d835b8..0189f90c 100644 --- a/spaceship/cmd/cmd.go +++ b/spaceship/cmd/cmd.go @@ -47,8 +47,8 @@ func GetCommands() []*plugin.Command { Short: "Deploy a chain remote through SSH using ignite build system", Commands: []*plugin.Command{ { - Use: "deploy", - Short: "deploy your chain", + Use: "deploy [host]", + Short: "deploy the chain", Flags: append(defaultFlags, &plugin.Flag{ Name: flagInitChain, @@ -56,40 +56,143 @@ func GetCommands() []*plugin.Command { Usage: "run init chain and create the home folder", Type: plugin.FlagTypeBool, }, + &plugin.Flag{ + Name: flagFaucet, + Shorthand: "f", + Usage: "run the chain faucet", + Type: plugin.FlagTypeBool, + DefaultValue: "false", + }, + &plugin.Flag{ + Name: flagFaucetPort, + Usage: "chain faucet port", + Type: plugin.FlagTypeUint64, + }, ), }, { - Use: "log", - Short: "get chain logs if its running", - Flags: append(defaultFlags, - &plugin.Flag{ - Name: flagLines, - Shorthand: "l", - Usage: "number of lines of chain logs", - Type: plugin.FlagTypeInt, - DefaultValue: "100", + Use: "log [host]", + Short: "get remote logs", + Commands: []*plugin.Command{ + { + Use: "chain", + Short: "get chain logs if its running", + Flags: append(defaultFlags, + &plugin.Flag{ + Name: flagLines, + Shorthand: "l", + Usage: "number of lines of chain logs", + Type: plugin.FlagTypeInt, + DefaultValue: "100", + }, + &plugin.Flag{ + Name: flagRealTime, + Usage: "show the logs in the real time", + Type: plugin.FlagTypeBool, + }, + ), + }, + { + Use: "faucet", + Short: "get faucet logs if its running", + Flags: append(defaultFlags, + &plugin.Flag{ + Name: flagLines, + Shorthand: "l", + Usage: "number of lines of chain logs", + Type: plugin.FlagTypeInt, + DefaultValue: "100", + }, + &plugin.Flag{ + Name: flagRealTime, + Usage: "show the logs in the real time", + Type: plugin.FlagTypeBool, + }, + ), }, + }, + }, + { + Use: "status [host]", + Short: "get chain status if its running", + Flags: append(defaultFlags, &plugin.Flag{ - Name: flagRealTime, - Usage: "show the logs in the real time", - Type: plugin.FlagTypeBool, + Name: flagFaucet, + Shorthand: "f", + Usage: "show faucet status", + Type: plugin.FlagTypeBool, + DefaultValue: "false", }, ), }, { - Use: "status", - Short: "get chain status if its running", - Flags: defaultFlags, + Use: "restart [host]", + Short: "restart the chain", + Flags: append(defaultFlags, + &plugin.Flag{ + Name: flagFaucet, + Shorthand: "f", + Usage: "run the chain faucet", + Type: plugin.FlagTypeBool, + DefaultValue: "false", + }, + &plugin.Flag{ + Name: flagFaucetPort, + Usage: "chain faucet port", + Type: plugin.FlagTypeUint64, + }, + ), }, { - Use: "restart", - Short: "restart your chain", - Flags: defaultFlags, + Use: "stop [host]", + Short: "stop the chain", + Flags: append(defaultFlags, + &plugin.Flag{ + Name: flagFaucet, + Shorthand: "f", + Usage: "stop the chain faucet", + Type: plugin.FlagTypeBool, + DefaultValue: "false", + }, + ), }, { - Use: "stop", - Short: "stop your chain", - Flags: defaultFlags, + Use: "faucet", + Short: "faucet commands", + Commands: []*plugin.Command{ + { + Use: "status [host]", + Short: "get faucet status if its running", + Flags: defaultFlags, + }, + { + Use: "start [host]", + Short: "start the faucet", + Flags: append(defaultFlags, + &plugin.Flag{ + Name: flagFaucetPort, + Usage: "chain faucet port", + Type: plugin.FlagTypeUint64, + }, + ), + }, + { + Use: "restart [host]", + Short: "restart the faucet", + Flags: append(defaultFlags, + &plugin.Flag{ + Name: flagFaucetPort, + Usage: "chain faucet port", + Type: plugin.FlagTypeUint64, + }, + ), + }, + { + Use: "stop", + Short: "stop the faucet", + Flags: defaultFlags, + }, + }, }, }, }, diff --git a/spaceship/cmd/debug/main.go b/spaceship/cmd/debug/main.go index 1326640b..4fd7c4f6 100644 --- a/spaceship/cmd/debug/main.go +++ b/spaceship/cmd/debug/main.go @@ -21,8 +21,9 @@ func main() { args = os.Args ctx = context.Background() chainInfo = &plugin.ChainInfo{ - AppPath: filepath.Join(home, "Desktop/go/src/github.com/ignite/mars"), - ChainId: "mars", + AppPath: filepath.Join(home, "Desktop/go/src/github.com/ignite/mars"), + ConfigPath: filepath.Join(home, "Desktop/go/src/github.com/ignite/mars/config.yml"), + ChainId: "mars", } c = &plugin.ExecutedCommand{ Use: args[1], @@ -57,7 +58,15 @@ func main() { Usage: "run init chain and create the home folder", Type: plugin.FlagTypeBool, Value: "true", - }) + }, + &plugin.Flag{ + Name: "faucet", + Shorthand: "f", + Usage: "create a chain faucet", + Type: plugin.FlagTypeBool, + DefaultValue: "true", + }, + ) if err := cmd.ExecuteSSHDeploy(ctx, c, chainInfo); err != nil { fmt.Fprintln(os.Stderr, err) return @@ -69,8 +78,18 @@ func main() { Type: plugin.FlagTypeBool, Value: "true", }) - if err := cmd.ExecuteSSHLog(ctx, c, chainInfo); err != nil { - fmt.Fprintln(os.Stderr, err) + switch args[2] { + case "chain": + if err := cmd.ExecuteChainSSHLog(ctx, c, chainInfo); err != nil { + fmt.Fprintln(os.Stderr, err) + return + } + case "faucet": + if err := cmd.ExecuteFaucetSSHLog(ctx, c, chainInfo); err != nil { + fmt.Fprintln(os.Stderr, err) + return + } + fmt.Fprintf(os.Stderr, "unknown log command: %s", args[2]) return } case "status": @@ -88,8 +107,32 @@ func main() { fmt.Fprintln(os.Stderr, err) return } - default: - fmt.Fprintf(os.Stderr, "unknown command: %s", args[1]) - return + case "faucet": + switch args[2] { + case "status": + if err := cmd.ExecuteSSHFaucetStatus(ctx, c, chainInfo); err != nil { + fmt.Fprintln(os.Stderr, err) + return + } + case "start": + if err := cmd.ExecuteSSHFaucetStart(ctx, c, chainInfo); err != nil { + fmt.Fprintln(os.Stderr, err) + return + } + case "restart": + if err := cmd.ExecuteSSHFaucetRestart(ctx, c, chainInfo); err != nil { + fmt.Fprintln(os.Stderr, err) + return + } + case "stop": + if err := cmd.ExecuteSSHSFaucetStop(ctx, c, chainInfo); err != nil { + fmt.Fprintln(os.Stderr, err) + return + } + + default: + fmt.Fprintf(os.Stderr, "unknown faucet command: %s", args[2]) + return + } } } diff --git a/spaceship/cmd/faucet.go b/spaceship/cmd/faucet.go new file mode 100644 index 00000000..a63a4b13 --- /dev/null +++ b/spaceship/cmd/faucet.go @@ -0,0 +1,137 @@ +package cmd + +import ( + "context" + + "github.com/ignite/cli/v28/ignite/pkg/availableport" + "github.com/ignite/cli/v28/ignite/pkg/cliui" + "github.com/ignite/cli/v28/ignite/pkg/errors" + "github.com/ignite/cli/v28/ignite/services/plugin" +) + +func faucetPort(f []*plugin.Flag) (uint64, error) { + flags := plugin.Flags(f) + port, err := flags.GetUint64(flagFaucetPort) + if err != nil { + return 0, err + } + if port == 0 { + return availablePort() + } + return port, nil +} + +func availablePort() (uint64, error) { + ports, err := availableport.Find( + 1, + availableport.WithMinPort(8000), + availableport.WithMaxPort(9000), + ) + if err != nil { + return 0, err + } + if len(ports) == 0 { + return 0, errors.New("no available ports") + } + return uint64(ports[0]), nil +} + +// ExecuteSSHFaucetStatus executes the ssh faucet status subcommand. +func ExecuteSSHFaucetStatus(ctx context.Context, cmd *plugin.ExecutedCommand, chain *plugin.ChainInfo) error { + session := cliui.New(cliui.StartSpinnerWithText(statusConnecting)) + defer session.End() + + c, err := executeSSH(cmd, chain) + if err != nil { + return err + } + defer c.Close() + + if !c.HasFaucetScript(ctx) { + return ErrServerNotInitialized + } + + stopStatus, err := c.FaucetStatus(ctx) + if err != nil { + return err + } + + return session.Println(stopStatus) +} + +// ExecuteSSHFaucetStart executes the ssh faucet start subcommand. +func ExecuteSSHFaucetStart(ctx context.Context, cmd *plugin.ExecutedCommand, chain *plugin.ChainInfo) error { + session := cliui.New(cliui.StartSpinnerWithText(statusConnecting)) + defer session.End() + + c, err := executeSSH(cmd, chain) + if err != nil { + return err + } + defer c.Close() + + if !c.HasFaucetScript(ctx) { + return ErrServerNotInitialized + } + + faucetPort, err := faucetPort(cmd.Flags) + if err != nil { + return err + } + faucetRestart, err := c.FaucetStart(ctx, faucetPort) + if err != nil { + return err + } + + return session.Println(faucetRestart) +} + +// ExecuteSSHFaucetRestart executes the ssh faucet restart subcommand. +func ExecuteSSHFaucetRestart(ctx context.Context, cmd *plugin.ExecutedCommand, chain *plugin.ChainInfo) error { + session := cliui.New(cliui.StartSpinnerWithText(statusConnecting)) + defer session.End() + + c, err := executeSSH(cmd, chain) + if err != nil { + return err + } + defer c.Close() + + if !c.HasFaucetScript(ctx) { + return ErrServerNotInitialized + } + + faucetPort, err := faucetPort(cmd.Flags) + if err != nil { + return err + } + faucetRestart, err := c.FaucetRestart(ctx, faucetPort) + if err != nil { + return err + } + + return session.Println(faucetRestart) +} + +// ExecuteSSHSFaucetStop executes the ssh faucet stop subcommand. +func ExecuteSSHSFaucetStop(ctx context.Context, cmd *plugin.ExecutedCommand, chain *plugin.ChainInfo) error { + session := cliui.New(cliui.StartSpinnerWithText(statusConnecting)) + defer session.End() + + c, err := executeSSH(cmd, chain) + if err != nil { + return err + } + defer c.Close() + + if !c.HasFaucetScript(ctx) { + return ErrServerNotInitialized + } + + faucetStop, err := c.FaucetStop(ctx) + if err != nil { + return err + } + + return session.Println(faucetStop) +} diff --git a/spaceship/cmd/log.go b/spaceship/cmd/log.go new file mode 100644 index 00000000..6a5f33bd --- /dev/null +++ b/spaceship/cmd/log.go @@ -0,0 +1,78 @@ +package cmd + +import ( + "context" + + "github.com/ignite/cli/v28/ignite/pkg/cliui" + "github.com/ignite/cli/v28/ignite/pkg/errors" + "github.com/ignite/cli/v28/ignite/services/plugin" + "golang.org/x/sync/errgroup" + + "github.com/ignite/apps/spaceship/pkg/ssh" +) + +func ExecuteChainSSHLog(ctx context.Context, cmd *plugin.ExecutedCommand, chain *plugin.ChainInfo) error { + return ExecuteSSHLog(ctx, ssh.LogChain, cmd, chain) +} + +func ExecuteFaucetSSHLog(ctx context.Context, cmd *plugin.ExecutedCommand, chain *plugin.ChainInfo) error { + return ExecuteSSHLog(ctx, ssh.LogFaucet, cmd, chain) +} + +// ExecuteSSHLog executes the ssh log subcommand. +func ExecuteSSHLog(ctx context.Context, logType ssh.LogType, cmd *plugin.ExecutedCommand, chain *plugin.ChainInfo) error { + session := cliui.New(cliui.StartSpinnerWithText(statusConnecting)) + defer session.End() + + var ( + flags = plugin.Flags(cmd.Flags) + lines, _ = flags.GetInt(flagLines) + realTime, _ = flags.GetBool(flagRealTime) + ) + + c, err := executeSSH(cmd, chain) + if err != nil { + return err + } + defer c.Close() + + if !c.HasRunnerScript(ctx) { + return ErrServerNotInitialized + } + + logs, err := c.LatestLog(logType, lines) + if err != nil { + return err + } + _ = session.Println(logs) + + if realTime { + // Create a buffered channel to receive log lines. + logChannel := make(chan string, 100) + g, ctx := errgroup.WithContext(ctx) + + // Start the FollowLog method in a goroutine using errgroup + g.Go(func() error { + return c.FollowLog(ctx, logType, logChannel) + }) + + // Start a goroutine to consume log lines + g.Go(func() error { + for { + select { + case line := <-logChannel: + _ = session.Print(line) + case <-ctx.Done(): + return ctx.Err() + } + } + }) + + // Wait for all goroutines to complete + if err := g.Wait(); err != nil && !errors.Is(err, context.Canceled) { + return err + } + } + + return nil +} diff --git a/spaceship/cmd/ssh.go b/spaceship/cmd/ssh.go index a5418062..11b7ca6c 100644 --- a/spaceship/cmd/ssh.go +++ b/spaceship/cmd/ssh.go @@ -1,23 +1,10 @@ package cmd import ( - "context" - "fmt" - "os" - "path/filepath" - "strings" - - "github.com/gookit/color" - ignitecmd "github.com/ignite/cli/v28/ignite/cmd" - "github.com/ignite/cli/v28/ignite/pkg/cliui" "github.com/ignite/cli/v28/ignite/pkg/errors" "github.com/ignite/cli/v28/ignite/services/plugin" - "github.com/schollz/progressbar/v3" - "golang.org/x/sync/errgroup" "github.com/ignite/apps/spaceship/pkg/ssh" - "github.com/ignite/apps/spaceship/pkg/tarball" - "github.com/ignite/apps/spaceship/templates/script" ) var ErrServerNotInitialized = errors.New("server not initialized") @@ -30,6 +17,8 @@ const ( flagRawKey = "raw-key" flagKeyPassword = "key-password" flagInitChain = "init-chain" + flagFaucet = "faucet" + flagFaucetPort = "faucet-port" flagLines = "lines" flagRealTime = "real-time" @@ -71,262 +60,3 @@ func executeSSH(cmd *plugin.ExecutedCommand, chain *plugin.ChainInfo) (*ssh.SSH, return c, c.Connect() } - -// ExecuteSSHStatus executes the ssh status subcommand. -func ExecuteSSHStatus(ctx context.Context, cmd *plugin.ExecutedCommand, chain *plugin.ChainInfo) error { - session := cliui.New(cliui.StartSpinnerWithText(statusConnecting)) - defer session.End() - - c, err := executeSSH(cmd, chain) - if err != nil { - return err - } - defer c.Close() - - if !c.HasRunnerScript(ctx) { - return ErrServerNotInitialized - } - - status, err := c.Status(ctx) - if err != nil { - return err - } - - return session.Println(status) -} - -// ExecuteSSHSStop executes the ssh stop subcommand. -func ExecuteSSHSStop(ctx context.Context, cmd *plugin.ExecutedCommand, chain *plugin.ChainInfo) error { - session := cliui.New(cliui.StartSpinnerWithText(statusConnecting)) - defer session.End() - - c, err := executeSSH(cmd, chain) - if err != nil { - return err - } - defer c.Close() - - if !c.HasRunnerScript(ctx) { - return ErrServerNotInitialized - } - - stop, err := c.Stop(ctx) - if err != nil { - return err - } - - return session.Println(stop) -} - -// ExecuteSSHRestart executes the ssh restart subcommand. -func ExecuteSSHRestart(ctx context.Context, cmd *plugin.ExecutedCommand, chain *plugin.ChainInfo) error { - session := cliui.New(cliui.StartSpinnerWithText(statusConnecting)) - defer session.End() - - c, err := executeSSH(cmd, chain) - if err != nil { - return err - } - defer c.Close() - - if !c.HasRunnerScript(ctx) { - return ErrServerNotInitialized - } - - restart, err := c.Restart(ctx) - if err != nil { - return err - } - - return session.Println(restart) -} - -// ExecuteSSHLog executes the ssh log subcommand. -func ExecuteSSHLog(ctx context.Context, cmd *plugin.ExecutedCommand, chain *plugin.ChainInfo) error { - session := cliui.New(cliui.StartSpinnerWithText(statusConnecting)) - defer session.End() - - var ( - flags = plugin.Flags(cmd.Flags) - lines, _ = flags.GetInt(flagLines) - realTime, _ = flags.GetBool(flagRealTime) - ) - - c, err := executeSSH(cmd, chain) - if err != nil { - return err - } - defer c.Close() - - if !c.HasRunnerScript(ctx) { - return ErrServerNotInitialized - } - - logs, err := c.LatestLog(lines) - if err != nil { - return err - } - _ = session.Println(logs) - - if realTime { - // Create a buffered channel to receive log lines. - logChannel := make(chan string, 100) - g, ctx := errgroup.WithContext(ctx) - - // Start the FollowLog method in a goroutine using errgroup - g.Go(func() error { - return c.FollowLog(ctx, logChannel) - }) - - // Start a goroutine to consume log lines - g.Go(func() error { - for { - select { - case line := <-logChannel: - _ = session.Print(line) - case <-ctx.Done(): - return ctx.Err() - } - } - }) - - // Wait for all goroutines to complete - if err := g.Wait(); err != nil && !errors.Is(err, context.Canceled) { - return err - } - } - - return nil -} - -// ExecuteSSHDeploy executes the ssh deploy subcommand. -func ExecuteSSHDeploy(ctx context.Context, cmd *plugin.ExecutedCommand, chain *plugin.ChainInfo) error { - session := cliui.New(cliui.StartSpinnerWithText(statusConnecting)) - defer session.End() - - flags := plugin.Flags(cmd.Flags) - - localDir, err := os.MkdirTemp(os.TempDir(), "spaceship") - if err != nil { - return err - } - defer func() { - _ = os.RemoveAll(localDir) - }() - - var ( - initChain, _ = flags.GetBool(flagInitChain) - - localChainHome = filepath.Join(localDir, "home") - localBinOutput = filepath.Join(localDir, "bin") - ) - - c, err := executeSSH(cmd, chain) - if err != nil { - return err - } - defer c.Close() - - _ = session.Println(color.Yellow.Sprintf("Building chain binary using Ignite:")) - - target, err := c.Target(ctx) - if err != nil { - return err - } - - // We are using the ignite chain build command to build the app. - igniteChainBuildCmd := ignitecmd.NewChainBuild() - igniteChainBuildCmd.SetArgs([]string{ - "-p", - chain.AppPath, - "-o", - localBinOutput, - "--release", - "--release.targets", - target, - "-v", - }) - if err := igniteChainBuildCmd.ExecuteContext(ctx); err != nil { - return err - } - - // Define a progress callback function. - bar := progressbar.DefaultBytes(1, "uploading") - progressCallback := func(bytesUploaded int64, totalBytes int64) error { - if bar.GetMax64() != totalBytes { - bar.ChangeMax64(totalBytes) - bar.Reset() - } - if err := bar.Set64(bytesUploaded); err != nil { - return err - } - if bytesUploaded == totalBytes { - if err := bar.Finish(); err != nil { - return err - } - } - return nil - } - - // Extract and upload the built binary. - var ( - binName = fmt.Sprintf("%sd", chain.ChainId) - localChainTarball = fmt.Sprintf( - "%s/%s_%s.tar.gz", - localBinOutput, - chain.ChainId, - strings.ReplaceAll(target, ":", "_"), - ) - ) - extracted, err := tarball.Extract(ctx, localChainTarball, localBinOutput, binName) - if err != nil { - return err - } - if len(extracted) == 0 { - return errors.Errorf("zero files extracted from the tarball %s", localChainTarball) - } - - bar.Describe("Uploading chain binary") - binPath, err := c.UploadBinary(extracted[0], progressCallback) - if err != nil { - return err - } - _ = session.Println(color.Yellow.Sprintf("Chain binary uploaded to '%s'\n", binPath)) - - home := c.Home() - if initChain || !c.HasGenesis(ctx) { - _ = session.Println(color.Yellow.Sprintf("Initializing the chain home folder using Ignite:")) - - igniteChainInitCmd := ignitecmd.NewChainInit() - igniteChainInitCmd.SetArgs([]string{"-p", chain.AppPath, "--home", localChainHome}) // TODO add verbose flag after merge and backport this one https://github.com/ignite/cli/pull/4286 - if err := igniteChainInitCmd.ExecuteContext(ctx); err != nil { - return err - } - - bar.Describe("Uploading chain home folder") - homeFiles, err := c.UploadHome(ctx, localChainHome, progressCallback) - if err != nil { - return err - } - _ = session.Println(color.Yellow.Sprintf("Uploaded files: \n- %s\n", strings.Join(homeFiles, "\n- "))) - } - - // Create the runner script. - localRunScriptPath, err := script.NewRunScript(c.Workspace(), c.Log(), home, binPath, localDir) - if err != nil { - return err - } - - bar.Describe("Uploading runner script") - if _, err := c.UploadRunnerScript(localRunScriptPath, progressCallback); err != nil { - return err - } - - start, err := c.Start(ctx) - if err != nil { - return err - } - _ = session.Println("") - - return session.Println(color.Blue.Sprint(start)) -} diff --git a/spaceship/go.mod b/spaceship/go.mod index 29e32446..a6a51060 100644 --- a/spaceship/go.mod +++ b/spaceship/go.mod @@ -1,10 +1,10 @@ module github.com/ignite/apps/spaceship -go 1.22 - -toolchain go1.22.3 +go 1.22.7 require ( + github.com/blang/semver/v4 v4.0.0 + github.com/cosmos/cosmos-sdk v0.50.10 github.com/gobuffalo/genny/v2 v2.1.0 github.com/gobuffalo/plush/v4 v4.1.19 github.com/gookit/color v1.5.4 @@ -16,7 +16,7 @@ require ( github.com/pkg/sftp v1.13.6 github.com/schollz/progressbar/v3 v3.14.5 github.com/stretchr/testify v1.9.0 - golang.org/x/crypto v0.26.0 + golang.org/x/crypto v0.28.0 golang.org/x/sync v0.8.0 ) @@ -27,9 +27,9 @@ require ( cosmossdk.io/depinject v1.0.0 // indirect cosmossdk.io/errors v1.0.1 // indirect cosmossdk.io/log v1.4.1 // indirect - cosmossdk.io/math v1.3.0 // indirect + cosmossdk.io/math v1.4.0 // indirect cosmossdk.io/store v1.1.1 // indirect - cosmossdk.io/x/tx v0.13.4 // indirect + cosmossdk.io/x/tx v0.13.5 // indirect dario.cat/mergo v1.0.0 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect @@ -47,16 +47,13 @@ require ( github.com/aymerick/douceur v0.2.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect - github.com/blang/semver/v4 v4.0.0 // indirect github.com/bodgit/plumbing v1.2.0 // indirect github.com/bodgit/sevenzip v1.3.0 // indirect github.com/bodgit/windows v1.0.0 // indirect github.com/briandowns/spinner v1.23.0 // indirect - github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect github.com/calmh/randomart v1.1.0 // indirect github.com/cenkalti/backoff v2.2.1+incompatible // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect - github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/charmbracelet/bubbles v0.7.6 // indirect github.com/charmbracelet/bubbletea v0.23.2 // indirect @@ -73,8 +70,8 @@ require ( github.com/cockroachdb/pebble v1.1.1 // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect - github.com/cometbft/cometbft v0.38.12 // indirect - github.com/cometbft/cometbft-db v0.11.0 // indirect + github.com/cometbft/cometbft v0.38.15 // indirect + github.com/cometbft/cometbft-db v0.14.1 // indirect github.com/connesc/cipherio v0.2.1 // indirect github.com/containerd/console v1.0.4-0.20230508195404-8d3c090fd31c // indirect github.com/containerd/containerd v1.7.11 // indirect @@ -83,7 +80,6 @@ require ( github.com/cosmos/btcutil v1.0.5 // indirect github.com/cosmos/cosmos-db v1.0.2 // indirect github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect - github.com/cosmos/cosmos-sdk v0.50.9 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gogogateway v1.2.0 // indirect github.com/cosmos/gogoproto v1.7.0 // indirect @@ -94,15 +90,14 @@ require ( github.com/danieljoos/wincred v1.2.1 // indirect github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect github.com/derekparker/trie v0.0.0-20230829180723-39f4de51ef7d // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect - github.com/dgraph-io/badger/v2 v2.2007.4 // indirect + github.com/dgraph-io/badger/v4 v4.2.0 // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect - github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dlclark/regexp2 v1.2.0 // indirect - github.com/docker/docker v27.0.0+incompatible // indirect + github.com/docker/docker v27.1.1+incompatible // indirect github.com/dsnet/compress v0.0.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.6.0 // indirect @@ -120,7 +115,7 @@ require ( github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.5.0 // indirect github.com/go-git/go-git/v5 v5.12.0 // indirect - github.com/go-kit/kit v0.12.0 // indirect + github.com/go-kit/kit v0.13.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect github.com/go-openapi/analysis v0.23.0 // indirect @@ -144,11 +139,12 @@ require ( github.com/gofrs/uuid v4.4.0+incompatible // indirect github.com/gogo/googleapis v1.4.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/glog v1.2.0 // indirect + github.com/golang/glog v1.2.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect - github.com/google/btree v1.1.2 // indirect + github.com/google/btree v1.1.3 // indirect + github.com/google/flatbuffers v1.12.1 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/go-dap v0.11.0 // indirect github.com/google/go-github/v48 v48.2.0 // indirect @@ -225,14 +221,14 @@ require ( github.com/otiai10/copy v1.14.0 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect - github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect + github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect github.com/pierrec/lz4/v4 v4.1.15 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.20.1 // indirect + github.com/prometheus/client_golang v1.20.5 // indirect github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.55.0 // indirect + github.com/prometheus/common v0.60.1 // indirect github.com/prometheus/procfs v0.15.1 // indirect github.com/radovskyb/watcher v1.0.7 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect @@ -244,7 +240,7 @@ require ( github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sahilm/fuzzy v0.1.0 // indirect - github.com/sasha-s/go-deadlock v0.3.1 // indirect + github.com/sasha-s/go-deadlock v0.3.5 // indirect github.com/segmentio/ksuid v1.0.3 // indirect github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect github.com/sirupsen/logrus v1.9.3 // indirect @@ -269,25 +265,26 @@ require ( github.com/yuin/goldmark-emoji v1.0.1 // indirect github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v0.14.3 // indirect - go.etcd.io/bbolt v1.3.10 // indirect + go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 // indirect go.mongodb.org/mongo-driver v1.14.0 // indirect + go.opencensus.io v0.24.0 // indirect go.starlark.net v0.0.0-20231101134539-556fd59b42f6 // indirect go.uber.org/multierr v1.11.0 // indirect go4.org v0.0.0-20200411211856-f5505b9728dd // indirect golang.org/x/arch v0.6.0 // indirect golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/mod v0.18.0 // indirect - golang.org/x/net v0.28.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/term v0.23.0 // indirect - golang.org/x/text v0.17.0 // indirect + golang.org/x/net v0.30.0 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/term v0.25.0 // indirect + golang.org/x/text v0.19.0 // indirect golang.org/x/tools v0.22.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/genproto v0.0.0-20240701130421-f6361c86f094 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect - google.golang.org/grpc v1.64.1 // indirect - google.golang.org/protobuf v1.34.2 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/grpc v1.67.1 // indirect + google.golang.org/protobuf v1.35.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/spaceship/go.sum b/spaceship/go.sum index 6f386fb3..93b64f04 100644 --- a/spaceship/go.sum +++ b/spaceship/go.sum @@ -27,12 +27,12 @@ cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0= cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U= cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM= cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU= -cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE= -cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k= +cosmossdk.io/math v1.4.0 h1:XbgExXFnXmF/CccPPEto40gOO7FpWu9yWNAZPN3nkNQ= +cosmossdk.io/math v1.4.0/go.mod h1:O5PkD4apz2jZs4zqFdTr16e1dcaQCc5z6lkEnrrppuk= cosmossdk.io/store v1.1.1 h1:NA3PioJtWDVU7cHHeyvdva5J/ggyLDkyH0hGHl2804Y= cosmossdk.io/store v1.1.1/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM= -cosmossdk.io/x/tx v0.13.4 h1:Eg0PbJgeO0gM8p5wx6xa0fKR7hIV6+8lC56UrsvSo0Y= -cosmossdk.io/x/tx v0.13.4/go.mod h1:BkFqrnGGgW50Y6cwTy+JvgAhiffbGEKW6KF9ufcDpvk= +cosmossdk.io/x/tx v0.13.5 h1:FdnU+MdmFWn1pTsbfU0OCf2u6mJ8cqc1H4OMG418MLw= +cosmossdk.io/x/tx v0.13.5/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w= dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= @@ -61,8 +61,6 @@ github.com/Microsoft/hcsshim v0.11.4/go.mod h1:smjE4dvqPX9Zldna+t5FG3rnoHhaB7QYx github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s= github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/OneOfOne/xxhash v1.2.8 h1:31czK/TI9sNkxIKfaUfGlU47BAxQ0ztGgd9vPyqimf8= -github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= @@ -135,8 +133,6 @@ github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurT github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.1.6 h1:zFL2+c3Lb9gEgqKNzowKUPQNb8jV7v5Oaodi/AYFd6c= github.com/btcsuite/btcd/btcutil v1.1.6/go.mod h1:9dFymx8HpuLqBnsPELrImQeTQfKBQqzqGbbV3jK55aE= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 h1:KdUfX2zKommPRa+PD0sWZUyXe9w277ABlgELO7H04IM= -github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/bufbuild/protocompile v0.14.0 h1:z3DW4IvXE5G/uTOnSQn+qwQQxvhckkTWLS/0No/o7KU= github.com/bufbuild/protocompile v0.14.0/go.mod h1:N6J1NYzkspJo3ZwyL4Xjvli86XOj1xq4qAasUFxGups= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= @@ -149,7 +145,6 @@ github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInq github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= @@ -212,10 +207,10 @@ github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZ github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/cometbft/cometbft v0.38.12 h1:OWsLZN2KcSSFe8bet9xCn07VwhBnavPea3VyPnNq1bg= -github.com/cometbft/cometbft v0.38.12/go.mod h1:GPHp3/pehPqgX1930HmK1BpBLZPxB75v/dZg8Viwy+o= -github.com/cometbft/cometbft-db v0.11.0 h1:M3Lscmpogx5NTbb1EGyGDaFRdsoLWrUWimFEyf7jej8= -github.com/cometbft/cometbft-db v0.11.0/go.mod h1:GDPJAC/iFHNjmZZPN8V8C1yr/eyityhi2W1hz2MGKSc= +github.com/cometbft/cometbft v0.38.15 h1:5veFd8k1uXM27PBg9sMO3hAfRJ3vbh4OmmLf6cVrqXg= +github.com/cometbft/cometbft v0.38.15/go.mod h1:+wh6ap6xctVG+JOHwbl8pPKZ0GeqdPYqISu7F4b43cQ= +github.com/cometbft/cometbft-db v0.14.1 h1:SxoamPghqICBAIcGpleHbmoPqy+crij/++eZz3DlerQ= +github.com/cometbft/cometbft-db v0.14.1/go.mod h1:KHP1YghilyGV/xjD5DP3+2hyigWx0WTp9X+0Gnx0RxQ= github.com/connesc/cipherio v0.2.1 h1:FGtpTPMbKNNWByNrr9aEBtaJtXjqOzkIXNYJp6OEycw= github.com/connesc/cipherio v0.2.1/go.mod h1:ukY0MWJDFnJEbXMQtOcn2VmTpRfzcTz4OoVrWGGJZcA= github.com/containerd/console v1.0.1/go.mod h1:XUsP6YE/mKtz6bxc+I8UiKKTP04qjQL4qcS3XoQ5xkw= @@ -229,7 +224,6 @@ github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3 github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= @@ -245,8 +239,8 @@ github.com/cosmos/cosmos-db v1.0.2 h1:hwMjozuY1OlJs/uh6vddqnk9j7VamLv+0DBlbEXbAK github.com/cosmos/cosmos-db v1.0.2/go.mod h1:Z8IXcFJ9PqKK6BIsVOB3QXtkKoqUOp1vRvPT39kOXEA= github.com/cosmos/cosmos-proto v1.0.0-beta.5 h1:eNcayDLpip+zVLRLYafhzLvQlSmyab+RC5W7ZfmxJLA= github.com/cosmos/cosmos-proto v1.0.0-beta.5/go.mod h1:hQGLpiIUloJBMdQMMWb/4wRApmI9hjHH05nefC0Ojec= -github.com/cosmos/cosmos-sdk v0.50.9 h1:gt2usjz0H0qW6KwAxWw7ZJ3XU8uDwmhN+hYG3nTLeSg= -github.com/cosmos/cosmos-sdk v0.50.9/go.mod h1:TMH6wpoYBcg7Cp5BEg8fneLr+8XloNQkf2MRNF9V6JE= +github.com/cosmos/cosmos-sdk v0.50.10 h1:zXfeu/z653tWZARr/jESzAEiCUYjgJwwG4ytnYWMoDM= +github.com/cosmos/cosmos-sdk v0.50.10/go.mod h1:6Eesrx3ZE7vxBZWpK++30H+Uc7Q4ahQWCL7JKU/LEdU= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gogogateway v1.2.0 h1:Ae/OivNhp8DqBi/sh2A8a1D0y638GpL3tkmLQAiKxTE= @@ -260,7 +254,6 @@ github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5Rtn github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0= github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5nvue4rK+yM= github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -280,16 +273,15 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/derekparker/trie v0.0.0-20221213183930-4c74548207f4/go.mod h1:C7Es+DLenIpPc9J6IYw4jrK0h7S9bKj4DNl8+KxGEXU= github.com/derekparker/trie v0.0.0-20230829180723-39f4de51ef7d h1:hUWoLdw5kvo2xCsqlsIBMvWUc1QCSsCYD2J2+Fg6YoU= github.com/derekparker/trie v0.0.0-20230829180723-39f4de51ef7d/go.mod h1:C7Es+DLenIpPc9J6IYw4jrK0h7S9bKj4DNl8+KxGEXU= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= -github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= -github.com/dgraph-io/badger/v2 v2.2007.4/go.mod h1:vSw/ax2qojzbN6eXHIx6KPKtCSHJN/Uz0X0VPruTIhk= -github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= +github.com/dgraph-io/badger/v4 v4.2.0 h1:kJrlajbXXL9DFTNuhhu9yCx7JJa4qpYWxtE8BzuWsEs= +github.com/dgraph-io/badger/v4 v4.2.0/go.mod h1:qfCqhPoWDFJRx1gp5QwwyGo8xk1lbHUxvK9nK0OGAak= github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8= github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= @@ -300,8 +292,8 @@ github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUn github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dlclark/regexp2 v1.2.0 h1:8sAhBGEM0dRWogWqWyQeIJnxjWO6oIjl8FKqREDsGfk= github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= -github.com/docker/docker v27.0.0+incompatible h1:JRugTYuelmWlW0M3jakcIadDx2HUoUO6+Tf2C5jVfwA= -github.com/docker/docker v27.0.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v27.1.1+incompatible h1:hO/M4MtV36kzKldqnA37IWhebRA+LnqqcqDja6kVaKY= +github.com/docker/docker v27.1.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/dsnet/compress v0.0.1 h1:PlZu0n3Tuv04TzpfPbrnI0HW/YwodEXDS+oPKahKF0Q= github.com/dsnet/compress v0.0.1/go.mod h1:Aw8dCMJ7RioblQeTqt88akK31OvO8Dhf5JflhBbQEHo= github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY= @@ -386,8 +378,8 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= -github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4= -github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs= +github.com/go-kit/kit v0.13.0 h1:OoneCcHKHQ03LfBpoQCUfCluwd2Vt3ohz+kvbJneZAU= +github.com/go-kit/kit v0.13.0/go.mod h1:phqEHMMUbyrCFCTgH48JueqrM3md2HcAZ8N3XE4FKDg= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= @@ -474,8 +466,8 @@ github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXP github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68= -github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= +github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY= +github.com/golang/glog v1.2.2/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -509,13 +501,14 @@ github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= -github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= +github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg= +github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= +github.com/google/flatbuffers v1.12.1 h1:MVlul7pQNoDzWRLTw5imwYsl+usrS1TXG2H4jg6ImGw= +github.com/google/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -523,6 +516,7 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -695,7 +689,6 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= @@ -784,8 +777,8 @@ github.com/microcosm-cc/bluemonday v1.0.23/go.mod h1:mN70sk7UkkF8TUr2IGBpNN0jAgS github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/mikesmitty/edkey v0.0.0-20170222072505-3356ea4e686a h1:eU8j/ClY2Ty3qdHnn0TyW3ivFoPC/0F1gQZz8yTxbbE= github.com/mikesmitty/edkey v0.0.0-20170222072505-3356ea4e686a/go.mod h1:v8eSC2SMp9/7FTKUncp7fH9IwPfw+ysMObcEz5FWheQ= -github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g= -github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= +github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD6Q= +github.com/minio/highwayhash v1.0.3/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= @@ -910,9 +903,8 @@ github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCko github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= -github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= -github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 h1:jik8PHtAIsPlCRJjJzl4udgEf7hawInF9texMeO2jrU= -github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= +github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 h1:Dx7Ovyv/SFnMFw3fD4oEoeorXc6saIiQ23LrGLth0Gw= +github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4/v4 v4.1.15 h1:MO0/ucJhngq7299dKLwIMtgTfbkoSPF6AoMYDd8Q4q0= @@ -941,8 +933,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.20.1 h1:IMJXHOD6eARkQpxo8KkhgEVFlBNm+nkrFUyGlIu7Na8= -github.com/prometheus/client_golang v1.20.1/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y= +github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -959,8 +951,8 @@ github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt2 github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= -github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= +github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc= +github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= @@ -992,7 +984,6 @@ github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= @@ -1006,8 +997,8 @@ github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWR github.com/sahilm/fuzzy v0.1.0 h1:FzWGaw2Opqyu+794ZQ9SYifWv2EIXpwP4q8dY1kDAwI= github.com/sahilm/fuzzy v0.1.0/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= -github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0= -github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= +github.com/sasha-s/go-deadlock v0.3.5 h1:tNCOEEDG6tBqrNDOX35j/7hL5FcFViG6awUGROb2NsU= +github.com/sasha-s/go-deadlock v0.3.5/go.mod h1:bugP6EGbdGYObIlx7pUZtWqlvo8k9H6vCBBsiChJQ5U= github.com/schollz/progressbar/v3 v3.14.5 h1:97RrSxbBASxQuZN9yemnyGrFZ/swnG6IrEe2R0BseX8= github.com/schollz/progressbar/v3 v3.14.5/go.mod h1:Nrzpuw3Nl0srLY0VlTvC4V6RL50pcEymjy6qyJAaLa0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= @@ -1039,8 +1030,6 @@ github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIK github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e h1:qpG93cPwA5f7s/ZPBJnGOYQNK/vKsaDaseuKT5Asee8= github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= -github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= @@ -1048,7 +1037,6 @@ github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= @@ -1058,7 +1046,6 @@ github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= @@ -1082,6 +1069,7 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= @@ -1102,7 +1090,6 @@ github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqri github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= @@ -1130,8 +1117,8 @@ github.com/zondax/ledger-go v0.14.3 h1:wEpJt2CEcBJ428md/5MgSLsXLBos98sBOyxNmCjfU github.com/zondax/ledger-go v0.14.3/go.mod h1:IKKaoxupuB43g4NxeQmbLXv7T9AlQyie1UpHb342ycI= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.10 h1:+BqfJTcCzTItrop8mq/lbzL8wSGtj94UO/3U31shqG0= -go.etcd.io/bbolt v1.3.10/go.mod h1:bK3UQLPJZly7IlNmV7uVHJDxfe5aK9Ll93e/74Y9oEQ= +go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5 h1:qxen9oVGzDdIRP6ejyAJc760RwW4SnVDiTYTzwnXuxo= +go.etcd.io/bbolt v1.4.0-alpha.0.0.20240404170359-43604f3112c5/go.mod h1:eW0HG9/oHQhvRCvb1/pIXW4cOvtDqeQK+XSi3TnwaXY= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.mongodb.org/mongo-driver v1.14.0 h1:P98w8egYRjYe3XDjxhYJagTokP/H6HzlsnojRgZRd80= go.mongodb.org/mongo-driver v1.14.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c= @@ -1141,6 +1128,8 @@ go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= +go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.starlark.net v0.0.0-20220816155156-cfacd8902214/go.mod h1:VZcBMdr3cT3PnBoWunTabuSEXwVAH+ZJ5zxfs3AdASk= go.starlark.net v0.0.0-20231101134539-556fd59b42f6 h1:+eC0F/k4aBLC4szgOcjd7bDTEnpxADJyWJE0yowgM3E= @@ -1166,7 +1155,6 @@ golang.org/x/arch v0.6.0 h1:S0JTfE48HbRj80+4tbvZDYsJ3tGv6BUU3XxyZ7CirAc= golang.org/x/arch v0.6.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -1184,8 +1172,8 @@ golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= -golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= +golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1250,6 +1238,7 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= @@ -1265,8 +1254,8 @@ golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1293,7 +1282,6 @@ golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1303,7 +1291,6 @@ golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1363,8 +1350,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1375,8 +1362,8 @@ golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= -golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= -golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= +golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= +golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1388,8 +1375,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1478,10 +1465,10 @@ google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20220314164441-57ef72a4c106/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= google.golang.org/genproto v0.0.0-20240701130421-f6361c86f094 h1:6whtk83KtD3FkGrVb2hFXuQ+ZMbCNdakARIn/aHMmG8= google.golang.org/genproto v0.0.0-20240701130421-f6361c86f094/go.mod h1:Zs4wYw8z1zr6RNF4cwYb31mvN/EGaKAdQjNCF3DW6K4= -google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d h1:Aqf0fiIdUQEj0Gn9mKFFXoQfTTEaNopWpfVyYADxiSg= -google.golang.org/genproto/googleapis/api v0.0.0-20240624140628-dc46fd24d27d/go.mod h1:Od4k8V1LQSizPRUK4OzZ7TBE/20k+jPczUDAEyvn69Y= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 h1:SbSDUWW1PAO24TNpLdeheoYPd7kllICcLU52x6eD4kQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= @@ -1498,11 +1485,12 @@ google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA= -google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0= +google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= +google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -1517,8 +1505,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/spaceship/main.go b/spaceship/main.go index 13ab1eec..7b4d8edd 100644 --- a/spaceship/main.go +++ b/spaceship/main.go @@ -29,16 +29,36 @@ func (app) Execute(ctx context.Context, c *plugin.ExecutedCommand, api plugin.Cl // Remove the first two elements "ignite" and "spaceship" from OsArgs. args := c.OsArgs[2:] switch args[0] { - case "deploy": - return cmd.ExecuteSSHDeploy(ctx, c, chainInfo) - case "log": - return cmd.ExecuteSSHLog(ctx, c, chainInfo) case "status": return cmd.ExecuteSSHStatus(ctx, c, chainInfo) + case "deploy": + return cmd.ExecuteSSHDeploy(ctx, c, chainInfo) case "restart": return cmd.ExecuteSSHRestart(ctx, c, chainInfo) case "stop": return cmd.ExecuteSSHSStop(ctx, c, chainInfo) + case "log": + switch args[1] { + case "chain": + return cmd.ExecuteChainSSHLog(ctx, c, chainInfo) + case "faucet": + return cmd.ExecuteFaucetSSHLog(ctx, c, chainInfo) + default: + return fmt.Errorf("unknown log command: %s", args[1]) + } + case "faucet": + switch args[1] { + case "status": + return cmd.ExecuteSSHFaucetStatus(ctx, c, chainInfo) + case "start": + return cmd.ExecuteSSHFaucetStart(ctx, c, chainInfo) + case "restart": + return cmd.ExecuteSSHFaucetRestart(ctx, c, chainInfo) + case "stop": + return cmd.ExecuteSSHSFaucetStop(ctx, c, chainInfo) + default: + return fmt.Errorf("unknown faucet command: %s", args[1]) + } default: return fmt.Errorf("unknown command: %s", args[0]) } diff --git a/spaceship/pkg/faucet/faucet.go b/spaceship/pkg/faucet/faucet.go new file mode 100644 index 00000000..5537947f --- /dev/null +++ b/spaceship/pkg/faucet/faucet.go @@ -0,0 +1,104 @@ +package faucet + +import ( + "context" + "fmt" + "net/http" + "os" + "path/filepath" + + "github.com/blang/semver/v4" + "github.com/ignite/cli/v28/ignite/config" + "github.com/ignite/cli/v28/ignite/pkg/errors" + "github.com/ignite/cli/v28/ignite/pkg/xfilepath" + "github.com/ignite/cli/v28/ignite/pkg/xos" + + "github.com/ignite/apps/spaceship/pkg/tarball" +) + +const ( + faucetBinaryName = "faucet" + binaryCacheDirectory = "apps/spaceship/bin" + faucetLastRelease = "https://github.com/ignite/faucet/releases/download" +) + +// faucetVersion specifies the current version of the faucet application. +var faucetVersion = semver.MustParse("0.0.2") + +// faucetReleaseName constructs the download URL for a faucet binary tarball given the target platform. +func faucetReleaseName(target string) string { + return fmt.Sprintf("%[1]v/v%[2]v/faucet_%[2]v_%[3]v.tar.gz", faucetLastRelease, faucetVersion.String(), target) +} + +// FetchBinary downloads the faucet binary file from a specific target +// and caches it locally if not already cached. +// +// Parameters: +// - ctx: The context for managing timeouts and cancellation. +// - target: The target platform for which the binary is being downloaded. +// +// Returns: +// - A string representing the path to the cached binary file. +// - An error if any issues occur during the process of fetching or extracting the binary. +func FetchBinary(ctx context.Context, target string) (string, error) { + binPath, err := binCachePath() + if err != nil { + return "", err + } + + // Check if the binary already exists in the ignite cache. + if _, err := os.Stat(binPath); err == nil { + return binPath, nil + } + + // Create a temporary folder to extract the faucet binary. + tempDir, err := os.MkdirTemp("", "faucet") + if err != nil { + return "", errors.Errorf("failed to create temp dir: %w", err) + } + + binaryURL := faucetReleaseName(target) + + // Download the binary. + resp, err := http.Get(binaryURL) + if err != nil { + return "", errors.Errorf("failed to download faucet binary: %w", err) + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + return "", errors.Errorf("failed to fetch faucet binary: %s status", resp.Status) + } + + // Extract the binary tarball. + extracted, err := tarball.ExtractData(ctx, resp.Body, tempDir, faucetBinaryName) + if err != nil { + return "", err + } + if len(extracted) == 0 { + return "", errors.Errorf("zero files extracted from %s faucet the tarball: %s", target, binaryURL) + } + + return binPath, xos.Rename(extracted[0], binPath) +} + +// BinaryName generates the binary name by concatenating the faucet binary name and version. +func BinaryName() string { + return fmt.Sprintf("%s_%s", faucetBinaryName, faucetVersion.String()) +} + +// binCacheDirPath constructs and returns the path to the binary cache directory based on the configuration directory. +func binCacheDirPath() (string, error) { + return xfilepath.Join(config.DirPath, xfilepath.Path(binaryCacheDirectory))() +} + +// binCachePath constructs the full path to the cached binary and ensures the necessary directories exist. +// Returns the constructed binary path as a string and any error encountered during directory creation. +func binCachePath() (string, error) { + dirPath, err := binCacheDirPath() + if err != nil { + return "", err + } + path := filepath.Join(dirPath, BinaryName()) + return path, os.MkdirAll(dirPath, 0o755) +} diff --git a/spaceship/pkg/ssh/chain.go b/spaceship/pkg/ssh/chain.go new file mode 100644 index 00000000..00fe4fe4 --- /dev/null +++ b/spaceship/pkg/ssh/chain.go @@ -0,0 +1,56 @@ +package ssh + +import ( + "context" + "path/filepath" +) + +// genesis returns the path to the genesis.json file within the home directory. +func (s *SSH) genesis() string { + return filepath.Join(s.Home(), "config", "genesis.json") +} + +// runnerScript returns the path to the runner script within the workspace. +func (s *SSH) runnerScript() string { + return filepath.Join(s.Workspace(), "run.sh") +} + +// Home returns the home directory within the workspace. +func (s *SSH) Home() string { + return filepath.Join(s.Workspace(), "home") +} + +// HasGenesis checks if the genesis file exists on the remote server. +func (s *SSH) HasGenesis(ctx context.Context) bool { + return s.FileExist(ctx, s.genesis()) +} + +// HasRunnerScript checks if the runner script file exists on the remote server. +func (s *SSH) HasRunnerScript(ctx context.Context) bool { + return s.FileExist(ctx, s.runnerScript()) +} + +// Start runs the "start" script on the remote server. +func (s *SSH) Start(ctx context.Context) (string, error) { + return s.runScript(ctx, "start") +} + +// Restart runs the "restart" script on the remote server. +func (s *SSH) Restart(ctx context.Context) (string, error) { + return s.runScript(ctx, "restart") +} + +// Stop runs the "stop" script on the remote server. +func (s *SSH) Stop(ctx context.Context) (string, error) { + return s.runScript(ctx, "stop") +} + +// Status runs the "status" script on the remote server. +func (s *SSH) Status(ctx context.Context) (string, error) { + return s.runScript(ctx, "status") +} + +// runScript runs the specified script with arguments on the remote server. +func (s *SSH) runScript(ctx context.Context, args ...string) (string, error) { + return s.RunCommand(ctx, s.runnerScript(), args...) +} diff --git a/spaceship/pkg/ssh/faucet.go b/spaceship/pkg/ssh/faucet.go new file mode 100644 index 00000000..e6a000c2 --- /dev/null +++ b/spaceship/pkg/ssh/faucet.go @@ -0,0 +1,49 @@ +package ssh + +import ( + "context" + "path/filepath" + "strconv" + + "github.com/ignite/apps/spaceship/pkg/faucet" +) + +// faucet returns the path to the faucet script within the workspace. +func (s *SSH) faucet() string { + return filepath.Join(s.Bin(), faucet.BinaryName()) +} + +// faucetScript returns the path to the faucet runner script within the workspace. +func (s *SSH) faucetScript() string { + return filepath.Join(s.Workspace(), "faucet.sh") +} + +// HasFaucetScript checks if the runner faucet script file exists on the remote server. +func (s *SSH) HasFaucetScript(ctx context.Context) bool { + return s.FileExist(ctx, s.faucetScript()) +} + +// FaucetStart runs the faucet "start" script on the remote server. +func (s *SSH) FaucetStart(ctx context.Context, port uint64) (string, error) { + return s.runFaucetScript(ctx, "start", strconv.FormatUint(port, 10)) +} + +// FaucetRestart runs the faucet "restart" script on the remote server. +func (s *SSH) FaucetRestart(ctx context.Context, port uint64) (string, error) { + return s.runFaucetScript(ctx, "restart", strconv.FormatUint(port, 10)) +} + +// FaucetStop runs the faucet "stop" script on the remote server. +func (s *SSH) FaucetStop(ctx context.Context) (string, error) { + return s.runFaucetScript(ctx, "stop") +} + +// FaucetStatus runs the faucet "status" script on the remote server. +func (s *SSH) FaucetStatus(ctx context.Context) (string, error) { + return s.runFaucetScript(ctx, "status") +} + +// runFaucetScript runs the specified faucet script with arguments on the remote server. +func (s *SSH) runFaucetScript(ctx context.Context, args ...string) (string, error) { + return s.RunCommand(ctx, s.faucetScript(), args...) +} diff --git a/spaceship/pkg/ssh/file.go b/spaceship/pkg/ssh/file.go new file mode 100644 index 00000000..6bd4bdd5 --- /dev/null +++ b/spaceship/pkg/ssh/file.go @@ -0,0 +1,33 @@ +package ssh + +import ( + "context" + "fmt" +) + +// FolderExist checks if a directory exists at the specified path on the remote server. +// It returns true if the directory exists, otherwise false. +func (s *SSH) FolderExist(ctx context.Context, path string) bool { + return s.exist(ctx, path, false) +} + +// FileExist checks if a file exists at the specified path on the remote server. +// It returns true if the file exists, otherwise false. +func (s *SSH) FileExist(ctx context.Context, path string) bool { + return s.exist(ctx, path, true) +} + +// exist checks if a file or directory exists at the specified path on the remote server. +// If isFile is true, it checks for a file, otherwise it checks for a directory. +// It returns true if the specified file or directory exists, otherwise false. +func (s *SSH) exist(ctx context.Context, path string, isFile bool) bool { + cmd := fmt.Sprintf("[ -d '%s' ] && echo 'true'", path) + if isFile { + cmd = fmt.Sprintf("[ -f '%s' ] && echo 'true'", path) + } + exist, err := s.RunCommand(ctx, cmd) + if err != nil { + return false + } + return exist == "true" +} diff --git a/spaceship/pkg/ssh/info.go b/spaceship/pkg/ssh/info.go new file mode 100644 index 00000000..5e15bfef --- /dev/null +++ b/spaceship/pkg/ssh/info.go @@ -0,0 +1,49 @@ +package ssh + +import ( + "context" + "strings" + + "github.com/ignite/cli/v28/ignite/pkg/gocmd" +) + +// OS returns the operating system type of the remote server. +func (s *SSH) OS(ctx context.Context) (string, error) { + v, err := s.Uname(ctx) + if err != nil { + return "", err + } + return strings.ToLower(v), nil +} + +// Arch returns the architecture type of the remote server. +func (s *SSH) Arch(ctx context.Context) (string, error) { + v, err := s.Uname(ctx, "-m") + if err != nil { + return "", err + } + if arch, ok := archMap[v]; ok { + v = arch + } + return strings.ToLower(v), nil +} + +// Target returns the build target for the remote server based on its OS and architecture. +func (s *SSH) Target(ctx context.Context) (string, error) { + osType, err := s.OS(ctx) + if err != nil { + return "", err + } + + arch, err := s.Arch(ctx) + if err != nil { + return "", err + } + + return gocmd.BuildTarget(osType, arch), nil +} + +// Uname runs the "uname" command with the specified arguments on the remote server. +func (s *SSH) Uname(ctx context.Context, args ...string) (string, error) { + return s.RunCommand(ctx, "uname", args...) +} diff --git a/spaceship/pkg/ssh/log.go b/spaceship/pkg/ssh/log.go index d6ff7399..1be0f945 100644 --- a/spaceship/pkg/ssh/log.go +++ b/spaceship/pkg/ssh/log.go @@ -13,26 +13,39 @@ import ( "github.com/ignite/cli/v28/ignite/pkg/errors" ) -const ( - logExtension = ".log" +type ( + // LogType represents the log type. + LogType string + + // log represents a log file with its name and modification time. + log struct { + name string + time time.Time + } + + // logs implements sort.Interface based on the Time field. + logs []log ) -// log represents a log file with its name and modification time. -type log struct { - name string - time time.Time -} +const ( + logExtension = ".log" -// logs implements sort.Interface based on the Time field. -type logs []log + LogChain LogType = "chain_" + LogFaucet LogType = "faucet_" +) func (a logs) Len() int { return len(a) } func (a logs) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func (a logs) Less(i, j int) bool { return a[i].time.Before(a[j].time) } +// Log returns the log directory within the workspace. +func (s *SSH) Log() string { + return filepath.Join(s.Workspace(), "log") +} + // LatestLog returns the last n lines from the latest log file. -func (s *SSH) LatestLog(n int) (string, error) { - logFiles, err := s.getLogFiles() +func (s *SSH) LatestLog(logType LogType, n int) (string, error) { + logFiles, err := s.getLogFiles(logType) if err != nil { return "", errors.Wrap(err, "error fetching log files") } @@ -78,8 +91,8 @@ func (s *SSH) readLastNLines(filePath string, n int) ([]string, error) { } // FollowLog follows the latest log file and sends new lines to the provided channel in real-time. -func (s *SSH) FollowLog(ctx context.Context, ch chan<- string) error { - logFiles, err := s.getLogFiles() +func (s *SSH) FollowLog(ctx context.Context, logType LogType, ch chan<- string) error { + logFiles, err := s.getLogFiles(logType) if err != nil { return errors.Wrap(err, "error fetching log files") } @@ -121,7 +134,7 @@ func (s *SSH) FollowLog(ctx context.Context, ch chan<- string) error { } // getLogFiles fetches all log files from the specified directory. -func (s *SSH) getLogFiles() (logs, error) { +func (s *SSH) getLogFiles(logType LogType) (logs, error) { dir := s.Log() files, err := s.sftpClient.ReadDir(dir) @@ -134,14 +147,15 @@ func (s *SSH) getLogFiles() (logs, error) { if file.IsDir() { continue } - - // Assuming log files have a .log extension - if filepath.Ext(file.Name()) == logExtension { - logFiles = append(logFiles, log{ - name: filepath.Join(dir, file.Name()), - time: file.ModTime(), - }) + // Assuming log files have a .log extension and check the filename prefix + if filepath.Ext(file.Name()) != logExtension || + !strings.HasPrefix(file.Name(), string(logType)) { + continue } + logFiles = append(logFiles, log{ + name: filepath.Join(dir, file.Name()), + time: file.ModTime(), + }) } return logFiles, nil } diff --git a/spaceship/pkg/ssh/ssh.go b/spaceship/pkg/ssh/ssh.go index 70922e53..4501eed0 100644 --- a/spaceship/pkg/ssh/ssh.go +++ b/spaceship/pkg/ssh/ssh.go @@ -12,7 +12,6 @@ import ( "strings" "github.com/ignite/cli/v28/ignite/pkg/errors" - "github.com/ignite/cli/v28/ignite/pkg/gocmd" "github.com/ignite/cli/v28/ignite/pkg/randstr" "github.com/manifoldco/promptui" "github.com/melbahja/goph" @@ -20,9 +19,7 @@ import ( "golang.org/x/crypto/ssh/knownhosts" ) -const ( - workdir = "spaceship" -) +const workdir = "spaceship" // SSH represents the SSH configuration and clients for connecting and interacting // with remote servers via SSH. @@ -163,76 +160,6 @@ func parseURI(uri string) (host string, port string, username string, password s return host, port, username, password, nil } -// Close closes the SSH and SFTP clients. -func (s *SSH) Close() error { - if err := s.sftpClient.Close(); err != nil { - return err - } - return s.client.Close() -} - -// Connect establishes the SSH connection and initializes the SFTP client. -func (s *SSH) Connect() error { - auth, err := s.auth() - if err != nil { - return err - } - - s.client, err = goph.New(s.username, s.host, auth) - if errors.Is(err, &knownhosts.KeyError{}) { - prompt := promptui.Prompt{ - Label: fmt.Sprintf("Unknown host: %s. Do you want to proceed with the connection anyway", s.host), - IsConfirm: true, - Stdout: os.Stdout, - Stdin: os.Stdin, - } - if _, err := prompt.Run(); err != nil { - return err - } - s.client, err = goph.NewUnknown(s.username, s.host, auth) - } - if err != nil { - return errors.Wrapf(err, "Failed to connect to %v", s) - } - - s.sftpClient, err = s.client.NewSftp() - if err != nil { - return err - } - - return s.ensureEnvironment() -} - -// Workspace returns the workspace directory for the SSH session. -func (s *SSH) Workspace() string { - return filepath.Join(workdir, s.workspace) -} - -// Bin returns the binary directory within the workspace. -func (s *SSH) Bin() string { - return filepath.Join(s.Workspace(), "bin") -} - -// Home returns the home directory within the workspace. -func (s *SSH) Home() string { - return filepath.Join(s.Workspace(), "home") -} - -// Genesis returns the path to the genesis.json file within the home directory. -func (s *SSH) Genesis() string { - return filepath.Join(s.Home(), "config", "genesis.json") -} - -// Log returns the log directory within the workspace. -func (s *SSH) Log() string { - return filepath.Join(s.Workspace(), "log") -} - -// RunnerScript returns the path to the runner script within the workspace. -func (s *SSH) RunnerScript() string { - return filepath.Join(s.Workspace(), "run.sh") -} - // validate checks if the SSH configuration is valid. func (s *SSH) validate() error { switch { @@ -277,125 +204,72 @@ func (s *SSH) ensureEnvironment() error { return nil } -// RunCommand runs a command on the remote server and returns the output. -func (s *SSH) RunCommand(ctx context.Context, name string, args ...string) (string, error) { - cmd, err := s.client.CommandContext(ctx, name, args...) - if err != nil { - return "", err - } - cmdOut, err := cmd.CombinedOutput() - output := strings.TrimSpace(string(cmdOut)) - if err != nil { - return "", errors.Errorf( - "%s: failed to run %s %s\n%s", - err.Error(), - name, - strings.Join(args, " "), - output, - ) - } - return output, nil -} - -// Start runs the "start" script on the remote server. -func (s *SSH) Start(ctx context.Context) (string, error) { - return s.runScript(ctx, "start") -} - -// Restart runs the "restart" script on the remote server. -func (s *SSH) Restart(ctx context.Context) (string, error) { - return s.runScript(ctx, "restart") -} - -// Stop runs the "stop" script on the remote server. -func (s *SSH) Stop(ctx context.Context) (string, error) { - return s.runScript(ctx, "stop") -} - -// Status runs the "status" script on the remote server. -func (s *SSH) Status(ctx context.Context) (string, error) { - return s.runScript(ctx, "status") -} - -// runScript runs the specified script with arguments on the remote server. -func (s *SSH) runScript(ctx context.Context, args ...string) (string, error) { - return s.RunCommand(ctx, s.RunnerScript(), args...) -} - -// HasGenesis checks if the genesis file exists on the remote server. -func (s *SSH) HasGenesis(ctx context.Context) bool { - return s.FileExist(ctx, s.Genesis()) -} - -// HasRunnerScript checks if the runner script file exists on the remote server. -func (s *SSH) HasRunnerScript(ctx context.Context) bool { - return s.FileExist(ctx, s.RunnerScript()) +// Bin returns the binary directory within the workspace. +func (s *SSH) Bin() string { + return filepath.Join(s.Workspace(), "bin") } -// FolderExist checks if a directory exists at the specified path on the remote server. -// It returns true if the directory exists, otherwise false. -func (s *SSH) FolderExist(ctx context.Context, path string) bool { - return s.exist(ctx, path, false) +// Workspace returns the workspace directory for the SSH session. +func (s *SSH) Workspace() string { + return filepath.Join(workdir, s.workspace) } -// FileExist checks if a file exists at the specified path on the remote server. -// It returns true if the file exists, otherwise false. -func (s *SSH) FileExist(ctx context.Context, path string) bool { - return s.exist(ctx, path, true) +// Close closes the SSH and SFTP clients. +func (s *SSH) Close() error { + if err := s.sftpClient.Close(); err != nil { + return err + } + return s.client.Close() } -// exist checks if a file or directory exists at the specified path on the remote server. -// If isFile is true, it checks for a file, otherwise it checks for a directory. -// It returns true if the specified file or directory exists, otherwise false. -func (s *SSH) exist(ctx context.Context, path string, isFile bool) bool { - cmd := fmt.Sprintf("[ -d '%s' ] && echo 'true'", path) - if isFile { - cmd = fmt.Sprintf("[ -f '%s' ] && echo 'true'", path) - } - exist, err := s.RunCommand(ctx, cmd) +// Connect establishes the SSH connection and initializes the SFTP client. +func (s *SSH) Connect() error { + auth, err := s.auth() if err != nil { - return false + return err } - return exist == "true" -} -// OS returns the operating system type of the remote server. -func (s *SSH) OS(ctx context.Context) (string, error) { - v, err := s.Uname(ctx) + s.client, err = goph.New(s.username, s.host, auth) + if errors.Is(err, &knownhosts.KeyError{}) { + prompt := promptui.Prompt{ + Label: fmt.Sprintf("Unknown host: %s. Do you want to proceed with the connection anyway", s.host), + IsConfirm: true, + Stdout: os.Stdout, + Stdin: os.Stdin, + } + if _, err := prompt.Run(); err != nil { + return err + } + s.client, err = goph.NewUnknown(s.username, s.host, auth) + } if err != nil { - return "", err + return errors.Wrapf(err, "Failed to connect to %v", s) } - return strings.ToLower(v), nil -} -// Arch returns the architecture type of the remote server. -func (s *SSH) Arch(ctx context.Context) (string, error) { - v, err := s.Uname(ctx, "-m") + s.sftpClient, err = s.client.NewSftp() if err != nil { - return "", err - } - if arch, ok := archMap[v]; ok { - v = arch + return err } - return strings.ToLower(v), nil + + return s.ensureEnvironment() } -// Target returns the build target for the remote server based on its OS and architecture. -func (s *SSH) Target(ctx context.Context) (string, error) { - os, err := s.OS(ctx) +// RunCommand runs a command on the remote server and returns the output. +func (s *SSH) RunCommand(ctx context.Context, name string, args ...string) (string, error) { + cmd, err := s.client.CommandContext(ctx, name, args...) if err != nil { return "", err } - - arch, err := s.Arch(ctx) + cmdOut, err := cmd.CombinedOutput() + output := strings.TrimSpace(string(cmdOut)) if err != nil { - return "", err + return "", errors.Errorf( + "%s: failed to run %s %s\n%s", + err.Error(), + name, + strings.Join(args, " "), + output, + ) } - - return gocmd.BuildTarget(os, arch), nil -} - -// Uname runs the "uname" command with the specified arguments on the remote server. -func (s *SSH) Uname(ctx context.Context, args ...string) (string, error) { - return s.RunCommand(ctx, "uname", args...) + return output, nil } diff --git a/spaceship/pkg/ssh/upload.go b/spaceship/pkg/ssh/upload.go index 646f8ce1..7e8c4e18 100644 --- a/spaceship/pkg/ssh/upload.go +++ b/spaceship/pkg/ssh/upload.go @@ -9,6 +9,8 @@ import ( "github.com/ignite/cli/v28/ignite/pkg/errors" "golang.org/x/sync/errgroup" + + "github.com/ignite/apps/spaceship/pkg/faucet" ) // ProgressCallback is a type for the callback function to update the progress. @@ -138,7 +140,7 @@ func (s *SSH) UploadFile(filePath, dstPath string, progressCallback ProgressCall return dstPath, nil } -// UploadBinary uploads a binary file to the remote server's bin directory +// UploadBinary uploads a binary file to the remote server's Bin directory // and sets the appropriate permissions. func (s *SSH) UploadBinary(srcPath string, progressCallback ProgressCallback) (string, error) { var ( @@ -156,19 +158,21 @@ func (s *SSH) UploadBinary(srcPath string, progressCallback ProgressCallback) (s return binPath, nil } -// UploadRunnerScript uploads a runner script to the remote server +// UploadScripts uploads a runner and faucet scripts to the remote server // and sets the appropriate permissions. -func (s *SSH) UploadRunnerScript(srcPath string, progressCallback ProgressCallback) (string, error) { - path := s.RunnerScript() - if _, err := s.UploadFile(srcPath, s.RunnerScript(), progressCallback); err != nil { - return "", err +func (s *SSH) UploadScripts(ctx context.Context, srcPath string, progressCallback ProgressCallback) error { + if _, err := s.Upload(ctx, srcPath, s.Workspace(), progressCallback); err != nil { + return err } // give binary permission - if err := s.sftpClient.Chmod(path, 0o755); err != nil { - return "", err + if err := s.sftpClient.Chmod(s.runnerScript(), 0o755); err != nil { + return err } - return path, nil + if err := s.sftpClient.Chmod(s.faucetScript(), 0o755); err != nil { + return err + } + return nil } // UploadHome uploads the home directory to the remote server. @@ -176,3 +180,12 @@ func (s *SSH) UploadHome(ctx context.Context, srcPath string, progressCallback P path := s.Home() return s.Upload(ctx, srcPath, path, progressCallback) } + +// UploadFaucetBinary uploads the faucet binary to the remote server. +func (s *SSH) UploadFaucetBinary(ctx context.Context, target string, progressCallback ProgressCallback) (string, error) { + bin, err := faucet.FetchBinary(ctx, target) + if err != nil { + return "", err + } + return s.UploadBinary(bin, progressCallback) +} diff --git a/spaceship/pkg/tarball/tarball.go b/spaceship/pkg/tarball/tarball.go index 55abdfc2..4568cc73 100644 --- a/spaceship/pkg/tarball/tarball.go +++ b/spaceship/pkg/tarball/tarball.go @@ -2,8 +2,8 @@ package tarball import ( "context" + "io" "os" - "path" "path/filepath" "github.com/mholt/archiver/v4" @@ -13,15 +13,20 @@ import ( const tarballExt = ".tar.gz" -func Extract(ctx context.Context, file, output string, fileList ...string) ([]string, error) { - baseName := path.Base(file) +func ExtractFile(ctx context.Context, file, output string, fileList ...string) ([]string, error) { f, err := os.Open(file) if err != nil { return nil, err } defer f.Close() + return ExtractData(ctx, f, output, fileList...) +} - format, reader, err := archiver.Identify(baseName, f) +func ExtractData(ctx context.Context, file io.Reader, output string, fileList ...string) ([]string, error) { + // TODO check if need basename + // baseName := path.Base(file) + // format, reader, err := archiver.Identify(baseName, file) + format, reader, err := archiver.Identify("", file) if err != nil { return nil, err } diff --git a/spaceship/templates/script/files/faucet.sh.plush b/spaceship/templates/script/files/faucet.sh.plush new file mode 100644 index 00000000..ca8bcc18 --- /dev/null +++ b/spaceship/templates/script/files/faucet.sh.plush @@ -0,0 +1,77 @@ +#!/bin/bash + +PORT=${2:-8009} +COMMAND="$HOME/<%= faucetBinPath %> --home <%= home %> --cli-name <%= binary %> --account-name <%= account %> --denoms <%= denoms %> --port $PORT" +PID_FILE="$HOME/<%= path %>/faucet.pid" + +export PATH="$PATH:$HOME/<%= binDirPath %>" + +# Function to get the current date and time formatted for the log file +get_log_file_name() { + echo "$HOME/<%= log %>/faucet_$(date '+%Y-%m-%d_%H-%M-%S').log" +} + +# Function to ensure the directory exists +ensure_directory_exists() { + DIR=$(dirname "$1") + if [ ! -d "$DIR" ]; then + mkdir -p "$DIR" + fi +} + +start() { + ensure_directory_exists "$PID_FILE" + LOG_FILE=$(get_log_file_name) + ensure_directory_exists "$LOG_FILE" + + echo "Starting faucet on port $PORT..." + nohup $COMMAND > "$LOG_FILE" 2>&1 & + echo $! > "$PID_FILE" + echo "faucet started with PID $(cat $PID_FILE)." + echo "Logs are being written to $LOG_FILE" +} + +stop() { + if [ -f "$PID_FILE" ]; then + PID=$(cat "$PID_FILE") + echo "Stopping faucet with PID $PID..." + kill "$PID" + rm "$PID_FILE" + echo "faucet stopped." + else + echo "faucet is not running." + fi +} + +status() { + if [ -f "$PID_FILE" ]; then + PID=$(cat "$PID_FILE") + if ps -p "$PID" > /dev/null; then + echo "faucet is running with PID $PID." + else + echo "faucet is not running, but PID file exists." + fi + else + echo "faucet is not running." + fi +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + ;; + status) + status + ;; + *) + echo "Usage: $0 {start|stop|restart|status}" + exit 1 + ;; +esac \ No newline at end of file diff --git a/spaceship/templates/script/files/run.sh.plush b/spaceship/templates/script/files/run.sh.plush index 01e6723a..378c6cfe 100644 --- a/spaceship/templates/script/files/run.sh.plush +++ b/spaceship/templates/script/files/run.sh.plush @@ -1,12 +1,15 @@ #!/bin/bash HOME_PATH="$HOME/<%= home %>" -COMMAND="$HOME/<%= binary %> start --home $HOME_PATH" +BINARY="<%= binary %>" +COMMAND="$HOME/<%= chainBinPath %> start --home $HOME_PATH" PID_FILE="$HOME/<%= path %>/spaceship.pid" +export PATH="$PATH:$HOME/<%= binDirPath %>" + # Function to get the current date and time formatted for the log file get_log_file_name() { - echo "$HOME/<%= log %>/$(date '+%Y-%m-%d_%H-%M-%S').log" + echo "$HOME/<%= log %>/chain_$(date '+%Y-%m-%d_%H-%M-%S').log" } # Function to ensure the directory exists @@ -25,19 +28,19 @@ start() { echo "Starting $COMMAND..." nohup $COMMAND > "$LOG_FILE" 2>&1 & echo $! > "$PID_FILE" - echo "$COMMAND started with PID $(cat $PID_FILE)." + echo "$BINARY started with PID $(cat $PID_FILE)." echo "Logs are being written to $LOG_FILE" } stop() { if [ -f "$PID_FILE" ]; then PID=$(cat "$PID_FILE") - echo "Stopping $COMMAND with PID $PID..." + echo "Stopping $BINARY with PID $PID..." kill "$PID" rm "$PID_FILE" - echo "$COMMAND stopped." + echo "$BINARY stopped." else - echo "$COMMAND is not running." + echo "$BINARY is not running." fi } @@ -45,12 +48,12 @@ status() { if [ -f "$PID_FILE" ]; then PID=$(cat "$PID_FILE") if ps -p "$PID" > /dev/null; then - echo "$COMMAND is running with PID $PID." + echo "$BINARY is running with PID $PID." else - echo "$COMMAND is not running, but PID file exists." + echo "$BINARY is not running, but PID file exists." fi else - echo "$COMMAND is not running." + echo "$BINARY is not running." fi } diff --git a/spaceship/templates/script/script.go b/spaceship/templates/script/script.go index cfa2dee9..a0409c65 100644 --- a/spaceship/templates/script/script.go +++ b/spaceship/templates/script/script.go @@ -11,11 +11,11 @@ import ( "github.com/ignite/cli/v28/ignite/templates/field/plushhelpers" ) -//go:embed files/run.sh.plush +//go:embed files/* var fsRunScript embed.FS -// NewRunScript returns the generator to scaffold a chain run script. -func NewRunScript(path, log, home, binary, output string) (string, error) { +// NewRunScripts returns the generator to scaffold a chain and faucet run script. +func NewRunScripts(path, log, home, binDirPath, chainBinPath, faucetBinPath, account, denoms, output string) error { var ( g = genny.New() runScript = xgenny.NewEmbedWalker( @@ -25,18 +25,23 @@ func NewRunScript(path, log, home, binary, output string) (string, error) { ) ) if err := g.Box(runScript); err != nil { - return "", err + return err } ctx := plush.NewContext() ctx.Set("path", path) ctx.Set("log", log) ctx.Set("home", home) - ctx.Set("binary", binary) + ctx.Set("chainBinPath", chainBinPath) + ctx.Set("faucetBinPath", faucetBinPath) + ctx.Set("binDirPath", binDirPath) + ctx.Set("binary", filepath.Base(chainBinPath)) + ctx.Set("account", account) + ctx.Set("denoms", denoms) plushhelpers.ExtendPlushContext(ctx) g.Transformer(xgenny.Transformer(ctx)) _, err := xgenny.RunWithValidation(placeholder.New(), g) - return filepath.Join(output, "run.sh"), err + return err }