diff --git a/cmd/frostfs-adm/README.md b/cmd/frostfs-adm/README.md index f3dbe6950..3dfcc8781 100644 --- a/cmd/frostfs-adm/README.md +++ b/cmd/frostfs-adm/README.md @@ -56,7 +56,8 @@ credentials: # passwords for consensus node / alphabet wallets #### Network deployment - `generate-alphabet` generates a set of wallets for consensus and - Alphabet nodes. + Alphabet nodes. The list of the name for alphabet wallets(no gaps between names allowed, order is important): + - az, buky, vedi, glagoli, dobro, yest, zhivete, dzelo, zemlja, izhe, izhei, gerv, kako, ljudi, mislete, nash, on, pokoj, rtsi, slovo, tverdo, uk - `init` initializes the sidechain by deploying smart contracts and setting provided FrostFS network configuration. diff --git a/cmd/frostfs-adm/docs/deploy.md b/cmd/frostfs-adm/docs/deploy.md index e510f478d..87d2e47c1 100644 --- a/cmd/frostfs-adm/docs/deploy.md +++ b/cmd/frostfs-adm/docs/deploy.md @@ -64,6 +64,11 @@ alphabet-wallets: /home/user/deploy/alphabet-wallets wallet[0]: hunter2 ``` +This command generates wallets with the following names: + - az, buky, vedi, glagoli, dobro, yest, zhivete, dzelo, zemlja, izhe, izhei, gerv, kako, ljudi, mislete, nash, on, pokoj, rtsi, slovo, tverdo, uk + +No gaps between names allowed, order is important. + Do not lose wallet files and network config. Store it in an encrypted backed up storage. diff --git a/cmd/frostfs-adm/internal/modules/morph/helper/util.go b/cmd/frostfs-adm/internal/modules/morph/helper/util.go index ba557a033..ea8266b38 100644 --- a/cmd/frostfs-adm/internal/modules/morph/helper/util.go +++ b/cmd/frostfs-adm/internal/modules/morph/helper/util.go @@ -40,45 +40,48 @@ func openAlphabetWallets(v *viper.Viper, walletDir string) ([]*wallet.Wallet, er return nil, fmt.Errorf("can't read alphabet wallets dir: %w", err) } - var size int -loop: - for i := 0; i < len(walletFiles); i++ { - name := innerring.GlagoliticLetter(i).String() + ".json" - for j := range walletFiles { - if walletFiles[j].Name() == name { - size++ - continue loop - } - } - break - } - if size == 0 { - return nil, errors.New("alphabet wallets dir is empty (run `generate-alphabet` command first)") - } - - wallets := make([]*wallet.Wallet, size) - for i := 0; i < size; i++ { - letter := innerring.GlagoliticLetter(i).String() + var wallets []*wallet.Wallet + var letter string + for i := 0; i < constants.MaxAlphabetNodes; i++ { + letter = innerring.GlagoliticLetter(i).String() p := filepath.Join(walletDir, letter+".json") - w, err := wallet.NewWalletFromFile(p) + var w *wallet.Wallet + w, err = wallet.NewWalletFromFile(p) if err != nil { - return nil, fmt.Errorf("can't open wallet: %w", err) + if errors.Is(err, os.ErrNotExist) { + err = nil + } else { + err = fmt.Errorf("can't open wallet: %w", err) + } + break } - password, err := config.GetPassword(v, letter) + var password string + password, err = config.GetPassword(v, letter) if err != nil { - return nil, fmt.Errorf("can't fetch password: %w", err) + err = fmt.Errorf("can't fetch password: %w", err) + break } for i := range w.Accounts { - if err := w.Accounts[i].Decrypt(password, keys.NEP2ScryptParams()); err != nil { - return nil, fmt.Errorf("can't unlock wallet: %w", err) + if err = w.Accounts[i].Decrypt(password, keys.NEP2ScryptParams()); err != nil { + err = fmt.Errorf("can't unlock wallet: %w", err) + break } } - wallets[i] = w + wallets = append(wallets, w) + } + if err != nil { + return nil, fmt.Errorf("can't read wallet for letter '%s': %w", letter, err) + } + if len(wallets) == 0 { + err = errors.New("there are no alphabet wallets in dir (run `generate-alphabet` command first)") + if len(walletFiles) > 0 { + err = fmt.Errorf("use glagolitic names for wallets(run `print-alphabet`): %w", err) + } + return nil, err } - return wallets, nil }