From aa7ff82463710814dfa01409c2d8769836bbda45 Mon Sep 17 00:00:00 2001 From: artpav <19916123+artemijspavlovs@users.noreply.github.com> Date: Tue, 9 Jul 2024 20:08:01 +0300 Subject: [PATCH] fix: config files (#809) --- cmd/config/init/flags.go | 12 +---------- cmd/config/init/genesis.go | 6 ------ cmd/config/init/keys.go | 1 - cmd/config/init/rollapp.go | 32 +++++++++++++++++------------- cmd/config/show/show.go | 3 ++- cmd/da-light-client/start/start.go | 4 ++-- cmd/keys/export/export.go | 4 ++-- cmd/relayer/relayer.go | 3 ++- cmd/relayer/start/start.go | 5 ++--- cmd/relayer/status/status.go | 3 ++- cmd/rollapp/init/main.go | 1 + cmd/run/services_status.go | 6 +++--- cmd/services/services.go | 3 ++- cmd/utils/log.go | 3 ++- data_layer/avail/avail.go | 9 ++++----- sequencer/config.go | 15 +++++++++----- utils/archives/archives.go | 3 --- 17 files changed, 53 insertions(+), 60 deletions(-) diff --git a/cmd/config/init/flags.go b/cmd/config/init/flags.go index dd80eca7..4f694e4a 100644 --- a/cmd/config/init/flags.go +++ b/cmd/config/init/flags.go @@ -1,7 +1,6 @@ package initconfig import ( - "encoding/json" "fmt" "path/filepath" "strings" @@ -14,10 +13,6 @@ import ( "github.com/dymensionxyz/roller/config" ) -const ( - defaultTokenSupply = "1000000000" -) - func AddFlags(cmd *cobra.Command) error { cmd.Flags(). StringP(FlagNames.HubID, "", consts.LocalHubName, fmt.Sprintf("The ID of the Dymension hub. %s", getAvailableHubsMessage())) @@ -26,7 +21,7 @@ func AddFlags(cmd *cobra.Command) error { cmd.Flags(). StringP(FlagNames.VMType, "", string(config.EVM_ROLLAPP), "The rollapp type [evm, sdk]. Defaults to evm") cmd.Flags(). - StringP(FlagNames.TokenSupply, "", defaultTokenSupply, "The total token supply of the RollApp") + StringP(FlagNames.TokenSupply, "", consts.DefaultTokenSupply, "The total token supply of the RollApp") // cmd.Flags().BoolP(FlagNames.Interactive, "i", false, "Run roller in interactive mode") cmd.Flags().BoolP(FlagNames.NoOutput, "", false, "Run init without any output") cmd.Flags().UintP(FlagNames.Decimals, "", 18, @@ -71,17 +66,12 @@ func GetInitConfig( // cfg.RollappID = raID // cfg.Denom = raBaseDenom - fmt.Println(cfg.VMType == config.EVM_ROLLAPP) - if cfg.VMType == config.EVM_ROLLAPP { cfg.Decimals = 18 } else { cfg.Decimals = 6 } - j, _ := json.MarshalIndent(cfg, "", " ") - fmt.Println(string(j)) - return &cfg, nil } diff --git a/cmd/config/init/genesis.go b/cmd/config/init/genesis.go index d8645a5c..b8ff6b5a 100644 --- a/cmd/config/init/genesis.go +++ b/cmd/config/init/genesis.go @@ -109,8 +109,6 @@ func getGenesisOperatorAddress(home string) (string, error) { "val", ) - fmt.Println(getOperatorAddrCommand.String()) - addr, err := utils.ExecBashCommandWithStdout(getOperatorAddrCommand) if err != nil { fmt.Println("val addr failed") @@ -118,7 +116,6 @@ func getGenesisOperatorAddress(home string) (string, error) { } a := strings.TrimSpace(addr.String()) - fmt.Println(a) return a, nil } @@ -136,8 +133,6 @@ func getSequencerAddress(home string) (string, error) { rollappConfigDirPath, ) - fmt.Println(getOperatorAddrCommand.String()) - addr, err := utils.ExecBashCommandWithStdout(getOperatorAddrCommand) if err != nil { fmt.Println("seq addr failed") @@ -145,7 +140,6 @@ func getSequencerAddress(home string) (string, error) { } a := strings.TrimSpace(addr.String()) - fmt.Println(a) return a, nil } diff --git a/cmd/config/init/keys.go b/cmd/config/init/keys.go index 1a39f325..e7e088da 100644 --- a/cmd/config/init/keys.go +++ b/cmd/config/init/keys.go @@ -20,7 +20,6 @@ func GenerateKeys(rollappConfig config.RollappConfig) ([]utils.AddressData, erro // if err != nil { // return nil, err // } - fmt.Println(sequencerAddresses) return sequencerAddresses, nil } diff --git a/cmd/config/init/rollapp.go b/cmd/config/init/rollapp.go index 246ad455..f715d7e5 100644 --- a/cmd/config/init/rollapp.go +++ b/cmd/config/init/rollapp.go @@ -1,18 +1,17 @@ package initconfig import ( - "fmt" "os/exec" "path/filepath" "github.com/dymensionxyz/roller/cmd/consts" "github.com/dymensionxyz/roller/cmd/utils" "github.com/dymensionxyz/roller/config" + "github.com/dymensionxyz/roller/sequencer" ) func InitializeRollappConfig(initConfig config.RollappConfig) error { home := filepath.Join(initConfig.Home, consts.ConfigDirName.Rollapp) - fmt.Println(initConfig.RollappID) initRollappCmd := exec.Command( initConfig.RollappBinary, @@ -29,21 +28,26 @@ func InitializeRollappConfig(initConfig config.RollappConfig) error { return err } + err = setRollappConfig(initConfig) + if err != nil { + return err + } + return nil } -// func setRollappConfig(rlpCfg config.RollappConfig) error { -// if err := sequencer.SetAppConfig(rlpCfg); err != nil { -// return err -// } -// if err := sequencer.SetTMConfig(rlpCfg); err != nil { -// return err -// } -// if err := sequencer.SetDefaultDymintConfig(rlpCfg); err != nil { -// return err -// } -// return nil -// } +func setRollappConfig(rlpCfg config.RollappConfig) error { + if err := sequencer.SetAppConfig(rlpCfg); err != nil { + return err + } + if err := sequencer.SetTMConfig(rlpCfg); err != nil { + return err + } + if err := sequencer.SetDefaultDymintConfig(rlpCfg); err != nil { + return err + } + return nil +} func RollappConfigDir(root string) string { return filepath.Join(root, consts.ConfigDirName.Rollapp, "config") diff --git a/cmd/config/show/show.go b/cmd/config/show/show.go index f9b83ce5..02b486a6 100644 --- a/cmd/config/show/show.go +++ b/cmd/config/show/show.go @@ -5,9 +5,10 @@ import ( "os" "path/filepath" + "github.com/spf13/cobra" + "github.com/dymensionxyz/roller/cmd/utils" "github.com/dymensionxyz/roller/config" - "github.com/spf13/cobra" ) func Cmd() *cobra.Command { diff --git a/cmd/da-light-client/start/start.go b/cmd/da-light-client/start/start.go index 8fc206a3..cc076906 100644 --- a/cmd/da-light-client/start/start.go +++ b/cmd/da-light-client/start/start.go @@ -5,12 +5,12 @@ import ( "errors" "fmt" - "github.com/dymensionxyz/roller/data_layer/celestia" + "github.com/spf13/cobra" "github.com/dymensionxyz/roller/cmd/utils" "github.com/dymensionxyz/roller/config" datalayer "github.com/dymensionxyz/roller/data_layer" - "github.com/spf13/cobra" + "github.com/dymensionxyz/roller/data_layer/celestia" ) const ( diff --git a/cmd/keys/export/export.go b/cmd/keys/export/export.go index 4d9a8dd1..5c189057 100644 --- a/cmd/keys/export/export.go +++ b/cmd/keys/export/export.go @@ -5,12 +5,12 @@ import ( "path/filepath" "strings" - datalayer "github.com/dymensionxyz/roller/data_layer" + "github.com/spf13/cobra" "github.com/dymensionxyz/roller/cmd/consts" "github.com/dymensionxyz/roller/cmd/utils" "github.com/dymensionxyz/roller/config" - "github.com/spf13/cobra" + datalayer "github.com/dymensionxyz/roller/data_layer" ) func Cmd() *cobra.Command { diff --git a/cmd/relayer/relayer.go b/cmd/relayer/relayer.go index 854e0f11..442b10a9 100644 --- a/cmd/relayer/relayer.go +++ b/cmd/relayer/relayer.go @@ -1,9 +1,10 @@ package relayer import ( + "github.com/spf13/cobra" + "github.com/dymensionxyz/roller/cmd/relayer/start" "github.com/dymensionxyz/roller/cmd/relayer/status" - "github.com/spf13/cobra" ) func Cmd() *cobra.Command { diff --git a/cmd/relayer/start/start.go b/cmd/relayer/start/start.go index 0aea26e9..cc471988 100644 --- a/cmd/relayer/start/start.go +++ b/cmd/relayer/start/start.go @@ -5,14 +5,13 @@ import ( "fmt" "math/big" - "github.com/dymensionxyz/roller/sequencer" + "github.com/spf13/cobra" "github.com/dymensionxyz/roller/cmd/consts" - "github.com/dymensionxyz/roller/cmd/utils" "github.com/dymensionxyz/roller/config" "github.com/dymensionxyz/roller/relayer" - "github.com/spf13/cobra" + "github.com/dymensionxyz/roller/sequencer" ) // TODO: Test relaying on 35-C and update the prices diff --git a/cmd/relayer/status/status.go b/cmd/relayer/status/status.go index c9ca1738..8ed35581 100644 --- a/cmd/relayer/status/status.go +++ b/cmd/relayer/status/status.go @@ -5,10 +5,11 @@ import ( "fmt" "os" + "github.com/spf13/cobra" + "github.com/dymensionxyz/roller/cmd/utils" "github.com/dymensionxyz/roller/config" "github.com/dymensionxyz/roller/relayer" - "github.com/spf13/cobra" ) func Cmd() *cobra.Command { diff --git a/cmd/rollapp/init/main.go b/cmd/rollapp/init/main.go index eb146de7..4a23c1c2 100644 --- a/cmd/rollapp/init/main.go +++ b/cmd/rollapp/init/main.go @@ -230,6 +230,7 @@ func runInit(cmd *cobra.Command, args []string, configArchivePath string) error return err } + // adds the sequencer address to the whitelists err = initconfig.UpdateGenesisParams(home) if err != nil { return err diff --git a/cmd/run/services_status.go b/cmd/run/services_status.go index 1a145b11..cd2b90d6 100644 --- a/cmd/run/services_status.go +++ b/cmd/run/services_status.go @@ -5,12 +5,12 @@ import ( "path/filepath" "time" + ui "github.com/gizak/termui/v3" + "github.com/gizak/termui/v3/widgets" + "github.com/dymensionxyz/roller/cmd/utils" "github.com/dymensionxyz/roller/config" servicemanager "github.com/dymensionxyz/roller/utils/service_manager" - - ui "github.com/gizak/termui/v3" - "github.com/gizak/termui/v3/widgets" ) func RenderUI(rollappConfig config.RollappConfig, manager *servicemanager.ServiceConfig) { diff --git a/cmd/services/services.go b/cmd/services/services.go index 65d2679b..1b514c7a 100644 --- a/cmd/services/services.go +++ b/cmd/services/services.go @@ -1,8 +1,9 @@ package services import ( - "github.com/dymensionxyz/roller/cmd/services/load" "github.com/spf13/cobra" + + "github.com/dymensionxyz/roller/cmd/services/load" ) func Cmd() *cobra.Command { diff --git a/cmd/utils/log.go b/cmd/utils/log.go index 275aadb6..d9c45fca 100644 --- a/cmd/utils/log.go +++ b/cmd/utils/log.go @@ -6,9 +6,10 @@ import ( "os/exec" "path/filepath" + "gopkg.in/natefinch/lumberjack.v2" + "github.com/dymensionxyz/roller/cmd/consts" "github.com/dymensionxyz/roller/config" - "gopkg.in/natefinch/lumberjack.v2" ) func GetRollerLogger(home string) *log.Logger { diff --git a/data_layer/avail/avail.go b/data_layer/avail/avail.go index 35ea8a8d..eb66a235 100644 --- a/data_layer/avail/avail.go +++ b/data_layer/avail/avail.go @@ -5,15 +5,14 @@ import ( "math/big" "os/exec" - "github.com/dymensionxyz/roller/cmd/consts" - "github.com/dymensionxyz/roller/cmd/utils" - "github.com/dymensionxyz/roller/config" - gsrpc "github.com/centrifuge/go-substrate-rpc-client/v4" "github.com/centrifuge/go-substrate-rpc-client/v4/signature" availtypes "github.com/centrifuge/go-substrate-rpc-client/v4/types" - bip39 "github.com/cosmos/go-bip39" + + "github.com/dymensionxyz/roller/cmd/consts" + "github.com/dymensionxyz/roller/cmd/utils" + "github.com/dymensionxyz/roller/config" ) const ( diff --git a/sequencer/config.go b/sequencer/config.go index 8a032c6c..479fcadc 100644 --- a/sequencer/config.go +++ b/sequencer/config.go @@ -24,8 +24,11 @@ func SetDefaultDymintConfig(rlpCfg config.RollappConfig) error { if err := updateDaConfigInToml(rlpCfg, dymintCfg); err != nil { return err } + hubKeysDir := filepath.Join(rlpCfg.Home, consts.ConfigDirName.HubKeys) - dymintCfg.Set("settlement_layer", "dymension") + dymintCfg.Set("max_idle_time", "1h0m0s") + dymintCfg.Set("max_proof_time", "10s") + dymintCfg.Set("settlement_layer", "mock") dymintCfg.Set("block_batch_size", "500") dymintCfg.Set("block_time", "0.2s") dymintCfg.Set("batch_submit_max_time", "100s") @@ -37,6 +40,8 @@ func SetDefaultDymintConfig(rlpCfg config.RollappConfig) error { dymintCfg.Set("gas_prices", rlpCfg.HubData.GAS_PRICE+consts.Denoms.Hub) dymintCfg.Set("instrumentation.prometheus", true) dymintCfg.Set("instrumentation.prometheus_listen_addr", ":2112") + dymintCfg.Set("batch_submit_max_time", "1h0m0s") + file, err := os.Create(dymintTomlPath) if err != nil { return err @@ -59,9 +64,9 @@ func UpdateDymintDAConfig(rlpCfg config.RollappConfig) error { func updateDaConfigInToml(rlpCfg config.RollappConfig, dymintCfg *toml.Tree) error { damanager := datalayer.NewDAManager(rlpCfg.DA, rlpCfg.Home) - dymintCfg.Set("da_layer", string(rlpCfg.DA)) - daConfig := damanager.GetSequencerDAConfig() - dymintCfg.Set("da_config", daConfig) + dymintCfg.Set("da_layer", "mock") + // daConfig := damanager.GetSequencerDAConfig() + // dymintCfg.Set("da_config", daConfig) if rlpCfg.DA == config.Celestia { celDAManager, ok := damanager.DataLayer.(*celestia.Celestia) if !ok { @@ -87,7 +92,7 @@ func SetAppConfig(rlpCfg config.RollappConfig) error { return fmt.Errorf("failed to load %s: %v", appConfigFilePath, err) } - appCfg.Set("minimum-gas-prices", "0"+rlpCfg.Denom) + appCfg.Set("minimum-gas-prices", "1000000000"+rlpCfg.Denom) appCfg.Set("api.enable", true) appCfg.Set("api.enabled-unsafe-cors", true) diff --git a/utils/archives/archives.go b/utils/archives/archives.go index 3ce93b49..6608b7af 100644 --- a/utils/archives/archives.go +++ b/utils/archives/archives.go @@ -78,7 +78,6 @@ func TraverseTARFile(tarFile, fileName, outputDir string) error { if fileName == header.Name { fp := filepath.Join(outputDir, fileName) - fmt.Println(fp) err := createFileFromArchive(fp, tarReader) if err != nil { @@ -98,12 +97,10 @@ func TraverseTARFile(tarFile, fileName, outputDir string) error { func createFileFromArchive(outputPath string, tarReader *tar.Reader) error { dir := filepath.Dir(outputPath) - fmt.Println("creating dir:", dir) if err := os.MkdirAll(dir, 0o755); err != nil { return fmt.Errorf("ExtractTar: MkdirAll() failed: %w", err) } - fmt.Println("creating file:", outputPath) outFile, err := os.Create(outputPath) if err != nil { return fmt.Errorf("ExtractTar: Create() failed: %w", err)