diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e07bb2f2..efabd5f11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,8 @@ Changelog for FrostFS Node - Iterating over just removed files by FSTree (#98) - Parts of a locked object could not be removed anymore (#141) - Non-alphabet nodes do not try to handle alphabet events (#181) +- Failing SN and IR transactions because of incorrect scopes (#2230, #2263) +- Global scope used for some transactions (#2230, #2263) ### Removed ### Updated diff --git a/cmd/frostfs-adm/internal/modules/morph/initialize_nns.go b/cmd/frostfs-adm/internal/modules/morph/initialize_nns.go index edb7d6de5..15657a6d9 100644 --- a/cmd/frostfs-adm/internal/modules/morph/initialize_nns.go +++ b/cmd/frostfs-adm/internal/modules/morph/initialize_nns.go @@ -15,6 +15,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/rpcclient/invoker" + nnsClient "github.com/nspcc-dev/neo-go/pkg/rpcclient/nns" "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" @@ -284,10 +285,11 @@ func parseNNSResolveResult(res stackitem.Item) (util.Uint160, error) { } func nnsIsAvailable(c Client, nnsHash util.Uint160, name string) (bool, error) { - switch ct := c.(type) { + switch c.(type) { case *rpcclient.Client: - //lint:ignore SA1019 https://git.frostfs.info/TrueCloudLab/frostfs-node/issues/202 - return ct.NNSIsAvailable(nnsHash, name) + inv := invoker.New(c, nil) + reader := nnsClient.NewReader(inv, nnsHash) + return reader.IsAvailable(name) default: b, err := unwrap.Bool(invokeFunction(c, nnsHash, "isAvailable", []any{name}, nil)) if err != nil { diff --git a/cmd/frostfs-adm/internal/modules/morph/initialize_register.go b/cmd/frostfs-adm/internal/modules/morph/initialize_register.go index 27e1590cf..b1542cc92 100644 --- a/cmd/frostfs-adm/internal/modules/morph/initialize_register.go +++ b/cmd/frostfs-adm/internal/modules/morph/initialize_register.go @@ -9,6 +9,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/rpcclient" + "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/unwrap" "github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag" @@ -116,10 +117,11 @@ func (c *initializeContext) transferNEOFinished(neoHash util.Uint160) (bool, err var errGetPriceInvalid = errors.New("`getRegisterPrice`: invalid response") func (c *initializeContext) getCandidateRegisterPrice() (int64, error) { - switch ct := c.Client.(type) { + switch c.Client.(type) { case *rpcclient.Client: - //lint:ignore SA1019 https://git.frostfs.info/TrueCloudLab/frostfs-node/issues/202 - return ct.GetCandidateRegisterPrice() + inv := invoker.New(c.Client, nil) + reader := neo.NewReader(inv) + return reader.GetRegisterPrice() default: neoHash := neo.Hash res, err := invokeFunction(c.Client, neoHash, "getRegisterPrice", nil, nil) diff --git a/cmd/frostfs-adm/internal/modules/morph/initialize_test.go b/cmd/frostfs-adm/internal/modules/morph/initialize_test.go index 39a35b12e..fb2dc3e3f 100644 --- a/cmd/frostfs-adm/internal/modules/morph/initialize_test.go +++ b/cmd/frostfs-adm/internal/modules/morph/initialize_test.go @@ -6,6 +6,7 @@ import ( "path/filepath" "strconv" "testing" + "time" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring" "github.com/nspcc-dev/neo-go/pkg/config" @@ -101,11 +102,10 @@ func generateTestData(t *testing.T, dir string, size int) { cfg := config.Config{} cfg.ProtocolConfiguration.Magic = 12345 cfg.ProtocolConfiguration.ValidatorsCount = size - cfg.ProtocolConfiguration.SecondsPerBlock = 1 //lint:ignore SA1019 https://git.frostfs.info/TrueCloudLab/frostfs-node/issues/202 + cfg.ProtocolConfiguration.TimePerBlock = time.Second cfg.ProtocolConfiguration.StandbyCommittee = pubs // sorted by glagolic letters cfg.ProtocolConfiguration.P2PSigExtensions = true cfg.ProtocolConfiguration.VerifyTransactions = true - cfg.ProtocolConfiguration.VerifyBlocks = true //lint:ignore SA1019 https://git.frostfs.info/TrueCloudLab/frostfs-node/issues/202 data, err := yaml.Marshal(cfg) require.NoError(t, err) diff --git a/pkg/morph/client/client.go b/pkg/morph/client/client.go index b93c5f75f..5e98211c4 100644 --- a/pkg/morph/client/client.go +++ b/pkg/morph/client/client.go @@ -57,8 +57,6 @@ type Client struct { acc *wallet.Account // neo account accAddr util.Uint160 // account's address - signer *transaction.Signer - notary *notaryInfo cfg cfg diff --git a/pkg/morph/client/constructor.go b/pkg/morph/client/constructor.go index 9ed275029..c4ec70171 100644 --- a/pkg/morph/client/constructor.go +++ b/pkg/morph/client/constructor.go @@ -105,7 +105,6 @@ func New(ctx context.Context, key *keys.PrivateKey, opts ...Option) (*Client, er logger: cfg.logger, acc: acc, accAddr: accAddr, - signer: cfg.signer, cfg: *cfg, switchLock: &sync.RWMutex{}, notifications: make(chan rpcclient.Notification), diff --git a/pkg/morph/client/nns.go b/pkg/morph/client/nns.go index 0a23aa47a..473b3500b 100644 --- a/pkg/morph/client/nns.go +++ b/pkg/morph/client/nns.go @@ -208,8 +208,18 @@ func (c *Client) SetGroupSignerScope() error { return err } - c.signer.Scopes = transaction.CustomGroups - c.signer.AllowedGroups = []*keys.PublicKey{pub} + // Don't change c before everything is OK. + cfg := c.cfg + cfg.signer = &transaction.Signer{ + Scopes: transaction.CustomGroups | transaction.CalledByEntry, + AllowedGroups: []*keys.PublicKey{pub}, + } + rpcActor, err := newActor(c.client, c.acc, cfg) + if err != nil { + return err + } + c.cfg = cfg + c.setActor(rpcActor) return nil } diff --git a/pkg/morph/client/notary.go b/pkg/morph/client/notary.go index 96dca0319..7399c19cd 100644 --- a/pkg/morph/client/notary.go +++ b/pkg/morph/client/notary.go @@ -412,16 +412,11 @@ 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(magicNumber), mainTx)..., + multiaddrAccount.SignHashable(c.rpcActor.GetNetwork(), mainTx)..., ) //lint:ignore SA1019 https://git.frostfs.info/TrueCloudLab/frostfs-node/issues/202 @@ -596,18 +591,18 @@ func (c *Client) notaryCosigners(invokedByAlpha bool, ir []*keys.PublicKey, comm s = append(s, transaction.Signer{ Account: hash.Hash160(multisigScript), - Scopes: c.signer.Scopes, - AllowedContracts: c.signer.AllowedContracts, - AllowedGroups: c.signer.AllowedGroups, + Scopes: c.cfg.signer.Scopes, + AllowedContracts: c.cfg.signer.AllowedContracts, + AllowedGroups: c.cfg.signer.AllowedGroups, }) if !invokedByAlpha { // then we have invoker signature s = append(s, transaction.Signer{ Account: hash.Hash160(c.acc.GetVerificationScript()), - Scopes: c.signer.Scopes, - AllowedContracts: c.signer.AllowedContracts, - AllowedGroups: c.signer.AllowedGroups, + Scopes: c.cfg.signer.Scopes, + AllowedContracts: c.cfg.signer.AllowedContracts, + AllowedGroups: c.cfg.signer.AllowedGroups, }) } @@ -667,12 +662,12 @@ func (c *Client) notaryWitnesses(invokedByAlpha bool, multiaddr *wallet.Account, // to pass Notary module verification var invokeScript []byte - magicNumber, _ := c.MagicNumber() + magicNumber := c.rpcActor.GetNetwork() if invokedByAlpha { invokeScript = append( []byte{byte(opcode.PUSHDATA1), 64}, - multiaddr.PrivateKey().SignHashable(uint32(magicNumber), tx)..., + multiaddr.SignHashable(magicNumber, tx)..., ) } else { // we can't provide alphabet node signature @@ -694,7 +689,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(magicNumber), tx)..., + c.acc.SignHashable(magicNumber, tx)..., ) w = append(w, transaction.Witness{