Skip to content

Commit

Permalink
upd/Neo-go to v0.103.0 (#2635)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-khimov authored Nov 7, 2023
2 parents 9423030 + 6da2ec2 commit 6b077ad
Show file tree
Hide file tree
Showing 16 changed files with 169 additions and 154 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Changelog for NeoFS Node
- Iteration over locally collected container estimation values (#2597)
- Synchronous objects `PUT` to the local storage (#2607)
- `copies_number` field was not used in `PUT` request handling (#2607)
- Neo-go notary deposit data workaround (#2429)

### Changed
- FSTree storage now uses more efficient and safe temporary files under Linux (#2566)
Expand All @@ -30,7 +31,7 @@ Changelog for NeoFS Node

### Updated
- Update minimal supported Go version up to v1.19 (#2485)
- Update `neo-go` to `v0.102.0` (#2221, #2309, #2596)
- Update `neo-go` to `v0.103.0` (#2221, #2309, #2596, #2626)
- `neofs-lens` `inspect` object commands to `get` with `inspect` deprecation (#2548)
- Update `tzhash` to `v1.7.1`
- `github.com/panjf2000/ants/v2` to `v2.8.2`
Expand Down
30 changes: 15 additions & 15 deletions cmd/neofs-adm/internal/modules/morph/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ import (
"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/fixedn"
"github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/gas"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/invoker"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/rolemgmt"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
"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/stackitem"
"github.com/nspcc-dev/neo-go/pkg/vm/vmstate"
"github.com/nspcc-dev/neofs-contract/nns"
Expand Down Expand Up @@ -126,17 +124,17 @@ func dumpBalances(cmd *cobra.Command, _ []string) error {
if dumpAlphabet {
alphaList := make([]accBalancePair, len(irList))

w := io.NewBufBinWriter()
b := smartcontract.NewBuilder()
for i := range alphaList {
emit.AppCall(w.BinWriter, nnsCs.Hash, "resolve", callflag.ReadOnly,
getAlphabetNNSDomain(i),
int64(nns.TXT))
b.InvokeMethod(nnsCs.Hash, "resolve", getAlphabetNNSDomain(i), int64(nns.TXT))
}
if w.Err != nil {
panic(w.Err)

script, err := b.Script()
if err != nil {
return fmt.Errorf("resolving alphabet hashes script: %w", err)
}

alphaRes, err := c.InvokeScript(w.Bytes(), nil)
alphaRes, err := c.InvokeScript(script, nil)
if err != nil {
return fmt.Errorf("can't fetch info from NNS: %w", err)
}
Expand Down Expand Up @@ -194,15 +192,17 @@ func printBalances(cmd *cobra.Command, prefix string, accounts []accBalancePair)
}

func fetchBalances(c *invoker.Invoker, gasHash util.Uint160, accounts []accBalancePair) error {
w := io.NewBufBinWriter()
b := smartcontract.NewBuilder()
for i := range accounts {
emit.AppCall(w.BinWriter, gasHash, "balanceOf", callflag.ReadStates, accounts[i].scriptHash)
b.InvokeMethod(gasHash, "balanceOf", accounts[i].scriptHash)
}
if w.Err != nil {
panic(w.Err)

script, err := b.Script()
if err != nil {
return fmt.Errorf("reading balances script: %w", err)
}

res, err := c.Run(w.Bytes())
res, err := c.Run(script)
if err != nil || res.State != vmstate.Halt.String() || len(res.Stack) != len(accounts) {
return errors.New("can't fetch account balances")
}
Expand Down
18 changes: 9 additions & 9 deletions cmd/neofs-adm/internal/modules/morph/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import (
"strings"
"text/tabwriter"

"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/unwrap"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down Expand Up @@ -116,7 +114,7 @@ func setConfigCmd(cmd *cobra.Command, args []string) error {

forceFlag, _ := cmd.Flags().GetBool(forceConfigSet)

bw := io.NewBufBinWriter()
b := smartcontract.NewBuilder()
for _, arg := range args {
k, v, err := parseConfigPair(arg, forceFlag)
if err != nil {
Expand All @@ -126,13 +124,15 @@ func setConfigCmd(cmd *cobra.Command, args []string) error {
// In NeoFS this is done via Notary contract. Here, however, we can form the
// transaction locally. The first `nil` argument is required only for notary
// disabled environment which is not supported by that command.
emit.AppCall(bw.BinWriter, nmHash, "setConfig", callflag.All, nil, k, v)
if bw.Err != nil {
return fmt.Errorf("can't form raw transaction: %w", bw.Err)
}
b.InvokeMethod(nmHash, "setConfig", nil, k, v)
}

script, err := b.Script()
if err != nil {
return fmt.Errorf("config setting script: %w", err)
}

err = wCtx.sendConsensusTx(bw.Bytes())
err = wCtx.sendConsensusTx(script)
if err != nil {
return err
}
Expand Down
50 changes: 30 additions & 20 deletions cmd/neofs-adm/internal/modules/morph/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ import (
"sort"

"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
"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/unwrap"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
"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/stackitem"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -82,15 +80,21 @@ func dumpContainers(cmd *cobra.Command, _ []string) error {
}

var containers []*Container
bw := io.NewBufBinWriter()
b := smartcontract.NewBuilder()
for _, id := range cids {
if !isOK(id) {
continue
}
bw.Reset()
emit.AppCall(bw.BinWriter, ch, "get", callflag.All, id)
emit.AppCall(bw.BinWriter, ch, "eACL", callflag.All, id)
res, err := inv.Run(bw.Bytes())
b.Reset()
b.InvokeMethod(ch, "get", id)
b.InvokeMethod(ch, "eACL", id)

script, err := b.Script()
if err != nil {
return fmt.Errorf("dumping '%s' container script: %w", id, err)
}

res, err := inv.Run(script)
if err != nil {
return fmt.Errorf("can't get container info: %w", err)
}
Expand Down Expand Up @@ -190,15 +194,21 @@ func restoreContainers(cmd *cobra.Command, _ []string) error {
return err
}

bw := io.NewBufBinWriter()
b := smartcontract.NewBuilder()
for _, cnt := range containers {
hv := hash.Sha256(cnt.Value)
if !isOK(hv[:]) {
continue
}
bw.Reset()
emit.AppCall(bw.BinWriter, ch, "get", callflag.All, hv.BytesBE())
res, err := wCtx.Client.InvokeScript(bw.Bytes(), nil)
b.Reset()
b.InvokeMethod(ch, "get", hv.BytesBE())

script, err := b.Script()
if err != nil {
return fmt.Errorf("reading container script: %w", err)
}

res, err := wCtx.Client.InvokeScript(script, nil)
if err != nil {
return fmt.Errorf("can't check if container is already restored: %w", err)
}
Expand All @@ -217,18 +227,18 @@ func restoreContainers(cmd *cobra.Command, _ []string) error {
continue
}

bw.Reset()
emit.AppCall(bw.BinWriter, ch, "put", callflag.All,
cnt.Value, cnt.Signature, cnt.PublicKey, cnt.Token)
b.Reset()
b.InvokeMethod(ch, "put", cnt.Value, cnt.Signature, cnt.PublicKey, cnt.Token)
if ea := cnt.EACL; ea != nil {
emit.AppCall(bw.BinWriter, ch, "setEACL", callflag.All,
ea.Value, ea.Signature, ea.PublicKey, ea.Token)
b.InvokeMethod(ch, "setEACL", ea.Value, ea.Signature, ea.PublicKey, ea.Token)
}
if bw.Err != nil {
panic(bw.Err)

script, err = b.Script()
if err != nil {
return fmt.Errorf("container update script: %w", err)
}

if err := wCtx.sendConsensusTx(bw.Bytes()); err != nil {
if err := wCtx.sendConsensusTx(script); err != nil {
return err
}
}
Expand Down
28 changes: 18 additions & 10 deletions cmd/neofs-adm/internal/modules/morph/dump_hashes.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/rpcclient/invoker"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/nep11"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
"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"
Expand Down Expand Up @@ -60,17 +61,20 @@ func dumpContractHashes(cmd *cobra.Command, _ []string) error {
}
}

bw := io.NewBufBinWriter()
b := smartcontract.NewBuilder()

if irSize != 0 {
bw.Reset()
b.Reset()
for i := 0; i < irSize; i++ {
emit.AppCall(bw.BinWriter, cs.Hash, "resolve", callflag.ReadOnly,
getAlphabetNNSDomain(i),
int64(nns.TXT))
b.InvokeMethod(cs.Hash, "resolve", getAlphabetNNSDomain(i), int64(nns.TXT))
}

script, err := b.Script()
if err != nil {
return fmt.Errorf("resolving alphabet hashes script: %w", err)
}

alphaRes, err := c.InvokeScript(bw.Bytes(), nil)
alphaRes, err := c.InvokeScript(script, nil)
if err != nil {
return fmt.Errorf("can't fetch info from NNS: %w", err)
}
Expand All @@ -85,11 +89,15 @@ func dumpContractHashes(cmd *cobra.Command, _ []string) error {
}

for _, ctrName := range contractList {
bw.Reset()
emit.AppCall(bw.BinWriter, cs.Hash, "resolve", callflag.ReadOnly,
ctrName+".neofs", int64(nns.TXT))
b.Reset()
b.InvokeMethod(cs.Hash, "resolve", ctrName+".neofs", int64(nns.TXT))

script, err := b.Script()
if err != nil {
return fmt.Errorf("resolving neofs contract hashes script: %w", err)
}

res, err := c.InvokeScript(bw.Bytes(), nil)
res, err := c.InvokeScript(script, nil)
if err != nil {
return fmt.Errorf("can't fetch info from NNS: %w", err)
}
Expand Down
22 changes: 17 additions & 5 deletions cmd/neofs-adm/internal/modules/morph/initialize_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package morph
import (
"errors"
"fmt"
"math/big"

"github.com/nspcc-dev/neo-go/pkg/core/native"
"github.com/nspcc-dev/neo-go/pkg/core/state"
Expand All @@ -12,6 +13,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/rpcclient/actor"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/invoker"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/neo"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/nep17"
"github.com/nspcc-dev/neo-go/pkg/rpcclient/unwrap"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
"github.com/nspcc-dev/neo-go/pkg/util"
Expand Down Expand Up @@ -100,15 +102,25 @@ func (c *initializeContext) transferNEOToAlphabetContracts() error {
cs := c.getContract(alphabetContract)
amount := initialAlphabetNEOAmount / len(c.Wallets)

bw := io.NewBufBinWriter()
tNeo := nep17.New(c.CommitteeAct, neo.Hash)
pp := make([]nep17.TransferParameters, 0, len(c.Accounts))

for _, acc := range c.Accounts {
h := state.CreateContractHash(acc.Contract.ScriptHash(), cs.NEF.Checksum, cs.Manifest.Name)
emit.AppCall(bw.BinWriter, neo.Hash, "transfer", callflag.All,
c.CommitteeAcc.Contract.ScriptHash(), h, int64(amount), nil)
emit.Opcodes(bw.BinWriter, opcode.ASSERT)

pp = append(pp, nep17.TransferParameters{
From: c.CommitteeAcc.Contract.ScriptHash(),
To: h,
Amount: big.NewInt(int64(amount)),
})
}

tx, err := tNeo.MultiTransferUnsigned(pp)
if err != nil {
return fmt.Errorf("multi-transfer script: %w", err)
}

if err := c.sendCommitteeTx(bw.Bytes(), false); err != nil {
if err := c.multiSignAndSend(tx, committeeAccountName); err != nil {
return err
}

Expand Down
Loading

0 comments on commit 6b077ad

Please sign in to comment.