Skip to content

Commit

Permalink
fix: add genesis account to genesis file (#815)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemijspavlovs authored Jul 16, 2024
1 parent db2fd80 commit 2eb6a09
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
27 changes: 22 additions & 5 deletions cmd/config/init/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/dymensionxyz/roller/cmd/consts"
"github.com/dymensionxyz/roller/cmd/utils"
"github.com/dymensionxyz/roller/config"
)

const (
Expand All @@ -33,11 +34,6 @@ func getDefaultGenesisParams(
) []PathValue {
return []PathValue{
// these should be injected from the genesis creator
// {"app_state.mint.params.mint_denom", denom},
// {"app_state.staking.params.bond_denom", denom},
// {"app_state.crisis.constant_fee.denom", denom},
// {"app_state.evm.params.evm_denom", denom},
// {"app_state.gov.deposit_params.min_deposit.0.denom", denom},
// {"consensus_params.block.max_gas", "40000000"},
// {"app_state.feemarket.params.no_base_fee", true},
// {"app_state.feemarket.params.min_gas_price", "0.0"},
Expand Down Expand Up @@ -82,13 +78,34 @@ func UpdateGenesisParams(home string) error {
if err != nil {
return err
}
cfg, err := config.LoadConfigFromTOML(home)
if err != nil {
return err
}

sa, err := getSequencerAddress(home)
if err != nil {
return err
}
params := getDefaultGenesisParams(sa, oa)

addGenAccountCmd := exec.Command(
consts.Executables.RollappEVM,
"add-genesis-account",
sa,
fmt.Sprintf("%s%s", consts.DefaultTokenSupply, cfg.BaseDenom),
"--home",
fmt.Sprintf("%s/%s", home, consts.ConfigDirName.Rollapp),
"--keyring-backend",
"test",
)

fmt.Println(addGenAccountCmd.String())
_, err = utils.ExecBashCommandWithStdout(addGenAccountCmd)
if err != nil {
return err
}

genesisFilePath := filepath.Join(home, consts.ConfigDirName.Rollapp, "config", "genesis.json")
return UpdateJSONParams(genesisFilePath, params)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/config/init/local_hub.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package initconfig

//
// import (
// "fmt"
// "os/exec"
// "path/filepath"
//
// "github.com/pelletier/go-toml"
//
// "github.com/dymensionxyz/roller/cmd/consts"
// "github.com/dymensionxyz/roller/cmd/utils"
// "github.com/dymensionxyz/roller/config"
// global_utils "github.com/dymensionxyz/roller/utils"
// "github.com/pelletier/go-toml"
// )
//
// const validatorKeyID = "local-user"
Expand Down
3 changes: 2 additions & 1 deletion cmd/keys/keys.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package keys

import (
"github.com/spf13/cobra"

"github.com/dymensionxyz/roller/cmd/keys/export"
"github.com/dymensionxyz/roller/cmd/keys/list"
"github.com/spf13/cobra"
)

func Cmd() *cobra.Command {
Expand Down
8 changes: 4 additions & 4 deletions cmd/rollapp/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"math/big"
"os/exec"
"path/filepath"
"strings"

Expand Down Expand Up @@ -35,15 +36,13 @@ func Cmd() *cobra.Command {
seq := sequencer.GetInstance(rollappConfig)
startRollappCmd := seq.GetStartCmd()

c := seq.GetStartCmd()
fmt.Println(c.String())
LogPath = filepath.Join(rollappConfig.Home, consts.ConfigDirName.Rollapp, "rollapp.log")
RollappDirPath = filepath.Join(rollappConfig.Home, consts.ConfigDirName.Rollapp)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
go utils.RunBashCmdAsync(ctx, startRollappCmd, func() {
printOutput(rollappConfig)
printOutput(rollappConfig, startRollappCmd)
}, parseError,
utils.WithLogging(utils.GetSequencerLogPath(rollappConfig)))
select {}
Expand All @@ -52,7 +51,7 @@ func Cmd() *cobra.Command {
return cmd
}

func printOutput(rlpCfg config.RollappConfig) {
func printOutput(rlpCfg config.RollappConfig, cmd *exec.Cmd) {
seq := sequencer.GetInstance(rlpCfg)
fmt.Println("πŸ’ˆ The Rollapp sequencer is running on your local machine!")
fmt.Println("πŸ’ˆ Endpoints:")
Expand All @@ -63,6 +62,7 @@ func printOutput(rlpCfg config.RollappConfig) {

fmt.Println("πŸ’ˆ Log file path: ", LogPath)
fmt.Println("πŸ’ˆ Rollapp root dir: ", RollappDirPath)
fmt.Println("πŸ’ˆ PID: ", cmd.Process.Pid)
}

func parseError(errMsg string) string {
Expand Down

0 comments on commit 2eb6a09

Please sign in to comment.