Compare commits
7 commits
master
...
neofs-adm-
Author | SHA1 | Date | |
---|---|---|---|
|
1231db87b5 | ||
|
9a91ec4c5b | ||
|
bfabbb7968 | ||
|
f9ff3adef2 | ||
|
44bf2e8d06 | ||
|
bd3f43cdeb | ||
|
a01b05a09c |
7 changed files with 92 additions and 14 deletions
|
@ -38,7 +38,7 @@ const (
|
||||||
// notaryEnabled signifies whether contracts were deployed in a notary-enabled environment.
|
// notaryEnabled signifies whether contracts were deployed in a notary-enabled environment.
|
||||||
// The setting is here to simplify testing and building the command for testnet (notary currently disabled).
|
// The setting is here to simplify testing and building the command for testnet (notary currently disabled).
|
||||||
// It will be removed eventually.
|
// It will be removed eventually.
|
||||||
notaryEnabled = true
|
notaryEnabled = false
|
||||||
)
|
)
|
||||||
|
|
||||||
func dumpBalances(cmd *cobra.Command, _ []string) error {
|
func dumpBalances(cmd *cobra.Command, _ []string) error {
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
|
||||||
"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/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"
|
||||||
|
@ -414,16 +413,16 @@ func getNativeHashes(c Client) (map[string]util.Uint160, error) {
|
||||||
return nil, fmt.Errorf("can't get native contract hashes: %w", err)
|
return nil, fmt.Errorf("can't get native contract hashes: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
notaryEnabled := false
|
//notaryEnabled := false
|
||||||
nativeHashes := make(map[string]util.Uint160, len(ns))
|
nativeHashes := make(map[string]util.Uint160, len(ns))
|
||||||
for i := range ns {
|
for i := range ns {
|
||||||
if ns[i].Manifest.Name == nativenames.Notary {
|
//if ns[i].Manifest.Name == nativenames.Notary {
|
||||||
notaryEnabled = len(ns[i].UpdateHistory) > 0
|
// notaryEnabled = len(ns[i].UpdateHistory) > 0
|
||||||
}
|
//}
|
||||||
nativeHashes[ns[i].Manifest.Name] = ns[i].Hash
|
nativeHashes[ns[i].Manifest.Name] = ns[i].Hash
|
||||||
}
|
}
|
||||||
if !notaryEnabled {
|
//if !notaryEnabled {
|
||||||
return nil, errors.New("notary contract must be enabled")
|
// return nil, errors.New("notary contract must be enabled")
|
||||||
}
|
//}
|
||||||
return nativeHashes, nil
|
return nativeHashes, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
io2 "github.com/nspcc-dev/neo-go/pkg/io"
|
io2 "github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/nef"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/nef"
|
||||||
|
@ -70,7 +69,6 @@ var (
|
||||||
containerContract,
|
containerContract,
|
||||||
neofsIDContract,
|
neofsIDContract,
|
||||||
netmapContract,
|
netmapContract,
|
||||||
proxyContract,
|
|
||||||
reputationContract,
|
reputationContract,
|
||||||
subnetContract,
|
subnetContract,
|
||||||
}
|
}
|
||||||
|
@ -521,14 +519,14 @@ func getContractDeployParameters(cs *contractState, deployData []interface{}) []
|
||||||
|
|
||||||
func (c *initializeContext) getContractDeployData(ctrName string, keysParam []interface{}) []interface{} {
|
func (c *initializeContext) getContractDeployData(ctrName string, keysParam []interface{}) []interface{} {
|
||||||
items := make([]interface{}, 1, 6)
|
items := make([]interface{}, 1, 6)
|
||||||
items[0] = false // notaryDisabled is false
|
items[0] = true // notaryDisabled is false
|
||||||
|
|
||||||
switch ctrName {
|
switch ctrName {
|
||||||
case neofsContract:
|
case neofsContract:
|
||||||
items = append(items,
|
items = append(items,
|
||||||
c.Contracts[processingContract].Hash,
|
c.Contracts[processingContract].Hash,
|
||||||
keysParam,
|
keysParam,
|
||||||
smartcontract.Parameter{})
|
[]interface{}{})
|
||||||
case processingContract:
|
case processingContract:
|
||||||
items = append(items, c.Contracts[neofsContract].Hash)
|
items = append(items, c.Contracts[neofsContract].Hash)
|
||||||
return items[1:] // no notary info
|
return items[1:] // no notary info
|
||||||
|
@ -588,7 +586,7 @@ func (c *initializeContext) getAlphabetDeployItems(i, n int) []interface{} {
|
||||||
items := make([]interface{}, 6)
|
items := make([]interface{}, 6)
|
||||||
items[0] = false
|
items[0] = false
|
||||||
items[1] = c.Contracts[netmapContract].Hash
|
items[1] = c.Contracts[netmapContract].Hash
|
||||||
items[2] = c.Contracts[proxyContract].Hash
|
items[2] = util.Uint160{}
|
||||||
items[3] = innerring.GlagoliticLetter(i).String()
|
items[3] = innerring.GlagoliticLetter(i).String()
|
||||||
items[4] = int64(i)
|
items[4] = int64(i)
|
||||||
items[5] = int64(n)
|
items[5] = int64(n)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *initializeContext) setNotaryAndAlphabetNodes() error {
|
func (c *initializeContext) setNotaryAndAlphabetNodes() error {
|
||||||
|
return nil
|
||||||
if ok, err := c.setRolesFinished(); ok || err != nil {
|
if ok, err := c.setRolesFinished(); ok || err != nil {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
c.Command.Println("Stage 2: already performed.")
|
c.Command.Println("Stage 2: already performed.")
|
||||||
|
|
|
@ -135,6 +135,7 @@ func (c *initializeContext) multiSign(tx *transaction.Transaction, accType strin
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *initializeContext) transferGASToProxy() error {
|
func (c *initializeContext) transferGASToProxy() error {
|
||||||
|
return nil
|
||||||
gasHash := c.nativeHash(nativenames.Gas)
|
gasHash := c.nativeHash(nativenames.Gas)
|
||||||
proxyCs := c.getContract(proxyContract)
|
proxyCs := c.getContract(proxyContract)
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,16 @@ var (
|
||||||
RunE: updateContracts,
|
RunE: updateContracts,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hardcodeNNSCmd = &cobra.Command{
|
||||||
|
Use: "hardcode-nns",
|
||||||
|
Short: "FIX for mainnet update",
|
||||||
|
PreRun: func(cmd *cobra.Command, _ []string) {
|
||||||
|
_ = viper.BindPFlag(alphabetWalletsFlag, cmd.Flags().Lookup(alphabetWalletsFlag))
|
||||||
|
_ = viper.BindPFlag(endpointFlag, cmd.Flags().Lookup(endpointFlag))
|
||||||
|
},
|
||||||
|
RunE: hardcodeNNS,
|
||||||
|
}
|
||||||
|
|
||||||
dumpContainersCmd = &cobra.Command{
|
dumpContainersCmd = &cobra.Command{
|
||||||
Use: "dump-containers",
|
Use: "dump-containers",
|
||||||
Short: "Dump NeoFS containers to file",
|
Short: "Dump NeoFS containers to file",
|
||||||
|
@ -274,6 +284,10 @@ func init() {
|
||||||
dumpBalancesCmd.Flags().BoolP(dumpBalancesProxyFlag, "p", false, "dump balances of the proxy contract")
|
dumpBalancesCmd.Flags().BoolP(dumpBalancesProxyFlag, "p", false, "dump balances of the proxy contract")
|
||||||
dumpBalancesCmd.Flags().Bool(dumpBalancesUseScriptHashFlag, false, "use script-hash format for addresses")
|
dumpBalancesCmd.Flags().Bool(dumpBalancesUseScriptHashFlag, false, "use script-hash format for addresses")
|
||||||
|
|
||||||
|
RootCmd.AddCommand(hardcodeNNSCmd)
|
||||||
|
hardcodeNNSCmd.Flags().String(alphabetWalletsFlag, "", "path to alphabet wallets dir")
|
||||||
|
hardcodeNNSCmd.Flags().StringP(endpointFlag, "r", "", "N3 RPC node endpoint")
|
||||||
|
|
||||||
RootCmd.AddCommand(updateContractsCmd)
|
RootCmd.AddCommand(updateContractsCmd)
|
||||||
updateContractsCmd.Flags().String(alphabetWalletsFlag, "", "path to alphabet wallets dir")
|
updateContractsCmd.Flags().String(alphabetWalletsFlag, "", "path to alphabet wallets dir")
|
||||||
updateContractsCmd.Flags().StringP(endpointFlag, "r", "", "N3 RPC node endpoint")
|
updateContractsCmd.Flags().StringP(endpointFlag, "r", "", "N3 RPC node endpoint")
|
||||||
|
|
|
@ -3,6 +3,11 @@ package morph
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
@ -19,3 +24,63 @@ func updateContracts(cmd *cobra.Command, _ []string) error {
|
||||||
|
|
||||||
return wCtx.updateContracts()
|
return wCtx.updateContracts()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func hardcodeNNS(cmd *cobra.Command, _ []string) error {
|
||||||
|
c, err := newInitializeContext(cmd, viper.GetViper())
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("initialization error: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
nnsCs, err := c.Client.GetContractStateByID(1)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIX for mainnet, set hardcoded hashes. */
|
||||||
|
hashes := map[string]string{
|
||||||
|
//"neofs.neofs": "2cafa46838e8b564468ebd868dcafdd99dce6221",
|
||||||
|
"audit.neofs": "85fe181f4aa3cbdc94023d97c69001ece0730398",
|
||||||
|
"balance.neofs": "dc1ec98d9d0c5f9dfade16144defe08cffc5ca55",
|
||||||
|
"container.neofs": "1b6e68d299b570e1cb7e86eadfdc06aa2e8e0cc5",
|
||||||
|
"neofsid.neofs": "0a64ce753653cc97c0467e1334d9d3678ca8c682",
|
||||||
|
"netmap.neofs": "7c5bdb23e36cc7cce95bf42f3ab9e452c2501df1",
|
||||||
|
"reputation.neofs": "7ad824fd1eeb1565be2cee3889214b9aa605d2fc",
|
||||||
|
/* "az": */ getAlphabetNNSDomain(0): "2392438eb31100857c0f161c66791872b249aa13",
|
||||||
|
/* "buky": */ getAlphabetNNSDomain(1): "83ef4226d5d6519ca9c99a5de13b1b5ca223a6ad",
|
||||||
|
/* "vedi": */ getAlphabetNNSDomain(2): "6250927beaa9aa5a00171379dcb7187b0c91d17d",
|
||||||
|
/* "glagoli": */ getAlphabetNNSDomain(3): "1d6a2519ba41a139b2ced1bfd5013938271a7578",
|
||||||
|
/* "dobro": */ getAlphabetNNSDomain(4): "b65fc7a3c31cf57a90d7eb1c0e9909e4ca69133c",
|
||||||
|
/* "yest": */ getAlphabetNNSDomain(5): "f95b6ff8cd3b027c9911c18115518ad8c5d2f591",
|
||||||
|
/* "zhivete": */ getAlphabetNNSDomain(6): "5b17c579bf56884fd68af152432b3b5aee7aee76",
|
||||||
|
}
|
||||||
|
|
||||||
|
w := io.NewBufBinWriter()
|
||||||
|
emit.AppCall(w.BinWriter, nnsCs.Hash, "setPrice", callflag.All, 1)
|
||||||
|
for name, sh := range hashes {
|
||||||
|
h, err := util.Uint160DecodeStringLE(sh)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("invalid hash: %s", sh)
|
||||||
|
}
|
||||||
|
cs, err := c.Client.GetContractStateByHash(h)
|
||||||
|
if err != nil || cs.Hash != h {
|
||||||
|
return fmt.Errorf("contract %s should have hash %s, but: %w", name, sh, err)
|
||||||
|
}
|
||||||
|
c.Command.Printf("Domain %s will be registered again\n", name)
|
||||||
|
emit.AppCall(w.BinWriter, nnsCs.Hash, "register", callflag.All,
|
||||||
|
name, c.CommitteeAcc.Contract.ScriptHash(),
|
||||||
|
"ops@nspcc.ru", int64(3600), int64(600), int64(604800), int64(3600))
|
||||||
|
emit.Opcodes(w.BinWriter, opcode.ASSERT)
|
||||||
|
//emit.AppCall(w.BinWriter, nnsCs.Hash, "addRecord", callflag.All,
|
||||||
|
// name, int64(nns.TXT), h.StringLE())
|
||||||
|
//c.Command.Printf("NNS: Set %s -> %s\n", name, h.StringLE())
|
||||||
|
}
|
||||||
|
emit.AppCall(w.BinWriter, nnsCs.Hash, "setPrice", callflag.All, 10_0000_0000)
|
||||||
|
if w.Err != nil {
|
||||||
|
panic(w.Err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := c.sendCommitteeTx(w.Bytes(), -1, false); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return c.awaitTx()
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue