Skip to content

Commit

Permalink
fix: minimum gas price setting in app.toml (#1214)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemijspavlovs authored Dec 31, 2024
1 parent cd38d70 commit bf91e3f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
7 changes: 2 additions & 5 deletions cmd/config/set/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"path/filepath"
"time"

toml "github.com/pelletier/go-toml"
"github.com/pterm/pterm"

"github.com/dymensionxyz/roller/utils/config/tomlconfig"
Expand All @@ -16,12 +15,10 @@ import (

func SetMinimumGasPrice(cfg roller.RollappConfig, value string) error {
appConfigFilePath := filepath.Join(sequencerutils.GetSequencerConfigDir(cfg.Home), "app.toml")
appCfg, err := toml.LoadFile(appConfigFilePath)
err := tomlconfig.UpdateFieldInFile(appConfigFilePath, "minimum-gas-prices", value)
if err != nil {
return fmt.Errorf("failed to load %s: %v", appConfigFilePath, err)
return err
}

appCfg.Set("minimum-gas-prices", value)
return nil
}

Expand Down
27 changes: 18 additions & 9 deletions cmd/rollapp/sequencer/metadata/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import (
"github.com/spf13/cobra"

initconfig "github.com/dymensionxyz/roller/cmd/config/init"
"github.com/dymensionxyz/roller/cmd/config/set"
"github.com/dymensionxyz/roller/cmd/consts"
"github.com/dymensionxyz/roller/cmd/tx/tx_utils"
"github.com/dymensionxyz/roller/utils/bash"
"github.com/dymensionxyz/roller/utils/config/tomlconfig"
"github.com/dymensionxyz/roller/utils/filesystem"
"github.com/dymensionxyz/roller/utils/roller"
"github.com/dymensionxyz/roller/utils/sequencer"
sequencerutils "github.com/dymensionxyz/roller/utils/sequencer"
"github.com/dymensionxyz/roller/utils/tx"
)

Expand All @@ -41,7 +41,7 @@ func Cmd() *cobra.Command {
return
}

rollerData, err := roller.LoadConfig(home)
raData, err := roller.LoadConfig(home)
if err != nil {
pterm.Error.Println("failed to load roller config file", err)
return
Expand All @@ -60,18 +60,18 @@ func Cmd() *cobra.Command {
"--from",
consts.KeysIds.HubSequencer,
"--keyring-backend",
string(rollerData.KeyringBackend),
string(raData.KeyringBackend),
"--fees",
fmt.Sprintf("%d%s", consts.DefaultTxFee, consts.Denoms.Hub),
"--gas-adjustment",
"1.3",
"--keyring-dir",
filepath.Join(home, consts.ConfigDirName.HubKeys),
"--node", rollerData.HubData.RpcUrl, "--chain-id", rollerData.HubData.ID,
"--node", raData.HubData.RpcUrl, "--chain-id", raData.HubData.ID,
}
var txHash string

if rollerData.KeyringBackend == consts.SupportedKeyringBackends.OS {
if raData.KeyringBackend == consts.SupportedKeyringBackends.OS {
pswFileName, err := filesystem.GetOsKeyringPswFileName(consts.Executables.Dymension)
if err != nil {
pterm.Error.Println("failed to get os keyring psw file name", err)
Expand Down Expand Up @@ -129,13 +129,13 @@ func Cmd() *cobra.Command {
}
}

err = tx.MonitorTransaction(rollerData.HubData.RpcUrl, txHash)
err = tx.MonitorTransaction(raData.HubData.RpcUrl, txHash)
if err != nil {
pterm.Error.Println("transaction failed", err)
return
}

var seqMetadata sequencer.Metadata
var seqMetadata sequencerutils.Metadata
b, err := os.ReadFile(metadataFilePath)
if err != nil {
pterm.Error.Println("failed to read metadata file: ", err)
Expand All @@ -147,7 +147,16 @@ func Cmd() *cobra.Command {
return
}

err = set.SetMinimumGasPrice(rollerData, seqMetadata.GasPrice)
appConfigFilePath := filepath.Join(
sequencerutils.GetSequencerConfigDir(raData.Home),
"app.toml",
)
pterm.Info.Println("setting minimum gas price in app.toml to", seqMetadata.GasPrice)
err = tomlconfig.UpdateFieldInFile(
appConfigFilePath,
"minimum-gas-prices",
seqMetadata.GasPrice,
)
if err != nil {
pterm.Error.Println("failed to set minimum gas price in app.toml: ", err)
return
Expand Down

0 comments on commit bf91e3f

Please sign in to comment.