forked from TrueCloudLab/frostfs-node
Each stage waits until transaction persists. This is needed to ensure the next stage will see the result of the previous one. However, some of the stages do not depend one on another, so we may execute them in parallel. `AwaitDisabled` flag is used to localize this batching on the code level. We could've removed `AwaitTx()` from respective stages, but it seems more error prone. Close #652. Change-Id: Ib9c6f6cd5e0db0f31aa1cda8e127b1fad5166336 Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
65 lines
1.7 KiB
Go
65 lines
1.7 KiB
Go
package initialize
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/helper"
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
func initializeSideChainCmd(cmd *cobra.Command, _ []string) error {
|
|
initCtx, err := helper.NewInitializeContext(cmd, viper.GetViper())
|
|
if err != nil {
|
|
return fmt.Errorf("initialization error: %w", err)
|
|
}
|
|
defer initCtx.Close()
|
|
|
|
// 1. Transfer funds to committee accounts.
|
|
cmd.Println("Stage 1: transfer GAS to alphabet nodes.")
|
|
if err := transferFunds(initCtx); err != nil {
|
|
return err
|
|
}
|
|
|
|
cmd.Println("Stage 2: set notary and alphabet nodes in designate contract.")
|
|
if err := setNotaryAndAlphabetNodes(initCtx); err != nil {
|
|
return err
|
|
}
|
|
|
|
// 3. Deploy NNS contract.
|
|
cmd.Println("Stage 3: deploy NNS contract.")
|
|
if err := helper.DeployNNS(initCtx, constants.DeployMethodName); err != nil {
|
|
return err
|
|
}
|
|
|
|
// 4. Deploy NeoFS contracts.
|
|
cmd.Println("Stage 4: deploy NeoFS contracts.")
|
|
if err := deployContracts(initCtx); err != nil {
|
|
return err
|
|
}
|
|
|
|
initCtx.AwaitDisabled = true
|
|
cmd.Println("Stage 4.1: Transfer GAS to proxy contract.")
|
|
if err := transferGASToProxy(initCtx); err != nil {
|
|
return err
|
|
}
|
|
|
|
cmd.Println("Stage 5: register candidates.")
|
|
if err := registerCandidates(initCtx); err != nil {
|
|
return err
|
|
}
|
|
|
|
cmd.Println("Stage 6: transfer NEO to alphabet contracts.")
|
|
if err := transferNEOToAlphabetContracts(initCtx); err != nil {
|
|
return err
|
|
}
|
|
|
|
cmd.Println("Stage 7: set addresses in NNS.")
|
|
if err := setNNS(initCtx); err != nil {
|
|
return err
|
|
}
|
|
|
|
initCtx.AwaitDisabled = false
|
|
return initCtx.AwaitTx()
|
|
}
|