Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Removed addresses that doesn't require funding from roller config init output #127

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/config/init/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func initializeRollappGenesis(initConfig utils.RollappConfig) error {
relayerBalanceStr := relayerGenesisBalance.String() + initConfig.Denom
rollappConfigDirPath := filepath.Join(initConfig.Home, consts.ConfigDirName.Rollapp)
genesisSequencerAccountCmd := exec.Command(initConfig.RollappBinary, "add-genesis-account",
consts.KeyNames.RollappSequencer, sequencerBalanceStr, "--keyring-backend", "test", "--home", rollappConfigDirPath)
consts.KeysIds.RollappSequencer, sequencerBalanceStr, "--keyring-backend", "test", "--home", rollappConfigDirPath)
_, err := utils.ExecBashCommand(genesisSequencerAccountCmd)
if err != nil {
return err
Expand Down
5 changes: 4 additions & 1 deletion cmd/config/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ func InitCmd() *cobra.Command {
utils.PrettifyErrorIfExists(initializeLightNodeConfig(initConfig))
daAddress, err := utils.GetCelestiaAddress(initConfig.Home)
utils.PrettifyErrorIfExists(err)
addresses[consts.KeyNames.DALightNode] = daAddress
addresses = append(addresses, utils.AddressData{
Addr: daAddress,
Name: consts.KeysIds.DALightNode,
})
utils.PrettifyErrorIfExists(initializeRollappConfig(initConfig))
utils.PrettifyErrorIfExists(initializeRollappGenesis(initConfig))
utils.PrettifyErrorIfExists(utils.WriteConfigToTOML(initConfig))
Expand Down
43 changes: 26 additions & 17 deletions cmd/config/init/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/dymensionxyz/roller/cmd/utils"
)

func generateKeys(rollappConfig utils.RollappConfig) (map[string]string, error) {
func generateKeys(rollappConfig utils.RollappConfig) ([]utils.AddressData, error) {
sequencerAddresses, err := generateSequencersKeys(rollappConfig)
if err != nil {
return nil, err
Expand All @@ -19,12 +19,12 @@ func generateKeys(rollappConfig utils.RollappConfig) (map[string]string, error)
if err != nil {
return nil, err
}
return utils.MergeMaps(sequencerAddresses, relayerAddresses), nil
return append(sequencerAddresses, relayerAddresses...), nil
}

func generateSequencersKeys(initConfig utils.RollappConfig) (map[string]string, error) {
func generateSequencersKeys(initConfig utils.RollappConfig) ([]utils.AddressData, error) {
keys := getSequencerKeysConfig()
addresses := make(map[string]string)
addresses := make([]utils.AddressData, 0)
for _, key := range keys {
var address string
var err error
Expand All @@ -36,7 +36,10 @@ func generateSequencersKeys(initConfig utils.RollappConfig) (map[string]string,
if err != nil {
return nil, err
}
addresses[key.ID] = address
addresses = append(addresses, utils.AddressData{
Addr: address,
Name: key.ID,
})
}
return addresses, nil
}
Expand All @@ -45,13 +48,13 @@ func getSequencerKeysConfig() []utils.CreateKeyConfig {
return []utils.CreateKeyConfig{
{
Dir: consts.ConfigDirName.HubKeys,
ID: consts.KeyNames.HubSequencer,
ID: consts.KeysIds.HubSequencer,
CoinType: consts.CoinTypes.Cosmos,
Prefix: consts.AddressPrefixes.Hub,
},
{
Dir: consts.ConfigDirName.Rollapp,
ID: consts.KeyNames.RollappSequencer,
ID: consts.KeysIds.RollappSequencer,
CoinType: consts.CoinTypes.EVM,
Prefix: consts.AddressPrefixes.Rollapp,
},
Expand All @@ -60,15 +63,15 @@ func getSequencerKeysConfig() []utils.CreateKeyConfig {

func getRelayerKeysConfig(rollappConfig utils.RollappConfig) map[string]utils.CreateKeyConfig {
return map[string]utils.CreateKeyConfig{
consts.KeyNames.RollappRelayer: {
consts.KeysIds.RollappRelayer: {
Dir: path.Join(rollappConfig.Home, consts.ConfigDirName.Relayer),
ID: consts.KeyNames.RollappRelayer,
ID: consts.KeysIds.RollappRelayer,
CoinType: consts.CoinTypes.EVM,
Prefix: consts.AddressPrefixes.Rollapp,
},
consts.KeyNames.HubRelayer: {
consts.KeysIds.HubRelayer: {
Dir: path.Join(rollappConfig.Home, consts.ConfigDirName.Relayer),
ID: consts.KeyNames.HubRelayer,
ID: consts.KeysIds.HubRelayer,
CoinType: consts.CoinTypes.Cosmos,
Prefix: consts.AddressPrefixes.Hub,
},
Expand All @@ -89,11 +92,11 @@ func createAddressBinary(keyConfig utils.CreateKeyConfig, binaryPath string, hom
return utils.ParseAddressFromOutput(out)
}

func generateRelayerKeys(rollappConfig utils.RollappConfig) (map[string]string, error) {
relayerAddresses := make(map[string]string)
func generateRelayerKeys(rollappConfig utils.RollappConfig) ([]utils.AddressData, error) {
relayerAddresses := make([]utils.AddressData, 0)
keys := getRelayerKeysConfig(rollappConfig)
createRollappKeyCmd := getAddRlyKeyCmd(keys[consts.KeyNames.RollappRelayer], rollappConfig.RollappID)
createHubKeyCmd := getAddRlyKeyCmd(keys[consts.KeyNames.HubRelayer], rollappConfig.HubData.ID)
createRollappKeyCmd := getAddRlyKeyCmd(keys[consts.KeysIds.RollappRelayer], rollappConfig.RollappID)
createHubKeyCmd := getAddRlyKeyCmd(keys[consts.KeysIds.HubRelayer], rollappConfig.HubData.ID)
out, err := utils.ExecBashCommand(createRollappKeyCmd)
if err != nil {
return nil, err
Expand All @@ -102,7 +105,10 @@ func generateRelayerKeys(rollappConfig utils.RollappConfig) (map[string]string,
if err != nil {
return nil, err
}
relayerAddresses[consts.KeyNames.RollappRelayer] = relayerRollappAddress
relayerAddresses = append(relayerAddresses, utils.AddressData{
Addr: relayerRollappAddress,
Name: consts.KeysIds.RollappRelayer,
})
out, err = utils.ExecBashCommand(createHubKeyCmd)
if err != nil {
return nil, err
Expand All @@ -111,7 +117,10 @@ func generateRelayerKeys(rollappConfig utils.RollappConfig) (map[string]string,
if err != nil {
return nil, err
}
relayerAddresses[consts.KeyNames.HubRelayer] = relayerHubAddress
relayerAddresses = append(relayerAddresses, utils.AddressData{
Addr: relayerHubAddress,
Name: consts.KeysIds.HubRelayer,
})
return relayerAddresses, err
}

Expand Down
17 changes: 15 additions & 2 deletions cmd/config/init/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,24 @@ package initconfig

import (
"fmt"
"github.com/dymensionxyz/roller/cmd/consts"
"github.com/dymensionxyz/roller/cmd/utils"
)

func printInitOutput(addresses map[string]string, rollappId string) {
func printInitOutput(addresses []utils.AddressData, rollappId string) {
fmt.Printf("💈 RollApp '%s' configuration files have been successfully generated on your local machine. Congratulations!\n\n", rollappId)
utils.PrintAddresses(addresses)
requireFundingKeys := map[string]string{
consts.KeysIds.HubSequencer: "Sequencer",
consts.KeysIds.HubRelayer: "Relayer",
consts.KeysIds.DALightNode: "Celestia",
}
filteredAddresses := make([]utils.AddressData, 0)
for _, address := range addresses {
if newName, ok := requireFundingKeys[address.Name]; ok {
address.Name = newName
filteredAddresses = append(filteredAddresses, address)
}
}
utils.PrintAddresses(filteredAddresses)
fmt.Printf("\n🔔 Please fund these addresses to register and run the rollapp.\n")
}
4 changes: 2 additions & 2 deletions cmd/config/init/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ func addChainsConfig(rollappConfig ChainConfig, hubConfig ChainConfig, relayerHo
ChainConfig: rollappConfig,
GasPrices: "0.0" + rollappConfig.Denom,
ClientType: "01-dymint",
KeyName: consts.KeyNames.RollappRelayer,
KeyName: consts.KeysIds.RollappRelayer,
})

relayerHubConfig := getRelayerFileChainConfig(RelayerChainConfig{
ChainConfig: hubConfig,
GasPrices: "0.0" + hubConfig.Denom,
ClientType: "07-tendermint",
KeyName: consts.KeyNames.HubRelayer,
KeyName: consts.KeysIds.HubRelayer,
})

if err := addChainToRelayer(relayerRollappConfig, relayerHome); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/config/init/rollapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func initializeRollappConfig(initConfig utils.RollappConfig) error {
initRollappCmd := exec.Command(initConfig.RollappBinary, "init", consts.KeyNames.HubSequencer, "--chain-id",
initRollappCmd := exec.Command(initConfig.RollappBinary, "init", consts.KeysIds.HubSequencer, "--chain-id",
initConfig.RollappID, "--home", filepath.Join(initConfig.Home, consts.ConfigDirName.Rollapp))
_, err := utils.ExecBashCommand(initRollappCmd)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var Executables = struct {
Dymension: fmt.Sprintf("%s/dymd", internalBinsDir),
}

var KeyNames = struct {
var KeysIds = struct {
HubSequencer string
RollappSequencer string
RollappRelayer string
Expand Down Expand Up @@ -79,4 +79,4 @@ const DefaultRelayerPath = "hub-rollapp"
const DefaultRollappRPC = "http://localhost:26657"
const DefaultDALCRPC = "http://localhost:26659"
const CelestiaRestApiEndpoint = "https://api-arabica-8.consensus.celestia-arabica.com"
const DefaultCelestiaRPC = "consensus-full-arabica-8.celestia-arabica.com"
const DefaultCelestiaRPC = "consensus-full-arabica-8.celestia-arabica.com"
2 changes: 1 addition & 1 deletion cmd/da-light-client/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func CheckDABalance(config utils.RollappConfig) ([]utils.NotFundedAddressData, e
Address: accData.Address,
CurrentBalance: accData.Balance,
RequiredBalance: lcMinBalance,
KeyName: consts.KeyNames.DALightNode,
KeyName: consts.KeysIds.DALightNode,
Denom: consts.Denoms.Celestia,
})
}
Expand Down
31 changes: 23 additions & 8 deletions cmd/keys/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,41 @@ func Cmd() *cobra.Command {
utils.PrettifyErrorIfExists(err)
daAddr, err := utils.GetCelestiaAddress(rollappConfig.Home)
utils.PrettifyErrorIfExists(err)
addresses := map[string]string{}
addresses[consts.KeyNames.DALightNode] = daAddr
addresses := make([]utils.AddressData, 0)
addresses = append(addresses, utils.AddressData{
Addr: daAddr,
Name: consts.KeysIds.DALightNode,
})
hubSeqAddr, err := utils.GetAddressBinary(utils.GetKeyConfig{
Dir: filepath.Join(rollappConfig.Home, consts.ConfigDirName.HubKeys),
ID: consts.KeyNames.HubSequencer,
ID: consts.KeysIds.HubSequencer,
}, consts.Executables.Dymension)
utils.PrettifyErrorIfExists(err)
addresses[consts.KeyNames.HubSequencer] = hubSeqAddr
addresses = append(addresses, utils.AddressData{
Addr: hubSeqAddr,
Name: consts.KeysIds.HubSequencer,
})
rollappSeqAddr, err := utils.GetAddressBinary(utils.GetKeyConfig{
Dir: filepath.Join(rollappConfig.Home, consts.ConfigDirName.Rollapp),
ID: consts.KeyNames.RollappSequencer,
ID: consts.KeysIds.RollappSequencer,
}, consts.Executables.RollappEVM)
utils.PrettifyErrorIfExists(err)
addresses[consts.KeyNames.RollappSequencer] = rollappSeqAddr
addresses = append(addresses, utils.AddressData{
Addr: rollappSeqAddr,
Name: consts.KeysIds.RollappSequencer,
})
hubRlyAddr, err := utils.GetRelayerAddress(rollappConfig.Home, rollappConfig.HubData.ID)
utils.PrettifyErrorIfExists(err)
addresses[consts.KeyNames.HubRelayer] = hubRlyAddr
addresses = append(addresses, utils.AddressData{
Addr: hubRlyAddr,
Name: consts.KeysIds.HubRelayer,
})
rollappRlyAddr, err := utils.GetRelayerAddress(rollappConfig.Home, rollappConfig.RollappID)
utils.PrettifyErrorIfExists(err)
addresses[consts.KeyNames.RollappRelayer] = rollappRlyAddr
addresses = append(addresses, utils.AddressData{
Addr: rollappRlyAddr,
Name: consts.KeysIds.RollappRelayer,
})
utils.PrintAddresses(addresses)
},
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/register/bash_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func getRegisterSequencerCmd(rollappConfig utils.RollappConfig) (*exec.Cmd, erro
return nil, err
}
description := fmt.Sprintf(`{"Moniker":"%s","Identity":"","Website":"","SecurityContact":"","Details":""}`,
consts.KeyNames.HubSequencer)
consts.KeysIds.HubSequencer)
cmdArgs := []string{
"tx", "sequencer", "create-sequencer",
seqPubKey,
Expand All @@ -57,7 +57,7 @@ func getRegisterSequencerCmd(rollappConfig utils.RollappConfig) (*exec.Cmd, erro
func getCommonDymdTxFlags(rollappConfig utils.RollappConfig) []string {
commonFlags := utils.GetCommonDymdFlags(rollappConfig)
txArgs := []string{
"--from", consts.KeyNames.HubSequencer,
"--from", consts.KeysIds.HubSequencer,
"--keyring-backend", "test",
"--keyring-dir", filepath.Join(rollappConfig.Home, consts.ConfigDirName.HubKeys),
"--yes", "--broadcast-mode", "block", "--chain-id", rollappConfig.HubData.ID,
Expand Down
4 changes: 2 additions & 2 deletions cmd/relayer/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func GetRlyHubInsufficientBalances(config utils.RollappConfig) ([]utils.NotFunde
insufficientBalances := make([]utils.NotFundedAddressData, 0)
if HubRlyBalance.Cmp(oneDayRelayPriceHub) < 0 {
insufficientBalances = append(insufficientBalances, utils.NotFundedAddressData{
KeyName: consts.KeyNames.HubRelayer,
KeyName: consts.KeysIds.HubRelayer,
Address: HubRlyAddr,
CurrentBalance: HubRlyBalance,
RequiredBalance: oneDayRelayPriceHub,
Expand All @@ -110,7 +110,7 @@ func GetRelayerInsufficientBalances(config utils.RollappConfig) ([]utils.NotFund
}
if rolRlyData.Balance.Cmp(oneDayRelayPriceRollapp) < 0 {
insufficientBalances = append(insufficientBalances, utils.NotFundedAddressData{
KeyName: consts.KeyNames.RollappRelayer,
KeyName: consts.KeysIds.RollappRelayer,
Address: rolRlyData.Address,
CurrentBalance: rolRlyData.Balance,
RequiredBalance: oneDayRelayPriceRollapp,
Expand Down
2 changes: 1 addition & 1 deletion cmd/sequencer/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func GetStartRollappCmd(rollappConfig utils.RollappConfig, lightNodeEndpoint str
"--max-log-size", "2000",
"--module-log-level-override", "",
"--dymint.settlement_config.node_address", rollappConfig.HubData.RPC_URL,
"--dymint.settlement_config.dym_account_name", consts.KeyNames.HubSequencer,
"--dymint.settlement_config.dym_account_name", consts.KeysIds.HubSequencer,
"--dymint.settlement_config.keyring_home_dir", hubKeysDir,
"--dymint.settlement_config.gas_fees", "0udym",
"--dymint.settlement_config.gas_prices", "0udym",
Expand Down
2 changes: 1 addition & 1 deletion cmd/utils/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func GetSequencerInsufficientAddrs(config RollappConfig, requiredBalance big.Int
Denom: consts.Denoms.Hub,
CurrentBalance: sequencerData.Balance,
RequiredBalance: &requiredBalance,
KeyName: consts.KeyNames.HubSequencer,
KeyName: consts.KeysIds.HubSequencer,
},
}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/utils/fetch_accounts_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func GetHubRlyAccData(config RollappConfig) (*AccountData, error) {

func GetSequencerData(config RollappConfig) (*AccountData, error) {
sequencerAddress, err := GetAddressBinary(GetKeyConfig{
ID: consts.KeyNames.HubSequencer,
ID: consts.KeysIds.HubSequencer,
Dir: filepath.Join(config.Home, consts.ConfigDirName.HubKeys),
}, consts.Executables.Dymension)
if err != nil {
Expand Down
20 changes: 10 additions & 10 deletions cmd/utils/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func ParseAddressFromOutput(output bytes.Buffer) (string, error) {
func GetCelestiaAddress(rollerRoot string) (string, error) {
daKeysDir := filepath.Join(rollerRoot, consts.ConfigDirName.DALightNode, consts.KeysDirName)
cmd := exec.Command(
consts.Executables.CelKey, "show", consts.KeyNames.DALightNode, "--node.type", "light", "--keyring-dir",
consts.Executables.CelKey, "show", consts.KeysIds.DALightNode, "--node.type", "light", "--keyring-dir",
daKeysDir, "--keyring-backend", "test", "--output", "json",
)
output, err := ExecBashCommand(cmd)
Expand Down Expand Up @@ -84,17 +84,17 @@ func GetRelayerAddress(home string, chainID string) (string, error) {
return strings.TrimSuffix(out.String(), "\n"), err
}

func PrintAddresses(addresses map[string]string) {
fmt.Printf("🔑 Addresses:\n\n")
type AddressData struct {
Name string
Addr string
}

data := [][]string{
{"Celestia", addresses[consts.KeyNames.DALightNode]},
{"Sequencer, Hub", addresses[consts.KeyNames.HubSequencer]},
{"Sequencer, Rollapp", addresses[consts.KeyNames.RollappSequencer]},
{"Relayer, Hub", addresses[consts.KeyNames.HubRelayer]},
{"Relayer, RollApp", addresses[consts.KeyNames.RollappRelayer]},
func PrintAddresses(addresses []AddressData) {
fmt.Printf("🔑 Addresses:\n\n")
data := make([][]string, 0, len(addresses))
for _, address := range addresses {
data = append(data, []string{address.Name, address.Addr})
}

table := tablewriter.NewWriter(os.Stdout)
table.SetAlignment(tablewriter.ALIGN_LEFT)
table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
Expand Down
6 changes: 3 additions & 3 deletions test/config/init/testutils/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func getLightNodeKeysDir(root string) string {

func VerifyLightNodeKeys(root string) error {
lightNodeKeysDir := filepath.Join(getLightNodeKeysDir(root), innerKeysDirName)
infoFilePath := filepath.Join(lightNodeKeysDir, consts.KeyNames.DALightNode+".info")
infoFilePath := filepath.Join(lightNodeKeysDir, consts.KeysIds.DALightNode+".info")
err := verifyFileExists(infoFilePath)
if err != nil {
return err
Expand All @@ -108,15 +108,15 @@ func getRelayerKeysDir(root string) string {
func VerifyRelayerKeys(root string, rollappID string, hubID string) error {
relayerKeysDir := getRelayerKeysDir(root)
rollappKeysDir := filepath.Join(relayerKeysDir, rollappID, innerKeysDirName)
rollappKeyInfoPath := filepath.Join(rollappKeysDir, consts.KeyNames.RollappRelayer+".info")
rollappKeyInfoPath := filepath.Join(rollappKeysDir, consts.KeysIds.RollappRelayer+".info")
if err := verifyFileExists(rollappKeyInfoPath); err != nil {
return err
}
if err := verifyAndRemoveFilePattern(addressPattern, rollappKeysDir); err != nil {
return err
}
hubKeysDir := filepath.Join(relayerKeysDir, hubID, innerKeysDirName)
hubKeyInfoPath := filepath.Join(hubKeysDir, consts.KeyNames.HubRelayer+".info")
hubKeyInfoPath := filepath.Join(hubKeysDir, consts.KeysIds.HubRelayer+".info")
if err := verifyFileExists(hubKeyInfoPath); err != nil {
return err
}
Expand Down
Loading