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