From 424cc6d49566cd57c25ef3ff1a99ce0aff5d6b02 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Sun, 27 Mar 2022 20:30:08 +0300 Subject: [PATCH] [#1170] go.mod: Update `neo-go` github.com/nspcc-dev/neo-go v0.98.0 => v0.98.2 Signed-off-by: Pavel Karpy --- cmd/neofs-adm/internal/modules/morph/dump.go | 2 +- .../internal/modules/morph/initialize_nns.go | 2 +- .../modules/morph/initialize_transfer.go | 7 ++++++- .../internal/modules/morph/notary.go | 9 ++++++++- go.mod | 3 ++- go.sum | Bin 96656 -> 98064 bytes pkg/morph/client/client.go | 13 +++++++++---- pkg/morph/client/nns.go | 2 +- pkg/morph/client/notary.go | 13 ++++++++++--- 9 files changed, 38 insertions(+), 13 deletions(-) diff --git a/cmd/neofs-adm/internal/modules/morph/dump.go b/cmd/neofs-adm/internal/modules/morph/dump.go index 7a63aa26dc..d785b47e9e 100644 --- a/cmd/neofs-adm/internal/modules/morph/dump.go +++ b/cmd/neofs-adm/internal/modules/morph/dump.go @@ -8,7 +8,6 @@ import ( "fmt" "text/tabwriter" - nns "github.com/nspcc-dev/neo-go/examples/nft-nd-nns" "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/smartcontract" @@ -17,6 +16,7 @@ import ( "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/neofs-contract/nns" "github.com/spf13/cobra" "github.com/spf13/viper" ) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_nns.go b/cmd/neofs-adm/internal/modules/morph/initialize_nns.go index cb4ec8a64c..7e109b23c1 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_nns.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_nns.go @@ -7,7 +7,6 @@ import ( "strconv" "strings" - nns "github.com/nspcc-dev/neo-go/examples/nft-nd-nns" "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/crypto/keys" @@ -20,6 +19,7 @@ import ( "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/neofs-contract/nns" morphClient "github.com/nspcc-dev/neofs-node/pkg/morph/client" ) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_transfer.go b/cmd/neofs-adm/internal/modules/morph/initialize_transfer.go index f8b00ae033..982c9da97d 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_transfer.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_transfer.go @@ -91,7 +91,12 @@ func (c *initializeContext) multiSignAndSend(tx *transaction.Transaction, accTyp } func (c *initializeContext) multiSign(tx *transaction.Transaction, accType string) error { - network := c.Client.GetNetwork() + network, err := c.Client.GetNetwork() + if err != nil { + // error appears only if client + // has not been initialized + panic(err) + } // Use parameter context to avoid dealing with signature order. pc := scContext.NewParameterContext("", network, tx) diff --git a/cmd/neofs-adm/internal/modules/morph/notary.go b/cmd/neofs-adm/internal/modules/morph/notary.go index be6b0a49b5..7c60ddd90f 100644 --- a/cmd/neofs-adm/internal/modules/morph/notary.go +++ b/cmd/neofs-adm/internal/modules/morph/notary.go @@ -124,7 +124,14 @@ func depositNotary(cmd *cobra.Command, _ []string) error { return fmt.Errorf("can't create tx: %w", err) } - err = acc.SignTx(c.GetNetwork(), tx) + mn, err := c.GetNetwork() + if err != nil { + // error appears only if client + // has not been initialized + panic(err) + } + + err = acc.SignTx(mn, tx) if err != nil { return fmt.Errorf("can't sign tx: %w", err) } diff --git a/go.mod b/go.mod index 6a0aff35c8..e123c85c74 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +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.98.0 + github.com/nspcc-dev/neo-go v0.98.2 + github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af // indirect github.com/nspcc-dev/neofs-api-go/v2 v2.12.1 github.com/nspcc-dev/neofs-contract v0.14.2 github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.3.0.20220316141620-a55ffa47966a diff --git a/go.sum b/go.sum index ed7526f867465868cc3cba55cfb4b2e3851cc1e7..cbe9c9182b9135636602a006e7d12ce1fec682a2 100644 GIT binary patch delta 1238 zcmb7@JCEa36o6$$qh+>&h8+g&G6)e6k>h)>uU|-rjT7fRNt}oCkSH8Gj-TT=&SR1S zwx!#_E3yS04RoLsBRWLGLbv<}BqRzzh-OzjY$QY^gjU=u-R_+4obTLo_m{)FzaM`3 znZ7$1fAsXbBh_`)nNCf7GBn4o8!Y_!_;d*}@g)&}Jiv$tGys4j1qRSa<uO~ zeErmfZ{#*bsb_QAU=r#jUeDTMQJOKl=u2E%Th#Qlu__EPPE!~Bo7X4S++2(@n(tAL z6z*Uc5Xh#=Q8j3>U)?10fiV5vL=RP|opCE##_mIF&0p*X;Xe6?HW1 zRfVx_k7^BN=D3vG=z5_!iGKdzMw0Kwf8^UexV%F|A4bjSi}$b50-yN{pw>Hb3y8Mk z+c~AbgdC-tFwFD33bL@4=8E;TH(k4(s+9mvl2{>$-7`_`SA)vR=&Y5>Ca=!gxqMJi zt21RZp@IzwG?*`O|-_BNU5{O(YM=AXdYOR$0jG zvt&^MWf~Na)5wzH=x@&qfD2A$ptk?%2l5P!x+*WsWYme8Vt_@ z)kv(%4SL$8?Dk;Yr=^nE=f!3NK)>ZEW>M@nXR<0w=6M<$OFp4Iv88`g_VoR~mTpEr zM)#hAncYkG9v<}m{;;vS*c(JNhiQ^CXvoG60m}$`9LiSL(4EmMt}g48k{2DxbShrn zTQ}?B0{7Cgg8Wg~RWOL;?JLpw{nvIU_df^G&9AN>;0)Zo_u%!@=#THN2~1{x5tv55 zF>D(_vs@l|idZgJd#!>ow3{s;G4V!pYG&6i0Ts3U=<KxDWb6TQp6G9 zl9~DLbhT`vs;c$iu(u3b+(I_}b!V`wW*1XKp0$c%;f!Wb(b>M8BA#ctJvWOqN>l7+ zlD0TFlg};~XtQvkxf^@#RdfS*m4>Z!huux16F6C?S4+F>Y8#Nmu@J}YRdJpbhZZBd mt#GKgo949S0vZR#oLx-^c%0Y5&Ya1rmM>b}tG8|wvhXM3@r(-q delta 363 zcmbR6k9ERl)(sm|^c6A;tFScG z?Uin5;Zl*B6cAjLVwRL{=sUefn^AH)k2a(GbOT*R-t9lN8NW*Cfr2PI$jK+dyv*D& z%_7{~JtZkA+0wwm-zzyKy~Nuh$-l}nG%?FU-_6j`d3vJ@qxAH*E{ty5&$%)>Spop| C$AokM diff --git a/pkg/morph/client/client.go b/pkg/morph/client/client.go index 54fa7f6f37..ee98aa53c9 100644 --- a/pkg/morph/client/client.go +++ b/pkg/morph/client/client.go @@ -468,9 +468,7 @@ func toStackParameter(value interface{}) (sc.Parameter, error) { // MagicNumber returns the magic number of the network // to which the underlying RPC node client is connected. -// -// Returns 0 in case of connection problems. -func (c *Client) MagicNumber() (res uint64, err error) { +func (c *Client) MagicNumber() (uint64, error) { c.switchLock.RLock() defer c.switchLock.RUnlock() @@ -478,7 +476,14 @@ func (c *Client) MagicNumber() (res uint64, err error) { return 0, ErrConnectionLost } - return uint64(c.client.GetNetwork()), nil + mNum, err := c.client.GetNetwork() + if err != nil { + // error appears only if client + // has not been initialized + panic(err) + } + + return uint64(mNum), nil } // BlockCount returns block count of the network diff --git a/pkg/morph/client/nns.go b/pkg/morph/client/nns.go index f85f99a108..083cfc5dd1 100644 --- a/pkg/morph/client/nns.go +++ b/pkg/morph/client/nns.go @@ -5,7 +5,6 @@ import ( "fmt" "strconv" - nns "github.com/nspcc-dev/neo-go/examples/nft-nd-nns" "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/rpc/client" @@ -13,6 +12,7 @@ import ( "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/neofs-contract/nns" ) const ( diff --git a/pkg/morph/client/notary.go b/pkg/morph/client/notary.go index 14b881fb23..91afa02a7f 100644 --- a/pkg/morph/client/notary.go +++ b/pkg/morph/client/notary.go @@ -380,11 +380,16 @@ func (c *Client) NotarySignAndInvokeTX(mainTx *transaction.Transaction) error { return err } + // error appears only if client + // is in inactive mode; that has + // been already checked above + magicNumber, _ := c.MagicNumber() + // mainTX is expected to be pre-validated: second witness must exist and be empty mainTx.Scripts[1].VerificationScript = multiaddrAccount.GetVerificationScript() mainTx.Scripts[1].InvocationScript = append( []byte{byte(opcode.PUSHDATA1), 64}, - multiaddrAccount.PrivateKey().SignHashable(uint32(c.client.GetNetwork()), mainTx)..., + multiaddrAccount.PrivateKey().SignHashable(uint32(magicNumber), mainTx)..., ) resp, err := c.client.SignAndPushP2PNotaryRequest(mainTx, @@ -618,10 +623,12 @@ func (c *Client) notaryWitnesses(invokedByAlpha bool, multiaddr *wallet.Account, // to pass Notary module verification var invokeScript []byte + magicNumber, _ := c.MagicNumber() + if invokedByAlpha { invokeScript = append( []byte{byte(opcode.PUSHDATA1), 64}, - multiaddr.PrivateKey().SignHashable(uint32(c.client.GetNetwork()), tx)..., + multiaddr.PrivateKey().SignHashable(uint32(magicNumber), tx)..., ) } else { // we can't provide alphabet node signature @@ -643,7 +650,7 @@ func (c *Client) notaryWitnesses(invokedByAlpha bool, multiaddr *wallet.Account, // then we have invoker witness invokeScript = append( []byte{byte(opcode.PUSHDATA1), 64}, - c.acc.PrivateKey().SignHashable(uint32(c.client.GetNetwork()), tx)..., + c.acc.PrivateKey().SignHashable(uint32(magicNumber), tx)..., ) w = append(w, transaction.Witness{