Skip to content

Commit

Permalink
fix: config files (#809)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemijspavlovs authored Jul 9, 2024
1 parent 01827f4 commit aa7ff82
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 60 deletions.
12 changes: 1 addition & 11 deletions cmd/config/init/flags.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package initconfig

import (
"encoding/json"
"fmt"
"path/filepath"
"strings"
Expand All @@ -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()))
Expand All @@ -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,
Expand Down Expand Up @@ -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
}

Expand Down
6 changes: 0 additions & 6 deletions cmd/config/init/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,13 @@ func getGenesisOperatorAddress(home string) (string, error) {
"val",
)

fmt.Println(getOperatorAddrCommand.String())

addr, err := utils.ExecBashCommandWithStdout(getOperatorAddrCommand)
if err != nil {
fmt.Println("val addr failed")
return "", err
}

a := strings.TrimSpace(addr.String())
fmt.Println(a)
return a, nil
}

Expand All @@ -136,16 +133,13 @@ func getSequencerAddress(home string) (string, error) {
rollappConfigDirPath,
)

fmt.Println(getOperatorAddrCommand.String())

addr, err := utils.ExecBashCommandWithStdout(getOperatorAddrCommand)
if err != nil {
fmt.Println("seq addr failed")
return "", err
}

a := strings.TrimSpace(addr.String())
fmt.Println(a)
return a, nil
}

Expand Down
1 change: 0 additions & 1 deletion cmd/config/init/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func GenerateKeys(rollappConfig config.RollappConfig) ([]utils.AddressData, erro
// if err != nil {
// return nil, err
// }
fmt.Println(sequencerAddresses)
return sequencerAddresses, nil
}

Expand Down
32 changes: 18 additions & 14 deletions cmd/config/init/rollapp.go
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion cmd/config/show/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions cmd/da-light-client/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions cmd/keys/export/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion cmd/relayer/relayer.go
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions cmd/relayer/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion cmd/relayer/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions cmd/rollapp/init/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions cmd/run/services_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion cmd/services/services.go
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion cmd/utils/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 4 additions & 5 deletions data_layer/avail/avail.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
15 changes: 10 additions & 5 deletions sequencer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand All @@ -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 {
Expand All @@ -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)

Expand Down
3 changes: 0 additions & 3 deletions utils/archives/archives.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down

0 comments on commit aa7ff82

Please sign in to comment.