diff --git a/Makefile b/Makefile index b4d779d..555c50b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION := v0.2.1 +VERSION := v0.2.2 ldflags := $(LDFLAGS) ldflags += -X main.Version=$(VERSION) diff --git a/backup/backup.go b/backup/backup.go new file mode 100644 index 0000000..7b51b69 --- /dev/null +++ b/backup/backup.go @@ -0,0 +1,120 @@ +package backup + +import ( + "fmt" + "io" + "os" + "os/exec" + "path/filepath" + "sort" + "strings" +) + +func ClearBackups(srcPath string, threshold int) error { + // Get and sort all created Backups + entries, err := os.ReadDir(srcPath) + if err != nil { + return err + } + + backups := []os.DirEntry{} + for _, entry := range entries { + if entry.IsDir() { + // Make sure to only clear timestamped backups + if strings.HasPrefix(entry.Name(), "20") && len(entry.Name()) == 15 { + backups = append(backups, entry) + } + } + } + + sort.Slice(backups, func(i, j int) bool { + return backups[i].Name() < backups[j].Name() + }) + + if len(backups) > threshold { + for { + oldestBackup := backups[0].Name() + err = os.RemoveAll(filepath.Join(srcPath, oldestBackup)) + if err != nil { + return err + } + + backups = backups[1:] + + if len(backups) <= threshold { + break + } + } + } + return nil +} + +// CompressDirectory compresses a directory using Gzip and creates a .tar.gz file. +func CompressDirectory(srcPath, compressionType string) error { + var cmd *exec.Cmd + + switch compressionType { + case "tar.gz": + cmd = exec.Command("tar", "-zcvf", filepath.Base(srcPath)+"."+compressionType, filepath.Base(srcPath)) + case "zip": + cmd = exec.Command("zip", "-r", filepath.Base(srcPath)+"."+compressionType, filepath.Base(srcPath)) + default: + return fmt.Errorf("unsupported compression type") + } + + cmd.Dir = filepath.Dir(srcPath) + cmd.Stderr = os.Stderr + + // Run the command + if err := cmd.Run(); err != nil { + return err + } + + if err := os.RemoveAll(srcPath); err != nil { + return err + } + + return nil +} + +func CopyDir(srcDir, destDir string) error { + // Create the destination directory if it doesn't exist + if err := os.MkdirAll(destDir, 0o755); err != nil { + return err + } + + // Walk through the source directory and copy its contents to the destination + return filepath.Walk(srcDir, func(srcPath string, fileInfo os.FileInfo, err error) error { + if err != nil { + return err + } + + // Construct the corresponding destination path + destPath := filepath.Join(destDir, srcPath[len(srcDir):]) + + if fileInfo.IsDir() { + // Create the destination directory if it doesn't exist + return os.MkdirAll(destPath, 0o755) + } else { + // Open the source file for reading + srcFile, err := os.Open(srcPath) + if err != nil { + return err + } + defer srcFile.Close() + + // Create the destination file + destFile, err := os.Create(destPath) + if err != nil { + return err + } + defer destFile.Close() + + // Copy the contents from source to destination + if _, err := io.Copy(destFile, srcFile); err != nil { + return err + } + } + return nil + }) +} diff --git a/cmd/supervysor/backup.go b/cmd/supervysor/backup.go new file mode 100644 index 0000000..823326d --- /dev/null +++ b/cmd/supervysor/backup.go @@ -0,0 +1,77 @@ +package main + +import ( + "fmt" + + "github.com/KYVENetwork/supervysor/backup" + "github.com/KYVENetwork/supervysor/cmd/supervysor/helpers" + "github.com/spf13/cobra" +) + +var ( + compressionType string + destPath string + maxBackups int + srcPath string +) + +func init() { + backupCmd.Flags().StringVar(&srcPath, "src-path", "", "source path of the directory to backup") + if err := backupCmd.MarkFlagRequired("src-path"); err != nil { + panic(fmt.Errorf("flag 'src-path' should be required: %w", err)) + } + + backupCmd.Flags().StringVar(&destPath, "dest-path", "", "destination path of the written backup (default '~/.ksync/backups)'") + + backupCmd.Flags().StringVar(&compressionType, "compression", "", "compression type to compress backup directory ['tar.gz', 'zip', '']") + + backupCmd.Flags().IntVar(&maxBackups, "max-backups", 0, "number of kept backups (set 0 to keep all)") +} + +var backupCmd = &cobra.Command{ + Use: "backup", + Short: "Backup data directory", + Run: func(cmd *cobra.Command, args []string) { + backupDir, err := helpers.GetBackupDir() + if err != nil { + logger.Error("failed to get ksync home directory", "err", err) + return + } + + if destPath == "" { + d, err := helpers.CreateDestPath(backupDir) + if err != nil { + return + } + destPath = d + } + + if err := helpers.ValidatePaths(srcPath, destPath); err != nil { + return + } + + logger.Info("starting to copy backup", "from", srcPath, "to", destPath) + + if err := backup.CopyDir(srcPath, destPath); err != nil { + logger.Error("error copying directory to backup destination", "err", err) + } + + logger.Info("directory copied successfully") + + if compressionType != "" { + if err := backup.CompressDirectory(destPath, compressionType); err != nil { + logger.Error("compression failed", "err", err) + } + + logger.Info("compressed backup successfully") + } + + if maxBackups > 0 { + logger.Info("starting to cleanup backup directory", "path", backupDir) + if err := backup.ClearBackups(backupDir, maxBackups); err != nil { + logger.Error("clearing backup directory failed", "err", err) + return + } + } + }, +} diff --git a/cmd/supervysor/helpers/helpers.go b/cmd/supervysor/helpers/helpers.go index 4b89cad..f8b9128 100644 --- a/cmd/supervysor/helpers/helpers.go +++ b/cmd/supervysor/helpers/helpers.go @@ -5,6 +5,7 @@ import ( "net/http" "os" "path/filepath" + "time" "github.com/spf13/viper" @@ -14,6 +15,18 @@ import ( cfg "github.com/tendermint/tendermint/config" ) +func CreateDestPath(backupDir string) (string, error) { + t := time.Now().Format("20060102_150405") + + if err := os.Mkdir(filepath.Join(backupDir, t), 0o755); err != nil { + return "", fmt.Errorf("error creating backup directory: %v", err) + } + if err := os.Mkdir(filepath.Join(backupDir, t, "data"), 0o755); err != nil { + return "", fmt.Errorf("error creating data backup directory: %v", err) + } + return filepath.Join(backupDir, t, "data"), nil +} + func GetDirectorySize(dirPath string) (float64, error) { var s int64 err := filepath.Walk(dirPath, func(_ string, info os.FileInfo, err error) error { @@ -47,6 +60,23 @@ func GetLogsDir() (string, error) { return logsDir, nil } +func GetBackupDir() (string, error) { + home, err := GetSupervysorDir() + if err != nil { + return "", fmt.Errorf("could not find home directory: %s", err) + } + + backupDir := filepath.Join(home, "backups") + if _, err = os.Stat(backupDir); os.IsNotExist(err) { + err = os.Mkdir(backupDir, 0o755) + if err != nil { + return "", err + } + } + + return backupDir, nil +} + func GetSupervysorDir() (string, error) { home, err := os.UserHomeDir() if err != nil { @@ -128,3 +158,22 @@ func StartMetricsServer(reg *prometheus.Registry) error { } return nil } + +func ValidatePaths(srcPath, destPath string) error { + pathInfo, err := os.Stat(srcPath) + if err != nil { + return err + } + if !pathInfo.IsDir() { + return err + } + pathInfo, err = os.Stat(destPath) + if err != nil { + return err + } + if !pathInfo.IsDir() { + return err + } + + return nil +} diff --git a/cmd/supervysor/init.go b/cmd/supervysor/init.go index cec21df..c766793 100644 --- a/cmd/supervysor/init.go +++ b/cmd/supervysor/init.go @@ -21,7 +21,7 @@ var ( chainId string fallbackEndpoints string homePath string - metrics string + metrics bool poolId int seeds string pruningInterval int @@ -59,7 +59,7 @@ func init() { initCmd.Flags().IntVar(&pruningInterval, "pruning-interval", 24, "block-pruning interval (hours)") - initCmd.Flags().StringVar(&metrics, "metrics", "true", "exposing Prometheus metrics (true or false)") + initCmd.Flags().BoolVar(&metrics, "metrics", true, "exposing Prometheus metrics (true or false)") initCmd.Flags().StringVar(&abciEndpoint, "abci-endpoint", "http://127.0.0.1:26657", "ABCI Endpoint to request node information") } @@ -83,7 +83,7 @@ func InitializeSupervysor() error { logger.Error("pruning-interval should be higher than 6 hours") } - if err := settings.InitializeSettings(binaryPath, homePath, poolId, false, seeds, chainId, fallbackEndpoints, metrics); err != nil { + if err := settings.InitializeSettings(binaryPath, homePath, poolId, false, seeds, chainId, fallbackEndpoints); err != nil { logger.Error("could not initialize settings", "err", err) return err } @@ -107,22 +107,17 @@ func InitializeSupervysor() error { } logger.Info("initializing supverysor...") - m := true - if metrics == "false" { - m = false - } - config := types.SupervysorConfig{ ABCIEndpoint: abciEndpoint, - ChainId: chainId, BinaryPath: binaryPath, + ChainId: chainId, HomePath: homePath, + Interval: 10, + Metrics: metrics, PoolId: poolId, Seeds: seeds, FallbackEndpoints: fallbackEndpoints, PruningInterval: pruningInterval, - Metrics: m, - Interval: 10, HeightDifferenceMax: settings.Settings.MaxDifference, HeightDifferenceMin: settings.Settings.MaxDifference / 2, StateRequests: false, diff --git a/cmd/supervysor/main.go b/cmd/supervysor/main.go index fc210ff..cb4581c 100644 --- a/cmd/supervysor/main.go +++ b/cmd/supervysor/main.go @@ -48,6 +48,7 @@ func main() { supervysor.AddCommand(startCmd) supervysor.AddCommand(versionCmd) supervysor.AddCommand(pruneCmd) + supervysor.AddCommand(backupCmd) if err = supervysor.Execute(); err != nil { os.Exit(1) diff --git a/cmd/supervysor/start.go b/cmd/supervysor/start.go index 4552481..de98661 100644 --- a/cmd/supervysor/start.go +++ b/cmd/supervysor/start.go @@ -95,20 +95,22 @@ var startCmd = &cobra.Command{ logger.Info("fetched heights successfully", "node", nodeHeight, "pool", poolHeight, "max-height", poolHeight+config.HeightDifferenceMax, "min-height", poolHeight+config.HeightDifferenceMin) - logger.Info("current pruning count", "pruning-count", fmt.Sprintf("%.2f", pruningCount), "pruning-threshold", config.PruningInterval) - if pruningCount > float64(config.PruningInterval) && currentMode == "ghost" && nodeHeight > 0 { - pruneHeight := poolHeight - if nodeHeight < poolHeight { - pruneHeight = nodeHeight - } - logger.Info("pruning blocks after node shutdown", "until-height", pruneHeight) + if config.PruningInterval != 0 { + logger.Info("current pruning count", "pruning-count", fmt.Sprintf("%.2f", pruningCount), "pruning-threshold", config.PruningInterval) + if pruningCount > float64(config.PruningInterval) && currentMode == "ghost" && nodeHeight > 0 { + pruneHeight := poolHeight + if nodeHeight < poolHeight { + pruneHeight = nodeHeight + } + logger.Info("pruning blocks after node shutdown", "until-height", pruneHeight) - err = e.PruneBlocks(config.HomePath, pruneHeight-1, flags) - if err != nil { - logger.Error("could not prune blocks", "err", err) - return err + err = e.PruneBlocks(config.HomePath, pruneHeight-1, flags) + if err != nil { + logger.Error("could not prune blocks", "err", err) + return err + } + pruningCount = 0 } - pruningCount = 0 } // Calculate height difference to enable the correct mode. diff --git a/executor/executor.go b/executor/executor.go index 41c91f6..34743c9 100644 --- a/executor/executor.go +++ b/executor/executor.go @@ -104,6 +104,7 @@ func (e *Executor) PruneBlocks(homePath string, pruneHeight int, flags []string) e.Logger.Error("could not prune blocks, exiting") return err } + if e.Process.GhostMode { process, err := node.StartGhostNode(e.Cfg, e.Logger, &e.Process, true, flags) if err != nil { diff --git a/go.mod b/go.mod index 04873f6..09b62d4 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,6 @@ require ( github.com/GaijinEntertainment/go-exhaustruct/v2 v2.3.0 // indirect github.com/Masterminds/semver v1.5.0 // indirect github.com/OpenPeeDeeP/depguard v1.1.1 // indirect - github.com/Workiva/go-datastructures v1.0.52 // indirect github.com/alexkohler/prealloc v1.0.0 // indirect github.com/alingse/asasalint v0.0.11 // indirect github.com/ashanbrown/forbidigo v1.5.1 // indirect @@ -87,9 +86,7 @@ require ( github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 // indirect github.com/google/btree v1.0.0 // indirect github.com/google/go-cmp v0.5.9 // indirect - github.com/google/orderedcode v0.0.1 // indirect github.com/gordonklaus/ineffassign v0.0.0-20230107090616-13ace0543b28 // indirect - github.com/gorilla/websocket v1.4.2 // indirect github.com/gostaticanalysis/analysisutil v0.7.1 // indirect github.com/gostaticanalysis/comment v1.4.2 // indirect github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect @@ -116,7 +113,6 @@ require ( github.com/ldez/gomoddirectives v0.2.3 // indirect github.com/ldez/tagliatelle v0.4.0 // indirect github.com/leonklingele/grouper v1.1.1 // indirect - github.com/lib/pq v1.10.7 // indirect github.com/libp2p/go-buffer-pool v0.0.2 // indirect github.com/lufeee/execinquery v1.2.1 // indirect github.com/magiconair/properties v1.8.6 // indirect @@ -130,7 +126,6 @@ require ( github.com/mbilski/exhaustivestruct v1.2.0 // indirect github.com/mgechev/revive v1.3.1 // indirect github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect - github.com/minio/highwayhash v1.0.1 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/moricho/tparallel v0.3.1 // indirect @@ -152,8 +147,6 @@ require ( github.com/quasilyte/gogrep v0.5.0 // indirect github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect - github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect - github.com/rs/cors v1.7.0 // indirect github.com/ryancurrah/gomodguard v1.3.0 // indirect github.com/ryanrolds/sqlclosecheck v0.4.0 // indirect github.com/sanposhiho/wastedassign/v2 v2.0.7 // indirect diff --git a/go.sum b/go.sum index 2b7e177..a110eb8 100644 --- a/go.sum +++ b/go.sum @@ -50,7 +50,6 @@ github.com/Antonboom/errname v0.1.9/go.mod h1:nLTcJzevREuAsgTbG85UsuiWpMpAqbKD1H github.com/Antonboom/nilnil v0.1.3 h1:6RTbx3d2mcEu3Zwq9TowQpQMVpP75zugwOtqY1RTtcE= github.com/Antonboom/nilnil v0.1.3/go.mod h1:iOov/7gRcXkeEU+EMGpBu2ORih3iyVEiWjeste1SJm8= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= @@ -68,9 +67,7 @@ github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= -github.com/Microsoft/go-winio v0.5.0 h1:Elr9Wn+sGKPlkaBvwu4mTrxtmOp3F3yV9qhaHbXGjwU= github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= -github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= @@ -80,9 +77,7 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= -github.com/Workiva/go-datastructures v1.0.52 h1:PLSK6pwn8mYdaoaCZEMsXBpBotr4HHn9abU0yMQt0NI= github.com/Workiva/go-datastructures v1.0.52/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= -github.com/adlio/schema v1.1.13 h1:LeNMVg5Z1FX+Qgz8tJUijBLRdcpbFUElz+d1489On98= github.com/adlio/schema v1.1.13/go.mod h1:L5Z7tw+7lRK1Fnpi/LT/ooCP1elkXn0krMWBQHUhEDE= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= @@ -145,7 +140,6 @@ github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46f github.com/butuzov/ireturn v0.1.1 h1:QvrO2QF2+/Cx1WA/vETCIYBKtRjc30vesdoPUNo1EbY= github.com/butuzov/ireturn v0.1.1/go.mod h1:Wh6Zl3IMtTpaIKbmwzqi6olnM9ptYQxxVacMsOEFPoc= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= -github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= @@ -174,7 +168,6 @@ github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWH github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8acV1PGKCbzQ= -github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 h1:NmTXa/uVnDyp0TY5MKi197+3HWcnYWfnHGyaFthlnGw= github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= 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= @@ -217,9 +210,7 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= -github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= @@ -389,7 +380,6 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/orderedcode v0.0.1 h1:UzfcAexk9Vhv8+9pNOgRu41f16lHq725vPwnSeiG/Us= github.com/google/orderedcode v0.0.1/go.mod h1:iVyU4/qPKHY5h/wSd6rZZCDcLJNxiWO6dvsYES2Sb20= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -414,7 +404,6 @@ github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51 github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gostaticanalysis/analysisutil v0.7.1 h1:ZMCjoue3DtDWQ5WyU16YbjbQEQ3VuzwxALrpYd+HeKk= github.com/gostaticanalysis/analysisutil v0.7.1/go.mod h1:v21E3hY37WKMGSnbsw2S/ojApNWb6C1//mXO48CXbVc= @@ -540,8 +529,6 @@ github.com/ldez/tagliatelle v0.4.0/go.mod h1:mNtTfrHy2haaBAw+VT7IBV6VXBThS7TCreY github.com/leonklingele/grouper v1.1.1 h1:suWXRU57D4/Enn6pXR0QVqqWWrnJ9Osrz+5rjt8ivzU= github.com/leonklingele/grouper v1.1.1/go.mod h1:uk3I3uDfi9B6PeUjsCKi6ndcf63Uy7snXgR4yDYQVDY= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= -github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs= github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= @@ -583,7 +570,6 @@ github.com/mgechev/revive v1.3.1/go.mod h1:YlD6TTWl2B8A103R9KWJSPVI9DrEf+oqr15q2 github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 h1:hLDRPB66XQT/8+wG9WsDpiCvZf1yKO7sz7scAjSlBa0= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= -github.com/minio/highwayhash v1.0.1 h1:dZ6IIu8Z14VlC0VpfKofAhCy74wu/Qb5gcn52yWoz/0= github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= @@ -645,12 +631,9 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.26.0 h1:03cDLK28U6hWvCAns6NeydX3zIm4SF3ci69ulidS32Q= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= -github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= -github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI= github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= -github.com/opencontainers/runc v1.0.2 h1:opHZMaswlyxz1OuGpBE53Dwe4/xF7EZTY0A2L/FpCOg= github.com/opencontainers/runc v1.0.2/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0= github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xAPP8dBsCoU0KuF8= @@ -662,13 +645,13 @@ github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxS github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= -github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/otiai10/copy v1.2.0 h1:HvG945u96iNadPoG2/Ja2+AUJeW5YuFQMixq9yirC+k= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= +github.com/otiai10/mint v1.3.1 h1:BCmzIS3n71sGfHB5NMNDB3lHYPz8fWSkCAErHed//qc= github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= @@ -741,13 +724,11 @@ github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727/go.mod h1:r github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 h1:M8mH9eK4OUR4lu7Gd+PU1fV2/qnDNfzT635KRSObncs= github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567/go.mod h1:DWNGW8A4Y+GyBgPuaQJuWiy0XYftx4Xm/y5Jqk9I6VQ= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 h1:MkV+77GLUNo5oJ0jf870itWm3D0Sjh7+Za9gazKc5LQ= github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= diff --git a/settings/settings.go b/settings/settings.go index eac7f1f..cfa2a88 100644 --- a/settings/settings.go +++ b/settings/settings.go @@ -24,7 +24,7 @@ var Settings = types.SettingsType{ // and homePath and sets the seeds value required for the node. It retrieves the pool settings, calculates the // keepRecent and maxDifference values, and sets the pruning settings based on these calculated values. // If any step encounters an error, it returns the corresponding error message. -func InitializeSettings(binaryPath string, homePath string, poolId int, stateRequests bool, seeds string, chainId string, fallbackEndpoints string, metrics string) error { +func InitializeSettings(binaryPath string, homePath string, poolId int, stateRequests bool, seeds string, chainId string, fallbackEndpoints string) error { if err := helpers.CheckBinaryPath(binaryPath); err != nil { return fmt.Errorf("could not resolve binary path: %s", err) } diff --git a/store/store.go b/store/store.go index 49a1822..59db5ad 100644 --- a/store/store.go +++ b/store/store.go @@ -2,7 +2,6 @@ package store import ( "github.com/KYVENetwork/supervysor/types" - nm "github.com/tendermint/tendermint/node" "github.com/tendermint/tendermint/state" "github.com/tendermint/tendermint/store" dbm "github.com/tendermint/tm-db" @@ -39,19 +38,3 @@ func GetBlockstoreDBs(config *types.Config) (dbm.DB, *store.BlockStore, error) { return blockStoreDB, blockStore, nil } - -func GetStateAndGenDoc(config *types.Config) (*state.State, *types.GenesisDoc, error) { - stateDB, _, err := GetStateDBs(config) - if err != nil { - return nil, nil, err - } - - defaultDocProvider := nm.DefaultGenesisDocProviderFunc(config) - - s, genDoc, err := nm.LoadStateFromDBOrGenesisDocProvider(stateDB, defaultDocProvider) - if err != nil { - return nil, nil, err - } - - return &s, genDoc, nil -}