2024-02-02 10:25:04 +03:00
|
|
|
package initialize
|
2021-07-09 12:53:10 +03:00
|
|
|
|
|
|
|
import (
|
2021-07-19 14:04:19 +03:00
|
|
|
"fmt"
|
|
|
|
|
2024-02-02 15:26:57 +03:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
2024-02-02 15:36:14 +03:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/helper"
|
2021-07-09 12:53:10 +03:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
)
|
|
|
|
|
2023-04-26 11:24:40 +03:00
|
|
|
func initializeSideChainCmd(cmd *cobra.Command, _ []string) error {
|
2024-02-02 15:36:14 +03:00
|
|
|
initCtx, err := helper.NewInitializeContext(cmd, viper.GetViper())
|
2021-07-19 14:04:19 +03:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("initialization error: %w", err)
|
|
|
|
}
|
2024-02-01 14:30:59 +03:00
|
|
|
defer initCtx.Close()
|
2021-07-19 14:04:19 +03:00
|
|
|
|
|
|
|
// 1. Transfer funds to committee accounts.
|
|
|
|
cmd.Println("Stage 1: transfer GAS to alphabet nodes.")
|
2024-02-01 14:30:59 +03:00
|
|
|
if err := transferFunds(initCtx); err != nil {
|
2021-07-19 14:04:19 +03:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-07-20 15:08:47 +03:00
|
|
|
cmd.Println("Stage 2: set notary and alphabet nodes in designate contract.")
|
2024-02-01 14:30:59 +03:00
|
|
|
if err := setNotaryAndAlphabetNodes(initCtx); err != nil {
|
2021-07-20 15:08:47 +03:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-07-21 13:09:59 +03:00
|
|
|
// 3. Deploy NNS contract.
|
|
|
|
cmd.Println("Stage 3: deploy NNS contract.")
|
2024-02-02 15:36:14 +03:00
|
|
|
if err := helper.DeployNNS(initCtx, constants.DeployMethodName); err != nil {
|
2021-07-21 13:09:59 +03:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// 4. Deploy NeoFS contracts.
|
|
|
|
cmd.Println("Stage 4: deploy NeoFS contracts.")
|
2024-02-01 14:30:59 +03:00
|
|
|
if err := deployContracts(initCtx); err != nil {
|
2021-07-21 13:09:59 +03:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-07-23 15:07:44 +03:00
|
|
|
cmd.Println("Stage 4.1: Transfer GAS to proxy contract.")
|
2024-02-01 14:30:59 +03:00
|
|
|
if err := transferGASToProxy(initCtx); err != nil {
|
2021-07-23 15:07:44 +03:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-07-22 10:57:11 +03:00
|
|
|
cmd.Println("Stage 5: register candidates.")
|
2024-02-01 14:30:59 +03:00
|
|
|
if err := registerCandidates(initCtx); err != nil {
|
2021-07-22 10:57:11 +03:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd.Println("Stage 6: transfer NEO to alphabet contracts.")
|
2024-02-01 14:30:59 +03:00
|
|
|
if err := transferNEOToAlphabetContracts(initCtx); err != nil {
|
2021-07-22 10:57:11 +03:00
|
|
|
return err
|
|
|
|
}
|
2021-07-19 14:04:19 +03:00
|
|
|
|
2021-07-22 12:52:44 +03:00
|
|
|
cmd.Println("Stage 7: set addresses in NNS.")
|
2024-02-01 14:30:59 +03:00
|
|
|
return setNNS(initCtx)
|
2021-07-09 12:53:10 +03:00
|
|
|
}
|