[#932] adm: Move const
to package constants
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
814c411f4a
commit
e2cee4cf09
29 changed files with 140 additions and 114 deletions
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/config"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/config"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||||
parseutil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/util"
|
parseutil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/modules/util"
|
||||||
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
|
@ -86,7 +87,7 @@ func newPolicyContractInterface(cmd *cobra.Command) (*morph.ContractStorage, *ac
|
||||||
wallets, err := morphUtil.GetAlphabetWallets(v, walletDir)
|
wallets, err := morphUtil.GetAlphabetWallets(v, walletDir)
|
||||||
commonCmd.ExitOnErr(cmd, "unable to get alphabet wallets: %w", err)
|
commonCmd.ExitOnErr(cmd, "unable to get alphabet wallets: %w", err)
|
||||||
|
|
||||||
committeeAcc, err := morphUtil.GetWalletAccount(wallets[0], morphUtil.CommitteeAccountName)
|
committeeAcc, err := morphUtil.GetWalletAccount(wallets[0], constants.CommitteeAccountName)
|
||||||
commonCmd.ExitOnErr(cmd, "can't find committee account: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't find committee account: %w", err)
|
||||||
|
|
||||||
ac, err := morphUtil.NewActor(c, committeeAcc)
|
ac, err := morphUtil.NewActor(c, committeeAcc)
|
||||||
|
@ -98,7 +99,7 @@ func newPolicyContractInterface(cmd *cobra.Command) (*morph.ContractStorage, *ac
|
||||||
nnsCs, err := r.GetContractByID(1)
|
nnsCs, err := r.GetContractByID(1)
|
||||||
commonCmd.ExitOnErr(cmd, "can't get NNS contract state: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't get NNS contract state: %w", err)
|
||||||
|
|
||||||
ch, err = morphUtil.NNSResolveHash(inv, nnsCs.Hash, morphUtil.DomainOf(morphUtil.PolicyContract))
|
ch, err = morphUtil.NNSResolveHash(inv, nnsCs.Hash, morphUtil.DomainOf(constants.PolicyContract))
|
||||||
commonCmd.ExitOnErr(cmd, "unable to resolve policy contract hash: %w", err)
|
commonCmd.ExitOnErr(cmd, "unable to resolve policy contract hash: %w", err)
|
||||||
|
|
||||||
return morph.NewContractStorage(ac, ch), ac
|
return morph.NewContractStorage(ac, ch), ac
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/native/noderoles"
|
"github.com/nspcc-dev/neo-go/pkg/core/native/noderoles"
|
||||||
|
@ -64,7 +65,7 @@ func dumpBalances(cmd *cobra.Command, _ []string) error {
|
||||||
return fmt.Errorf("can't get NNS contract info: %w", err)
|
return fmt.Errorf("can't get NNS contract info: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
nmHash, err = morphUtil.NNSResolveHash(inv, nnsCs.Hash, morphUtil.DomainOf(morphUtil.NetmapContract))
|
nmHash, err = morphUtil.NNSResolveHash(inv, nnsCs.Hash, morphUtil.DomainOf(constants.NetmapContract))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't get netmap contract hash: %w", err)
|
return fmt.Errorf("can't get netmap contract hash: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -137,7 +138,7 @@ func printStorageNodeBalances(cmd *cobra.Command, inv *invoker.Invoker, nmHash u
|
||||||
}
|
}
|
||||||
|
|
||||||
func printProxyContractBalance(cmd *cobra.Command, inv *invoker.Invoker, nnsHash util.Uint160) error {
|
func printProxyContractBalance(cmd *cobra.Command, inv *invoker.Invoker, nnsHash util.Uint160) error {
|
||||||
h, err := morphUtil.NNSResolveHash(inv, nnsHash, morphUtil.DomainOf(morphUtil.ProxyContract))
|
h, err := morphUtil.NNSResolveHash(inv, nnsHash, morphUtil.DomainOf(constants.ProxyContract))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't get hash of the proxy contract: %w", err)
|
return fmt.Errorf("can't get hash of the proxy contract: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
|
|
||||||
|
"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/util"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
|
@ -38,7 +39,7 @@ func dumpNetworkConfig(cmd *cobra.Command, _ []string) error {
|
||||||
return fmt.Errorf("can't get NNS contract info: %w", err)
|
return fmt.Errorf("can't get NNS contract info: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
nmHash, err := util.NNSResolveHash(inv, cs.Hash, util.DomainOf(util.NetmapContract))
|
nmHash, err := util.NNSResolveHash(inv, cs.Hash, util.DomainOf(constants.NetmapContract))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't get netmap contract hash: %w", err)
|
return fmt.Errorf("can't get netmap contract hash: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -96,7 +97,7 @@ func SetConfigCmd(cmd *cobra.Command, args []string) error {
|
||||||
return fmt.Errorf("can't get NNS contract info: %w", err)
|
return fmt.Errorf("can't get NNS contract info: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
nmHash, err := util.NNSResolveHash(wCtx.ReadOnlyInvoker, cs.Hash, util.DomainOf(util.NetmapContract))
|
nmHash, err := util.NNSResolveHash(wCtx.ReadOnlyInvoker, cs.Hash, util.DomainOf(constants.NetmapContract))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't get netmap contract hash: %w", err)
|
return fmt.Errorf("can't get netmap contract hash: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package util
|
package constants
|
||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||||
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||||
|
@ -36,7 +37,7 @@ func getContainerContractHash(cmd *cobra.Command, inv *invoker.Invoker) (util.Ui
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.Uint160{}, fmt.Errorf("can't get NNS contract state: %w", err)
|
return util.Uint160{}, fmt.Errorf("can't get NNS contract state: %w", err)
|
||||||
}
|
}
|
||||||
ch, err = morphUtil.NNSResolveHash(inv, nnsCs.Hash, morphUtil.DomainOf(morphUtil.ContainerContract))
|
ch, err = morphUtil.NNSResolveHash(inv, nnsCs.Hash, morphUtil.DomainOf(constants.ContainerContract))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.Uint160{}, err
|
return util.Uint160{}, err
|
||||||
}
|
}
|
||||||
|
@ -307,7 +308,7 @@ func fetchContainerContractHash(wCtx *morphUtil.InitializeContext) (util.Uint160
|
||||||
return util.Uint160{}, fmt.Errorf("can't get NNS contract state: %w", err)
|
return util.Uint160{}, fmt.Errorf("can't get NNS contract state: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ch, err := morphUtil.NNSResolveHash(wCtx.ReadOnlyInvoker, nnsCs.Hash, morphUtil.DomainOf(morphUtil.ContainerContract))
|
ch, err := morphUtil.NNSResolveHash(wCtx.ReadOnlyInvoker, nnsCs.Hash, morphUtil.DomainOf(constants.ContainerContract))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.Uint160{}, fmt.Errorf("can't fetch container contract hash: %w", err)
|
return util.Uint160{}, fmt.Errorf("can't fetch container contract hash: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
||||||
|
"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/util"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||||
"github.com/nspcc-dev/neo-go/cli/cmdargs"
|
"github.com/nspcc-dev/neo-go/cli/cmdargs"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
|
@ -84,7 +85,7 @@ func deployContractCmd(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
callHash := management.Hash
|
callHash := management.Hash
|
||||||
method := util.DeployMethodName
|
method := constants.DeployMethodName
|
||||||
zone, _ := cmd.Flags().GetString(commonflags.CustomZoneFlag)
|
zone, _ := cmd.Flags().GetString(commonflags.CustomZoneFlag)
|
||||||
domain := ctrName + "." + zone
|
domain := ctrName + "." + zone
|
||||||
isUpdate, _ := cmd.Flags().GetBool(updateFlag)
|
isUpdate, _ := cmd.Flags().GetBool(updateFlag)
|
||||||
|
@ -94,7 +95,7 @@ func deployContractCmd(cmd *cobra.Command, args []string) error {
|
||||||
return fmt.Errorf("can't fetch contract hash from NNS: %w", err)
|
return fmt.Errorf("can't fetch contract hash from NNS: %w", err)
|
||||||
}
|
}
|
||||||
callHash = cs.Hash
|
callHash = cs.Hash
|
||||||
method = util.UpdateMethodName
|
method = constants.UpdateMethodName
|
||||||
} else {
|
} else {
|
||||||
cs.Hash = state.CreateContractHash(
|
cs.Hash = state.CreateContractHash(
|
||||||
c.CommitteeAcc.Contract.ScriptHash(),
|
c.CommitteeAcc.Contract.ScriptHash(),
|
||||||
|
@ -147,12 +148,12 @@ func registerNNS(nnsCs *state.Contract, c *util.InitializeContext, zone string,
|
||||||
|
|
||||||
emit.AppCall(bw.BinWriter, nnsCs.Hash, "register", callflag.All,
|
emit.AppCall(bw.BinWriter, nnsCs.Hash, "register", callflag.All,
|
||||||
zone, c.CommitteeAcc.Contract.ScriptHash(),
|
zone, c.CommitteeAcc.Contract.ScriptHash(),
|
||||||
util.FrostfsOpsEmail, int64(3600), int64(600), int64(util.DefaultExpirationTime), int64(3600))
|
constants.FrostfsOpsEmail, int64(3600), int64(600), int64(constants.DefaultExpirationTime), int64(3600))
|
||||||
emit.Opcodes(bw.BinWriter, opcode.ASSERT)
|
emit.Opcodes(bw.BinWriter, opcode.ASSERT)
|
||||||
|
|
||||||
emit.AppCall(bw.BinWriter, nnsCs.Hash, "register", callflag.All,
|
emit.AppCall(bw.BinWriter, nnsCs.Hash, "register", callflag.All,
|
||||||
domain, c.CommitteeAcc.Contract.ScriptHash(),
|
domain, c.CommitteeAcc.Contract.ScriptHash(),
|
||||||
util.FrostfsOpsEmail, int64(3600), int64(600), int64(util.DefaultExpirationTime), int64(3600))
|
constants.FrostfsOpsEmail, int64(3600), int64(600), int64(constants.DefaultExpirationTime), int64(3600))
|
||||||
emit.Opcodes(bw.BinWriter, opcode.ASSERT)
|
emit.Opcodes(bw.BinWriter, opcode.ASSERT)
|
||||||
} else {
|
} else {
|
||||||
s, ok, err := c.NNSRegisterDomainScript(nnsCs.Hash, cs.Hash, domain)
|
s, ok, err := c.NNSRegisterDomainScript(nnsCs.Hash, cs.Hash, domain)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||||
morphClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
morphClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
|
@ -51,7 +52,7 @@ func dumpContractHashes(cmd *cobra.Command, _ []string) error {
|
||||||
return dumpCustomZoneHashes(cmd, cs.Hash, zone, c)
|
return dumpCustomZoneHashes(cmd, cs.Hash, zone, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
infos := []contractDumpInfo{{name: morphUtil.NNSContract, hash: cs.Hash}}
|
infos := []contractDumpInfo{{name: constants.NNSContract, hash: cs.Hash}}
|
||||||
|
|
||||||
irSize := 0
|
irSize := 0
|
||||||
for ; irSize < lastGlagoliticLetter; irSize++ {
|
for ; irSize < lastGlagoliticLetter; irSize++ {
|
||||||
|
@ -87,7 +88,7 @@ func dumpContractHashes(cmd *cobra.Command, _ []string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, ctrName := range morphUtil.ContractList {
|
for _, ctrName := range constants.ContractList {
|
||||||
bw.Reset()
|
bw.Reset()
|
||||||
emit.AppCall(bw.BinWriter, cs.Hash, "resolve", callflag.ReadOnly,
|
emit.AppCall(bw.BinWriter, cs.Hash, "resolve", callflag.ReadOnly,
|
||||||
morphUtil.DomainOf(ctrName), int64(nns.TXT))
|
morphUtil.DomainOf(ctrName), int64(nns.TXT))
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-contract/common"
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/common"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||||
morphClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
morphClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||||
|
@ -29,7 +30,7 @@ func updateContracts(cmd *cobra.Command, _ []string) error {
|
||||||
return fmt.Errorf("initialization error: %w", err)
|
return fmt.Errorf("initialization error: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := morphUtil.DeployNNS(wCtx, morphUtil.UpdateMethodName); err != nil {
|
if err := morphUtil.DeployNNS(wCtx, constants.UpdateMethodName); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ func updateContracts(cmd *cobra.Command, _ []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateContractsInternal(c *morphUtil.InitializeContext) error {
|
func updateContractsInternal(c *morphUtil.InitializeContext) error {
|
||||||
alphaCs := c.GetContract(morphUtil.AlphabetContract)
|
alphaCs := c.GetContract(constants.AlphabetContract)
|
||||||
|
|
||||||
nnsCs, err := c.NNSContractState()
|
nnsCs, err := c.NNSContractState()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -116,7 +117,7 @@ func deployAlphabetAccounts(c *morphUtil.InitializeContext, nnsHash neoUtil.Uint
|
||||||
emit.Opcodes(w.BinWriter, opcode.LDSFLD0)
|
emit.Opcodes(w.BinWriter, opcode.LDSFLD0)
|
||||||
emit.Int(w.BinWriter, 3)
|
emit.Int(w.BinWriter, 3)
|
||||||
emit.Opcodes(w.BinWriter, opcode.PACK)
|
emit.Opcodes(w.BinWriter, opcode.PACK)
|
||||||
emit.AppCallNoArgs(w.BinWriter, ctrHash, morphUtil.UpdateMethodName, callflag.All)
|
emit.AppCallNoArgs(w.BinWriter, ctrHash, constants.UpdateMethodName, callflag.All)
|
||||||
}
|
}
|
||||||
if err := c.SendCommitteeTx(w.Bytes(), false); err != nil {
|
if err := c.SendCommitteeTx(w.Bytes(), false); err != nil {
|
||||||
if !strings.Contains(err.Error(), common.ErrAlreadyUpdated) {
|
if !strings.Contains(err.Error(), common.ErrAlreadyUpdated) {
|
||||||
|
@ -134,15 +135,15 @@ func deployOrUpdateContracts(c *morphUtil.InitializeContext, w *io2.BufBinWriter
|
||||||
emit.Opcodes(w.BinWriter, opcode.STSFLD0)
|
emit.Opcodes(w.BinWriter, opcode.STSFLD0)
|
||||||
emit.AppCall(w.BinWriter, nnsHash, "setPrice", callflag.All, 1)
|
emit.AppCall(w.BinWriter, nnsHash, "setPrice", callflag.All, 1)
|
||||||
|
|
||||||
for _, ctrName := range morphUtil.ContractList {
|
for _, ctrName := range constants.ContractList {
|
||||||
cs := c.GetContract(ctrName)
|
cs := c.GetContract(ctrName)
|
||||||
|
|
||||||
method := morphUtil.UpdateMethodName
|
method := constants.UpdateMethodName
|
||||||
ctrHash, err := morphUtil.NNSResolveHash(c.ReadOnlyInvoker, nnsHash, morphUtil.DomainOf(ctrName))
|
ctrHash, err := morphUtil.NNSResolveHash(c.ReadOnlyInvoker, nnsHash, morphUtil.DomainOf(ctrName))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, errMissingNNSRecord) {
|
if errors.Is(err, errMissingNNSRecord) {
|
||||||
// if contract not found we deploy it instead of update
|
// if contract not found we deploy it instead of update
|
||||||
method = morphUtil.DeployMethodName
|
method = constants.DeployMethodName
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("can't resolve hash for contract update: %w", err)
|
return fmt.Errorf("can't resolve hash for contract update: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -154,18 +155,18 @@ func deployOrUpdateContracts(c *morphUtil.InitializeContext, w *io2.BufBinWriter
|
||||||
}
|
}
|
||||||
|
|
||||||
invokeHash := management.Hash
|
invokeHash := management.Hash
|
||||||
if method == morphUtil.UpdateMethodName {
|
if method == constants.UpdateMethodName {
|
||||||
invokeHash = ctrHash
|
invokeHash = ctrHash
|
||||||
}
|
}
|
||||||
|
|
||||||
args, err := morphUtil.GetContractDeployData(c, ctrName, keysParam, morphUtil.UpdateMethodName)
|
args, err := morphUtil.GetContractDeployData(c, ctrName, keysParam, constants.UpdateMethodName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: getting update params: %v", ctrName, err)
|
return fmt.Errorf("%s: getting update params: %v", ctrName, err)
|
||||||
}
|
}
|
||||||
params := morphUtil.GetContractDeployParameters(cs, args)
|
params := morphUtil.GetContractDeployParameters(cs, args)
|
||||||
res, err := c.CommitteeAct.MakeCall(invokeHash, method, params...)
|
res, err := c.CommitteeAct.MakeCall(invokeHash, method, params...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if method != morphUtil.UpdateMethodName || !strings.Contains(err.Error(), common.ErrAlreadyUpdated) {
|
if method != constants.UpdateMethodName || !strings.Contains(err.Error(), common.ErrAlreadyUpdated) {
|
||||||
return fmt.Errorf("deploy contract: %w", err)
|
return fmt.Errorf("deploy contract: %w", err)
|
||||||
}
|
}
|
||||||
c.Command.Printf("%s contract is already updated.\n", ctrName)
|
c.Command.Printf("%s contract is already updated.\n", ctrName)
|
||||||
|
@ -174,7 +175,7 @@ func deployOrUpdateContracts(c *morphUtil.InitializeContext, w *io2.BufBinWriter
|
||||||
|
|
||||||
w.WriteBytes(res.Script)
|
w.WriteBytes(res.Script)
|
||||||
|
|
||||||
if method == morphUtil.DeployMethodName {
|
if method == constants.DeployMethodName {
|
||||||
// same actions are done in InitializeContext.setNNS, can be unified
|
// same actions are done in InitializeContext.setNNS, can be unified
|
||||||
domain := ctrName + ".frostfs"
|
domain := ctrName + ".frostfs"
|
||||||
script, ok, err := c.NNSRegisterDomainScript(nnsHash, cs.Hash, domain)
|
script, ok, err := c.NNSRegisterDomainScript(nnsHash, cs.Hash, domain)
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
frostfsidclient "git.frostfs.info/TrueCloudLab/frostfs-contract/frostfsid/client"
|
frostfsidclient "git.frostfs.info/TrueCloudLab/frostfs-contract/frostfsid/client"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||||
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
|
@ -432,7 +433,7 @@ func newFrostfsIDClient(cmd *cobra.Command) (*frostfsidClient, error) {
|
||||||
return nil, fmt.Errorf("can't get NNS contract info: %w", err)
|
return nil, fmt.Errorf("can't get NNS contract info: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ffsidHash, err := morphUtil.NNSResolveHash(wCtx.ReadOnlyInvoker, cs.Hash, morphUtil.DomainOf(morphUtil.FrostfsIDContract))
|
ffsidHash, err := morphUtil.NNSResolveHash(wCtx.ReadOnlyInvoker, cs.Hash, morphUtil.DomainOf(constants.FrostfsIDContract))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("can't get proxy contract hash: %w", err)
|
return nil, fmt.Errorf("can't get proxy contract hash: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/config"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/config"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
@ -34,7 +35,7 @@ func AlphabetCreds(cmd *cobra.Command, _ []string) error {
|
||||||
if size == 0 {
|
if size == 0 {
|
||||||
return errors.New("size must be > 0")
|
return errors.New("size must be > 0")
|
||||||
}
|
}
|
||||||
if size > morphUtil.MaxAlphabetNodes {
|
if size > constants.MaxAlphabetNodes {
|
||||||
return morphUtil.ErrTooManyAlphabetNodes
|
return morphUtil.ErrTooManyAlphabetNodes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +83,7 @@ func initializeWallets(v *viper.Viper, walletDir string, size int) ([]string, er
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("can't create wallet: %w", err)
|
return nil, fmt.Errorf("can't create wallet: %w", err)
|
||||||
}
|
}
|
||||||
if err := w.CreateAccount(morphUtil.SingleAccountName, password); err != nil {
|
if err := w.CreateAccount(constants.SingleAccountName, password); err != nil {
|
||||||
return nil, fmt.Errorf("can't create account: %w", err)
|
return nil, fmt.Errorf("can't create account: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,10 +102,10 @@ func initializeWallets(v *viper.Viper, walletDir string, size int) ([]string, er
|
||||||
i := i
|
i := i
|
||||||
ps := pubs.Copy()
|
ps := pubs.Copy()
|
||||||
errG.Go(func() error {
|
errG.Go(func() error {
|
||||||
if err := addMultisigAccount(wallets[i], majCount, morphUtil.CommitteeAccountName, passwords[i], ps); err != nil {
|
if err := addMultisigAccount(wallets[i], majCount, constants.CommitteeAccountName, passwords[i], ps); err != nil {
|
||||||
return fmt.Errorf("can't create committee account: %w", err)
|
return fmt.Errorf("can't create committee account: %w", err)
|
||||||
}
|
}
|
||||||
if err := addMultisigAccount(wallets[i], bftCount, morphUtil.ConsensusAccountName, passwords[i], ps); err != nil {
|
if err := addMultisigAccount(wallets[i], bftCount, constants.ConsensusAccountName, passwords[i], ps); err != nil {
|
||||||
return fmt.Errorf("can't create consentus account: %w", err)
|
return fmt.Errorf("can't create consentus account: %w", err)
|
||||||
}
|
}
|
||||||
if err := wallets[i].SavePretty(); err != nil {
|
if err := wallets[i].SavePretty(); err != nil {
|
||||||
|
@ -177,7 +178,7 @@ func refillGas(cmd *cobra.Command, gasFlag string, createWallet bool) (err error
|
||||||
}
|
}
|
||||||
|
|
||||||
if label == "" {
|
if label == "" {
|
||||||
label = morphUtil.SingleAccountName
|
label = constants.SingleAccountName
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := w.CreateAccount(label, password); err != nil {
|
if err := w.CreateAccount(label, password); err != nil {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring"
|
||||||
"github.com/nspcc-dev/neo-go/cli/input"
|
"github.com/nspcc-dev/neo-go/cli/input"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
@ -69,7 +69,7 @@ func TestGenerateAlphabet(t *testing.T) {
|
||||||
buf.WriteString(strconv.FormatUint(i, 10) + "\r")
|
buf.WriteString(strconv.FormatUint(i, 10) + "\r")
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.WriteString(util.TestContractPassword + "\r")
|
buf.WriteString(constants.TestContractPassword + "\r")
|
||||||
require.NoError(t, AlphabetCreds(GenerateAlphabetCmd, nil))
|
require.NoError(t, AlphabetCreds(GenerateAlphabetCmd, nil))
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
@ -87,12 +87,12 @@ func TestGenerateAlphabet(t *testing.T) {
|
||||||
err := a.Decrypt(strconv.FormatUint(i, 10), keys.NEP2ScryptParams())
|
err := a.Decrypt(strconv.FormatUint(i, 10), keys.NEP2ScryptParams())
|
||||||
require.NoError(t, err, "can't decrypt account")
|
require.NoError(t, err, "can't decrypt account")
|
||||||
switch a.Label {
|
switch a.Label {
|
||||||
case util.ConsensusAccountName:
|
case constants.ConsensusAccountName:
|
||||||
require.Equal(t, smartcontract.GetDefaultHonestNodeCount(size), len(a.Contract.Parameters))
|
require.Equal(t, smartcontract.GetDefaultHonestNodeCount(size), len(a.Contract.Parameters))
|
||||||
case util.CommitteeAccountName:
|
case constants.CommitteeAccountName:
|
||||||
require.Equal(t, smartcontract.GetMajorityHonestNodeCount(size), len(a.Contract.Parameters))
|
require.Equal(t, smartcontract.GetMajorityHonestNodeCount(size), len(a.Contract.Parameters))
|
||||||
default:
|
default:
|
||||||
require.Equal(t, util.SingleAccountName, a.Label)
|
require.Equal(t, constants.SingleAccountName, a.Label)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -100,11 +100,11 @@ func TestGenerateAlphabet(t *testing.T) {
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
t.Run("check contract group wallet", func(t *testing.T) {
|
t.Run("check contract group wallet", func(t *testing.T) {
|
||||||
p := filepath.Join(walletDir, util.ContractWalletFilename)
|
p := filepath.Join(walletDir, constants.ContractWalletFilename)
|
||||||
w, err := wallet.NewWalletFromFile(p)
|
w, err := wallet.NewWalletFromFile(p)
|
||||||
require.NoError(t, err, "contract wallet doesn't exist")
|
require.NoError(t, err, "contract wallet doesn't exist")
|
||||||
require.Equal(t, 1, len(w.Accounts), "contract wallet must have 1 accout")
|
require.Equal(t, 1, len(w.Accounts), "contract wallet must have 1 accout")
|
||||||
require.NoError(t, w.Accounts[0].Decrypt(util.TestContractPassword, keys.NEP2ScryptParams()))
|
require.NoError(t, w.Accounts[0].Decrypt(constants.TestContractPassword, keys.NEP2ScryptParams()))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package initialize
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
@ -28,7 +29,7 @@ func initializeSideChainCmd(cmd *cobra.Command, _ []string) error {
|
||||||
|
|
||||||
// 3. Deploy NNS contract.
|
// 3. Deploy NNS contract.
|
||||||
cmd.Println("Stage 3: deploy NNS contract.")
|
cmd.Println("Stage 3: deploy NNS contract.")
|
||||||
if err := morphUtil.DeployNNS(initCtx, morphUtil.DeployMethodName); err != nil {
|
if err := morphUtil.DeployNNS(initCtx, constants.DeployMethodName); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package initialize
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/actor"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/actor"
|
||||||
|
@ -10,7 +11,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func deployContracts(c *morphUtil.InitializeContext) error {
|
func deployContracts(c *morphUtil.InitializeContext) error {
|
||||||
alphaCs := c.GetContract(morphUtil.AlphabetContract)
|
alphaCs := c.GetContract(constants.AlphabetContract)
|
||||||
|
|
||||||
var keysParam []any
|
var keysParam []any
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ func deployContracts(c *morphUtil.InitializeContext) error {
|
||||||
return fmt.Errorf("could not create actor: %w", err)
|
return fmt.Errorf("could not create actor: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
txHash, vub, err := act.SendCall(management.Hash, morphUtil.DeployMethodName, params...)
|
txHash, vub, err := act.SendCall(management.Hash, constants.DeployMethodName, params...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't deploy alphabet #%d contract: %w", i, err)
|
return fmt.Errorf("can't deploy alphabet #%d contract: %w", i, err)
|
||||||
}
|
}
|
||||||
|
@ -46,7 +47,7 @@ func deployContracts(c *morphUtil.InitializeContext) error {
|
||||||
c.SentTxs = append(c.SentTxs, morphUtil.HashVUBPair{Hash: txHash, Vub: vub})
|
c.SentTxs = append(c.SentTxs, morphUtil.HashVUBPair{Hash: txHash, Vub: vub})
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, ctrName := range morphUtil.ContractList {
|
for _, ctrName := range constants.ContractList {
|
||||||
cs := c.GetContract(ctrName)
|
cs := c.GetContract(ctrName)
|
||||||
|
|
||||||
ctrHash := cs.Hash
|
ctrHash := cs.Hash
|
||||||
|
@ -60,12 +61,12 @@ func deployContracts(c *morphUtil.InitializeContext) error {
|
||||||
return fmt.Errorf("can't sign manifest group: %v", err)
|
return fmt.Errorf("can't sign manifest group: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
args, err := morphUtil.GetContractDeployData(c, ctrName, keysParam, morphUtil.DeployMethodName)
|
args, err := morphUtil.GetContractDeployData(c, ctrName, keysParam, constants.DeployMethodName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: getting deploy params: %v", ctrName, err)
|
return fmt.Errorf("%s: getting deploy params: %v", ctrName, err)
|
||||||
}
|
}
|
||||||
params := morphUtil.GetContractDeployParameters(cs, args)
|
params := morphUtil.GetContractDeployParameters(cs, args)
|
||||||
res, err := c.CommitteeAct.MakeCall(management.Hash, morphUtil.DeployMethodName, params...)
|
res, err := c.CommitteeAct.MakeCall(management.Hash, constants.DeployMethodName, params...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't deploy %s contract: %w", ctrName, err)
|
return fmt.Errorf("can't deploy %s contract: %w", ctrName, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||||
morphClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
morphClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
|
@ -32,7 +33,7 @@ func setNNS(c *morphUtil.InitializeContext) error {
|
||||||
bw := io.NewBufBinWriter()
|
bw := io.NewBufBinWriter()
|
||||||
emit.AppCall(bw.BinWriter, nnsCs.Hash, "register", callflag.All,
|
emit.AppCall(bw.BinWriter, nnsCs.Hash, "register", callflag.All,
|
||||||
"frostfs", c.CommitteeAcc.Contract.ScriptHash(),
|
"frostfs", c.CommitteeAcc.Contract.ScriptHash(),
|
||||||
morphUtil.FrostfsOpsEmail, int64(3600), int64(600), int64(morphUtil.DefaultExpirationTime), int64(3600))
|
constants.FrostfsOpsEmail, int64(3600), int64(600), int64(constants.DefaultExpirationTime), int64(3600))
|
||||||
emit.Opcodes(bw.BinWriter, opcode.ASSERT)
|
emit.Opcodes(bw.BinWriter, opcode.ASSERT)
|
||||||
if err := c.SendCommitteeTx(bw.Bytes(), true); err != nil {
|
if err := c.SendCommitteeTx(bw.Bytes(), true); err != nil {
|
||||||
return fmt.Errorf("can't add domain root to NNS: %w", err)
|
return fmt.Errorf("can't add domain root to NNS: %w", err)
|
||||||
|
@ -42,7 +43,7 @@ func setNNS(c *morphUtil.InitializeContext) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
alphaCs := c.GetContract(morphUtil.AlphabetContract)
|
alphaCs := c.GetContract(constants.AlphabetContract)
|
||||||
for i, acc := range c.Accounts {
|
for i, acc := range c.Accounts {
|
||||||
alphaCs.Hash = state.CreateContractHash(acc.Contract.ScriptHash(), alphaCs.NEF.Checksum, alphaCs.Manifest.Name)
|
alphaCs.Hash = state.CreateContractHash(acc.Contract.ScriptHash(), alphaCs.NEF.Checksum, alphaCs.Manifest.Name)
|
||||||
|
|
||||||
|
@ -53,7 +54,7 @@ func setNNS(c *morphUtil.InitializeContext) error {
|
||||||
c.Command.Printf("NNS: Set %s -> %s\n", domain, alphaCs.Hash.StringLE())
|
c.Command.Printf("NNS: Set %s -> %s\n", domain, alphaCs.Hash.StringLE())
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, ctrName := range morphUtil.ContractList {
|
for _, ctrName := range constants.ContractList {
|
||||||
cs := c.GetContract(ctrName)
|
cs := c.GetContract(ctrName)
|
||||||
|
|
||||||
domain := ctrName + ".frostfs"
|
domain := ctrName + ".frostfs"
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/native"
|
"github.com/nspcc-dev/neo-go/pkg/core/native"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
|
@ -68,7 +69,7 @@ func registerCandidateRange(c *morphUtil.InitializeContext, start, end int) erro
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't create tx: %w", err)
|
return fmt.Errorf("can't create tx: %w", err)
|
||||||
}
|
}
|
||||||
if err := c.MultiSign(tx, morphUtil.CommitteeAccountName); err != nil {
|
if err := c.MultiSign(tx, constants.CommitteeAccountName); err != nil {
|
||||||
return fmt.Errorf("can't sign a transaction: %w", err)
|
return fmt.Errorf("can't sign a transaction: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +124,7 @@ func transferNEOToAlphabetContracts(c *morphUtil.InitializeContext) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cs := c.GetContract(morphUtil.AlphabetContract)
|
cs := c.GetContract(constants.AlphabetContract)
|
||||||
amount := initialAlphabetNEOAmount / len(c.Wallets)
|
amount := initialAlphabetNEOAmount / len(c.Wallets)
|
||||||
|
|
||||||
bw := io.NewBufBinWriter()
|
bw := io.NewBufBinWriter()
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
||||||
cmdConfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/config"
|
cmdConfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/config"
|
||||||
|
"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/generate"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/generate"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/netmap"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/netmap"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/node"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/node"
|
||||||
|
@ -49,10 +50,10 @@ func TestInitialize(t *testing.T) {
|
||||||
testInitialize(t, 16)
|
testInitialize(t, 16)
|
||||||
})
|
})
|
||||||
t.Run("max nodes", func(t *testing.T) {
|
t.Run("max nodes", func(t *testing.T) {
|
||||||
testInitialize(t, util.MaxAlphabetNodes)
|
testInitialize(t, constants.MaxAlphabetNodes)
|
||||||
})
|
})
|
||||||
t.Run("too many nodes", func(t *testing.T) {
|
t.Run("too many nodes", func(t *testing.T) {
|
||||||
require.ErrorIs(t, generateTestData(t, t.TempDir(), util.MaxAlphabetNodes+1), util.ErrTooManyAlphabetNodes)
|
require.ErrorIs(t, generateTestData(t, t.TempDir(), constants.MaxAlphabetNodes+1), util.ErrTooManyAlphabetNodes)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@ func testInitialize(t *testing.T, committeeSize int) {
|
||||||
v := viper.GetViper()
|
v := viper.GetViper()
|
||||||
|
|
||||||
require.NoError(t, generateTestData(t, testdataDir, committeeSize))
|
require.NoError(t, generateTestData(t, testdataDir, committeeSize))
|
||||||
v.Set(util.ProtoConfigPath, filepath.Join(testdataDir, protoFileName))
|
v.Set(constants.ProtoConfigPath, filepath.Join(testdataDir, protoFileName))
|
||||||
|
|
||||||
// Set to the path or remove the next statement to download from the network.
|
// Set to the path or remove the next statement to download from the network.
|
||||||
require.NoError(t, Cmd.Flags().Set(commonflags.ContractsInitFlag, contractsPath))
|
require.NoError(t, Cmd.Flags().Set(commonflags.ContractsInitFlag, contractsPath))
|
||||||
|
@ -119,7 +120,7 @@ func generateTestData(t *testing.T, dir string, size int) error {
|
||||||
return fmt.Errorf("wallet doesn't exist: %w", err)
|
return fmt.Errorf("wallet doesn't exist: %w", err)
|
||||||
}
|
}
|
||||||
for _, acc := range w.Accounts {
|
for _, acc := range w.Accounts {
|
||||||
if acc.Label == util.SingleAccountName {
|
if acc.Label == constants.SingleAccountName {
|
||||||
pub, ok := vm.ParseSignatureContract(acc.Contract.Script)
|
pub, ok := vm.ParseSignatureContract(acc.Contract.Script)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("could not parse signature script for %s", acc.Address)
|
return fmt.Errorf("could not parse signature script for %s", acc.Address)
|
||||||
|
@ -150,7 +151,7 @@ func setTestCredentials(v *viper.Viper, size int) {
|
||||||
for i := 0; i < size; i++ {
|
for i := 0; i < size; i++ {
|
||||||
v.Set("credentials."+innerring.GlagoliticLetter(i).String(), strconv.FormatUint(uint64(i), 10))
|
v.Set("credentials."+innerring.GlagoliticLetter(i).String(), strconv.FormatUint(uint64(i), 10))
|
||||||
}
|
}
|
||||||
v.Set("credentials.contract", util.TestContractPassword)
|
v.Set("credentials.contract", constants.TestContractPassword)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNextPollInterval(t *testing.T) {
|
func TestNextPollInterval(t *testing.T) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/native"
|
"github.com/nspcc-dev/neo-go/pkg/core/native"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
|
@ -67,7 +68,7 @@ func transferFunds(c *morphUtil.InitializeContext) error {
|
||||||
return fmt.Errorf("can't create transfer transaction: %w", err)
|
return fmt.Errorf("can't create transfer transaction: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.MultiSignAndSend(tx, morphUtil.ConsensusAccountName); err != nil {
|
if err := c.MultiSignAndSend(tx, constants.ConsensusAccountName); err != nil {
|
||||||
return fmt.Errorf("can't send transfer transaction: %w", err)
|
return fmt.Errorf("can't send transfer transaction: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ func transferFundsFinished(c *morphUtil.InitializeContext) (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func transferGASToProxy(c *morphUtil.InitializeContext) error {
|
func transferGASToProxy(c *morphUtil.InitializeContext) error {
|
||||||
proxyCs := c.GetContract(morphUtil.ProxyContract)
|
proxyCs := c.GetContract(constants.ProxyContract)
|
||||||
|
|
||||||
r := nep17.NewReader(c.ReadOnlyInvoker, gas.Hash)
|
r := nep17.NewReader(c.ReadOnlyInvoker, gas.Hash)
|
||||||
bal, err := r.BalanceOf(proxyCs.Hash)
|
bal, err := r.BalanceOf(proxyCs.Hash)
|
||||||
|
@ -100,7 +101,7 @@ func transferGASToProxy(c *morphUtil.InitializeContext) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.MultiSignAndSend(tx, morphUtil.CommitteeAccountName); err != nil {
|
if err := c.MultiSignAndSend(tx, constants.CommitteeAccountName); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package initialize
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
@ -30,7 +30,7 @@ var Cmd = &cobra.Command{
|
||||||
_ = viper.BindPFlag(commonflags.ContainerFeeInitFlag, cmd.Flags().Lookup(containerFeeCLIFlag))
|
_ = viper.BindPFlag(commonflags.ContainerFeeInitFlag, cmd.Flags().Lookup(containerFeeCLIFlag))
|
||||||
_ = viper.BindPFlag(commonflags.ContainerAliasFeeInitFlag, cmd.Flags().Lookup(containerAliasFeeCLIFlag))
|
_ = viper.BindPFlag(commonflags.ContainerAliasFeeInitFlag, cmd.Flags().Lookup(containerAliasFeeCLIFlag))
|
||||||
_ = viper.BindPFlag(commonflags.WithdrawFeeInitFlag, cmd.Flags().Lookup(withdrawFeeCLIFlag))
|
_ = viper.BindPFlag(commonflags.WithdrawFeeInitFlag, cmd.Flags().Lookup(withdrawFeeCLIFlag))
|
||||||
_ = viper.BindPFlag(util.ProtoConfigPath, cmd.Flags().Lookup(util.ProtoConfigPath))
|
_ = viper.BindPFlag(constants.ProtoConfigPath, cmd.Flags().Lookup(constants.ProtoConfigPath))
|
||||||
},
|
},
|
||||||
RunE: initializeSideChainCmd,
|
RunE: initializeSideChainCmd,
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ func initInitCmd() {
|
||||||
// Defaults are taken from neo-preodolenie.
|
// Defaults are taken from neo-preodolenie.
|
||||||
Cmd.Flags().Uint64(containerFeeCLIFlag, 1000, "Container registration fee")
|
Cmd.Flags().Uint64(containerFeeCLIFlag, 1000, "Container registration fee")
|
||||||
Cmd.Flags().Uint64(containerAliasFeeCLIFlag, 500, "Container alias fee")
|
Cmd.Flags().Uint64(containerAliasFeeCLIFlag, 500, "Container alias fee")
|
||||||
Cmd.Flags().String(util.ProtoConfigPath, "", "Path to the consensus node configuration")
|
Cmd.Flags().String(constants.ProtoConfigPath, "", "Path to the consensus node configuration")
|
||||||
Cmd.Flags().String(commonflags.LocalDumpFlag, "", "Path to the blocks dump file")
|
Cmd.Flags().String(commonflags.LocalDumpFlag, "", "Path to the blocks dump file")
|
||||||
Cmd.MarkFlagsMutuallyExclusive(commonflags.ContractsInitFlag, commonflags.ContractsURLFlag)
|
Cmd.MarkFlagsMutuallyExclusive(commonflags.ContractsInitFlag, commonflags.ContractsURLFlag)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"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/util"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/management"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/management"
|
||||||
|
@ -23,7 +24,7 @@ func ForceNewEpochCmd(cmd *cobra.Command, _ []string) error {
|
||||||
return fmt.Errorf("can't get NNS contract info: %w", err)
|
return fmt.Errorf("can't get NNS contract info: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
nmHash, err := util.NNSResolveHash(wCtx.ReadOnlyInvoker, cs.Hash, util.DomainOf(util.NetmapContract))
|
nmHash, err := util.NNSResolveHash(wCtx.ReadOnlyInvoker, cs.Hash, util.DomainOf(constants.NetmapContract))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't get netmap contract hash: %w", err)
|
return fmt.Errorf("can't get netmap contract hash: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package netmap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
||||||
|
"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/util"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||||
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
|
||||||
|
@ -21,7 +22,7 @@ func listNetmapCandidatesNodes(cmd *cobra.Command, _ []string) {
|
||||||
cs, err := r.GetContractByID(1)
|
cs, err := r.GetContractByID(1)
|
||||||
commonCmd.ExitOnErr(cmd, "can't get NNS contract info: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't get NNS contract info: %w", err)
|
||||||
|
|
||||||
nmHash, err := util.NNSResolveHash(inv, cs.Hash, util.DomainOf(util.NetmapContract))
|
nmHash, err := util.NNSResolveHash(inv, cs.Hash, util.DomainOf(constants.NetmapContract))
|
||||||
commonCmd.ExitOnErr(cmd, "can't get netmap contract hash: %w", err)
|
commonCmd.ExitOnErr(cmd, "can't get netmap contract hash: %w", err)
|
||||||
|
|
||||||
res, err := inv.Call(nmHash, "netmapCandidates")
|
res, err := inv.Call(nmHash, "netmapCandidates")
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
netmapcontract "git.frostfs.info/TrueCloudLab/frostfs-contract/netmap"
|
netmapcontract "git.frostfs.info/TrueCloudLab/frostfs-contract/netmap"
|
||||||
|
"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/util"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
|
@ -41,7 +42,7 @@ func RemoveNodesCmd(cmd *cobra.Command, args []string) error {
|
||||||
return fmt.Errorf("can't get NNS contract info: %w", err)
|
return fmt.Errorf("can't get NNS contract info: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
nmHash, err := util.NNSResolveHash(wCtx.ReadOnlyInvoker, cs.Hash, util.DomainOf(util.NetmapContract))
|
nmHash, err := util.NNSResolveHash(wCtx.ReadOnlyInvoker, cs.Hash, util.DomainOf(constants.NetmapContract))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't get netmap contract hash: %w", err)
|
return fmt.Errorf("can't get netmap contract hash: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package proxy
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||||
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||||
|
@ -47,7 +48,7 @@ func processAccount(cmd *cobra.Command, addr util.Uint160, method string) error
|
||||||
return fmt.Errorf("can't get NNS contract info: %w", err)
|
return fmt.Errorf("can't get NNS contract info: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyHash, err := morphUtil.NNSResolveHash(wCtx.ReadOnlyInvoker, cs.Hash, morphUtil.DomainOf(morphUtil.ProxyContract))
|
proxyHash, err := morphUtil.NNSResolveHash(wCtx.ReadOnlyInvoker, cs.Hash, morphUtil.DomainOf(constants.ProxyContract))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't get proxy contract hash: %w", err)
|
return fmt.Errorf("can't get proxy contract hash: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package util
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/invoker"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/invoker"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/management"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/management"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
|
||||||
|
@ -18,7 +19,7 @@ func getFrostfsIDAdminFromContract(roInvoker *invoker.Invoker) (util.Uint160, bo
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.Uint160{}, false, fmt.Errorf("get nns contract: %w", err)
|
return util.Uint160{}, false, fmt.Errorf("get nns contract: %w", err)
|
||||||
}
|
}
|
||||||
fidHash, err := NNSResolveHash(roInvoker, cs.Hash, DomainOf(FrostfsIDContract))
|
fidHash, err := NNSResolveHash(roInvoker, cs.Hash, DomainOf(constants.FrostfsIDContract))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.Uint160{}, false, fmt.Errorf("resolve frostfsid contract hash: %w", err)
|
return util.Uint160{}, false, fmt.Errorf("resolve frostfsid contract hash: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -45,19 +46,19 @@ func GetContractDeployData(c *InitializeContext, ctrName string, keysParam []any
|
||||||
items := make([]any, 0, 6)
|
items := make([]any, 0, 6)
|
||||||
|
|
||||||
switch ctrName {
|
switch ctrName {
|
||||||
case FrostfsContract:
|
case constants.FrostfsContract:
|
||||||
items = append(items,
|
items = append(items,
|
||||||
c.Contracts[ProcessingContract].Hash,
|
c.Contracts[constants.ProcessingContract].Hash,
|
||||||
keysParam,
|
keysParam,
|
||||||
smartcontract.Parameter{})
|
smartcontract.Parameter{})
|
||||||
case ProcessingContract:
|
case constants.ProcessingContract:
|
||||||
items = append(items, c.Contracts[FrostfsContract].Hash)
|
items = append(items, c.Contracts[constants.FrostfsContract].Hash)
|
||||||
return items[1:], nil // no notary info
|
return items[1:], nil // no notary info
|
||||||
case BalanceContract:
|
case constants.BalanceContract:
|
||||||
items = append(items,
|
items = append(items,
|
||||||
c.Contracts[NetmapContract].Hash,
|
c.Contracts[constants.NetmapContract].Hash,
|
||||||
c.Contracts[ContainerContract].Hash)
|
c.Contracts[constants.ContainerContract].Hash)
|
||||||
case ContainerContract:
|
case constants.ContainerContract:
|
||||||
// In case if NNS is updated multiple times, we can't calculate
|
// In case if NNS is updated multiple times, we can't calculate
|
||||||
// it's actual hash based on local data, thus query chain.
|
// it's actual hash based on local data, thus query chain.
|
||||||
r := management.NewReader(c.ReadOnlyInvoker)
|
r := management.NewReader(c.ReadOnlyInvoker)
|
||||||
|
@ -66,21 +67,21 @@ func GetContractDeployData(c *InitializeContext, ctrName string, keysParam []any
|
||||||
return nil, fmt.Errorf("get nns contract: %w", err)
|
return nil, fmt.Errorf("get nns contract: %w", err)
|
||||||
}
|
}
|
||||||
items = append(items,
|
items = append(items,
|
||||||
c.Contracts[NetmapContract].Hash,
|
c.Contracts[constants.NetmapContract].Hash,
|
||||||
c.Contracts[BalanceContract].Hash,
|
c.Contracts[constants.BalanceContract].Hash,
|
||||||
c.Contracts[FrostfsIDContract].Hash,
|
c.Contracts[constants.FrostfsIDContract].Hash,
|
||||||
nnsCs.Hash,
|
nnsCs.Hash,
|
||||||
"container")
|
"container")
|
||||||
case FrostfsIDContract:
|
case constants.FrostfsIDContract:
|
||||||
var (
|
var (
|
||||||
h util.Uint160
|
h util.Uint160
|
||||||
found bool
|
found bool
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
if method == UpdateMethodName {
|
if method == constants.UpdateMethodName {
|
||||||
h, found, err = getFrostfsIDAdminFromContract(c.ReadOnlyInvoker)
|
h, found, err = getFrostfsIDAdminFromContract(c.ReadOnlyInvoker)
|
||||||
}
|
}
|
||||||
if method != UpdateMethodName || err == nil && !found {
|
if method != constants.UpdateMethodName || err == nil && !found {
|
||||||
h, found, err = GetFrostfsIDAdmin(viper.GetViper())
|
h, found, err = GetFrostfsIDAdmin(viper.GetViper())
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -90,11 +91,11 @@ func GetContractDeployData(c *InitializeContext, ctrName string, keysParam []any
|
||||||
if found {
|
if found {
|
||||||
items = append(items, h)
|
items = append(items, h)
|
||||||
} else {
|
} else {
|
||||||
items = append(items, c.Contracts[ProxyContract].Hash)
|
items = append(items, c.Contracts[constants.ProxyContract].Hash)
|
||||||
}
|
}
|
||||||
case NetmapContract:
|
case constants.NetmapContract:
|
||||||
md := GetDefaultNetmapContractConfigMap()
|
md := GetDefaultNetmapContractConfigMap()
|
||||||
if method == UpdateMethodName {
|
if method == constants.UpdateMethodName {
|
||||||
if err := MergeNetmapConfig(c.ReadOnlyInvoker, md); err != nil {
|
if err := MergeNetmapConfig(c.ReadOnlyInvoker, md); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -106,14 +107,14 @@ func GetContractDeployData(c *InitializeContext, ctrName string, keysParam []any
|
||||||
}
|
}
|
||||||
|
|
||||||
items = append(items,
|
items = append(items,
|
||||||
c.Contracts[BalanceContract].Hash,
|
c.Contracts[constants.BalanceContract].Hash,
|
||||||
c.Contracts[ContainerContract].Hash,
|
c.Contracts[constants.ContainerContract].Hash,
|
||||||
keysParam,
|
keysParam,
|
||||||
configParam)
|
configParam)
|
||||||
case ProxyContract:
|
case constants.ProxyContract:
|
||||||
items = nil
|
items = nil
|
||||||
case PolicyContract:
|
case constants.PolicyContract:
|
||||||
items = append(items, c.Contracts[ProxyContract].Hash)
|
items = append(items, c.Contracts[constants.ProxyContract].Hash)
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("invalid contract name: %s", ctrName))
|
panic(fmt.Sprintf("invalid contract name: %s", ctrName))
|
||||||
}
|
}
|
||||||
|
@ -125,7 +126,7 @@ func GetContractDeployParameters(cs *ContractState, deployData []any) []any {
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeployNNS(c *InitializeContext, method string) error {
|
func DeployNNS(c *InitializeContext, method string) error {
|
||||||
cs := c.GetContract(NNSContract)
|
cs := c.GetContract(constants.NNSContract)
|
||||||
h := cs.Hash
|
h := cs.Hash
|
||||||
|
|
||||||
nnsCs, err := c.NNSContractState()
|
nnsCs, err := c.NNSContractState()
|
||||||
|
@ -134,7 +135,7 @@ func DeployNNS(c *InitializeContext, method string) error {
|
||||||
}
|
}
|
||||||
if nnsCs != nil {
|
if nnsCs != nil {
|
||||||
if nnsCs.NEF.Checksum == cs.NEF.Checksum {
|
if nnsCs.NEF.Checksum == cs.NEF.Checksum {
|
||||||
if method == DeployMethodName {
|
if method == constants.DeployMethodName {
|
||||||
c.Command.Println("NNS contract is already deployed.")
|
c.Command.Println("NNS contract is already deployed.")
|
||||||
} else {
|
} else {
|
||||||
c.Command.Println("NNS contract is already updated.")
|
c.Command.Println("NNS contract is already updated.")
|
||||||
|
@ -152,16 +153,16 @@ func DeployNNS(c *InitializeContext, method string) error {
|
||||||
params := GetContractDeployParameters(cs, nil)
|
params := GetContractDeployParameters(cs, nil)
|
||||||
|
|
||||||
invokeHash := management.Hash
|
invokeHash := management.Hash
|
||||||
if method == UpdateMethodName {
|
if method == constants.UpdateMethodName {
|
||||||
invokeHash = nnsCs.Hash
|
invokeHash = nnsCs.Hash
|
||||||
}
|
}
|
||||||
|
|
||||||
tx, err := c.CommitteeAct.MakeCall(invokeHash, method, params...)
|
tx, err := c.CommitteeAct.MakeCall(invokeHash, method, params...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create deploy tx for %s: %w", NNSContract, err)
|
return fmt.Errorf("failed to create deploy tx for %s: %w", constants.NNSContract, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.MultiSignAndSend(tx, CommitteeAccountName); err != nil {
|
if err := c.MultiSignAndSend(tx, constants.CommitteeAccountName); err != nil {
|
||||||
return fmt.Errorf("can't send deploy transaction: %w", err)
|
return fmt.Errorf("can't send deploy transaction: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||||
|
@ -23,7 +24,7 @@ import (
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrTooManyAlphabetNodes = fmt.Errorf("too many alphabet nodes (maximum allowed is %d)", MaxAlphabetNodes)
|
var ErrTooManyAlphabetNodes = fmt.Errorf("too many alphabet nodes (maximum allowed is %d)", constants.MaxAlphabetNodes)
|
||||||
|
|
||||||
func AwaitTx(cmd *cobra.Command, c Client, txs []HashVUBPair) error {
|
func AwaitTx(cmd *cobra.Command, c Client, txs []HashVUBPair) error {
|
||||||
cmd.Println("Waiting for transactions to persist...")
|
cmd.Println("Waiting for transactions to persist...")
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/config"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/config"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||||
|
@ -99,12 +100,12 @@ func NewInitializeContext(cmd *cobra.Command, v *viper.Viper) (*InitializeContex
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
committeeAcc, err := GetWalletAccount(wallets[0], CommitteeAccountName)
|
committeeAcc, err := GetWalletAccount(wallets[0], constants.CommitteeAccountName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("can't find committee account: %w", err)
|
return nil, fmt.Errorf("can't find committee account: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
consensusAcc, err := GetWalletAccount(wallets[0], ConsensusAccountName)
|
consensusAcc, err := GetWalletAccount(wallets[0], constants.ConsensusAccountName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("can't find consensus account: %w", err)
|
return nil, fmt.Errorf("can't find consensus account: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -151,7 +152,7 @@ func NewInitializeContext(cmd *cobra.Command, v *viper.Viper) (*InitializeContex
|
||||||
}
|
}
|
||||||
|
|
||||||
if needContracts {
|
if needContracts {
|
||||||
err := readContracts(initCtx, FullContractList)
|
err := readContracts(initCtx, constants.FullContractList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -207,7 +208,7 @@ func getContractsPath(cmd *cobra.Command, needContracts bool) (string, error) {
|
||||||
func createWalletAccounts(wallets []*wallet.Wallet) ([]*wallet.Account, error) {
|
func createWalletAccounts(wallets []*wallet.Wallet) ([]*wallet.Account, error) {
|
||||||
accounts := make([]*wallet.Account, len(wallets))
|
accounts := make([]*wallet.Account, len(wallets))
|
||||||
for i, w := range wallets {
|
for i, w := range wallets {
|
||||||
acc, err := GetWalletAccount(w, SingleAccountName)
|
acc, err := GetWalletAccount(w, constants.SingleAccountName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("wallet %s is invalid (no single account): %w", w.Path(), err)
|
return nil, fmt.Errorf("wallet %s is invalid (no single account): %w", w.Path(), err)
|
||||||
}
|
}
|
||||||
|
@ -263,7 +264,7 @@ func readContracts(c *InitializeContext, names []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, ctrName := range names {
|
for _, ctrName := range names {
|
||||||
if ctrName != AlphabetContract {
|
if ctrName != constants.AlphabetContract {
|
||||||
cs := c.Contracts[ctrName]
|
cs := c.Contracts[ctrName]
|
||||||
cs.Hash = state.CreateContractHash(c.CommitteeAcc.Contract.ScriptHash(),
|
cs.Hash = state.CreateContractHash(c.CommitteeAcc.Contract.ScriptHash(),
|
||||||
cs.NEF.Checksum, cs.Manifest.Name)
|
cs.NEF.Checksum, cs.Manifest.Name)
|
||||||
|
@ -382,11 +383,11 @@ func (c *InitializeContext) sendMultiTx(script []byte, tryGroup bool, withConsen
|
||||||
return fmt.Errorf("could not perform test invocation: %w", err)
|
return fmt.Errorf("could not perform test invocation: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.MultiSign(tx, CommitteeAccountName); err != nil {
|
if err := c.MultiSign(tx, constants.CommitteeAccountName); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if withConsensus {
|
if withConsensus {
|
||||||
if err := c.MultiSign(tx, ConsensusAccountName); err != nil {
|
if err := c.MultiSign(tx, constants.ConsensusAccountName); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -414,7 +415,7 @@ func (c *InitializeContext) MultiSign(tx *transaction.Transaction, accType strin
|
||||||
// Use parameter context to avoid dealing with signature order.
|
// Use parameter context to avoid dealing with signature order.
|
||||||
pc := context.NewParameterContext("", network, tx)
|
pc := context.NewParameterContext("", network, tx)
|
||||||
h := c.CommitteeAcc.Contract.ScriptHash()
|
h := c.CommitteeAcc.Contract.ScriptHash()
|
||||||
if accType == ConsensusAccountName {
|
if accType == constants.ConsensusAccountName {
|
||||||
h = c.ConsensusAcc.Contract.ScriptHash()
|
h = c.ConsensusAcc.Contract.ScriptHash()
|
||||||
}
|
}
|
||||||
for _, w := range c.Wallets {
|
for _, w := range c.Wallets {
|
||||||
|
@ -477,7 +478,7 @@ func (c *InitializeContext) EmitUpdateNNSGroupScript(bw *io.BufBinWriter, nnsHas
|
||||||
if isAvail {
|
if isAvail {
|
||||||
emit.AppCall(bw.BinWriter, nnsHash, "register", callflag.All,
|
emit.AppCall(bw.BinWriter, nnsHash, "register", callflag.All,
|
||||||
client.NNSGroupKeyName, c.CommitteeAcc.Contract.ScriptHash(),
|
client.NNSGroupKeyName, c.CommitteeAcc.Contract.ScriptHash(),
|
||||||
FrostfsOpsEmail, int64(3600), int64(600), int64(DefaultExpirationTime), int64(3600))
|
constants.FrostfsOpsEmail, int64(3600), int64(600), int64(constants.DefaultExpirationTime), int64(3600))
|
||||||
emit.Opcodes(bw.BinWriter, opcode.ASSERT)
|
emit.Opcodes(bw.BinWriter, opcode.ASSERT)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,7 +499,7 @@ func (c *InitializeContext) NNSRegisterDomainScript(nnsHash, expectedHash util.U
|
||||||
bw := io.NewBufBinWriter()
|
bw := io.NewBufBinWriter()
|
||||||
emit.AppCall(bw.BinWriter, nnsHash, "register", callflag.All,
|
emit.AppCall(bw.BinWriter, nnsHash, "register", callflag.All,
|
||||||
domain, c.CommitteeAcc.Contract.ScriptHash(),
|
domain, c.CommitteeAcc.Contract.ScriptHash(),
|
||||||
FrostfsOpsEmail, int64(3600), int64(600), int64(DefaultExpirationTime), int64(3600))
|
constants.FrostfsOpsEmail, int64(3600), int64(600), int64(constants.DefaultExpirationTime), int64(3600))
|
||||||
emit.Opcodes(bw.BinWriter, opcode.ASSERT)
|
emit.Opcodes(bw.BinWriter, opcode.ASSERT)
|
||||||
|
|
||||||
if bw.Err != nil {
|
if bw.Err != nil {
|
||||||
|
@ -535,8 +536,8 @@ func (c *InitializeContext) GetContract(ctrName string) *ContractState {
|
||||||
|
|
||||||
func (c *InitializeContext) GetAlphabetDeployItems(i, n int) []any {
|
func (c *InitializeContext) GetAlphabetDeployItems(i, n int) []any {
|
||||||
items := make([]any, 5)
|
items := make([]any, 5)
|
||||||
items[0] = c.Contracts[NetmapContract].Hash
|
items[0] = c.Contracts[constants.NetmapContract].Hash
|
||||||
items[1] = c.Contracts[ProxyContract].Hash
|
items[1] = c.Contracts[constants.ProxyContract].Hash
|
||||||
items[2] = innerring.GlagoliticLetter(i).String()
|
items[2] = innerring.GlagoliticLetter(i).String()
|
||||||
items[3] = int64(i)
|
items[3] = int64(i)
|
||||||
items[4] = int64(n)
|
items[4] = int64(n)
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/config"
|
"github.com/nspcc-dev/neo-go/pkg/config"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core"
|
"github.com/nspcc-dev/neo-go/pkg/core"
|
||||||
|
@ -47,7 +48,7 @@ type LocalClient struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLocalClient(cmd *cobra.Command, v *viper.Viper, wallets []*wallet.Wallet, dumpPath string) (*LocalClient, error) {
|
func NewLocalClient(cmd *cobra.Command, v *viper.Viper, wallets []*wallet.Wallet, dumpPath string) (*LocalClient, error) {
|
||||||
cfg, err := config.LoadFile(v.GetString(ProtoConfigPath))
|
cfg, err := config.LoadFile(v.GetString(constants.ProtoConfigPath))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -60,7 +61,7 @@ func NewLocalClient(cmd *cobra.Command, v *viper.Viper, wallets []*wallet.Wallet
|
||||||
m := smartcontract.GetDefaultHonestNodeCount(int(cfg.ProtocolConfiguration.ValidatorsCount))
|
m := smartcontract.GetDefaultHonestNodeCount(int(cfg.ProtocolConfiguration.ValidatorsCount))
|
||||||
accounts := make([]*wallet.Account, len(wallets))
|
accounts := make([]*wallet.Account, len(wallets))
|
||||||
for i := range accounts {
|
for i := range accounts {
|
||||||
accounts[i], err = GetWalletAccount(wallets[i], ConsensusAccountName)
|
accounts[i], err = GetWalletAccount(wallets[i], constants.ConsensusAccountName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/invoker"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/invoker"
|
||||||
|
@ -88,7 +89,7 @@ func GetNetConfigFromNetmapContract(roInvoker *invoker.Invoker) ([]stackitem.Ite
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("get nns contract: %w", err)
|
return nil, fmt.Errorf("get nns contract: %w", err)
|
||||||
}
|
}
|
||||||
nmHash, err := NNSResolveHash(roInvoker, cs.Hash, DomainOf(NetmapContract))
|
nmHash, err := NNSResolveHash(roInvoker, cs.Hash, DomainOf(constants.NetmapContract))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("can't get netmap contract hash: %w", err)
|
return nil, fmt.Errorf("can't get netmap contract hash: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/config"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/config"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
@ -27,7 +28,7 @@ func GetAlphabetWallets(v *viper.Viper, walletDir string) ([]*wallet.Wallet, err
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(wallets) > MaxAlphabetNodes {
|
if len(wallets) > constants.MaxAlphabetNodes {
|
||||||
return nil, ErrTooManyAlphabetNodes
|
return nil, ErrTooManyAlphabetNodes
|
||||||
}
|
}
|
||||||
return wallets, nil
|
return wallets, nil
|
||||||
|
@ -161,7 +162,7 @@ func readContractsFromArchive(file io.Reader, names []string) (map[string]*Contr
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAlphabetNNSDomain(i int) string {
|
func GetAlphabetNNSDomain(i int) string {
|
||||||
return AlphabetContract + strconv.FormatUint(uint64(i), 10) + ".frostfs"
|
return constants.AlphabetContract + strconv.FormatUint(uint64(i), 10) + ".frostfs"
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseGASAmount(s string) (fixedn.Fixed8, error) {
|
func ParseGASAmount(s string) (fixedn.Fixed8, error) {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/config"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/config"
|
||||||
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -13,12 +14,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func InitializeContractWallet(v *viper.Viper, walletDir string) (*wallet.Wallet, error) {
|
func InitializeContractWallet(v *viper.Viper, walletDir string) (*wallet.Wallet, error) {
|
||||||
password, err := config.GetPassword(v, ContractWalletPasswordKey)
|
password, err := config.GetPassword(v, constants.ContractWalletPasswordKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
w, err := wallet.NewWallet(filepath.Join(walletDir, ContractWalletFilename))
|
w, err := wallet.NewWallet(filepath.Join(walletDir, constants.ContractWalletFilename))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -42,7 +43,7 @@ func InitializeContractWallet(v *viper.Viper, walletDir string) (*wallet.Wallet,
|
||||||
}
|
}
|
||||||
|
|
||||||
func openContractWallet(v *viper.Viper, cmd *cobra.Command, walletDir string) (*wallet.Wallet, error) {
|
func openContractWallet(v *viper.Viper, cmd *cobra.Command, walletDir string) (*wallet.Wallet, error) {
|
||||||
p := filepath.Join(walletDir, ContractWalletFilename)
|
p := filepath.Join(walletDir, constants.ContractWalletFilename)
|
||||||
w, err := wallet.NewWalletFromFile(p)
|
w, err := wallet.NewWalletFromFile(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
|
@ -53,7 +54,7 @@ func openContractWallet(v *viper.Viper, cmd *cobra.Command, walletDir string) (*
|
||||||
return InitializeContractWallet(v, walletDir)
|
return InitializeContractWallet(v, walletDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
password, err := config.GetPassword(v, ContractWalletPasswordKey)
|
password, err := config.GetPassword(v, constants.ContractWalletPasswordKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue