diff --git a/cmd/neofs-adm/internal/modules/morph/balance.go b/cmd/neofs-adm/internal/modules/morph/balance.go index a113758b..480a3e9d 100644 --- a/cmd/neofs-adm/internal/modules/morph/balance.go +++ b/cmd/neofs-adm/internal/modules/morph/balance.go @@ -15,9 +15,9 @@ import ( "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" "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" "github.com/nspcc-dev/neofs-sdk-go/netmap" "github.com/spf13/cobra" @@ -94,7 +94,7 @@ func dumpBalances(cmd *cobra.Command, _ []string) error { if dumpStorage { res, err := invokeFunction(c, nmHash, "netmap", []interface{}{}, nil) - if err != nil || res.State != vm.HaltState.String() || len(res.Stack) == 0 { + if err != nil || res.State != vmstate.Halt.String() || len(res.Stack) == 0 { return errors.New("can't fetch the list of storage nodes") } arr, ok := res.Stack[0].Value().([]stackitem.Item) @@ -197,7 +197,7 @@ func fetchIRNodes(c Client, nmHash, desigHash util.Uint160) ([]accBalancePair, e } } else { res, err := invokeFunction(c, nmHash, "innerRingList", []interface{}{}, nil) - if err != nil || res.State != vm.HaltState.String() || len(res.Stack) == 0 { + if err != nil || res.State != vmstate.Halt.String() || len(res.Stack) == 0 { return nil, errors.New("can't fetch list of IR nodes from the netmap contract") } @@ -251,7 +251,7 @@ func fetchBalances(c Client, gasHash util.Uint160, accounts []accBalancePair) er } res, err := c.InvokeScript(w.Bytes(), nil) - if err != nil || res.State != vm.HaltState.String() || len(res.Stack) != len(accounts) { + if err != nil || res.State != vmstate.Halt.String() || len(res.Stack) != len(accounts) { return errors.New("can't fetch account balances") } diff --git a/cmd/neofs-adm/internal/modules/morph/config.go b/cmd/neofs-adm/internal/modules/morph/config.go index ff2702e7..9f969a52 100644 --- a/cmd/neofs-adm/internal/modules/morph/config.go +++ b/cmd/neofs-adm/internal/modules/morph/config.go @@ -13,9 +13,9 @@ import ( "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" "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" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -112,7 +112,7 @@ func dumpContractHashes(cmd *cobra.Command, _ []string) error { return fmt.Errorf("can't fetch info from NNS: %w", err) } - if res.State == vm.HaltState.String() { + if res.State == vmstate.Halt.String() { for i := range res.Stack { infos[i].version = parseContractVersion(res.Stack[i]) } @@ -163,7 +163,7 @@ func dumpNetworkConfig(cmd *cobra.Command, _ []string) error { } res, err := invokeFunction(c, nmHash, "listConfig", nil, nil) - if err != nil || res.State != vm.HaltState.String() || len(res.Stack) == 0 { + if err != nil || res.State != vmstate.Halt.String() || len(res.Stack) == 0 { return errors.New("can't fetch list of network config keys from the netmap contract") } diff --git a/cmd/neofs-adm/internal/modules/morph/epoch.go b/cmd/neofs-adm/internal/modules/morph/epoch.go index 67dd048c..bbf498e2 100644 --- a/cmd/neofs-adm/internal/modules/morph/epoch.go +++ b/cmd/neofs-adm/internal/modules/morph/epoch.go @@ -7,8 +7,8 @@ import ( "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" "github.com/nspcc-dev/neo-go/pkg/vm/emit" + "github.com/nspcc-dev/neo-go/pkg/vm/vmstate" "github.com/spf13/cobra" "github.com/spf13/viper" ) @@ -43,7 +43,7 @@ func forceNewEpochCmd(cmd *cobra.Command, args []string) error { func emitNewEpochCall(bw *io.BufBinWriter, wCtx *initializeContext, nmHash util.Uint160) error { res, err := invokeFunction(wCtx.Client, nmHash, "epoch", nil, nil) - if err != nil || res.State != vm.HaltState.String() || len(res.Stack) == 0 { + if err != nil || res.State != vmstate.Halt.String() || len(res.Stack) == 0 { return errors.New("can't fetch current epoch from the netmap contract") } diff --git a/cmd/neofs-adm/internal/modules/morph/initialize.go b/cmd/neofs-adm/internal/modules/morph/initialize.go index aa63eff6..9ffd2853 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize.go @@ -14,7 +14,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/rpc/client" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/util" - "github.com/nspcc-dev/neo-go/pkg/vm" + "github.com/nspcc-dev/neo-go/pkg/vm/vmstate" "github.com/nspcc-dev/neo-go/pkg/wallet" "github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/config" "github.com/nspcc-dev/neofs-node/pkg/innerring" @@ -333,7 +333,7 @@ loop: for i := range c.Hashes { res, err := c.Client.GetApplicationLog(c.Hashes[i], &at) if err == nil { - if retErr == nil && len(res.Executions) > 0 && res.Executions[0].VMState != vm.HaltState { + if retErr == nil && len(res.Executions) > 0 && res.Executions[0].VMState != vmstate.Halt { retErr = fmt.Errorf("tx %d persisted in %s state: %s", i, res.Executions[0].VMState, res.Executions[0].FaultException) } @@ -344,7 +344,7 @@ loop: case <-tick.C: res, err := c.Client.GetApplicationLog(c.Hashes[i], &at) if err == nil { - if retErr == nil && len(res.Executions) > 0 && res.Executions[0].VMState != vm.HaltState { + if retErr == nil && len(res.Executions) > 0 && res.Executions[0].VMState != vmstate.Halt { retErr = fmt.Errorf("tx %d persisted in %s state: %s", i, res.Executions[0].VMState, res.Executions[0].FaultException) } diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go b/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go index 0a217ca3..0aba7dfe 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go @@ -23,9 +23,9 @@ import ( "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/util" - "github.com/nspcc-dev/neo-go/pkg/vm" "github.com/nspcc-dev/neo-go/pkg/vm/emit" "github.com/nspcc-dev/neo-go/pkg/vm/opcode" + "github.com/nspcc-dev/neo-go/pkg/vm/vmstate" "github.com/nspcc-dev/neofs-node/pkg/innerring" morphClient "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/spf13/viper" @@ -129,7 +129,7 @@ func (c *initializeContext) deployNNS(method string) error { if err != nil { return fmt.Errorf("can't deploy NNS contract: %w", err) } - if res.State != vm.HaltState.String() { + if res.State != vmstate.Halt.String() { return fmt.Errorf("can't deploy NNS contract: %s", res.FaultException) } @@ -201,7 +201,7 @@ func (c *initializeContext) updateContracts() error { if err != nil { return fmt.Errorf("can't update alphabet contracts: %w", err) } - if res.State != vm.HaltState.String() { + if res.State != vmstate.Halt.String() { return fmt.Errorf("can't update alphabet contracts: %s", res.FaultException) } @@ -243,7 +243,7 @@ func (c *initializeContext) updateContracts() error { if err != nil { return fmt.Errorf("can't deploy %s contract: %w", ctrName, err) } - if res.State != vm.HaltState.String() { + if res.State != vmstate.Halt.String() { return fmt.Errorf("can't deploy %s contract: %s", ctrName, res.FaultException) } @@ -311,7 +311,7 @@ func (c *initializeContext) deployContracts() error { if err != nil { return fmt.Errorf("can't deploy alphabet #%d contract: %w", i, err) } - if res.State != vm.HaltState.String() { + if res.State != vmstate.Halt.String() { return fmt.Errorf("can't deploy alpabet #%d contract: %s", i, res.FaultException) } @@ -344,7 +344,7 @@ func (c *initializeContext) deployContracts() error { if err != nil { return fmt.Errorf("can't deploy %s contract: %w", ctrName, err) } - if res.State != vm.HaltState.String() { + if res.State != vmstate.Halt.String() { return fmt.Errorf("can't deploy %s contract: %s", ctrName, res.FaultException) } diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_nns.go b/cmd/neofs-adm/internal/modules/morph/initialize_nns.go index d59a0307..63e94d06 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_nns.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_nns.go @@ -14,10 +14,10 @@ import ( "github.com/nspcc-dev/neo-go/pkg/rpc/client" "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" "github.com/nspcc-dev/neo-go/pkg/vm/emit" "github.com/nspcc-dev/neo-go/pkg/vm/opcode" "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" morphClient "github.com/nspcc-dev/neofs-node/pkg/morph/client" ) @@ -169,7 +169,7 @@ func (c *initializeContext) nnsRootRegistered(nnsHash util.Uint160) (bool, error if err != nil { return false, err } - return res.State == vm.HaltState.String(), nil + return res.State == vmstate.Halt.String(), nil } var errMissingNNSRecord = errors.New("missing NNS record") @@ -188,7 +188,7 @@ func nnsResolve(c Client, nnsHash util.Uint160, domain string) (stackitem.Item, if err != nil { return nil, fmt.Errorf("`resolve`: %w", err) } - if result.State != vm.HaltState.String() { + if result.State != vmstate.Halt.String() { if strings.Contains(result.FaultException, "token not found") { return nil, errMissingNNSRecord } diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_register.go b/cmd/neofs-adm/internal/modules/morph/initialize_register.go index 2480978f..9a770dc8 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_register.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_register.go @@ -11,10 +11,10 @@ import ( "github.com/nspcc-dev/neo-go/pkg/rpc/client" "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" "github.com/nspcc-dev/neo-go/pkg/vm/emit" "github.com/nspcc-dev/neo-go/pkg/vm/opcode" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" + "github.com/nspcc-dev/neo-go/pkg/vm/vmstate" ) // initialAlphabetNEOAmount represents the total amount of GAS distributed between alphabet nodes. @@ -27,7 +27,7 @@ func (c *initializeContext) registerCandidates() error { if err != nil { return err } - if res.State == vm.HaltState.String() && len(res.Stack) > 0 { + if res.State == vmstate.Halt.String() && len(res.Stack) > 0 { arr, ok := res.Stack[0].Value().([]stackitem.Item) if ok && len(arr) > 0 { return nil diff --git a/cmd/neofs-adm/internal/modules/morph/local_client.go b/cmd/neofs-adm/internal/modules/morph/local_client.go index 746079c7..ba497103 100644 --- a/cmd/neofs-adm/internal/modules/morph/local_client.go +++ b/cmd/neofs-adm/internal/modules/morph/local_client.go @@ -28,10 +28,10 @@ import ( "github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/util" - "github.com/nspcc-dev/neo-go/pkg/vm" "github.com/nspcc-dev/neo-go/pkg/vm/emit" "github.com/nspcc-dev/neo-go/pkg/vm/opcode" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" + "github.com/nspcc-dev/neo-go/pkg/vm/vmstate" "github.com/nspcc-dev/neo-go/pkg/wallet" "github.com/spf13/viper" "go.uber.org/zap" @@ -233,7 +233,7 @@ func (l *localClient) NEP17BalanceOf(h util.Uint160, acc util.Uint160) (int64, e if err != nil { return 0, err } - if res.State != vm.HaltState.String() || len(res.Stack) == 0 { + if res.State != vmstate.Halt.String() || len(res.Stack) == 0 { return 0, fmt.Errorf("`balance`: invalid response (empty: %t): %s", len(res.Stack) == 0, res.FaultException) } @@ -341,7 +341,7 @@ func getDesignatedByRole(c Client, h util.Uint160, role noderoles.Role, u uint32 if err != nil { return nil, err } - if res.State != vm.HaltState.String() || len(res.Stack) == 0 { + if res.State != vmstate.Halt.String() || len(res.Stack) == 0 { return nil, errGetDesignatedByRoleResponse } arr, ok := res.Stack[0].Value().([]stackitem.Item) diff --git a/cmd/neofs-adm/internal/modules/storagecfg/root.go b/cmd/neofs-adm/internal/modules/storagecfg/root.go index 45fd9abb..3e6fb5fa 100644 --- a/cmd/neofs-adm/internal/modules/storagecfg/root.go +++ b/cmd/neofs-adm/internal/modules/storagecfg/root.go @@ -28,7 +28,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/util" - "github.com/nspcc-dev/neo-go/pkg/vm" + "github.com/nspcc-dev/neo-go/pkg/vm/vmstate" "github.com/nspcc-dev/neo-go/pkg/wallet" netutil "github.com/nspcc-dev/neofs-node/pkg/network" @@ -328,7 +328,7 @@ func depositGas(cmd *cobra.Command, acc *wallet.Account, network string) { }}, nil) fatalOnErr(err) - if res.State != vm.HaltState.String() { + if res.State != vmstate.Halt.String() { fatalOnErr(fmt.Errorf("invalid response from balance contract: %s", res.FaultException)) } diff --git a/go.mod b/go.mod index 7b096a85..a6ccbecc 100644 --- a/go.mod +++ b/go.mod @@ -15,8 +15,8 @@ require ( github.com/multiformats/go-multiaddr v0.4.0 github.com/nats-io/nats.go v1.13.1-0.20220308171302-2f2f6968e98d github.com/nspcc-dev/hrw v1.0.9 - github.com/nspcc-dev/neo-go v0.99.1-pre.0.20220609082921-2c9fb2044242 - github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220601120906-3bec6657f5c5 // indirect + github.com/nspcc-dev/neo-go v0.99.1-pre.0.20220714084516-54849ef3e58e + github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220713145417-4f184498bc42 // indirect github.com/nspcc-dev/neofs-api-go/v2 v2.13.0 github.com/nspcc-dev/neofs-contract v0.15.1 github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.5.0.20220706151041-0d862d8568a4 diff --git a/go.sum b/go.sum index b74ff386..1c82bb69 100644 Binary files a/go.sum and b/go.sum differ diff --git a/pkg/morph/client/client.go b/pkg/morph/client/client.go index dd5ad73f..98613c44 100644 --- a/pkg/morph/client/client.go +++ b/pkg/morph/client/client.go @@ -18,8 +18,8 @@ import ( sc "github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/util" - "github.com/nspcc-dev/neo-go/pkg/vm" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" + "github.com/nspcc-dev/neo-go/pkg/vm/vmstate" "github.com/nspcc-dev/neo-go/pkg/wallet" "github.com/nspcc-dev/neofs-node/pkg/util/logger" "go.uber.org/zap" @@ -385,7 +385,7 @@ func (c *Client) TxHalt(h util.Uint256) (res bool, err error) { if err != nil { return false, err } - return len(aer.Executions) > 0 && aer.Executions[0].VMState.HasFlag(vm.HaltState), nil + return len(aer.Executions) > 0 && aer.Executions[0].VMState.HasFlag(vmstate.Halt), nil } // TxHeight returns true if transaction has been successfully executed and persisted. @@ -562,7 +562,7 @@ func (c *Client) IsValidScript(script []byte, signers []transaction.Signer) (res return false, fmt.Errorf("invokeScript: %w", err) } - return result.State == vm.HaltState.String(), nil + return result.State == vmstate.Halt.String(), nil } // NotificationChannel returns channel than receives subscribed diff --git a/pkg/morph/client/nns.go b/pkg/morph/client/nns.go index eff76c2b..3bf29c56 100644 --- a/pkg/morph/client/nns.go +++ b/pkg/morph/client/nns.go @@ -11,8 +11,8 @@ import ( "github.com/nspcc-dev/neo-go/pkg/rpc/client" "github.com/nspcc-dev/neo-go/pkg/smartcontract" "github.com/nspcc-dev/neo-go/pkg/util" - "github.com/nspcc-dev/neo-go/pkg/vm" "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" ) @@ -121,7 +121,7 @@ func nnsResolveItem(c *client.WSClient, nnsHash util.Uint160, domain string) (st if err != nil { return nil, err } - if result.State != vm.HaltState.String() { + if result.State != vmstate.Halt.String() { return nil, fmt.Errorf("invocation failed: %s", result.FaultException) } if len(result.Stack) == 0 {