From b0c360dbef289cf4662eeda3d1bf1c1b346b5b45 Mon Sep 17 00:00:00 2001 From: Itay Date: Tue, 13 Jun 2023 16:32:54 +0200 Subject: [PATCH] fix: Enhance error handling for 'roller register' common flows (#53) --- cmd/config/init/DALightClient.go | 2 +- cmd/config/init/consts.go | 47 +++-------- cmd/config/init/genesis.go | 5 +- cmd/config/init/init.go | 12 +-- cmd/config/init/keys.go | 79 ++++++++----------- cmd/config/init/output.go | 7 +- cmd/config/init/relayer.go | 6 +- cmd/config/init/rollapp.go | 7 +- cmd/config/init/unique_rollapp_id.go | 13 ++- cmd/consts/consts.go | 42 ++++++++++ cmd/register/register.go | 56 ++++++++++--- cmd/utils/keys.go | 46 +++++++++++ cmd/utils/utils.go | 1 + .../init_without_flags/light-node/config.toml | 45 +++++++---- test/config/init/testutils/keys.go | 13 +-- test/config/init/testutils/rollapp.go | 7 +- 16 files changed, 250 insertions(+), 138 deletions(-) create mode 100644 cmd/utils/keys.go diff --git a/cmd/config/init/DALightClient.go b/cmd/config/init/DALightClient.go index 470f89ac..2179b982 100644 --- a/cmd/config/init/DALightClient.go +++ b/cmd/config/init/DALightClient.go @@ -7,7 +7,7 @@ import ( ) func initializeLightNodeConfig(initConfig InitConfig) error { - initLightNodeCmd := exec.Command(consts.Executables.Celestia, "light", "init", "--p2p.network", "arabica", "--node.store", filepath.Join(initConfig.Home, ConfigDirName.DALightNode)) + initLightNodeCmd := exec.Command(consts.Executables.Celestia, "light", "init", "--p2p.network", "arabica", "--node.store", filepath.Join(initConfig.Home, consts.ConfigDirName.DALightNode)) err := initLightNodeCmd.Run() if err != nil { return err diff --git a/cmd/config/init/consts.go b/cmd/config/init/consts.go index 4b8200c2..e27b8c8a 100644 --- a/cmd/config/init/consts.go +++ b/cmd/config/init/consts.go @@ -14,39 +14,6 @@ var FlagNames = struct { HubRPC: "hub-rpc", } -var KeyNames = struct { - HubSequencer string - RollappSequencer string - RollappRelayer string - DALightNode string - HubRelayer string -}{ - HubSequencer: "hub_sequencer", - RollappSequencer: "rollapp_sequencer", - RollappRelayer: "relayer-rollapp-key", - DALightNode: "my-celes-key", - HubRelayer: "relayer-hub-key", -} - -var addressPrefixes = struct { - Hub string - Rollapp string - DA string -}{ - Rollapp: "rol", - Hub: "dym", - DA: "celestia", -} - -var ConfigDirName = struct { - Rollapp string - Relayer string - DALightNode string -}{ - Rollapp: "rollapp", - Relayer: "relayer", - DALightNode: "light-node", -} var HubData = struct { API_URL string @@ -58,9 +25,19 @@ var HubData = struct { RPC_URL: "https://rpc-hub-35c.dymension.xyz:443", } +var Executables = struct { + Celestia string + Rollapp string + Relayer string + Dymension string +}{ + Celestia: "/usr/local/bin/roller_bins/celestia", + Rollapp: "/usr/local/bin/rollapp_evm", + Relayer: "/usr/local/bin/roller_bins/rly", + Dymension: "/usr/local/bin/roller_bins/dymd", +} + const defaultRollappRPC = "http://localhost:26657" -const evmCoinType uint32 = 60 const KeysDirName = "keys" -const cosmosDefaultCointype uint32 = 118 const RollerConfigFileName = "config.toml" diff --git a/cmd/config/init/genesis.go b/cmd/config/init/genesis.go index 9dac28b2..ce07fc35 100644 --- a/cmd/config/init/genesis.go +++ b/cmd/config/init/genesis.go @@ -8,13 +8,14 @@ import ( "path/filepath" "github.com/tidwall/sjson" + "github.com/dymensionxyz/roller/cmd/consts" ) func initializeRollappGenesis(initConfig InitConfig) error { zeros := initConfig.Decimals + 9 tokenAmount := "1" + fmt.Sprintf("%0*d", zeros, 0) + initConfig.Denom - rollappConfigDirPath := filepath.Join(initConfig.Home, ConfigDirName.Rollapp) - genesisSequencerAccountCmd := exec.Command(initConfig.RollappBinary, "add-genesis-account", KeyNames.RollappSequencer, tokenAmount, "--keyring-backend", "test", "--home", rollappConfigDirPath) + rollappConfigDirPath := filepath.Join(initConfig.Home, consts.ConfigDirName.Rollapp) + genesisSequencerAccountCmd := exec.Command(initConfig.RollappBinary, "add-genesis-account", consts.KeyNames.RollappSequencer, tokenAmount, "--keyring-backend", "test", "--home", rollappConfigDirPath) err := genesisSequencerAccountCmd.Run() if err != nil { return err diff --git a/cmd/config/init/init.go b/cmd/config/init/init.go index d8d181df..ceb26746 100644 --- a/cmd/config/init/init.go +++ b/cmd/config/init/init.go @@ -1,11 +1,11 @@ package initconfig import ( - "fmt" "os" "github.com/spf13/cobra" "github.com/dymensionxyz/roller/cmd/utils" + "github.com/dymensionxyz/roller/cmd/consts" ) type InitConfig struct { @@ -24,11 +24,7 @@ func InitCmd() *cobra.Command { Short: "Initialize a RollApp configuration on your local machine.", Run: func(cmd *cobra.Command, args []string) { initConfig := GetInitConfig(cmd, args) - isUniqueRollapp, err := isRollappIDUnique(initConfig.RollappID) - utils.PrettifyErrorIfExists(err) - if !isUniqueRollapp { - utils.PrettifyErrorIfExists(fmt.Errorf("Rollapp ID %s already exists on the hub. Please use a unique ID.", initConfig.RollappID)) - } + utils.PrettifyErrorIfExists(VerifyUniqueRollappID(initConfig.RollappID)) isRootExist, err := dirNotEmpty(initConfig.Home) utils.PrettifyErrorIfExists(err) if isRootExist { @@ -51,12 +47,12 @@ func InitCmd() *cobra.Command { ID: initConfig.RollappID, RPC: defaultRollappRPC, Denom: initConfig.Denom, - AddressPrefix: addressPrefixes.Rollapp, + AddressPrefix: consts.AddressPrefixes.Rollapp, }, ChainConfig{ ID: HubData.ID, RPC: cmd.Flag(FlagNames.HubRPC).Value.String(), Denom: "udym", - AddressPrefix: addressPrefixes.Hub, + AddressPrefix: consts.AddressPrefixes.Hub, }, initConfig)) utils.PrettifyErrorIfExists(WriteConfigToTOML(initConfig)) printInitOutput(addresses, initConfig.RollappID) diff --git a/cmd/config/init/keys.go b/cmd/config/init/keys.go index e287a301..878a0ff1 100644 --- a/cmd/config/init/keys.go +++ b/cmd/config/init/keys.go @@ -6,18 +6,10 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" - "github.com/cosmos/cosmos-sdk/types/bech32" + "github.com/dymensionxyz/roller/cmd/consts" + "github.com/dymensionxyz/roller/cmd/utils" ) -func keyInfoToBech32Address(info keyring.Info, prefix string) (string, error) { - pk := info.GetPubKey() - bech32Address, err := bech32.ConvertAndEncode(prefix, pk.Bytes()) - if err != nil { - return "", err - } - return bech32Address, nil -} - func generateKeys(initConfig InitConfig, excludeKeys ...string) (map[string]string, error) { keys := getDefaultKeysConfig(initConfig) excludeKeysMap := make(map[string]struct{}) @@ -26,77 +18,70 @@ func generateKeys(initConfig InitConfig, excludeKeys ...string) (map[string]stri } addresses := make(map[string]string) for _, key := range keys { - if _, exists := excludeKeysMap[key.keyId]; !exists { + if _, exists := excludeKeysMap[key.ID]; !exists { keyInfo, err := createKey(key, initConfig.Home) if err != nil { return nil, err } - formattedAddress, err := keyInfoToBech32Address(keyInfo, key.prefix) + formattedAddress, err := utils.KeyInfoToBech32Address(keyInfo, key.Prefix) if err != nil { return nil, err } - addresses[key.keyId] = formattedAddress + addresses[key.ID] = formattedAddress } } return addresses, nil } -type KeyConfig struct { - dir string - keyId string - coinType uint32 - prefix string -} - -func createKey(keyConfig KeyConfig, home string) (keyring.Info, error) { +func createKey(keyConfig utils.KeyConfig, home string) (keyring.Info, error) { kr, err := keyring.New( "", keyring.BackendTest, - filepath.Join(home, keyConfig.dir), + filepath.Join(home, keyConfig.Dir), nil, ) if err != nil { return nil, err } - bip44Params := hd.NewFundraiserParams(0, keyConfig.coinType, 0) - info, _, err := kr.NewMnemonic(keyConfig.keyId, keyring.English, bip44Params.String(), "", hd.Secp256k1) + bip44Params := hd.NewFundraiserParams(0, keyConfig.CoinType, 0) + info, _, err := kr.NewMnemonic(keyConfig.ID, keyring.English, bip44Params.String(), "", hd.Secp256k1) if err != nil { return nil, err } return info, nil } -func getDefaultKeysConfig(initConfig InitConfig) []KeyConfig { - return []KeyConfig{ +func getDefaultKeysConfig(initConfig InitConfig) []utils.KeyConfig { + return []utils.KeyConfig{ { - dir: ConfigDirName.Rollapp, - keyId: KeyNames.HubSequencer, - coinType: cosmosDefaultCointype, - prefix: addressPrefixes.Hub, + Dir: consts.ConfigDirName.Rollapp, + ID: consts.KeyNames.HubSequencer, + CoinType: consts.CoinTypes.Cosmos, + Prefix: consts.AddressPrefixes.Hub, }, { - dir: ConfigDirName.Rollapp, - keyId: KeyNames.RollappSequencer, - coinType: evmCoinType, - prefix: addressPrefixes.Rollapp, + Dir: consts.ConfigDirName.Rollapp, + ID: consts.KeyNames.RollappSequencer, + CoinType: consts.CoinTypes.EVM, + Prefix: consts.AddressPrefixes.Rollapp, }, { - dir: path.Join(ConfigDirName.Relayer, KeysDirName, HubData.ID), - keyId: KeyNames.HubRelayer, - coinType: cosmosDefaultCointype, - prefix: addressPrefixes.Hub, + Dir: path.Join(consts.ConfigDirName.Relayer, KeysDirName, HubData.ID), + ID: consts.KeyNames.HubRelayer, + CoinType: consts.CoinTypes.Cosmos, + Prefix: consts.AddressPrefixes.Hub, }, { - dir: path.Join(ConfigDirName.Relayer, KeysDirName, initConfig.RollappID), - keyId: KeyNames.RollappRelayer, - coinType: evmCoinType, - prefix: addressPrefixes.Rollapp, + Dir: path.Join(consts.ConfigDirName.Relayer, KeysDirName, initConfig.RollappID), + ID: consts.KeyNames.RollappRelayer, + CoinType: consts.CoinTypes.EVM, + Prefix: consts.AddressPrefixes.Rollapp, }, { - dir: path.Join(ConfigDirName.DALightNode, KeysDirName), - keyId: KeyNames.DALightNode, - coinType: cosmosDefaultCointype, - prefix: addressPrefixes.DA, + Dir: path.Join(consts.ConfigDirName.DALightNode, KeysDirName), + ID: consts.KeyNames.DALightNode, + CoinType: consts.CoinTypes.Cosmos, + Prefix: consts.AddressPrefixes.DA, }, } } @@ -109,7 +94,7 @@ func initializeKeys(initConfig InitConfig) map[string]string { } return addresses } else { - addresses, err := generateKeys(initConfig, KeyNames.DALightNode) + addresses, err := generateKeys(initConfig, consts.KeyNames.DALightNode) if err != nil { panic(err) } diff --git a/cmd/config/init/output.go b/cmd/config/init/output.go index 933dd697..41a6ef8f 100644 --- a/cmd/config/init/output.go +++ b/cmd/config/init/output.go @@ -5,6 +5,7 @@ import ( "os" "github.com/olekukonko/tablewriter" + "github.com/dymensionxyz/roller/cmd/consts" ) func printInitOutput(addresses map[string]string, rollappId string) { @@ -13,9 +14,9 @@ func printInitOutput(addresses map[string]string, rollappId string) { fmt.Printf("🔑 Addresses:\n\n") data := [][]string{ - {"Celestia", addresses[KeyNames.DALightNode]}, - {"Sequencer", addresses[KeyNames.HubSequencer]}, - {"Relayer", addresses[KeyNames.HubRelayer]}, + {"Celestia", addresses[consts.KeyNames.DALightNode]}, + {"Sequencer", addresses[consts.KeyNames.HubSequencer]}, + {"Relayer", addresses[consts.KeyNames.HubRelayer]}, } table := tablewriter.NewWriter(os.Stdout) diff --git a/cmd/config/init/relayer.go b/cmd/config/init/relayer.go index a022047c..b738d6c7 100644 --- a/cmd/config/init/relayer.go +++ b/cmd/config/init/relayer.go @@ -97,14 +97,14 @@ func addChainsConfig(rollappConfig ChainConfig, hubConfig ChainConfig, relayerHo ChainConfig: rollappConfig, GasPrices: "0.0" + rollappConfig.Denom, ClientType: "01-dymint", - KeyName: KeyNames.RollappRelayer, + KeyName: consts.KeyNames.RollappRelayer, }) relayerHubConfig := getRelayerFileChainConfig(RelayerChainConfig{ ChainConfig: hubConfig, GasPrices: "0.25" + hubConfig.Denom, ClientType: "07-tendermint", - KeyName: KeyNames.HubRelayer, + KeyName: consts.KeyNames.HubRelayer, }) if err := addChainToRelayer(relayerRollappConfig, relayerHome); err != nil { @@ -130,7 +130,7 @@ func setupPath(rollappConfig ChainConfig, hubConfig ChainConfig, relayerHome str } func initializeRelayerConfig(rollappConfig ChainConfig, hubConfig ChainConfig, initConfig InitConfig) error { - relayerHome := filepath.Join(initConfig.Home, ConfigDirName.Relayer) + relayerHome := filepath.Join(initConfig.Home, consts.ConfigDirName.Relayer) if err := initRelayer(relayerHome); err != nil { return err } diff --git a/cmd/config/init/rollapp.go b/cmd/config/init/rollapp.go index 968d2b50..44052187 100644 --- a/cmd/config/init/rollapp.go +++ b/cmd/config/init/rollapp.go @@ -6,15 +6,16 @@ import ( "path/filepath" toml "github.com/pelletier/go-toml" + "github.com/dymensionxyz/roller/cmd/consts" ) func initializeRollappConfig(initConfig InitConfig) { - initRollappCmd := exec.Command(initConfig.RollappBinary, "init", KeyNames.HubSequencer, "--chain-id", initConfig.RollappID, "--home", filepath.Join(initConfig.Home, ConfigDirName.Rollapp)) + initRollappCmd := exec.Command(initConfig.RollappBinary, "init", consts.KeyNames.HubSequencer, "--chain-id", initConfig.RollappID, "--home", filepath.Join(initConfig.Home, consts.ConfigDirName.Rollapp)) err := initRollappCmd.Run() if err != nil { panic(err) } - setRollappAppConfig(filepath.Join(initConfig.Home, ConfigDirName.Rollapp, "config/app.toml"), initConfig.Denom) + setRollappAppConfig(filepath.Join(initConfig.Home, consts.ConfigDirName.Rollapp, "config/app.toml"), initConfig.Denom) } func setRollappAppConfig(appConfigFilePath string, denom string) { @@ -30,5 +31,5 @@ func setRollappAppConfig(appConfigFilePath string, denom string) { } func RollappConfigDir(root string) string { - return filepath.Join(root, ConfigDirName.Rollapp, "config") + return filepath.Join(root, consts.ConfigDirName.Rollapp, "config") } diff --git a/cmd/config/init/unique_rollapp_id.go b/cmd/config/init/unique_rollapp_id.go index 134c1bb2..4f18726a 100644 --- a/cmd/config/init/unique_rollapp_id.go +++ b/cmd/config/init/unique_rollapp_id.go @@ -5,7 +5,7 @@ import ( "net/http" ) -func isRollappIDUnique(rollappID string) (bool, error) { +func IsRollappIDUnique(rollappID string) (bool, error) { url := HubData.API_URL + "/dymensionxyz/dymension/rollapp/rollapp/" + rollappID req, err := http.NewRequest("GET", url, nil) @@ -30,3 +30,14 @@ func isRollappIDUnique(rollappID string) (bool, error) { return false, fmt.Errorf("unexpected status code: %d", resp.StatusCode) } } + +func VerifyUniqueRollappID(rollappID string) error { + isUniqueRollapp, err := IsRollappIDUnique(rollappID) + if err != nil { + return err + } + if !isUniqueRollapp { + return fmt.Errorf("Rollapp ID \"%s\" already exists on the hub. Please use a unique ID.", rollappID) + } + return nil +} diff --git a/cmd/consts/consts.go b/cmd/consts/consts.go index 47c59c89..44f244fc 100644 --- a/cmd/consts/consts.go +++ b/cmd/consts/consts.go @@ -11,3 +11,45 @@ var Executables = struct { Relayer: "/usr/local/bin/roller_bins/rly", Dymension: "/usr/local/bin/roller_bins/dymd", } + +var KeyNames = struct { + HubSequencer string + RollappSequencer string + RollappRelayer string + DALightNode string + HubRelayer string +}{ + HubSequencer: "hub_sequencer", + RollappSequencer: "rollapp_sequencer", + RollappRelayer: "relayer-rollapp-key", + DALightNode: "my-celes-key", + HubRelayer: "relayer-hub-key", +} + +var AddressPrefixes = struct { + Hub string + Rollapp string + DA string +}{ + Rollapp: "rol", + Hub: "dym", + DA: "celestia", +} + +var ConfigDirName = struct { + Rollapp string + Relayer string + DALightNode string +}{ + Rollapp: "rollapp", + Relayer: "relayer", + DALightNode: "light-node", +} + +var CoinTypes = struct { + Cosmos uint32 + EVM uint32 +}{ + Cosmos: 118, + EVM: 60, +} diff --git a/cmd/register/register.go b/cmd/register/register.go index 118998cd..5056ddd1 100644 --- a/cmd/register/register.go +++ b/cmd/register/register.go @@ -2,9 +2,14 @@ package register import ( "bytes" + "errors" "os/exec" "path/filepath" + "fmt" + + "strings" + initconfig "github.com/dymensionxyz/roller/cmd/config/init" "github.com/dymensionxyz/roller/cmd/consts" "github.com/dymensionxyz/roller/cmd/utils" @@ -19,6 +24,7 @@ func RegisterCmd() *cobra.Command { home := cmd.Flag(initconfig.FlagNames.Home).Value.String() rollappConfig, err := initconfig.LoadConfigFromTOML(home) utils.PrettifyErrorIfExists(err) + utils.PrettifyErrorIfExists(initconfig.VerifyUniqueRollappID(rollappConfig.RollappID)) utils.PrettifyErrorIfExists(registerRollapp(rollappConfig)) }, } @@ -31,18 +37,50 @@ func addFlags(cmd *cobra.Command) { } func registerRollapp(rollappConfig initconfig.InitConfig) error { - cmd := exec.Command( + cmd := getRegisterRollappCmd(rollappConfig) + var stdout bytes.Buffer + var stderr bytes.Buffer + cmd.Stdout = &stdout + cmd.Stderr = &stderr + cmdExecErr := cmd.Run() + if err := handleStdErr(stderr, rollappConfig); err != nil { + return err + } + if cmdExecErr != nil { + return cmdExecErr + } + return nil +} + +func handleStdErr(stderr bytes.Buffer, rollappConfig initconfig.InitConfig) error { + stderrStr := stderr.String() + if len(stderrStr) > 0 { + if strings.Contains(stderrStr, "key not found") { + sequencerAddress, err := utils.GetAddress( + utils.KeyConfig{ + ID: consts.KeyNames.HubSequencer, + Prefix: consts.AddressPrefixes.Hub, + Dir: filepath.Join(rollappConfig.Home, consts.ConfigDirName.Rollapp), + CoinType: consts.CoinTypes.Cosmos, + }, + ) + if err != nil { + return err + } + return fmt.Errorf("Insufficient funds in the sequencer's address to register the RollApp. Please deposit DYM to the following address: %s and attempt the registration again", sequencerAddress) + } + return errors.New(stderrStr) + } + return nil +} + +func getRegisterRollappCmd(rollappConfig initconfig.InitConfig) *exec.Cmd { + return exec.Command( consts.Executables.Dymension, "tx", "rollapp", "create-rollapp", - "--from", initconfig.KeyNames.HubSequencer, + "--from", consts.KeyNames.HubSequencer, "--keyring-backend", "test", - "--keyring-dir", filepath.Join(rollappConfig.Home, initconfig.ConfigDirName.Rollapp), + "--keyring-dir", filepath.Join(rollappConfig.Home, consts.ConfigDirName.Rollapp), rollappConfig.RollappID, "stamp1", "genesis-path/1", "3", "3", `{"Addresses":[]}`, "--output", "json", "--node", initconfig.HubData.RPC_URL, "--yes", "--broadcast-mode", "block", ) - var stdout bytes.Buffer - var stderr bytes.Buffer - cmd.Stdout = &stdout - cmd.Stderr = &stderr - error := cmd.Run() - return error } diff --git a/cmd/utils/keys.go b/cmd/utils/keys.go new file mode 100644 index 00000000..a6a2a4f3 --- /dev/null +++ b/cmd/utils/keys.go @@ -0,0 +1,46 @@ +package utils + +import ( + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/bech32" +) + +type KeyConfig struct { + Dir string + ID string + CoinType uint32 + Prefix string +} + +func KeyInfoToBech32Address(info keyring.Info, prefix string) (string, error) { + pk := info.GetPubKey() + addr := types.AccAddress(pk.Address()) + bech32Address, err := bech32.ConvertAndEncode(prefix, addr.Bytes()) + if err != nil { + return "", err + } + return bech32Address, nil +} + +func GetAddress(keyConfig KeyConfig) (string, error) { + kr, err := keyring.New( + "", + keyring.BackendTest, + keyConfig.Dir, + nil, + ) + if err != nil { + return "", err + } + keyInfo, err := kr.Key(keyConfig.ID) + if err != nil { + return "", err + } + formattedAddress, err := KeyInfoToBech32Address(keyInfo, keyConfig.Prefix) + if err != nil { + return "", err + } + + return formattedAddress, nil +} diff --git a/cmd/utils/utils.go b/cmd/utils/utils.go index 19e1b1ec..53874693 100644 --- a/cmd/utils/utils.go +++ b/cmd/utils/utils.go @@ -8,3 +8,4 @@ import ( func GetRollerRootDir() string { return filepath.Join(os.Getenv("HOME"), ".roller") } + diff --git a/test/config/init/goldens/init_without_flags/light-node/config.toml b/test/config/init/goldens/init_without_flags/light-node/config.toml index 35cf1194..5e9f1c04 100644 --- a/test/config/init/goldens/init_without_flags/light-node/config.toml +++ b/test/config/init/goldens/init_without_flags/light-node/config.toml @@ -5,12 +5,12 @@ [State] KeyringAccName = "" + KeyringBackend = "test" [P2P] ListenAddresses = ["/ip4/0.0.0.0/udp/2121/quic-v1", "/ip6/::/udp/2121/quic-v1", "/ip4/0.0.0.0/tcp/2121", "/ip6/::/tcp/2121"] AnnounceAddresses = [] NoAnnounceAddresses = ["/ip4/0.0.0.0/udp/2121/quic-v1", "/ip4/127.0.0.1/udp/2121/quic-v1", "/ip6/::/udp/2121/quic-v1", "/ip4/0.0.0.0/tcp/2121", "/ip4/127.0.0.1/tcp/2121", "/ip6/::/tcp/2121"] - Bootstrapper = false MutualPeers = [] PeerExchange = false RoutingTableRefreshPeriod = "1m0s" @@ -29,9 +29,28 @@ Enabled = false [Share] - PeersLimit = 3 - DiscoveryInterval = "30s" - AdvertiseInterval = "30s" + UseShareExchange = true + [Share.ShrExEDSParams] + ServerReadTimeout = "5s" + ServerWriteTimeout = "1m0s" + HandleRequestTimeout = "1m0s" + ConcurrencyLimit = 10 + BufferSize = 32768 + [Share.ShrExNDParams] + ServerReadTimeout = "5s" + ServerWriteTimeout = "1m0s" + HandleRequestTimeout = "1m0s" + ConcurrencyLimit = 10 + [Share.PeerManagerParams] + PoolValidationTimeout = "2m0s" + PeerCooldown = "3s" + GcInterval = "30s" + EnableBlackListing = false + [Share.LightAvailability] + SampleAmount = 16 + [Share.Discovery] + PeersLimit = 5 + AdvertiseInterval = "22h0m0s" [Header] TrustedHash = "" @@ -42,25 +61,17 @@ WriteBatchSize = 2048 [Header.Syncer] TrustingPeriod = "168h0m0s" - MaxRequestSize = 512 [Header.Server] - WriteDeadline = "5s" + WriteDeadline = "8s" ReadDeadline = "1m0s" - MaxRequestSize = 512 - RequestTimeout = "5s" + RangeRequestTimeout = "10s" [Header.Client] - MinResponses = 2 - MaxRequestSize = 512 - MaxHeadersPerRequest = 64 - MaxAwaitingTime = "1h0m0s" - DefaultScore = 1.0 - RequestTimeout = "3s" - MaxPeerTrackerSize = 100 + MaxHeadersPerRangeRequest = 64 + RangeRequestTimeout = "8s" [DASer] SamplingRange = 100 ConcurrencyLimit = 16 BackgroundStoreInterval = "10m0s" - PriorityQueueSize = 64 SampleFrom = 1 - SampleTimeout = "1m0s" + SampleTimeout = "4m0s" diff --git a/test/config/init/testutils/keys.go b/test/config/init/testutils/keys.go index 2c135640..0f5db9c7 100644 --- a/test/config/init/testutils/keys.go +++ b/test/config/init/testutils/keys.go @@ -8,7 +8,8 @@ import ( "path/filepath" "regexp" - + "github.com/dymensionxyz/roller/cmd/consts" + initconfig "github.com/dymensionxyz/roller/cmd/config/init" ) @@ -80,12 +81,12 @@ func verifyAndRemoveFilePattern(pattern string, dir string) error { } func getLightNodeKeysDir(root string) string { - return filepath.Join(root, initconfig.ConfigDirName.DALightNode, initconfig.KeysDirName) + return filepath.Join(root, consts.ConfigDirName.DALightNode, initconfig.KeysDirName) } func VerifyLightNodeKeys(root string) error { lightNodeKeysDir := filepath.Join(getLightNodeKeysDir(root), innerKeysDirName) - infoFilePath := filepath.Join(lightNodeKeysDir, initconfig.KeyNames.DALightNode+".info") + infoFilePath := filepath.Join(lightNodeKeysDir, consts.KeyNames.DALightNode+".info") err := verifyFileExists(infoFilePath) if err != nil { return err @@ -94,13 +95,13 @@ func VerifyLightNodeKeys(root string) error { } func getRelayerKeysDir(root string) string { - return filepath.Join(root, initconfig.ConfigDirName.Relayer, initconfig.KeysDirName) + return filepath.Join(root, consts.ConfigDirName.Relayer, initconfig.KeysDirName) } func VerifyRelayerKeys(root string, rollappID string, hubID string) error { relayerKeysDir := getRelayerKeysDir(root) rollappKeysDir := filepath.Join(relayerKeysDir, rollappID, innerKeysDirName) - rollappKeyInfoPath := filepath.Join(rollappKeysDir, initconfig.KeyNames.RollappRelayer+".info") + rollappKeyInfoPath := filepath.Join(rollappKeysDir, consts.KeyNames.RollappRelayer+".info") if err := verifyFileExists(rollappKeyInfoPath); err != nil { return err } @@ -108,7 +109,7 @@ func VerifyRelayerKeys(root string, rollappID string, hubID string) error { return err } hubKeysDir := filepath.Join(relayerKeysDir, hubID, innerKeysDirName) - hubKeyInfoPath := filepath.Join(hubKeysDir, initconfig.KeyNames.HubRelayer+".info") + hubKeyInfoPath := filepath.Join(hubKeysDir, consts.KeyNames.HubRelayer+".info") if err := verifyFileExists(hubKeyInfoPath); err != nil { return err } diff --git a/test/config/init/testutils/rollapp.go b/test/config/init/testutils/rollapp.go index 6820caa0..e7e01151 100644 --- a/test/config/init/testutils/rollapp.go +++ b/test/config/init/testutils/rollapp.go @@ -6,19 +6,20 @@ import ( "errors" initconfig "github.com/dymensionxyz/roller/cmd/config/init" + "github.com/dymensionxyz/roller/cmd/consts" ) func getRollappKeysDir(root string) string { - return filepath.Join(root, initconfig.ConfigDirName.Rollapp, innerKeysDirName) + return filepath.Join(root, consts.ConfigDirName.Rollapp, innerKeysDirName) } func VerifyRollappKeys(root string) error { rollappKeysDir := getRollappKeysDir(root) - sequencerKeyInfoPath := filepath.Join(rollappKeysDir, initconfig.KeyNames.RollappSequencer+".info") + sequencerKeyInfoPath := filepath.Join(rollappKeysDir, consts.KeyNames.RollappSequencer+".info") if err := verifyFileExists(sequencerKeyInfoPath); err != nil { return err } - relayerKeyInfoPath := filepath.Join(rollappKeysDir, initconfig.KeyNames.HubSequencer+".info") + relayerKeyInfoPath := filepath.Join(rollappKeysDir, consts.KeyNames.HubSequencer+".info") if err := verifyFileExists(relayerKeyInfoPath); err != nil { return err }