forked from TrueCloudLab/frostfs-node
[#749] morph/client: set group signer scope
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
fa947b85a6
commit
e21d054fe2
4 changed files with 31 additions and 2 deletions
|
@ -140,6 +140,9 @@ func initSubnetClientCheckNotary(c *morphsubnet.Client, key *keys.PrivateKey, ch
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Error means group was not set in NNS, continue with Global scope in this case.
|
||||||
|
_ = cMorph.SetGroupSignerScope()
|
||||||
|
|
||||||
// read contract address
|
// read contract address
|
||||||
contractAddr, err := cMorph.NNSContractAddress(client.NNSSubnetworkContractName)
|
contractAddr, err := cMorph.NNSContractAddress(client.NNSSubnetworkContractName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -51,6 +51,9 @@ func initMorphComponents(c *cfg) {
|
||||||
client.WithMaxConnectionPerHost(morphconfig.MaxConnPerHost(c.appCfg)),
|
client.WithMaxConnectionPerHost(morphconfig.MaxConnPerHost(c.appCfg)),
|
||||||
)
|
)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
if err := cli.SetGroupSignerScope(); err != nil {
|
||||||
|
c.log.Info("failed to set group signer scope, continue with Global", zap.Error(err))
|
||||||
|
}
|
||||||
handler(cli)
|
handler(cli)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
@ -364,6 +364,9 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if err := server.morphClient.SetGroupSignerScope(); err != nil {
|
||||||
|
morphChain.log.Info("failed to set group signer scope, continue with Global", zap.Error(err))
|
||||||
|
}
|
||||||
|
|
||||||
server.withoutMainNet = cfg.GetBool("without_mainnet")
|
server.withoutMainNet = cfg.GetBool("without_mainnet")
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
nns "github.com/nspcc-dev/neo-go/examples/nft-nd-nns"
|
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/crypto/keys"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
|
@ -175,8 +176,27 @@ func exists(c *client.Client, nnsHash util.Uint160, domain string) (bool, error)
|
||||||
return !available, nil
|
return !available, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContractGroupKey returns public key designating NeoFS contract group.
|
// SetGroupSignerScope makes the default signer scope include all NeoFS contracts.
|
||||||
func (c *Client) ContractGroupKey() (*keys.PublicKey, error) {
|
// Should be called for side-chain client only.
|
||||||
|
func (c *Client) SetGroupSignerScope() error {
|
||||||
|
if c.multiClient != nil {
|
||||||
|
return c.multiClient.iterateClients(func(c *Client) error {
|
||||||
|
return wrapNeoFSError(c.SetGroupSignerScope())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub, err := c.contractGroupKey()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
c.signer.Scopes = transaction.CustomGroups
|
||||||
|
c.signer.AllowedGroups = []*keys.PublicKey{pub}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// contractGroupKey returns public key designating NeoFS contract group.
|
||||||
|
func (c *Client) contractGroupKey() (*keys.PublicKey, error) {
|
||||||
if c.groupKey != nil {
|
if c.groupKey != nil {
|
||||||
return c.groupKey, nil
|
return c.groupKey, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue