Compare commits

..

No commits in common. "master" and "master" have entirely different histories.

166 changed files with 817 additions and 1787 deletions

View file

@ -18,8 +18,7 @@ jobs:
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v3 uses: actions/setup-go@v3
with: with:
go-version: '1.23' go-version: '1.23.5'
check-latest: true
- name: Install govulncheck - name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@latest run: go install golang.org/x/vuln/cmd/govulncheck@latest

View file

@ -16,16 +16,9 @@ const (
EndpointFlagDesc = "N3 RPC node endpoint" EndpointFlagDesc = "N3 RPC node endpoint"
EndpointFlagShort = "r" EndpointFlagShort = "r"
WalletPath = "wallet"
WalletPathShorthand = "w"
WalletPathUsage = "Path to the wallet"
AlphabetWalletsFlag = "alphabet-wallets" AlphabetWalletsFlag = "alphabet-wallets"
AlphabetWalletsFlagDesc = "Path to alphabet wallets dir" AlphabetWalletsFlagDesc = "Path to alphabet wallets dir"
AdminWalletPath = "wallet-admin"
AdminWalletUsage = "Path to the admin wallet"
LocalDumpFlag = "local-dump" LocalDumpFlag = "local-dump"
ProtoConfigPath = "protocol" ProtoConfigPath = "protocol"
ContractsInitFlag = "contracts" ContractsInitFlag = "contracts"

View file

@ -28,7 +28,6 @@ const (
var ( var (
errNoPathsFound = errors.New("no metabase paths found") errNoPathsFound = errors.New("no metabase paths found")
errNoMorphEndpointsFound = errors.New("no morph endpoints found") errNoMorphEndpointsFound = errors.New("no morph endpoints found")
errUpgradeFailed = errors.New("upgrade failed")
) )
var UpgradeCmd = &cobra.Command{ var UpgradeCmd = &cobra.Command{
@ -92,20 +91,15 @@ func upgrade(cmd *cobra.Command, _ []string) error {
if err := eg.Wait(); err != nil { if err := eg.Wait(); err != nil {
return err return err
} }
allSuccess := true
for mb, ok := range result { for mb, ok := range result {
if ok { if ok {
cmd.Println(mb, ": success") cmd.Println(mb, ": success")
} else { } else {
cmd.Println(mb, ": failed") cmd.Println(mb, ": failed")
allSuccess = false
} }
} }
if allSuccess {
return nil return nil
} }
return errUpgradeFailed
}
func getMetabasePaths(appCfg *config.Config) ([]string, error) { func getMetabasePaths(appCfg *config.Config) ([]string, error) {
var paths []string var paths []string

View file

@ -3,8 +3,6 @@ package ape
import ( import (
"errors" "errors"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/config"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/helper" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/helper"
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common" commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
@ -78,8 +76,7 @@ func newPolicyContractInterface(cmd *cobra.Command) (*morph.ContractStorage, *he
c, err := helper.NewRemoteClient(viper.GetViper()) c, err := helper.NewRemoteClient(viper.GetViper())
commonCmd.ExitOnErr(cmd, "unable to create NEO rpc client: %w", err) commonCmd.ExitOnErr(cmd, "unable to create NEO rpc client: %w", err)
walletDir := config.ResolveHomePath(viper.GetString(commonflags.AlphabetWalletsFlag)) ac, err := helper.NewLocalActor(cmd, c, constants.ConsensusAccountName)
ac, err := helper.NewLocalActor(c, &helper.AlphabetWallets{Path: walletDir, Label: constants.ConsensusAccountName})
commonCmd.ExitOnErr(cmd, "can't create actor: %w", err) commonCmd.ExitOnErr(cmd, "can't create actor: %w", err)
var ch util.Uint160 var ch util.Uint160

View file

@ -1,7 +1,6 @@
package frostfsid package frostfsid
import ( import (
"errors"
"fmt" "fmt"
"math/big" "math/big"
"sort" "sort"
@ -39,11 +38,6 @@ const (
groupIDFlag = "group-id" groupIDFlag = "group-id"
rootNamespacePlaceholder = "<root>" rootNamespacePlaceholder = "<root>"
keyFlag = "key"
keyDescFlag = "Key for storing a value in the subject's KV storage"
valueFlag = "value"
valueDescFlag = "Value to be stored in the subject's KV storage"
) )
var ( var (
@ -157,23 +151,6 @@ var (
}, },
Run: frostfsidListGroupSubjects, Run: frostfsidListGroupSubjects,
} }
frostfsidSetKVCmd = &cobra.Command{
Use: "set-kv",
Short: "Store a key-value pair in the subject's KV storage",
PreRun: func(cmd *cobra.Command, _ []string) {
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
},
Run: frostfsidSetKV,
}
frostfsidDeleteKVCmd = &cobra.Command{
Use: "delete-kv",
Short: "Delete a value from the subject's KV storage",
PreRun: func(cmd *cobra.Command, _ []string) {
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
},
Run: frostfsidDeleteKV,
}
) )
func initFrostfsIDCreateNamespaceCmd() { func initFrostfsIDCreateNamespaceCmd() {
@ -259,21 +236,6 @@ func initFrostfsIDListGroupSubjectsCmd() {
frostfsidListGroupSubjectsCmd.Flags().Bool(includeNamesFlag, false, "Whether include subject name (require additional requests)") frostfsidListGroupSubjectsCmd.Flags().Bool(includeNamesFlag, false, "Whether include subject name (require additional requests)")
} }
func initFrostfsIDSetKVCmd() {
Cmd.AddCommand(frostfsidSetKVCmd)
frostfsidSetKVCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
frostfsidSetKVCmd.Flags().String(subjectAddressFlag, "", "Subject address")
frostfsidSetKVCmd.Flags().String(keyFlag, "", keyDescFlag)
frostfsidSetKVCmd.Flags().String(valueFlag, "", valueDescFlag)
}
func initFrostfsIDDeleteKVCmd() {
Cmd.AddCommand(frostfsidDeleteKVCmd)
frostfsidDeleteKVCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
frostfsidDeleteKVCmd.Flags().String(subjectAddressFlag, "", "Subject address")
frostfsidDeleteKVCmd.Flags().String(keyFlag, "", keyDescFlag)
}
func frostfsidCreateNamespace(cmd *cobra.Command, _ []string) { func frostfsidCreateNamespace(cmd *cobra.Command, _ []string) {
ns := getFrostfsIDNamespace(cmd) ns := getFrostfsIDNamespace(cmd)
@ -441,45 +403,6 @@ func frostfsidRemoveSubjectFromGroup(cmd *cobra.Command, _ []string) {
commonCmd.ExitOnErr(cmd, "remove subject from group error: %w", err) commonCmd.ExitOnErr(cmd, "remove subject from group error: %w", err)
} }
func frostfsidSetKV(cmd *cobra.Command, _ []string) {
subjectAddress := getFrostfsIDSubjectAddress(cmd)
key, _ := cmd.Flags().GetString(keyFlag)
value, _ := cmd.Flags().GetString(valueFlag)
if key == "" {
commonCmd.ExitOnErr(cmd, "", errors.New("key can't be empty"))
}
ffsid, err := newFrostfsIDClient(cmd)
commonCmd.ExitOnErr(cmd, "init contract client: %w", err)
method, args := ffsid.roCli.SetSubjectKVCall(subjectAddress, key, value)
ffsid.addCall(method, args)
err = ffsid.sendWait()
commonCmd.ExitOnErr(cmd, "set KV: %w", err)
}
func frostfsidDeleteKV(cmd *cobra.Command, _ []string) {
subjectAddress := getFrostfsIDSubjectAddress(cmd)
key, _ := cmd.Flags().GetString(keyFlag)
if key == "" {
commonCmd.ExitOnErr(cmd, "", errors.New("key can't be empty"))
}
ffsid, err := newFrostfsIDClient(cmd)
commonCmd.ExitOnErr(cmd, "init contract client: %w", err)
method, args := ffsid.roCli.DeleteSubjectKVCall(subjectAddress, key)
ffsid.addCall(method, args)
err = ffsid.sendWait()
commonCmd.ExitOnErr(cmd, "delete KV: %w", err)
}
func frostfsidListGroupSubjects(cmd *cobra.Command, _ []string) { func frostfsidListGroupSubjects(cmd *cobra.Command, _ []string) {
ns := getFrostfsIDNamespace(cmd) ns := getFrostfsIDNamespace(cmd)
groupID := getFrostfsIDGroupID(cmd) groupID := getFrostfsIDGroupID(cmd)

View file

@ -12,8 +12,6 @@ func init() {
initFrostfsIDAddSubjectToGroupCmd() initFrostfsIDAddSubjectToGroupCmd()
initFrostfsIDRemoveSubjectFromGroupCmd() initFrostfsIDRemoveSubjectFromGroupCmd()
initFrostfsIDListGroupSubjectsCmd() initFrostfsIDListGroupSubjectsCmd()
initFrostfsIDSetKVCmd()
initFrostfsIDDeleteKVCmd()
initFrostfsIDAddSubjectKeyCmd() initFrostfsIDAddSubjectKeyCmd()
initFrostfsIDRemoveSubjectKeyCmd() initFrostfsIDRemoveSubjectKeyCmd()
} }

View file

@ -3,6 +3,9 @@ package helper
import ( import (
"fmt" "fmt"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/config"
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/state"
"github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/core/transaction"
@ -13,6 +16,7 @@ import (
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/nspcc-dev/neo-go/pkg/wallet" "github.com/nspcc-dev/neo-go/pkg/wallet"
"github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
) )
@ -24,86 +28,32 @@ type LocalActor struct {
rpcInvoker invoker.RPCInvoke rpcInvoker invoker.RPCInvoke
} }
type AlphabetWallets struct {
Label string
Path string
}
func (a *AlphabetWallets) GetAccount(v *viper.Viper) ([]*wallet.Account, error) {
w, err := GetAlphabetWallets(v, a.Path)
if err != nil {
return nil, err
}
var accounts []*wallet.Account
for _, wall := range w {
acc, err := GetWalletAccount(wall, a.Label)
if err != nil {
return nil, err
}
accounts = append(accounts, acc)
}
return accounts, nil
}
type RegularWallets struct{ Path string }
func (r *RegularWallets) GetAccount() ([]*wallet.Account, error) {
w, err := getRegularWallet(r.Path)
if err != nil {
return nil, err
}
return []*wallet.Account{w.GetAccount(w.GetChangeAddress())}, nil
}
// NewLocalActor create LocalActor with accounts form provided wallets. // NewLocalActor create LocalActor with accounts form provided wallets.
// In case of empty wallets provided created actor with dummy account only for read operation. // In case of empty wallets provided created actor with dummy account only for read operation.
// //
// If wallets are provided, the contract client will use accounts with accName name from these wallets. // If wallets are provided, the contract client will use accounts with accName name from these wallets.
// To determine which account name should be used in a contract client, refer to how the contract // To determine which account name should be used in a contract client, refer to how the contract
// verifies the transaction signature. // verifies the transaction signature.
func NewLocalActor(c actor.RPCActor, alphabet *AlphabetWallets, regularWallets ...*RegularWallets) (*LocalActor, error) { func NewLocalActor(cmd *cobra.Command, c actor.RPCActor, accName string) (*LocalActor, error) {
walletDir := config.ResolveHomePath(viper.GetString(commonflags.AlphabetWalletsFlag))
var act *actor.Actor var act *actor.Actor
var accounts []*wallet.Account var accounts []*wallet.Account
var signers []actor.SignerAccount
if alphabet != nil { wallets, err := GetAlphabetWallets(viper.GetViper(), walletDir)
account, err := alphabet.GetAccount(viper.GetViper()) commonCmd.ExitOnErr(cmd, "unable to get alphabet wallets: %w", err)
if err != nil {
return nil, err for _, w := range wallets {
acc, err := GetWalletAccount(w, accName)
commonCmd.ExitOnErr(cmd, fmt.Sprintf("can't find %s account: %%w", accName), err)
accounts = append(accounts, acc)
} }
act, err = actor.New(c, []actor.SignerAccount{{
accounts = append(accounts, account...)
signers = append(signers, actor.SignerAccount{
Signer: transaction.Signer{ Signer: transaction.Signer{
Account: account[0].Contract.ScriptHash(), Account: accounts[0].Contract.ScriptHash(),
Scopes: transaction.Global, Scopes: transaction.Global,
}, },
Account: account[0], Account: accounts[0],
}) }})
}
for _, w := range regularWallets {
if w == nil {
continue
}
account, err := w.GetAccount()
if err != nil {
return nil, err
}
accounts = append(accounts, account...)
signers = append(signers, actor.SignerAccount{
Signer: transaction.Signer{
Account: account[0].Contract.ScriptHash(),
Scopes: transaction.Global,
},
Account: account[0],
})
}
act, err := actor.New(c, signers)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -14,7 +14,6 @@ import (
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/config" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/config"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring"
"github.com/nspcc-dev/neo-go/cli/input"
"github.com/nspcc-dev/neo-go/pkg/core/state" "github.com/nspcc-dev/neo-go/pkg/core/state"
"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/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
@ -23,27 +22,6 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
) )
func getRegularWallet(walletPath string) (*wallet.Wallet, error) {
w, err := wallet.NewWalletFromFile(walletPath)
if err != nil {
return nil, err
}
password, err := input.ReadPassword("Enter password for wallet:")
if err != nil {
return nil, fmt.Errorf("can't fetch password: %w", err)
}
for i := range w.Accounts {
if err = w.Accounts[i].Decrypt(password, keys.NEP2ScryptParams()); err != nil {
err = fmt.Errorf("can't unlock wallet: %w", err)
break
}
}
return w, err
}
func GetAlphabetWallets(v *viper.Viper, walletDir string) ([]*wallet.Wallet, error) { func GetAlphabetWallets(v *viper.Viper, walletDir string) ([]*wallet.Wallet, error) {
wallets, err := openAlphabetWallets(v, walletDir) wallets, err := openAlphabetWallets(v, walletDir)
if err != nil { if err != nil {
@ -73,7 +51,7 @@ func openAlphabetWallets(v *viper.Viper, walletDir string) ([]*wallet.Wallet, er
if errors.Is(err, os.ErrNotExist) { if errors.Is(err, os.ErrNotExist) {
err = nil err = nil
} else { } else {
err = fmt.Errorf("can't open alphabet wallet: %w", err) err = fmt.Errorf("can't open wallet: %w", err)
} }
break break
} }

View file

@ -6,9 +6,7 @@ import (
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common" commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
"github.com/nspcc-dev/neo-go/pkg/wallet"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper"
) )
func initRegisterCmd() { func initRegisterCmd() {
@ -21,7 +19,6 @@ func initRegisterCmd() {
registerCmd.Flags().Int64(nnsRetryFlag, constants.NNSRetryDefVal, "SOA record RETRY parameter") registerCmd.Flags().Int64(nnsRetryFlag, constants.NNSRetryDefVal, "SOA record RETRY parameter")
registerCmd.Flags().Int64(nnsExpireFlag, int64(constants.DefaultExpirationTime), "SOA record EXPIRE parameter") registerCmd.Flags().Int64(nnsExpireFlag, int64(constants.DefaultExpirationTime), "SOA record EXPIRE parameter")
registerCmd.Flags().Int64(nnsTTLFlag, constants.NNSTtlDefVal, "SOA record TTL parameter") registerCmd.Flags().Int64(nnsTTLFlag, constants.NNSTtlDefVal, "SOA record TTL parameter")
registerCmd.Flags().StringP(commonflags.WalletPath, commonflags.WalletPathShorthand, "", commonflags.WalletPathUsage)
_ = cobra.MarkFlagRequired(registerCmd.Flags(), nnsNameFlag) _ = cobra.MarkFlagRequired(registerCmd.Flags(), nnsNameFlag)
} }
@ -51,7 +48,6 @@ func initDeleteCmd() {
deleteCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc) deleteCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
deleteCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc) deleteCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc)
deleteCmd.Flags().String(nnsNameFlag, "", nnsNameFlagDesc) deleteCmd.Flags().String(nnsNameFlag, "", nnsNameFlagDesc)
deleteCmd.Flags().StringP(commonflags.WalletPath, commonflags.WalletPathShorthand, "", commonflags.WalletPathUsage)
_ = cobra.MarkFlagRequired(deleteCmd.Flags(), nnsNameFlag) _ = cobra.MarkFlagRequired(deleteCmd.Flags(), nnsNameFlag)
} }
@ -66,28 +62,3 @@ func deleteDomain(cmd *cobra.Command, _ []string) {
commonCmd.ExitOnErr(cmd, "delete domain error: %w", err) commonCmd.ExitOnErr(cmd, "delete domain error: %w", err)
cmd.Println("Domain deleted successfully") cmd.Println("Domain deleted successfully")
} }
func initSetAdminCmd() {
Cmd.AddCommand(setAdminCmd)
setAdminCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
setAdminCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc)
setAdminCmd.Flags().String(nnsNameFlag, "", nnsNameFlagDesc)
setAdminCmd.Flags().StringP(commonflags.WalletPath, commonflags.WalletPathShorthand, "", commonflags.WalletPathUsage)
setAdminCmd.Flags().String(commonflags.AdminWalletPath, "", commonflags.AdminWalletUsage)
_ = setAdminCmd.MarkFlagRequired(commonflags.AdminWalletPath)
_ = cobra.MarkFlagRequired(setAdminCmd.Flags(), nnsNameFlag)
}
func setAdmin(cmd *cobra.Command, _ []string) {
c, actor := nnsWriter(cmd)
name, _ := cmd.Flags().GetString(nnsNameFlag)
w, err := wallet.NewWalletFromFile(viper.GetString(commonflags.AdminWalletPath))
commonCmd.ExitOnErr(cmd, "can't get admin wallet: %w", err)
h, vub, err := c.SetAdmin(name, w.GetAccount(w.GetChangeAddress()).ScriptHash())
_, err = actor.Wait(h, vub, err)
commonCmd.ExitOnErr(cmd, "Set admin error: %w", err)
cmd.Println("Set admin successfully")
}

View file

@ -1,11 +1,7 @@
package nns package nns
import ( import (
"errors"
client "git.frostfs.info/TrueCloudLab/frostfs-contract/rpcclient/nns" client "git.frostfs.info/TrueCloudLab/frostfs-contract/rpcclient/nns"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/config"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/helper" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/helper"
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common" commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
@ -20,32 +16,7 @@ func nnsWriter(cmd *cobra.Command) (*client.Contract, *helper.LocalActor) {
c, err := helper.NewRemoteClient(v) c, err := helper.NewRemoteClient(v)
commonCmd.ExitOnErr(cmd, "unable to create NEO rpc client: %w", err) commonCmd.ExitOnErr(cmd, "unable to create NEO rpc client: %w", err)
alphabetWalletPath := config.ResolveHomePath(v.GetString(commonflags.AlphabetWalletsFlag)) ac, err := helper.NewLocalActor(cmd, c, constants.CommitteeAccountName)
walletPath := config.ResolveHomePath(v.GetString(commonflags.WalletPath))
adminWalletPath := config.ResolveHomePath(v.GetString(commonflags.AdminWalletPath))
var (
alphabet *helper.AlphabetWallets
regularWallets []*helper.RegularWallets
)
if alphabetWalletPath != "" {
alphabet = &helper.AlphabetWallets{Path: alphabetWalletPath, Label: constants.ConsensusAccountName}
}
if walletPath != "" {
regularWallets = append(regularWallets, &helper.RegularWallets{Path: walletPath})
}
if adminWalletPath != "" {
regularWallets = append(regularWallets, &helper.RegularWallets{Path: adminWalletPath})
}
if alphabet == nil && regularWallets == nil {
commonCmd.ExitOnErr(cmd, "", errors.New("no wallets provided"))
}
ac, err := helper.NewLocalActor(c, alphabet, regularWallets...)
commonCmd.ExitOnErr(cmd, "can't create actor: %w", err) commonCmd.ExitOnErr(cmd, "can't create actor: %w", err)
r := management.NewReader(ac.Invoker) r := management.NewReader(ac.Invoker)

View file

@ -19,7 +19,6 @@ func initAddRecordCmd() {
addRecordCmd.Flags().String(nnsNameFlag, "", nnsNameFlagDesc) addRecordCmd.Flags().String(nnsNameFlag, "", nnsNameFlagDesc)
addRecordCmd.Flags().String(nnsRecordTypeFlag, "", nnsRecordTypeFlagDesc) addRecordCmd.Flags().String(nnsRecordTypeFlag, "", nnsRecordTypeFlagDesc)
addRecordCmd.Flags().String(nnsRecordDataFlag, "", nnsRecordDataFlagDesc) addRecordCmd.Flags().String(nnsRecordDataFlag, "", nnsRecordDataFlagDesc)
addRecordCmd.Flags().StringP(commonflags.WalletPath, commonflags.WalletPathShorthand, "", commonflags.WalletPathUsage)
_ = cobra.MarkFlagRequired(addRecordCmd.Flags(), nnsNameFlag) _ = cobra.MarkFlagRequired(addRecordCmd.Flags(), nnsNameFlag)
_ = cobra.MarkFlagRequired(addRecordCmd.Flags(), nnsRecordTypeFlag) _ = cobra.MarkFlagRequired(addRecordCmd.Flags(), nnsRecordTypeFlag)
@ -41,7 +40,6 @@ func initDelRecordsCmd() {
delRecordsCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc) delRecordsCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc)
delRecordsCmd.Flags().String(nnsNameFlag, "", nnsNameFlagDesc) delRecordsCmd.Flags().String(nnsNameFlag, "", nnsNameFlagDesc)
delRecordsCmd.Flags().String(nnsRecordTypeFlag, "", nnsRecordTypeFlagDesc) delRecordsCmd.Flags().String(nnsRecordTypeFlag, "", nnsRecordTypeFlagDesc)
delRecordsCmd.Flags().StringP(commonflags.WalletPath, commonflags.WalletPathShorthand, "", commonflags.WalletPathUsage)
_ = cobra.MarkFlagRequired(delRecordsCmd.Flags(), nnsNameFlag) _ = cobra.MarkFlagRequired(delRecordsCmd.Flags(), nnsNameFlag)
_ = cobra.MarkFlagRequired(delRecordsCmd.Flags(), nnsRecordTypeFlag) _ = cobra.MarkFlagRequired(delRecordsCmd.Flags(), nnsRecordTypeFlag)
@ -54,7 +52,6 @@ func initDelRecordCmd() {
delRecordCmd.Flags().String(nnsNameFlag, "", nnsNameFlagDesc) delRecordCmd.Flags().String(nnsNameFlag, "", nnsNameFlagDesc)
delRecordCmd.Flags().String(nnsRecordTypeFlag, "", nnsRecordTypeFlagDesc) delRecordCmd.Flags().String(nnsRecordTypeFlag, "", nnsRecordTypeFlagDesc)
delRecordCmd.Flags().String(nnsRecordDataFlag, "", nnsRecordDataFlagDesc) delRecordCmd.Flags().String(nnsRecordDataFlag, "", nnsRecordDataFlagDesc)
delRecordCmd.Flags().StringP(commonflags.WalletPath, commonflags.WalletPathShorthand, "", commonflags.WalletPathUsage)
_ = cobra.MarkFlagRequired(delRecordCmd.Flags(), nnsNameFlag) _ = cobra.MarkFlagRequired(delRecordCmd.Flags(), nnsNameFlag)
_ = cobra.MarkFlagRequired(delRecordCmd.Flags(), nnsRecordTypeFlag) _ = cobra.MarkFlagRequired(delRecordCmd.Flags(), nnsRecordTypeFlag)

View file

@ -39,7 +39,6 @@ var (
PreRun: func(cmd *cobra.Command, _ []string) { PreRun: func(cmd *cobra.Command, _ []string) {
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag)) _ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
_ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag)) _ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag))
_ = viper.BindPFlag(commonflags.WalletPath, cmd.Flags().Lookup(commonflags.WalletPath))
}, },
Run: registerDomain, Run: registerDomain,
} }
@ -49,7 +48,6 @@ var (
PreRun: func(cmd *cobra.Command, _ []string) { PreRun: func(cmd *cobra.Command, _ []string) {
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag)) _ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
_ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag)) _ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag))
_ = viper.BindPFlag(commonflags.WalletPath, cmd.Flags().Lookup(commonflags.WalletPath))
}, },
Run: deleteDomain, Run: deleteDomain,
} }
@ -77,7 +75,6 @@ var (
PreRun: func(cmd *cobra.Command, _ []string) { PreRun: func(cmd *cobra.Command, _ []string) {
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag)) _ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
_ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag)) _ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag))
_ = viper.BindPFlag(commonflags.WalletPath, cmd.Flags().Lookup(commonflags.WalletPath))
}, },
Run: addRecord, Run: addRecord,
} }
@ -95,7 +92,6 @@ var (
PreRun: func(cmd *cobra.Command, _ []string) { PreRun: func(cmd *cobra.Command, _ []string) {
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag)) _ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
_ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag)) _ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag))
_ = viper.BindPFlag(commonflags.WalletPath, cmd.Flags().Lookup(commonflags.WalletPath))
}, },
Run: delRecords, Run: delRecords,
} }
@ -105,21 +101,9 @@ var (
PreRun: func(cmd *cobra.Command, _ []string) { PreRun: func(cmd *cobra.Command, _ []string) {
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag)) _ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
_ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag)) _ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag))
_ = viper.BindPFlag(commonflags.WalletPath, cmd.Flags().Lookup(commonflags.WalletPath))
}, },
Run: delRecord, Run: delRecord,
} }
setAdminCmd = &cobra.Command{
Use: "set-admin",
Short: "Sets admin for domain",
PreRun: func(cmd *cobra.Command, _ []string) {
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
_ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag))
_ = viper.BindPFlag(commonflags.WalletPath, cmd.Flags().Lookup(commonflags.WalletPath))
_ = viper.BindPFlag(commonflags.AdminWalletPath, cmd.Flags().Lookup(commonflags.AdminWalletPath))
},
Run: setAdmin,
}
) )
func init() { func init() {
@ -132,5 +116,4 @@ func init() {
initGetRecordsCmd() initGetRecordsCmd()
initDelRecordsCmd() initDelRecordsCmd()
initDelRecordCmd() initDelRecordCmd()
initSetAdminCmd()
} }

View file

@ -127,7 +127,7 @@ func awaitSetNetmapStatus(cmd *cobra.Command, pk *ecdsa.PrivateKey, cli *client.
var resp *control.GetNetmapStatusResponse var resp *control.GetNetmapStatusResponse
var err error var err error
err = cli.ExecRaw(func(client *rawclient.Client) error { err = cli.ExecRaw(func(client *rawclient.Client) error {
resp, err = control.GetNetmapStatus(cmd.Context(), client, req) resp, err = control.GetNetmapStatus(client, req)
return err return err
}) })
commonCmd.ExitOnErr(cmd, "failed to get current netmap status: %w", err) commonCmd.ExitOnErr(cmd, "failed to get current netmap status: %w", err)

View file

@ -320,7 +320,7 @@ func getReplicaRequiredPlacement(cmd *cobra.Command, objects []phyObject, placem
} }
placementBuilder := placement.NewNetworkMapBuilder(netmap) placementBuilder := placement.NewNetworkMapBuilder(netmap)
for _, object := range objects { for _, object := range objects {
placement, err := placementBuilder.BuildPlacement(cmd.Context(), object.containerID, &object.objectID, placementPolicy) placement, err := placementBuilder.BuildPlacement(object.containerID, &object.objectID, placementPolicy)
commonCmd.ExitOnErr(cmd, "failed to get required placement for object: %w", err) commonCmd.ExitOnErr(cmd, "failed to get required placement for object: %w", err)
for repIdx, rep := range placement { for repIdx, rep := range placement {
numOfReplicas := placementPolicy.ReplicaDescriptor(repIdx).NumberOfObjects() numOfReplicas := placementPolicy.ReplicaDescriptor(repIdx).NumberOfObjects()
@ -358,7 +358,7 @@ func getECRequiredPlacementInternal(cmd *cobra.Command, object phyObject, placem
placementObjectID = object.ecHeader.parent placementObjectID = object.ecHeader.parent
} }
placementBuilder := placement.NewNetworkMapBuilder(netmap) placementBuilder := placement.NewNetworkMapBuilder(netmap)
placement, err := placementBuilder.BuildPlacement(cmd.Context(), object.containerID, &placementObjectID, placementPolicy) placement, err := placementBuilder.BuildPlacement(object.containerID, &placementObjectID, placementPolicy)
commonCmd.ExitOnErr(cmd, "failed to get required placement: %w", err) commonCmd.ExitOnErr(cmd, "failed to get required placement: %w", err)
for _, vector := range placement { for _, vector := range placement {

View file

@ -9,6 +9,7 @@ import (
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/tree" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/tree"
metrics "git.frostfs.info/TrueCloudLab/frostfs-observability/metrics/grpc"
tracing "git.frostfs.info/TrueCloudLab/frostfs-observability/tracing/grpc" tracing "git.frostfs.info/TrueCloudLab/frostfs-observability/tracing/grpc"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
@ -33,9 +34,11 @@ func _client() (tree.TreeServiceClient, error) {
opts := []grpc.DialOption{ opts := []grpc.DialOption{
grpc.WithChainUnaryInterceptor( grpc.WithChainUnaryInterceptor(
metrics.NewUnaryClientInterceptor(),
tracing.NewUnaryClientInteceptor(), tracing.NewUnaryClientInteceptor(),
), ),
grpc.WithChainStreamInterceptor( grpc.WithChainStreamInterceptor(
metrics.NewStreamClientInterceptor(),
tracing.NewStreamClientInterceptor(), tracing.NewStreamClientInterceptor(),
), ),
grpc.WithDefaultCallOptions(grpc.WaitForReady(true)), grpc.WithDefaultCallOptions(grpc.WaitForReady(true)),

View file

@ -1,7 +1,6 @@
package main package main
import ( import (
"context"
"sync" "sync"
"time" "time"
@ -17,7 +16,7 @@ import (
"github.com/hashicorp/golang-lru/v2/expirable" "github.com/hashicorp/golang-lru/v2/expirable"
) )
type netValueReader[K any, V any] func(ctx context.Context, cid K) (V, error) type netValueReader[K any, V any] func(K) (V, error)
type valueWithError[V any] struct { type valueWithError[V any] struct {
v V v V
@ -50,7 +49,7 @@ func newNetworkTTLCache[K comparable, V any](sz int, ttl time.Duration, netRdr n
// updates the value from the network on cache miss or by TTL. // updates the value from the network on cache miss or by TTL.
// //
// returned value should not be modified. // returned value should not be modified.
func (c *ttlNetCache[K, V]) get(ctx context.Context, key K) (V, error) { func (c *ttlNetCache[K, V]) get(key K) (V, error) {
hit := false hit := false
startedAt := time.Now() startedAt := time.Now()
defer func() { defer func() {
@ -72,7 +71,7 @@ func (c *ttlNetCache[K, V]) get(ctx context.Context, key K) (V, error) {
return val.v, val.e return val.v, val.e
} }
v, err := c.netRdr(ctx, key) v, err := c.netRdr(key)
c.cache.Add(key, &valueWithError[V]{ c.cache.Add(key, &valueWithError[V]{
v: v, v: v,
@ -136,7 +135,7 @@ func newNetworkLRUCache(sz int, netRdr netValueReader[uint64, *netmapSDK.NetMap]
// updates the value from the network on cache miss. // updates the value from the network on cache miss.
// //
// returned value should not be modified. // returned value should not be modified.
func (c *lruNetCache) get(ctx context.Context, key uint64) (*netmapSDK.NetMap, error) { func (c *lruNetCache) get(key uint64) (*netmapSDK.NetMap, error) {
hit := false hit := false
startedAt := time.Now() startedAt := time.Now()
defer func() { defer func() {
@ -149,7 +148,7 @@ func (c *lruNetCache) get(ctx context.Context, key uint64) (*netmapSDK.NetMap, e
return val, nil return val, nil
} }
val, err := c.netRdr(ctx, key) val, err := c.netRdr(key)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -167,11 +166,11 @@ type ttlContainerStorage struct {
} }
func newCachedContainerStorage(v container.Source, ttl time.Duration, containerCacheSize uint32) ttlContainerStorage { func newCachedContainerStorage(v container.Source, ttl time.Duration, containerCacheSize uint32) ttlContainerStorage {
lruCnrCache := newNetworkTTLCache(int(containerCacheSize), ttl, func(ctx context.Context, id cid.ID) (*container.Container, error) { lruCnrCache := newNetworkTTLCache(int(containerCacheSize), ttl, func(id cid.ID) (*container.Container, error) {
return v.Get(ctx, id) return v.Get(id)
}, metrics.NewCacheMetrics("container")) }, metrics.NewCacheMetrics("container"))
lruDelInfoCache := newNetworkTTLCache(int(containerCacheSize), ttl, func(ctx context.Context, id cid.ID) (*container.DelInfo, error) { lruDelInfoCache := newNetworkTTLCache(int(containerCacheSize), ttl, func(id cid.ID) (*container.DelInfo, error) {
return v.DeletionInfo(ctx, id) return v.DeletionInfo(id)
}, metrics.NewCacheMetrics("container_deletion_info")) }, metrics.NewCacheMetrics("container_deletion_info"))
return ttlContainerStorage{ return ttlContainerStorage{
@ -189,12 +188,12 @@ func (s ttlContainerStorage) handleRemoval(cnr cid.ID) {
// Get returns container value from the cache. If value is missing in the cache // Get returns container value from the cache. If value is missing in the cache
// or expired, then it returns value from side chain and updates the cache. // or expired, then it returns value from side chain and updates the cache.
func (s ttlContainerStorage) Get(ctx context.Context, cnr cid.ID) (*container.Container, error) { func (s ttlContainerStorage) Get(cnr cid.ID) (*container.Container, error) {
return s.containerCache.get(ctx, cnr) return s.containerCache.get(cnr)
} }
func (s ttlContainerStorage) DeletionInfo(ctx context.Context, cnr cid.ID) (*container.DelInfo, error) { func (s ttlContainerStorage) DeletionInfo(cnr cid.ID) (*container.DelInfo, error) {
return s.delInfoCache.get(ctx, cnr) return s.delInfoCache.get(cnr)
} }
type lruNetmapSource struct { type lruNetmapSource struct {
@ -206,8 +205,8 @@ type lruNetmapSource struct {
func newCachedNetmapStorage(s netmap.State, v netmap.Source) netmap.Source { func newCachedNetmapStorage(s netmap.State, v netmap.Source) netmap.Source {
const netmapCacheSize = 10 const netmapCacheSize = 10
lruNetmapCache := newNetworkLRUCache(netmapCacheSize, func(ctx context.Context, key uint64) (*netmapSDK.NetMap, error) { lruNetmapCache := newNetworkLRUCache(netmapCacheSize, func(key uint64) (*netmapSDK.NetMap, error) {
return v.GetNetMapByEpoch(ctx, key) return v.GetNetMapByEpoch(key)
}, metrics.NewCacheMetrics("netmap")) }, metrics.NewCacheMetrics("netmap"))
return &lruNetmapSource{ return &lruNetmapSource{
@ -216,16 +215,16 @@ func newCachedNetmapStorage(s netmap.State, v netmap.Source) netmap.Source {
} }
} }
func (s *lruNetmapSource) GetNetMap(ctx context.Context, diff uint64) (*netmapSDK.NetMap, error) { func (s *lruNetmapSource) GetNetMap(diff uint64) (*netmapSDK.NetMap, error) {
return s.getNetMapByEpoch(ctx, s.netState.CurrentEpoch()-diff) return s.getNetMapByEpoch(s.netState.CurrentEpoch() - diff)
} }
func (s *lruNetmapSource) GetNetMapByEpoch(ctx context.Context, epoch uint64) (*netmapSDK.NetMap, error) { func (s *lruNetmapSource) GetNetMapByEpoch(epoch uint64) (*netmapSDK.NetMap, error) {
return s.getNetMapByEpoch(ctx, epoch) return s.getNetMapByEpoch(epoch)
} }
func (s *lruNetmapSource) getNetMapByEpoch(ctx context.Context, epoch uint64) (*netmapSDK.NetMap, error) { func (s *lruNetmapSource) getNetMapByEpoch(epoch uint64) (*netmapSDK.NetMap, error) {
val, err := s.cache.get(ctx, epoch) val, err := s.cache.get(epoch)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -233,7 +232,7 @@ func (s *lruNetmapSource) getNetMapByEpoch(ctx context.Context, epoch uint64) (*
return val, nil return val, nil
} }
func (s *lruNetmapSource) Epoch(_ context.Context) (uint64, error) { func (s *lruNetmapSource) Epoch() (uint64, error) {
return s.netState.CurrentEpoch(), nil return s.netState.CurrentEpoch(), nil
} }
@ -241,10 +240,7 @@ type cachedIRFetcher struct {
*ttlNetCache[struct{}, [][]byte] *ttlNetCache[struct{}, [][]byte]
} }
func newCachedIRFetcher(f interface { func newCachedIRFetcher(f interface{ InnerRingKeys() ([][]byte, error) }) cachedIRFetcher {
InnerRingKeys(ctx context.Context) ([][]byte, error)
},
) cachedIRFetcher {
const ( const (
irFetcherCacheSize = 1 // we intend to store only one value irFetcherCacheSize = 1 // we intend to store only one value
@ -258,8 +254,8 @@ func newCachedIRFetcher(f interface {
) )
irFetcherCache := newNetworkTTLCache(irFetcherCacheSize, irFetcherCacheTTL, irFetcherCache := newNetworkTTLCache(irFetcherCacheSize, irFetcherCacheTTL,
func(ctx context.Context, _ struct{}) ([][]byte, error) { func(_ struct{}) ([][]byte, error) {
return f.InnerRingKeys(ctx) return f.InnerRingKeys()
}, metrics.NewCacheMetrics("ir_keys"), }, metrics.NewCacheMetrics("ir_keys"),
) )
@ -269,8 +265,8 @@ func newCachedIRFetcher(f interface {
// InnerRingKeys returns cached list of Inner Ring keys. If keys are missing in // InnerRingKeys returns cached list of Inner Ring keys. If keys are missing in
// the cache or expired, then it returns keys from side chain and updates // the cache or expired, then it returns keys from side chain and updates
// the cache. // the cache.
func (f cachedIRFetcher) InnerRingKeys(ctx context.Context) ([][]byte, error) { func (f cachedIRFetcher) InnerRingKeys() ([][]byte, error) {
val, err := f.get(ctx, struct{}{}) val, err := f.get(struct{}{})
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -293,7 +289,7 @@ func newCachedMaxObjectSizeSource(src objectwriter.MaxSizeSource) objectwriter.M
} }
} }
func (c *ttlMaxObjectSizeCache) MaxObjectSize(ctx context.Context) uint64 { func (c *ttlMaxObjectSizeCache) MaxObjectSize() uint64 {
const ttl = time.Second * 30 const ttl = time.Second * 30
hit := false hit := false
@ -315,7 +311,7 @@ func (c *ttlMaxObjectSizeCache) MaxObjectSize(ctx context.Context) uint64 {
c.mtx.Lock() c.mtx.Lock()
size = c.lastSize size = c.lastSize
if !c.lastUpdated.After(prevUpdated) { if !c.lastUpdated.After(prevUpdated) {
size = c.src.MaxObjectSize(ctx) size = c.src.MaxObjectSize()
c.lastSize = size c.lastSize = size
c.lastUpdated = time.Now() c.lastUpdated = time.Now()
} }

View file

@ -1,7 +1,6 @@
package main package main
import ( import (
"context"
"errors" "errors"
"testing" "testing"
"time" "time"
@ -18,7 +17,7 @@ func TestTTLNetCache(t *testing.T) {
t.Run("Test Add and Get", func(t *testing.T) { t.Run("Test Add and Get", func(t *testing.T) {
ti := time.Now() ti := time.Now()
cache.set(key, ti, nil) cache.set(key, ti, nil)
val, err := cache.get(context.Background(), key) val, err := cache.get(key)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, ti, val) require.Equal(t, ti, val)
}) })
@ -27,7 +26,7 @@ func TestTTLNetCache(t *testing.T) {
ti := time.Now() ti := time.Now()
cache.set(key, ti, nil) cache.set(key, ti, nil)
time.Sleep(2 * ttlDuration) time.Sleep(2 * ttlDuration)
val, err := cache.get(context.Background(), key) val, err := cache.get(key)
require.NoError(t, err) require.NoError(t, err)
require.NotEqual(t, val, ti) require.NotEqual(t, val, ti)
}) })
@ -36,20 +35,20 @@ func TestTTLNetCache(t *testing.T) {
ti := time.Now() ti := time.Now()
cache.set(key, ti, nil) cache.set(key, ti, nil)
cache.remove(key) cache.remove(key)
val, err := cache.get(context.Background(), key) val, err := cache.get(key)
require.NoError(t, err) require.NoError(t, err)
require.NotEqual(t, val, ti) require.NotEqual(t, val, ti)
}) })
t.Run("Test Cache Error", func(t *testing.T) { t.Run("Test Cache Error", func(t *testing.T) {
cache.set("error", time.Now(), errors.New("mock error")) cache.set("error", time.Now(), errors.New("mock error"))
_, err := cache.get(context.Background(), "error") _, err := cache.get("error")
require.Error(t, err) require.Error(t, err)
require.Equal(t, "mock error", err.Error()) require.Equal(t, "mock error", err.Error())
}) })
} }
func testNetValueReader(_ context.Context, key string) (time.Time, error) { func testNetValueReader(key string) (time.Time, error) {
if key == "error" { if key == "error" {
return time.Now(), errors.New("mock error") return time.Now(), errors.New("mock error")
} }

View file

@ -493,7 +493,6 @@ type cfg struct {
cfgNetmap cfgNetmap cfgNetmap cfgNetmap
cfgControlService cfgControlService cfgControlService cfgControlService
cfgObject cfgObject cfgObject cfgObject
cfgQoSService cfgQoSService
} }
// ReadCurrentNetMap reads network map which has been cached at the // ReadCurrentNetMap reads network map which has been cached at the
@ -1206,7 +1205,7 @@ func (c *cfg) setContractNodeInfo(ni *netmap.NodeInfo) {
} }
func (c *cfg) updateContractNodeInfo(ctx context.Context, epoch uint64) { func (c *cfg) updateContractNodeInfo(ctx context.Context, epoch uint64) {
ni, err := c.netmapLocalNodeState(ctx, epoch) ni, err := c.netmapLocalNodeState(epoch)
if err != nil { if err != nil {
c.log.Error(ctx, logs.FrostFSNodeCouldNotUpdateNodeStateOnNewEpoch, c.log.Error(ctx, logs.FrostFSNodeCouldNotUpdateNodeStateOnNewEpoch,
zap.Uint64("epoch", epoch), zap.Uint64("epoch", epoch),

View file

@ -1,46 +0,0 @@
package qos
import (
"fmt"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
)
const (
subsection = "qos"
criticalSubSection = "critical"
internalSubSection = "internal"
)
// CriticalAuthorizedKeys parses and returns an array of "critical.authorized_keys" config
// parameter from "qos" section.
//
// Returns an empty list if not set.
func CriticalAuthorizedKeys(c *config.Config) keys.PublicKeys {
return authorizedKeys(c, criticalSubSection)
}
// InternalAuthorizedKeys parses and returns an array of "internal.authorized_keys" config
// parameter from "qos" section.
//
// Returns an empty list if not set.
func InternalAuthorizedKeys(c *config.Config) keys.PublicKeys {
return authorizedKeys(c, internalSubSection)
}
func authorizedKeys(c *config.Config, sub string) keys.PublicKeys {
strKeys := config.StringSliceSafe(c.Sub(subsection).Sub(sub), "authorized_keys")
pubs := make(keys.PublicKeys, 0, len(strKeys))
for i := range strKeys {
pub, err := keys.NewPublicKeyFromString(strKeys[i])
if err != nil {
panic(fmt.Errorf("invalid authorized key %s for qos.%s: %w", strKeys[i], sub, err))
}
pubs = append(pubs, pub)
}
return pubs
}

View file

@ -1,40 +0,0 @@
package qos
import (
"testing"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config"
configtest "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/test"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/stretchr/testify/require"
)
func TestQoSSection(t *testing.T) {
t.Run("defaults", func(t *testing.T) {
empty := configtest.EmptyConfig()
require.Empty(t, CriticalAuthorizedKeys(empty))
require.Empty(t, InternalAuthorizedKeys(empty))
})
const path = "../../../../config/example/node"
criticalPubs := make(keys.PublicKeys, 2)
criticalPubs[0], _ = keys.NewPublicKeyFromString("035839e45d472a3b7769a2a1bd7d54c4ccd4943c3b40f547870e83a8fcbfb3ce11")
criticalPubs[1], _ = keys.NewPublicKeyFromString("028f42cfcb74499d7b15b35d9bff260a1c8d27de4f446a627406a382d8961486d6")
internalPubs := make(keys.PublicKeys, 2)
internalPubs[0], _ = keys.NewPublicKeyFromString("02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2")
internalPubs[1], _ = keys.NewPublicKeyFromString("031a6c6fbbdf02ca351745fa86b9ba5a9452d785ac4f7fc2b7548ca2a46c4fcf4a")
fileConfigTest := func(c *config.Config) {
require.Equal(t, criticalPubs, CriticalAuthorizedKeys(c))
require.Equal(t, internalPubs, InternalAuthorizedKeys(c))
}
configtest.ForEachFileType(path, fileConfigTest)
t.Run("ENV", func(t *testing.T) {
configtest.ForEnvFileType(t, path, fileConfigTest)
})
}

View file

@ -100,7 +100,7 @@ func configureEACLAndContainerSources(c *cfg, client *cntClient.Client, cnrSrc c
// TODO: use owner directly from the event after neofs-contract#256 will become resolved // TODO: use owner directly from the event after neofs-contract#256 will become resolved
// but don't forget about the profit of reading the new container and caching it: // but don't forget about the profit of reading the new container and caching it:
// creation success are most commonly tracked by polling GET op. // creation success are most commonly tracked by polling GET op.
cnr, err := cnrSrc.Get(ctx, ev.ID) cnr, err := cnrSrc.Get(ev.ID)
if err == nil { if err == nil {
containerCache.containerCache.set(ev.ID, cnr, nil) containerCache.containerCache.set(ev.ID, cnr, nil)
} else { } else {
@ -221,25 +221,25 @@ type morphContainerReader struct {
src containerCore.Source src containerCore.Source
lister interface { lister interface {
ContainersOf(context.Context, *user.ID) ([]cid.ID, error) ContainersOf(*user.ID) ([]cid.ID, error)
IterateContainersOf(context.Context, *user.ID, func(cid.ID) error) error IterateContainersOf(*user.ID, func(cid.ID) error) error
} }
} }
func (x *morphContainerReader) Get(ctx context.Context, id cid.ID) (*containerCore.Container, error) { func (x *morphContainerReader) Get(id cid.ID) (*containerCore.Container, error) {
return x.src.Get(ctx, id) return x.src.Get(id)
} }
func (x *morphContainerReader) DeletionInfo(ctx context.Context, id cid.ID) (*containerCore.DelInfo, error) { func (x *morphContainerReader) DeletionInfo(id cid.ID) (*containerCore.DelInfo, error) {
return x.src.DeletionInfo(ctx, id) return x.src.DeletionInfo(id)
} }
func (x *morphContainerReader) ContainersOf(ctx context.Context, id *user.ID) ([]cid.ID, error) { func (x *morphContainerReader) ContainersOf(id *user.ID) ([]cid.ID, error) {
return x.lister.ContainersOf(ctx, id) return x.lister.ContainersOf(id)
} }
func (x *morphContainerReader) IterateContainersOf(ctx context.Context, id *user.ID, processCID func(cid.ID) error) error { func (x *morphContainerReader) IterateContainersOf(id *user.ID, processCID func(cid.ID) error) error {
return x.lister.IterateContainersOf(ctx, id, processCID) return x.lister.IterateContainersOf(id, processCID)
} }
type morphContainerWriter struct { type morphContainerWriter struct {

View file

@ -7,12 +7,9 @@ import (
controlconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/control" controlconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/control"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs" "git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/qos"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control"
controlSvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control/server" controlSvc "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control/server"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/sdnotify" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/sdnotify"
metrics "git.frostfs.info/TrueCloudLab/frostfs-observability/metrics/grpc"
tracing "git.frostfs.info/TrueCloudLab/frostfs-observability/tracing/grpc"
"go.uber.org/zap" "go.uber.org/zap"
"google.golang.org/grpc" "google.golang.org/grpc"
) )
@ -53,14 +50,7 @@ func initControlService(ctx context.Context, c *cfg) {
return return
} }
c.cfgControlService.server = grpc.NewServer( c.cfgControlService.server = grpc.NewServer()
grpc.ChainUnaryInterceptor(
qos.NewSetCriticalIOTagUnaryServerInterceptor(),
metrics.NewUnaryServerInterceptor(),
tracing.NewUnaryServerInterceptor(),
),
// control service has no stream methods, so no stream interceptors added
)
c.onShutdown(func() { c.onShutdown(func() {
stopGRPC(ctx, "FrostFS Control API", c.cfgControlService.server, c.log) stopGRPC(ctx, "FrostFS Control API", c.cfgControlService.server, c.log)

View file

@ -1,7 +1,6 @@
package main package main
import ( import (
"context"
"strings" "strings"
"time" "time"
@ -43,7 +42,7 @@ func newMorphFrostfsIDCache(subjProvider frostfsidcore.SubjectProvider, size int
} }
} }
func (m *morphFrostfsIDCache) GetSubject(ctx context.Context, addr util.Uint160) (*client.Subject, error) { func (m *morphFrostfsIDCache) GetSubject(addr util.Uint160) (*client.Subject, error) {
hit := false hit := false
startedAt := time.Now() startedAt := time.Now()
defer func() { defer func() {
@ -56,7 +55,7 @@ func (m *morphFrostfsIDCache) GetSubject(ctx context.Context, addr util.Uint160)
return result.subject, result.err return result.subject, result.err
} }
subj, err := m.subjProvider.GetSubject(ctx, addr) subj, err := m.subjProvider.GetSubject(addr)
if err != nil { if err != nil {
if m.isCacheableError(err) { if m.isCacheableError(err) {
m.subjCache.Add(addr, subjectWithError{ m.subjCache.Add(addr, subjectWithError{
@ -70,7 +69,7 @@ func (m *morphFrostfsIDCache) GetSubject(ctx context.Context, addr util.Uint160)
return subj, nil return subj, nil
} }
func (m *morphFrostfsIDCache) GetSubjectExtended(ctx context.Context, addr util.Uint160) (*client.SubjectExtended, error) { func (m *morphFrostfsIDCache) GetSubjectExtended(addr util.Uint160) (*client.SubjectExtended, error) {
hit := false hit := false
startedAt := time.Now() startedAt := time.Now()
defer func() { defer func() {
@ -83,7 +82,7 @@ func (m *morphFrostfsIDCache) GetSubjectExtended(ctx context.Context, addr util.
return result.subject, result.err return result.subject, result.err
} }
subjExt, err := m.subjProvider.GetSubjectExtended(ctx, addr) subjExt, err := m.subjProvider.GetSubjectExtended(addr)
if err != nil { if err != nil {
if m.isCacheableError(err) { if m.isCacheableError(err) {
m.subjExtCache.Add(addr, subjectExtWithError{ m.subjExtCache.Add(addr, subjectExtWithError{

View file

@ -12,7 +12,6 @@ import (
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
metrics "git.frostfs.info/TrueCloudLab/frostfs-observability/metrics/grpc" metrics "git.frostfs.info/TrueCloudLab/frostfs-observability/metrics/grpc"
tracing "git.frostfs.info/TrueCloudLab/frostfs-observability/tracing/grpc" tracing "git.frostfs.info/TrueCloudLab/frostfs-observability/tracing/grpc"
qos "git.frostfs.info/TrueCloudLab/frostfs-qos/tagging"
"go.uber.org/zap" "go.uber.org/zap"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials"
@ -131,12 +130,10 @@ func getGrpcServerOpts(ctx context.Context, c *cfg, sc *grpcconfig.Config) ([]gr
serverOpts := []grpc.ServerOption{ serverOpts := []grpc.ServerOption{
grpc.MaxRecvMsgSize(maxRecvMsgSize), grpc.MaxRecvMsgSize(maxRecvMsgSize),
grpc.ChainUnaryInterceptor( grpc.ChainUnaryInterceptor(
qos.NewUnaryServerInterceptor(),
metrics.NewUnaryServerInterceptor(), metrics.NewUnaryServerInterceptor(),
tracing.NewUnaryServerInterceptor(), tracing.NewUnaryServerInterceptor(),
), ),
grpc.ChainStreamInterceptor( grpc.ChainStreamInterceptor(
qos.NewStreamServerInterceptor(),
metrics.NewStreamServerInterceptor(), metrics.NewStreamServerInterceptor(),
tracing.NewStreamServerInterceptor(), tracing.NewStreamServerInterceptor(),
), ),

View file

@ -101,7 +101,6 @@ func initApp(ctx context.Context, c *cfg) {
initAndLog(ctx, c, "gRPC", func(c *cfg) { initGRPC(ctx, c) }) initAndLog(ctx, c, "gRPC", func(c *cfg) { initGRPC(ctx, c) })
initAndLog(ctx, c, "netmap", func(c *cfg) { initNetmapService(ctx, c) }) initAndLog(ctx, c, "netmap", func(c *cfg) { initNetmapService(ctx, c) })
initAndLog(ctx, c, "qos", func(c *cfg) { initQoSService(c) })
initAccessPolicyEngine(ctx, c) initAccessPolicyEngine(ctx, c)
initAndLog(ctx, c, "access policy engine", func(c *cfg) { initAndLog(ctx, c, "access policy engine", func(c *cfg) {

View file

@ -239,7 +239,7 @@ func setNetmapNotificationParser(c *cfg, sTyp string, p event.NotificationParser
// initNetmapState inits current Network map state. // initNetmapState inits current Network map state.
// Must be called after Morph components initialization. // Must be called after Morph components initialization.
func initNetmapState(ctx context.Context, c *cfg) { func initNetmapState(ctx context.Context, c *cfg) {
epoch, err := c.cfgNetmap.wrapper.Epoch(ctx) epoch, err := c.cfgNetmap.wrapper.Epoch()
fatalOnErrDetails("could not initialize current epoch number", err) fatalOnErrDetails("could not initialize current epoch number", err)
var ni *netmapSDK.NodeInfo var ni *netmapSDK.NodeInfo
@ -278,7 +278,7 @@ func nodeState(ni *netmapSDK.NodeInfo) string {
} }
func (c *cfg) netmapInitLocalNodeState(ctx context.Context, epoch uint64) (*netmapSDK.NodeInfo, error) { func (c *cfg) netmapInitLocalNodeState(ctx context.Context, epoch uint64) (*netmapSDK.NodeInfo, error) {
nmNodes, err := c.cfgNetmap.wrapper.GetCandidates(ctx) nmNodes, err := c.cfgNetmap.wrapper.GetCandidates()
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -291,7 +291,7 @@ func (c *cfg) netmapInitLocalNodeState(ctx context.Context, epoch uint64) (*netm
} }
} }
node, err := c.netmapLocalNodeState(ctx, epoch) node, err := c.netmapLocalNodeState(epoch)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -312,9 +312,9 @@ func (c *cfg) netmapInitLocalNodeState(ctx context.Context, epoch uint64) (*netm
return candidate, nil return candidate, nil
} }
func (c *cfg) netmapLocalNodeState(ctx context.Context, epoch uint64) (*netmapSDK.NodeInfo, error) { func (c *cfg) netmapLocalNodeState(epoch uint64) (*netmapSDK.NodeInfo, error) {
// calculate current network state // calculate current network state
nm, err := c.cfgNetmap.wrapper.GetNetMapByEpoch(ctx, epoch) nm, err := c.cfgNetmap.wrapper.GetNetMapByEpoch(epoch)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -376,8 +376,8 @@ func (c *cfg) SetNetmapStatus(ctx context.Context, st control.NetmapStatus) erro
return c.updateNetMapState(ctx, func(*nmClient.UpdatePeerPrm) {}) return c.updateNetMapState(ctx, func(*nmClient.UpdatePeerPrm) {})
} }
func (c *cfg) GetNetmapStatus(ctx context.Context) (control.NetmapStatus, uint64, error) { func (c *cfg) GetNetmapStatus() (control.NetmapStatus, uint64, error) {
epoch, err := c.netMapSource.Epoch(ctx) epoch, err := c.netMapSource.Epoch()
if err != nil { if err != nil {
return control.NetmapStatus_STATUS_UNDEFINED, 0, fmt.Errorf("failed to get current epoch: %w", err) return control.NetmapStatus_STATUS_UNDEFINED, 0, fmt.Errorf("failed to get current epoch: %w", err)
} }
@ -390,7 +390,7 @@ func (c *cfg) ForceMaintenance(ctx context.Context) error {
} }
func (c *cfg) setMaintenanceStatus(ctx context.Context, force bool) error { func (c *cfg) setMaintenanceStatus(ctx context.Context, force bool) error {
netSettings, err := c.cfgNetmap.wrapper.ReadNetworkConfiguration(ctx) netSettings, err := c.cfgNetmap.wrapper.ReadNetworkConfiguration()
if err != nil { if err != nil {
err = fmt.Errorf("read network settings to check maintenance allowance: %w", err) err = fmt.Errorf("read network settings to check maintenance allowance: %w", err)
} else if !netSettings.MaintenanceModeAllowed { } else if !netSettings.MaintenanceModeAllowed {
@ -438,7 +438,7 @@ type netInfo struct {
msPerBlockRdr func() (int64, error) msPerBlockRdr func() (int64, error)
} }
func (n *netInfo) Dump(ctx context.Context, ver version.Version) (*netmapSDK.NetworkInfo, error) { func (n *netInfo) Dump(ver version.Version) (*netmapSDK.NetworkInfo, error) {
magic, err := n.magic.MagicNumber() magic, err := n.magic.MagicNumber()
if err != nil { if err != nil {
return nil, err return nil, err
@ -448,7 +448,7 @@ func (n *netInfo) Dump(ctx context.Context, ver version.Version) (*netmapSDK.Net
ni.SetCurrentEpoch(n.netState.CurrentEpoch()) ni.SetCurrentEpoch(n.netState.CurrentEpoch())
ni.SetMagicNumber(magic) ni.SetMagicNumber(magic)
netInfoMorph, err := n.morphClientNetMap.ReadNetworkConfiguration(ctx) netInfoMorph, err := n.morphClientNetMap.ReadNetworkConfiguration()
if err != nil { if err != nil {
return nil, fmt.Errorf("read network configuration using netmap contract client: %w", err) return nil, fmt.Errorf("read network configuration using netmap contract client: %w", err)
} }

View file

@ -54,10 +54,10 @@ type objectSvc struct {
patch *patchsvc.Service patch *patchsvc.Service
} }
func (c *cfg) MaxObjectSize(ctx context.Context) uint64 { func (c *cfg) MaxObjectSize() uint64 {
sz, err := c.cfgNetmap.wrapper.MaxObjectSize(ctx) sz, err := c.cfgNetmap.wrapper.MaxObjectSize()
if err != nil { if err != nil {
c.log.Error(ctx, logs.FrostFSNodeCouldNotGetMaxObjectSizeValue, c.log.Error(context.Background(), logs.FrostFSNodeCouldNotGetMaxObjectSizeValue,
zap.Error(err), zap.Error(err),
) )
} }
@ -122,8 +122,8 @@ type innerRingFetcherWithNotary struct {
sidechain *morphClient.Client sidechain *morphClient.Client
} }
func (fn *innerRingFetcherWithNotary) InnerRingKeys(ctx context.Context) ([][]byte, error) { func (fn *innerRingFetcherWithNotary) InnerRingKeys() ([][]byte, error) {
keys, err := fn.sidechain.NeoFSAlphabetList(ctx) keys, err := fn.sidechain.NeoFSAlphabetList()
if err != nil { if err != nil {
return nil, fmt.Errorf("can't get inner ring keys from alphabet role: %w", err) return nil, fmt.Errorf("can't get inner ring keys from alphabet role: %w", err)
} }
@ -168,7 +168,7 @@ func initObjectService(c *cfg) {
sPatch := createPatchSvc(sGet, sPut) sPatch := createPatchSvc(sGet, sPut)
// build service pipeline // build service pipeline
// grpc | audit | qos | <metrics> | signature | response | acl | ape | split // grpc | audit | <metrics> | signature | response | acl | ape | split
splitSvc := createSplitService(c, sPutV2, sGetV2, sSearchV2, sDeleteV2, sPatch) splitSvc := createSplitService(c, sPutV2, sGetV2, sSearchV2, sDeleteV2, sPatch)
@ -191,8 +191,7 @@ func initObjectService(c *cfg) {
c.shared.metricsSvc = objectService.NewMetricCollector( c.shared.metricsSvc = objectService.NewMetricCollector(
signSvc, c.metricsCollector.ObjectService(), metricsconfig.Enabled(c.appCfg)) signSvc, c.metricsCollector.ObjectService(), metricsconfig.Enabled(c.appCfg))
qosService := objectService.NewQoSObjectService(c.shared.metricsSvc, &c.cfgQoSService) auditSvc := objectService.NewAuditService(c.shared.metricsSvc, c.log, c.audit)
auditSvc := objectService.NewAuditService(qosService, c.log, c.audit)
server := objectTransportGRPC.New(auditSvc) server := objectTransportGRPC.New(auditSvc)
c.cfgGRPC.performAndSave(func(_ string, _ net.Listener, s *grpc.Server) { c.cfgGRPC.performAndSave(func(_ string, _ net.Listener, s *grpc.Server) {

View file

@ -1,95 +0,0 @@
package main
import (
"bytes"
"context"
qosconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/qos"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/qos"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/netmap"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
qosTagging "git.frostfs.info/TrueCloudLab/frostfs-qos/tagging"
"go.uber.org/zap"
)
type cfgQoSService struct {
netmapSource netmap.Source
logger *logger.Logger
allowedCriticalPubs [][]byte
allowedInternalPubs [][]byte
}
func initQoSService(c *cfg) {
criticalPubs := qosconfig.CriticalAuthorizedKeys(c.appCfg)
internalPubs := qosconfig.InternalAuthorizedKeys(c.appCfg)
rawCriticalPubs := make([][]byte, 0, len(criticalPubs))
rawInternalPubs := make([][]byte, 0, len(internalPubs))
for i := range criticalPubs {
rawCriticalPubs = append(rawCriticalPubs, criticalPubs[i].Bytes())
}
for i := range internalPubs {
rawInternalPubs = append(rawInternalPubs, internalPubs[i].Bytes())
}
c.cfgQoSService = cfgQoSService{
netmapSource: c.netMapSource,
logger: c.log,
allowedCriticalPubs: rawCriticalPubs,
allowedInternalPubs: rawInternalPubs,
}
}
func (s *cfgQoSService) AdjustIncomingTag(ctx context.Context, requestSignPublicKey []byte) context.Context {
rawTag, defined := qosTagging.IOTagFromContext(ctx)
if !defined {
return qosTagging.ContextWithIOTag(ctx, qos.IOTagClient.String())
}
ioTag, err := qos.FromRawString(rawTag)
if err != nil {
s.logger.Warn(ctx, logs.FailedToParseIncomingIOTag, zap.Error(err))
return qosTagging.ContextWithIOTag(ctx, qos.IOTagClient.String())
}
switch ioTag {
case qos.IOTagClient:
return ctx
case qos.IOTagCritical:
for _, pk := range s.allowedCriticalPubs {
if bytes.Equal(pk, requestSignPublicKey) {
return ctx
}
}
nm, err := s.netmapSource.GetNetMap(ctx, 0)
if err != nil {
s.logger.Debug(ctx, logs.FailedToGetNetmapToAdjustIOTag, zap.Error(err))
return qosTagging.ContextWithIOTag(ctx, qos.IOTagClient.String())
}
for _, node := range nm.Nodes() {
if bytes.Equal(node.PublicKey(), requestSignPublicKey) {
return ctx
}
}
return qosTagging.ContextWithIOTag(ctx, qos.IOTagClient.String())
case qos.IOTagInternal:
for _, pk := range s.allowedInternalPubs {
if bytes.Equal(pk, requestSignPublicKey) {
return ctx
}
}
nm, err := s.netmapSource.GetNetMap(ctx, 0)
if err != nil {
s.logger.Debug(ctx, logs.FailedToGetNetmapToAdjustIOTag, zap.Error(err))
return qosTagging.ContextWithIOTag(ctx, qos.IOTagClient.String())
}
for _, node := range nm.Nodes() {
if bytes.Equal(node.PublicKey(), requestSignPublicKey) {
return ctx
}
}
return qosTagging.ContextWithIOTag(ctx, qos.IOTagClient.String())
default:
s.logger.Warn(ctx, logs.NotSupportedIncomingIOTagReplacedWithClient, zap.Stringer("io_tag", ioTag))
return qosTagging.ContextWithIOTag(ctx, qos.IOTagClient.String())
}
}

View file

@ -29,16 +29,16 @@ type cnrSource struct {
cli *containerClient.Client cli *containerClient.Client
} }
func (c cnrSource) Get(ctx context.Context, id cid.ID) (*container.Container, error) { func (c cnrSource) Get(id cid.ID) (*container.Container, error) {
return c.src.Get(ctx, id) return c.src.Get(id)
} }
func (c cnrSource) DeletionInfo(ctx context.Context, cid cid.ID) (*container.DelInfo, error) { func (c cnrSource) DeletionInfo(cid cid.ID) (*container.DelInfo, error) {
return c.src.DeletionInfo(ctx, cid) return c.src.DeletionInfo(cid)
} }
func (c cnrSource) List(ctx context.Context) ([]cid.ID, error) { func (c cnrSource) List() ([]cid.ID, error) {
return c.cli.ContainersOf(ctx, nil) return c.cli.ContainersOf(nil)
} }
func initTreeService(c *cfg) { func initTreeService(c *cfg) {
@ -72,7 +72,7 @@ func initTreeService(c *cfg) {
) )
c.cfgGRPC.performAndSave(func(_ string, _ net.Listener, s *grpc.Server) { c.cfgGRPC.performAndSave(func(_ string, _ net.Listener, s *grpc.Server) {
tree.RegisterTreeServiceServer(s, tree.NewIOTagAdjustServer(c.treeService, &c.cfgQoSService)) tree.RegisterTreeServiceServer(s, c.treeService)
}) })
c.workers = append(c.workers, newWorkerFromFunc(func(ctx context.Context) { c.workers = append(c.workers, newWorkerFromFunc(func(ctx context.Context) {

View file

@ -225,6 +225,3 @@ FROSTFS_MULTINET_SUBNETS_1_SOURCE_IPS="10.78.70.185 10.78.71.185"
FROSTFS_MULTINET_BALANCER=roundrobin FROSTFS_MULTINET_BALANCER=roundrobin
FROSTFS_MULTINET_RESTRICT=false FROSTFS_MULTINET_RESTRICT=false
FROSTFS_MULTINET_FALLBACK_DELAY=350ms FROSTFS_MULTINET_FALLBACK_DELAY=350ms
FROSTFS_QOS_CRITICAL_AUTHORIZED_KEYS="035839e45d472a3b7769a2a1bd7d54c4ccd4943c3b40f547870e83a8fcbfb3ce11 028f42cfcb74499d7b15b35d9bff260a1c8d27de4f446a627406a382d8961486d6"
FROSTFS_QOS_INTERNAL_AUTHORIZED_KEYS="02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2 031a6c6fbbdf02ca351745fa86b9ba5a9452d785ac4f7fc2b7548ca2a46c4fcf4a"

View file

@ -305,19 +305,5 @@
"balancer": "roundrobin", "balancer": "roundrobin",
"restrict": false, "restrict": false,
"fallback_delay": "350ms" "fallback_delay": "350ms"
},
"qos": {
"critical": {
"authorized_keys": [
"035839e45d472a3b7769a2a1bd7d54c4ccd4943c3b40f547870e83a8fcbfb3ce11",
"028f42cfcb74499d7b15b35d9bff260a1c8d27de4f446a627406a382d8961486d6"
]
},
"internal": {
"authorized_keys": [
"02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2",
"031a6c6fbbdf02ca351745fa86b9ba5a9452d785ac4f7fc2b7548ca2a46c4fcf4a"
]
}
} }
} }

View file

@ -270,13 +270,3 @@ multinet:
balancer: roundrobin balancer: roundrobin
restrict: false restrict: false
fallback_delay: 350ms fallback_delay: 350ms
qos:
critical:
authorized_keys: # list of hex-encoded public keys that have rights to use `critical` IO tag
- 035839e45d472a3b7769a2a1bd7d54c4ccd4943c3b40f547870e83a8fcbfb3ce11
- 028f42cfcb74499d7b15b35d9bff260a1c8d27de4f446a627406a382d8961486d6
internal:
authorized_keys: # list of hex-encoded public keys that have rights to use `internal` IO tag
- 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
- 031a6c6fbbdf02ca351745fa86b9ba5a9452d785ac4f7fc2b7548ca2a46c4fcf4a

View file

@ -27,7 +27,6 @@ There are some custom types used for brevity:
| `runtime` | [Runtime configuration](#runtime-section) | | `runtime` | [Runtime configuration](#runtime-section) |
| `audit` | [Audit configuration](#audit-section) | | `audit` | [Audit configuration](#audit-section) |
| `multinet` | [Multinet configuration](#multinet-section) | | `multinet` | [Multinet configuration](#multinet-section) |
| `qos` | [QoS configuration](#qos-section) |
# `control` section # `control` section
```yaml ```yaml
@ -472,20 +471,3 @@ multinet:
| `balancer` | `string` | "" | Balancer to select network interfaces, allowed values are "" (no balancing, use first suitable interface) or "roundrobin". | | `balancer` | `string` | "" | Balancer to select network interfaces, allowed values are "" (no balancing, use first suitable interface) or "roundrobin". |
| `restrict` | `bool` | false | If `true` then any requests that do not match `subnets` will fail. | | `restrict` | `bool` | false | If `true` then any requests that do not match `subnets` will fail. |
| `fallback_delay` | `duration` | 350ms | Delay before fallback to secondary IP addresses in case of hostname resolve. | | `fallback_delay` | `duration` | 350ms | Delay before fallback to secondary IP addresses in case of hostname resolve. |
# `qos` section
```yaml
qos:
critical:
authorized_keys:
- 035839e45d472a3b7769a2a1bd7d54c4ccd4943c3b40f547870e83a8fcbfb3ce11
- 028f42cfcb74499d7b15b35d9bff260a1c8d27de4f446a627406a382d8961486d6
internal:
authorized_keys:
- 035839e45d472a3b7769a2a1bd7d54c4ccd4943c3b40f547870e83a8fcbfb3ce11
- 028f42cfcb74499d7b15b35d9bff260a1c8d27de4f446a627406a382d8961486d6
```
| Parameter | Type | Default value | Description |
| -------------------------- | -------------- | ------------- | --------------------------------------------------------------------------- |
| `critical.authorized_keys` | `[]public key` | empty | List of public keys for which requests with the tag `critical` are allowed. |
| `internal.authorized_keys` | `[]public key` | empty | List of public keys for which requests with the tag `internal` are allowed. |

5
go.mod
View file

@ -7,9 +7,8 @@ require (
git.frostfs.info/TrueCloudLab/frostfs-contract v0.21.1-0.20241205083807-762d7f9f9f08 git.frostfs.info/TrueCloudLab/frostfs-contract v0.21.1-0.20241205083807-762d7f9f9f08
git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0 git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0
git.frostfs.info/TrueCloudLab/frostfs-locode-db v0.4.1-0.20240710074952-65761deb5c0d git.frostfs.info/TrueCloudLab/frostfs-locode-db v0.4.1-0.20240710074952-65761deb5c0d
git.frostfs.info/TrueCloudLab/frostfs-observability v0.0.0-20250212111929-d34e1329c824 git.frostfs.info/TrueCloudLab/frostfs-observability v0.0.0-20241112082307-f17779933e88
git.frostfs.info/TrueCloudLab/frostfs-qos v0.0.0-20250128150313-cfbca7fa1dfe git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20250109084609-328d214d2d76
git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20250202151421-8389887a3421
git.frostfs.info/TrueCloudLab/hrw v1.2.1 git.frostfs.info/TrueCloudLab/hrw v1.2.1
git.frostfs.info/TrueCloudLab/multinet v0.0.0-20241015075604-6cb0d80e0972 git.frostfs.info/TrueCloudLab/multinet v0.0.0-20241015075604-6cb0d80e0972
git.frostfs.info/TrueCloudLab/policy-engine v0.0.0-20240814080254-96225afacb88 git.frostfs.info/TrueCloudLab/policy-engine v0.0.0-20240814080254-96225afacb88

10
go.sum
View file

@ -6,12 +6,10 @@ git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0 h1:FxqFDhQYYgpe41qsIHVOcdzSV
git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0/go.mod h1:RUIKZATQLJ+TaYQa60X2fTDwfuhMfm8Ar60bQ5fr+vU= git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0/go.mod h1:RUIKZATQLJ+TaYQa60X2fTDwfuhMfm8Ar60bQ5fr+vU=
git.frostfs.info/TrueCloudLab/frostfs-locode-db v0.4.1-0.20240710074952-65761deb5c0d h1:uJ/wvuMdepbkaV8XMS5uN9B0FQWMep0CttSuDZiDhq0= git.frostfs.info/TrueCloudLab/frostfs-locode-db v0.4.1-0.20240710074952-65761deb5c0d h1:uJ/wvuMdepbkaV8XMS5uN9B0FQWMep0CttSuDZiDhq0=
git.frostfs.info/TrueCloudLab/frostfs-locode-db v0.4.1-0.20240710074952-65761deb5c0d/go.mod h1:7ZZq8iguY7qFsXajdHGmZd2AW4QbucyrJwhbsRfOfek= git.frostfs.info/TrueCloudLab/frostfs-locode-db v0.4.1-0.20240710074952-65761deb5c0d/go.mod h1:7ZZq8iguY7qFsXajdHGmZd2AW4QbucyrJwhbsRfOfek=
git.frostfs.info/TrueCloudLab/frostfs-observability v0.0.0-20250212111929-d34e1329c824 h1:Mxw1c/8t96vFIUOffl28lFaHKi413oCBfLMGJmF9cFA= git.frostfs.info/TrueCloudLab/frostfs-observability v0.0.0-20241112082307-f17779933e88 h1:9bvBDLApbbO5sXBKdODpE9tzy3HV99nXxkDWNn22rdI=
git.frostfs.info/TrueCloudLab/frostfs-observability v0.0.0-20250212111929-d34e1329c824/go.mod h1:kbwB4v2o6RyOfCo9kEFeUDZIX3LKhmS0yXPrtvzkQ1g= git.frostfs.info/TrueCloudLab/frostfs-observability v0.0.0-20241112082307-f17779933e88/go.mod h1:kbwB4v2o6RyOfCo9kEFeUDZIX3LKhmS0yXPrtvzkQ1g=
git.frostfs.info/TrueCloudLab/frostfs-qos v0.0.0-20250128150313-cfbca7fa1dfe h1:81gDNdWNLP24oMQukRiCE9R1wGSh0l0dRq3F1W+Oesc= git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20250109084609-328d214d2d76 h1:wzvSJIiS+p9qKfl3eg1oH6qlrjaEWiqTc/iMDKG3Ml4=
git.frostfs.info/TrueCloudLab/frostfs-qos v0.0.0-20250128150313-cfbca7fa1dfe/go.mod h1:PCijYq4oa8vKtIEcUX6jRiszI6XAW+nBwU+T1kB4d1U= git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20250109084609-328d214d2d76/go.mod h1:aQpPWfG8oyfJ2X+FenPTJpSRWZjwcP5/RAtkW+/VEX8=
git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20250202151421-8389887a3421 h1:pP19IawSdsLCKFv7HMNfWAeH6E3uSnntKZkwka+/2+4=
git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20250202151421-8389887a3421/go.mod h1:aQpPWfG8oyfJ2X+FenPTJpSRWZjwcP5/RAtkW+/VEX8=
git.frostfs.info/TrueCloudLab/hrw v1.2.1 h1:ccBRK21rFvY5R1WotI6LNoPlizk7qSvdfD8lNIRudVc= git.frostfs.info/TrueCloudLab/hrw v1.2.1 h1:ccBRK21rFvY5R1WotI6LNoPlizk7qSvdfD8lNIRudVc=
git.frostfs.info/TrueCloudLab/hrw v1.2.1/go.mod h1:C1Ygde2n843yTZEQ0FP69jYiuaYV0kriLvP4zm8JuvM= git.frostfs.info/TrueCloudLab/hrw v1.2.1/go.mod h1:C1Ygde2n843yTZEQ0FP69jYiuaYV0kriLvP4zm8JuvM=
git.frostfs.info/TrueCloudLab/multinet v0.0.0-20241015075604-6cb0d80e0972 h1:/960fWeyn2AFHwQUwDsWB3sbP6lTEnFnMzLMM6tx6N8= git.frostfs.info/TrueCloudLab/multinet v0.0.0-20241015075604-6cb0d80e0972 h1:/960fWeyn2AFHwQUwDsWB3sbP6lTEnFnMzLMM6tx6N8=

View file

@ -510,7 +510,4 @@ const (
BlobovniczatreeFailedToRemoveRebuildTempFile = "failed to remove rebuild temp file" BlobovniczatreeFailedToRemoveRebuildTempFile = "failed to remove rebuild temp file"
WritecacheCantGetObject = "can't get an object from fstree" WritecacheCantGetObject = "can't get an object from fstree"
FailedToUpdateMultinetConfiguration = "failed to update multinet configuration" FailedToUpdateMultinetConfiguration = "failed to update multinet configuration"
FailedToParseIncomingIOTag = "failed to parse incoming IO tag"
NotSupportedIncomingIOTagReplacedWithClient = "incoming IO tag is not supported, replaced with `client`"
FailedToGetNetmapToAdjustIOTag = "failed to get netmap to adjust IO tag, replaced with `client`"
) )

View file

@ -1,51 +0,0 @@
package qos
import (
"context"
"git.frostfs.info/TrueCloudLab/frostfs-qos/tagging"
"google.golang.org/grpc"
)
func NewSetCriticalIOTagUnaryServerInterceptor() grpc.UnaryServerInterceptor {
return func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) {
ctx = tagging.ContextWithIOTag(ctx, IOTagCritical.String())
return handler(ctx, req)
}
}
func NewAdjustOutgoingIOTagUnaryClientInterceptor() grpc.UnaryClientInterceptor {
return func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
rawTag, ok := tagging.IOTagFromContext(ctx)
if !ok {
return invoker(ctx, method, req, reply, cc, opts...)
}
tag, err := FromRawString(rawTag)
if err != nil {
tag = IOTagClient
}
if tag == IOTagBackground || tag == IOTagPolicer || tag == IOTagWritecache {
tag = IOTagInternal
}
ctx = tagging.ContextWithIOTag(ctx, tag.String())
return invoker(ctx, method, req, reply, cc, opts...)
}
}
func NewAdjustOutgoingIOTagStreamClientInterceptor() grpc.StreamClientInterceptor {
return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
rawTag, ok := tagging.IOTagFromContext(ctx)
if !ok {
return streamer(ctx, desc, cc, method, opts...)
}
tag, err := FromRawString(rawTag)
if err != nil {
tag = IOTagClient
}
if tag == IOTagBackground || tag == IOTagPolicer || tag == IOTagWritecache {
tag = IOTagInternal
}
ctx = tagging.ContextWithIOTag(ctx, tag.String())
return streamer(ctx, desc, cc, method, opts...)
}
}

View file

@ -1,39 +0,0 @@
package qos
import "fmt"
type IOTag string
const (
IOTagClient IOTag = "client"
IOTagInternal IOTag = "internal"
IOTagBackground IOTag = "background"
IOTagWritecache IOTag = "writecache"
IOTagPolicer IOTag = "policer"
IOTagCritical IOTag = "critical"
ioTagUnknown IOTag = ""
)
func FromRawString(s string) (IOTag, error) {
switch s {
case string(IOTagCritical):
return IOTagCritical, nil
case string(IOTagClient):
return IOTagClient, nil
case string(IOTagInternal):
return IOTagInternal, nil
case string(IOTagBackground):
return IOTagBackground, nil
case string(IOTagWritecache):
return IOTagWritecache, nil
case string(IOTagPolicer):
return IOTagPolicer, nil
default:
return ioTagUnknown, fmt.Errorf("unknown tag %s", s)
}
}
func (t IOTag) String() string {
return string(t)
}

View file

@ -1,7 +1,6 @@
package request package request
import ( import (
"context"
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
@ -13,9 +12,9 @@ import (
) )
// FormFrostfsIDRequestProperties forms frostfsid specific request properties like user-claim tags and group ID. // FormFrostfsIDRequestProperties forms frostfsid specific request properties like user-claim tags and group ID.
func FormFrostfsIDRequestProperties(ctx context.Context, frostFSIDClient frostfsidcore.SubjectProvider, pk *keys.PublicKey) (map[string]string, error) { func FormFrostfsIDRequestProperties(frostFSIDClient frostfsidcore.SubjectProvider, pk *keys.PublicKey) (map[string]string, error) {
reqProps := make(map[string]string) reqProps := make(map[string]string)
subj, err := frostFSIDClient.GetSubjectExtended(ctx, pk.GetScriptHash()) subj, err := frostFSIDClient.GetSubjectExtended(pk.GetScriptHash())
if err != nil { if err != nil {
if !strings.Contains(err.Error(), frostfsidcore.SubjectNotFoundErrorMessage) { if !strings.Contains(err.Error(), frostfsidcore.SubjectNotFoundErrorMessage) {
return nil, fmt.Errorf("get subject error: %w", err) return nil, fmt.Errorf("get subject error: %w", err)
@ -37,8 +36,8 @@ func FormFrostfsIDRequestProperties(ctx context.Context, frostFSIDClient frostfs
} }
// Groups return the actor's group ids from frostfsid contract. // Groups return the actor's group ids from frostfsid contract.
func Groups(ctx context.Context, frostFSIDClient frostfsidcore.SubjectProvider, pk *keys.PublicKey) ([]string, error) { func Groups(frostFSIDClient frostfsidcore.SubjectProvider, pk *keys.PublicKey) ([]string, error) {
subj, err := frostFSIDClient.GetSubjectExtended(ctx, pk.GetScriptHash()) subj, err := frostFSIDClient.GetSubjectExtended(pk.GetScriptHash())
if err != nil { if err != nil {
if !strings.Contains(err.Error(), frostfsidcore.SubjectNotFoundErrorMessage) { if !strings.Contains(err.Error(), frostfsidcore.SubjectNotFoundErrorMessage) {
return nil, fmt.Errorf("get subject error: %w", err) return nil, fmt.Errorf("get subject error: %w", err)

View file

@ -1,7 +1,6 @@
package container package container
import ( import (
"context"
"sync" "sync"
utilSync "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/sync" utilSync "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/sync"
@ -20,7 +19,7 @@ type infoValue struct {
} }
type InfoProvider interface { type InfoProvider interface {
Info(ctx context.Context, id cid.ID) (Info, error) Info(id cid.ID) (Info, error)
} }
type infoProvider struct { type infoProvider struct {
@ -44,13 +43,13 @@ func NewInfoProvider(sourceFactory func() (Source, error)) InfoProvider {
} }
} }
func (r *infoProvider) Info(ctx context.Context, id cid.ID) (Info, error) { func (r *infoProvider) Info(id cid.ID) (Info, error) {
v, found := r.tryGetFromCache(id) v, found := r.tryGetFromCache(id)
if found { if found {
return v.info, v.err return v.info, v.err
} }
return r.getFromSource(ctx, id) return r.getFromSource(id)
} }
func (r *infoProvider) tryGetFromCache(id cid.ID) (infoValue, bool) { func (r *infoProvider) tryGetFromCache(id cid.ID) (infoValue, bool) {
@ -61,7 +60,7 @@ func (r *infoProvider) tryGetFromCache(id cid.ID) (infoValue, bool) {
return value, found return value, found
} }
func (r *infoProvider) getFromSource(ctx context.Context, id cid.ID) (Info, error) { func (r *infoProvider) getFromSource(id cid.ID) (Info, error) {
r.kl.Lock(id) r.kl.Lock(id)
defer r.kl.Unlock(id) defer r.kl.Unlock(id)
@ -76,11 +75,11 @@ func (r *infoProvider) getFromSource(ctx context.Context, id cid.ID) (Info, erro
return Info{}, r.sourceErr return Info{}, r.sourceErr
} }
cnr, err := r.source.Get(ctx, id) cnr, err := r.source.Get(id)
var civ infoValue var civ infoValue
if err != nil { if err != nil {
if client.IsErrContainerNotFound(err) { if client.IsErrContainerNotFound(err) {
removed, err := WasRemoved(ctx, r.source, id) removed, err := WasRemoved(r.source, id)
if err != nil { if err != nil {
civ.err = err civ.err = err
} else { } else {

View file

@ -1,8 +1,6 @@
package container package container
import ( import (
"context"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
frostfscrypto "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto" frostfscrypto "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto"
@ -43,9 +41,9 @@ type Source interface {
// //
// Implementations must not retain the container pointer and modify // Implementations must not retain the container pointer and modify
// the container through it. // the container through it.
Get(ctx context.Context, cid cid.ID) (*Container, error) Get(cid.ID) (*Container, error)
DeletionInfo(ctx context.Context, cid cid.ID) (*DelInfo, error) DeletionInfo(cid.ID) (*DelInfo, error)
} }
// EACL groups information about the FrostFS container's extended ACL stored in // EACL groups information about the FrostFS container's extended ACL stored in

View file

@ -1,7 +1,6 @@
package container package container
import ( import (
"context"
"errors" "errors"
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status" apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
@ -11,8 +10,8 @@ import (
// WasRemoved checks whether the container ever existed or // WasRemoved checks whether the container ever existed or
// it just has not been created yet at the current epoch. // it just has not been created yet at the current epoch.
func WasRemoved(ctx context.Context, s Source, cid cid.ID) (bool, error) { func WasRemoved(s Source, cid cid.ID) (bool, error) {
_, err := s.DeletionInfo(ctx, cid) _, err := s.DeletionInfo(cid)
if err == nil { if err == nil {
return true, nil return true, nil
} }

View file

@ -1,8 +1,6 @@
package frostfsid package frostfsid
import ( import (
"context"
"git.frostfs.info/TrueCloudLab/frostfs-contract/frostfsid/client" "git.frostfs.info/TrueCloudLab/frostfs-contract/frostfsid/client"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
) )
@ -13,6 +11,6 @@ const (
// SubjectProvider interface provides methods to get subject from FrostfsID contract. // SubjectProvider interface provides methods to get subject from FrostfsID contract.
type SubjectProvider interface { type SubjectProvider interface {
GetSubject(ctx context.Context, addr util.Uint160) (*client.Subject, error) GetSubject(util.Uint160) (*client.Subject, error)
GetSubjectExtended(ctx context.Context, addr util.Uint160) (*client.SubjectExtended, error) GetSubjectExtended(util.Uint160) (*client.SubjectExtended, error)
} }

View file

@ -1,8 +1,6 @@
package netmap package netmap
import ( import (
"context"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
) )
@ -18,7 +16,7 @@ type Source interface {
// //
// Implementations must not retain the network map pointer and modify // Implementations must not retain the network map pointer and modify
// the network map through it. // the network map through it.
GetNetMap(ctx context.Context, diff uint64) (*netmap.NetMap, error) GetNetMap(diff uint64) (*netmap.NetMap, error)
// GetNetMapByEpoch reads network map by the epoch number from the storage. // GetNetMapByEpoch reads network map by the epoch number from the storage.
// It returns the pointer to the requested network map and any error encountered. // It returns the pointer to the requested network map and any error encountered.
@ -27,21 +25,21 @@ type Source interface {
// //
// Implementations must not retain the network map pointer and modify // Implementations must not retain the network map pointer and modify
// the network map through it. // the network map through it.
GetNetMapByEpoch(ctx context.Context, epoch uint64) (*netmap.NetMap, error) GetNetMapByEpoch(epoch uint64) (*netmap.NetMap, error)
// Epoch reads the current epoch from the storage. // Epoch reads the current epoch from the storage.
// It returns thw number of the current epoch and any error encountered. // It returns thw number of the current epoch and any error encountered.
// //
// Must return exactly one non-default value. // Must return exactly one non-default value.
Epoch(ctx context.Context) (uint64, error) Epoch() (uint64, error)
} }
// GetLatestNetworkMap requests and returns the latest network map from the storage. // GetLatestNetworkMap requests and returns the latest network map from the storage.
func GetLatestNetworkMap(ctx context.Context, src Source) (*netmap.NetMap, error) { func GetLatestNetworkMap(src Source) (*netmap.NetMap, error) {
return src.GetNetMap(ctx, 0) return src.GetNetMap(0)
} }
// GetPreviousNetworkMap requests and returns previous from the latest network map from the storage. // GetPreviousNetworkMap requests and returns previous from the latest network map from the storage.
func GetPreviousNetworkMap(ctx context.Context, src Source) (*netmap.NetMap, error) { func GetPreviousNetworkMap(src Source) (*netmap.NetMap, error) {
return src.GetNetMap(ctx, 1) return src.GetNetMap(1)
} }

View file

@ -199,7 +199,7 @@ func (v *FormatValidator) isIROrContainerNode(ctx context.Context, obj *objectSD
cnrIDBin := make([]byte, sha256.Size) cnrIDBin := make([]byte, sha256.Size)
cnrID.Encode(cnrIDBin) cnrID.Encode(cnrIDBin)
cnr, err := v.containers.Get(ctx, cnrID) cnr, err := v.containers.Get(cnrID)
if err != nil { if err != nil {
return acl.RoleOthers, fmt.Errorf("failed to get container (id=%s): %w", cnrID.EncodeToString(), err) return acl.RoleOthers, fmt.Errorf("failed to get container (id=%s): %w", cnrID.EncodeToString(), err)
} }

View file

@ -578,7 +578,7 @@ type testIRSource struct {
irNodes [][]byte irNodes [][]byte
} }
func (s *testIRSource) InnerRingKeys(_ context.Context) ([][]byte, error) { func (s *testIRSource) InnerRingKeys() ([][]byte, error) {
return s.irNodes, nil return s.irNodes, nil
} }
@ -586,14 +586,14 @@ type testContainerSource struct {
containers map[cid.ID]*container.Container containers map[cid.ID]*container.Container
} }
func (s *testContainerSource) Get(ctx context.Context, cnrID cid.ID) (*container.Container, error) { func (s *testContainerSource) Get(cnrID cid.ID) (*container.Container, error) {
if cnr, found := s.containers[cnrID]; found { if cnr, found := s.containers[cnrID]; found {
return cnr, nil return cnr, nil
} }
return nil, fmt.Errorf("container not found") return nil, fmt.Errorf("container not found")
} }
func (s *testContainerSource) DeletionInfo(context.Context, cid.ID) (*container.DelInfo, error) { func (s *testContainerSource) DeletionInfo(cid.ID) (*container.DelInfo, error) {
return nil, nil return nil, nil
} }
@ -602,20 +602,20 @@ type testNetmapSource struct {
currentEpoch uint64 currentEpoch uint64
} }
func (s *testNetmapSource) GetNetMap(ctx context.Context, diff uint64) (*netmap.NetMap, error) { func (s *testNetmapSource) GetNetMap(diff uint64) (*netmap.NetMap, error) {
if diff >= s.currentEpoch { if diff >= s.currentEpoch {
return nil, fmt.Errorf("invalid diff") return nil, fmt.Errorf("invalid diff")
} }
return s.GetNetMapByEpoch(ctx, s.currentEpoch-diff) return s.GetNetMapByEpoch(s.currentEpoch - diff)
} }
func (s *testNetmapSource) GetNetMapByEpoch(ctx context.Context, epoch uint64) (*netmap.NetMap, error) { func (s *testNetmapSource) GetNetMapByEpoch(epoch uint64) (*netmap.NetMap, error) {
if nm, found := s.netmaps[epoch]; found { if nm, found := s.netmaps[epoch]; found {
return nm, nil return nm, nil
} }
return nil, fmt.Errorf("netmap not found") return nil, fmt.Errorf("netmap not found")
} }
func (s *testNetmapSource) Epoch(ctx context.Context) (uint64, error) { func (s *testNetmapSource) Epoch() (uint64, error) {
return s.currentEpoch, nil return s.currentEpoch, nil
} }

View file

@ -18,7 +18,7 @@ import (
) )
type InnerRing interface { type InnerRing interface {
InnerRingKeys(ctx context.Context) ([][]byte, error) InnerRingKeys() ([][]byte, error)
} }
type SenderClassifier struct { type SenderClassifier struct {
@ -63,7 +63,7 @@ func (c SenderClassifier) Classify(
} }
func (c SenderClassifier) IsInnerRingOrContainerNode(ctx context.Context, ownerKeyInBytes []byte, idCnr cid.ID, cnr container.Container) (*ClassifyResult, error) { func (c SenderClassifier) IsInnerRingOrContainerNode(ctx context.Context, ownerKeyInBytes []byte, idCnr cid.ID, cnr container.Container) (*ClassifyResult, error) {
isInnerRingNode, err := c.isInnerRingKey(ctx, ownerKeyInBytes) isInnerRingNode, err := c.isInnerRingKey(ownerKeyInBytes)
if err != nil { if err != nil {
// do not throw error, try best case matching // do not throw error, try best case matching
c.log.Debug(ctx, logs.V2CantCheckIfRequestFromInnerRing, c.log.Debug(ctx, logs.V2CantCheckIfRequestFromInnerRing,
@ -78,7 +78,7 @@ func (c SenderClassifier) IsInnerRingOrContainerNode(ctx context.Context, ownerK
binCnr := make([]byte, sha256.Size) binCnr := make([]byte, sha256.Size)
idCnr.Encode(binCnr) idCnr.Encode(binCnr)
isContainerNode, err := c.isContainerKey(ctx, ownerKeyInBytes, binCnr, cnr) isContainerNode, err := c.isContainerKey(ownerKeyInBytes, binCnr, cnr)
if err != nil { if err != nil {
// error might happen if request has `RoleOther` key and placement // error might happen if request has `RoleOther` key and placement
// is not possible for previous epoch, so // is not possible for previous epoch, so
@ -99,8 +99,8 @@ func (c SenderClassifier) IsInnerRingOrContainerNode(ctx context.Context, ownerK
}, nil }, nil
} }
func (c SenderClassifier) isInnerRingKey(ctx context.Context, owner []byte) (bool, error) { func (c SenderClassifier) isInnerRingKey(owner []byte) (bool, error) {
innerRingKeys, err := c.innerRing.InnerRingKeys(ctx) innerRingKeys, err := c.innerRing.InnerRingKeys()
if err != nil { if err != nil {
return false, err return false, err
} }
@ -116,11 +116,10 @@ func (c SenderClassifier) isInnerRingKey(ctx context.Context, owner []byte) (boo
} }
func (c SenderClassifier) isContainerKey( func (c SenderClassifier) isContainerKey(
ctx context.Context,
owner, idCnr []byte, owner, idCnr []byte,
cnr container.Container, cnr container.Container,
) (bool, error) { ) (bool, error) {
nm, err := core.GetLatestNetworkMap(ctx, c.netmap) // first check current netmap nm, err := core.GetLatestNetworkMap(c.netmap) // first check current netmap
if err != nil { if err != nil {
return false, err return false, err
} }
@ -134,7 +133,7 @@ func (c SenderClassifier) isContainerKey(
// then check previous netmap, this can happen in-between epoch change // then check previous netmap, this can happen in-between epoch change
// when node migrates data from last epoch container // when node migrates data from last epoch container
nm, err = core.GetPreviousNetworkMap(ctx, c.netmap) nm, err = core.GetPreviousNetworkMap(c.netmap)
if err != nil { if err != nil {
return false, err return false, err
} }

View file

@ -1,8 +1,6 @@
package innerring package innerring
import ( import (
"context"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
nmClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap" nmClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
@ -49,12 +47,12 @@ type IrFetcherWithoutNotary struct {
// InnerRingKeys fetches list of innerring keys from NeoFSAlphabet // InnerRingKeys fetches list of innerring keys from NeoFSAlphabet
// role in the sidechain. // role in the sidechain.
func (fN IrFetcherWithNotary) InnerRingKeys(ctx context.Context) (keys.PublicKeys, error) { func (fN IrFetcherWithNotary) InnerRingKeys() (keys.PublicKeys, error) {
return fN.cli.NeoFSAlphabetList(ctx) return fN.cli.NeoFSAlphabetList()
} }
// InnerRingKeys fetches list of innerring keys from netmap contract // InnerRingKeys fetches list of innerring keys from netmap contract
// in the sidechain. // in the sidechain.
func (f IrFetcherWithoutNotary) InnerRingKeys(ctx context.Context) (keys.PublicKeys, error) { func (f IrFetcherWithoutNotary) InnerRingKeys() (keys.PublicKeys, error) {
return f.nm.GetInnerRingList(ctx) return f.nm.GetInnerRingList()
} }

View file

@ -1,7 +1,6 @@
package innerring package innerring
import ( import (
"context"
"fmt" "fmt"
"sync" "sync"
"time" "time"
@ -11,7 +10,7 @@ import (
type ( type (
irFetcher interface { irFetcher interface {
InnerRingKeys(ctx context.Context) (keys.PublicKeys, error) InnerRingKeys() (keys.PublicKeys, error)
} }
committeeFetcher interface { committeeFetcher interface {
@ -46,7 +45,7 @@ func newInnerRingIndexer(comf committeeFetcher, irf irFetcher, key *keys.PublicK
} }
} }
func (s *innerRingIndexer) update(ctx context.Context) (ind indexes, err error) { func (s *innerRingIndexer) update() (ind indexes, err error) {
s.RLock() s.RLock()
if time.Since(s.lastAccess) < s.timeout { if time.Since(s.lastAccess) < s.timeout {
@ -63,7 +62,7 @@ func (s *innerRingIndexer) update(ctx context.Context) (ind indexes, err error)
return s.ind, nil return s.ind, nil
} }
innerRing, err := s.irFetcher.InnerRingKeys(ctx) innerRing, err := s.irFetcher.InnerRingKeys()
if err != nil { if err != nil {
return indexes{}, err return indexes{}, err
} }
@ -82,8 +81,8 @@ func (s *innerRingIndexer) update(ctx context.Context) (ind indexes, err error)
return s.ind, nil return s.ind, nil
} }
func (s *innerRingIndexer) InnerRingIndex(ctx context.Context) (int32, error) { func (s *innerRingIndexer) InnerRingIndex() (int32, error) {
ind, err := s.update(ctx) ind, err := s.update()
if err != nil { if err != nil {
return 0, fmt.Errorf("can't update index state: %w", err) return 0, fmt.Errorf("can't update index state: %w", err)
} }
@ -91,8 +90,8 @@ func (s *innerRingIndexer) InnerRingIndex(ctx context.Context) (int32, error) {
return ind.innerRingIndex, nil return ind.innerRingIndex, nil
} }
func (s *innerRingIndexer) InnerRingSize(ctx context.Context) (int32, error) { func (s *innerRingIndexer) InnerRingSize() (int32, error) {
ind, err := s.update(ctx) ind, err := s.update()
if err != nil { if err != nil {
return 0, fmt.Errorf("can't update index state: %w", err) return 0, fmt.Errorf("can't update index state: %w", err)
} }
@ -100,8 +99,8 @@ func (s *innerRingIndexer) InnerRingSize(ctx context.Context) (int32, error) {
return ind.innerRingSize, nil return ind.innerRingSize, nil
} }
func (s *innerRingIndexer) AlphabetIndex(ctx context.Context) (int32, error) { func (s *innerRingIndexer) AlphabetIndex() (int32, error) {
ind, err := s.update(ctx) ind, err := s.update()
if err != nil { if err != nil {
return 0, fmt.Errorf("can't update index state: %w", err) return 0, fmt.Errorf("can't update index state: %w", err)
} }

View file

@ -1,7 +1,6 @@
package innerring package innerring
import ( import (
"context"
"fmt" "fmt"
"sync/atomic" "sync/atomic"
"testing" "testing"
@ -38,15 +37,15 @@ func TestIndexerReturnsIndexes(t *testing.T) {
indexer := newInnerRingIndexer(cf, irf, key, time.Second) indexer := newInnerRingIndexer(cf, irf, key, time.Second)
idx, err := indexer.AlphabetIndex(context.Background()) idx, err := indexer.AlphabetIndex()
require.NoError(t, err, "failed to get alphabet index") require.NoError(t, err, "failed to get alphabet index")
require.Equal(t, int32(1), idx, "invalid alphabet index") require.Equal(t, int32(1), idx, "invalid alphabet index")
idx, err = indexer.InnerRingIndex(context.Background()) idx, err = indexer.InnerRingIndex()
require.NoError(t, err, "failed to get IR index") require.NoError(t, err, "failed to get IR index")
require.Equal(t, int32(2), idx, "invalid IR index") require.Equal(t, int32(2), idx, "invalid IR index")
size, err := indexer.InnerRingSize(context.Background()) size, err := indexer.InnerRingSize()
require.NoError(t, err, "failed to get IR size") require.NoError(t, err, "failed to get IR size")
require.Equal(t, int32(3), size, "invalid IR size") require.Equal(t, int32(3), size, "invalid IR size")
}) })
@ -57,11 +56,11 @@ func TestIndexerReturnsIndexes(t *testing.T) {
indexer := newInnerRingIndexer(cf, irf, key, time.Second) indexer := newInnerRingIndexer(cf, irf, key, time.Second)
idx, err := indexer.AlphabetIndex(context.Background()) idx, err := indexer.AlphabetIndex()
require.NoError(t, err, "failed to get alphabet index") require.NoError(t, err, "failed to get alphabet index")
require.Equal(t, int32(-1), idx, "invalid alphabet index") require.Equal(t, int32(-1), idx, "invalid alphabet index")
idx, err = indexer.InnerRingIndex(context.Background()) idx, err = indexer.InnerRingIndex()
require.NoError(t, err, "failed to get IR index") require.NoError(t, err, "failed to get IR index")
require.Equal(t, int32(0), idx, "invalid IR index") require.Equal(t, int32(0), idx, "invalid IR index")
}) })
@ -72,11 +71,11 @@ func TestIndexerReturnsIndexes(t *testing.T) {
indexer := newInnerRingIndexer(cf, irf, key, time.Second) indexer := newInnerRingIndexer(cf, irf, key, time.Second)
idx, err := indexer.AlphabetIndex(context.Background()) idx, err := indexer.AlphabetIndex()
require.NoError(t, err, "failed to get alphabet index") require.NoError(t, err, "failed to get alphabet index")
require.Equal(t, int32(0), idx, "invalid alphabet index") require.Equal(t, int32(0), idx, "invalid alphabet index")
idx, err = indexer.InnerRingIndex(context.Background()) idx, err = indexer.InnerRingIndex()
require.NoError(t, err, "failed to get IR index") require.NoError(t, err, "failed to get IR index")
require.Equal(t, int32(-1), idx, "invalid IR index") require.Equal(t, int32(-1), idx, "invalid IR index")
}) })
@ -101,30 +100,30 @@ func TestIndexerCachesIndexes(t *testing.T) {
indexer := newInnerRingIndexer(cf, irf, key, time.Second) indexer := newInnerRingIndexer(cf, irf, key, time.Second)
idx, err := indexer.AlphabetIndex(context.Background()) idx, err := indexer.AlphabetIndex()
require.NoError(t, err, "failed to get alphabet index") require.NoError(t, err, "failed to get alphabet index")
require.Equal(t, int32(-1), idx, "invalid alphabet index") require.Equal(t, int32(-1), idx, "invalid alphabet index")
idx, err = indexer.InnerRingIndex(context.Background()) idx, err = indexer.InnerRingIndex()
require.NoError(t, err, "failed to get IR index") require.NoError(t, err, "failed to get IR index")
require.Equal(t, int32(-1), idx, "invalid IR index") require.Equal(t, int32(-1), idx, "invalid IR index")
size, err := indexer.InnerRingSize(context.Background()) size, err := indexer.InnerRingSize()
require.NoError(t, err, "failed to get IR size") require.NoError(t, err, "failed to get IR size")
require.Equal(t, int32(0), size, "invalid IR size") require.Equal(t, int32(0), size, "invalid IR size")
require.Equal(t, int32(1), cf.calls.Load(), "invalid commitee calls count") require.Equal(t, int32(1), cf.calls.Load(), "invalid commitee calls count")
require.Equal(t, int32(1), irf.calls.Load(), "invalid IR calls count") require.Equal(t, int32(1), irf.calls.Load(), "invalid IR calls count")
idx, err = indexer.AlphabetIndex(context.Background()) idx, err = indexer.AlphabetIndex()
require.NoError(t, err, "failed to get alphabet index") require.NoError(t, err, "failed to get alphabet index")
require.Equal(t, int32(-1), idx, "invalid alphabet index") require.Equal(t, int32(-1), idx, "invalid alphabet index")
idx, err = indexer.InnerRingIndex(context.Background()) idx, err = indexer.InnerRingIndex()
require.NoError(t, err, "failed to get IR index") require.NoError(t, err, "failed to get IR index")
require.Equal(t, int32(-1), idx, "invalid IR index") require.Equal(t, int32(-1), idx, "invalid IR index")
size, err = indexer.InnerRingSize(context.Background()) size, err = indexer.InnerRingSize()
require.NoError(t, err, "failed to get IR size") require.NoError(t, err, "failed to get IR size")
require.Equal(t, int32(0), size, "invalid IR size") require.Equal(t, int32(0), size, "invalid IR size")
@ -133,15 +132,15 @@ func TestIndexerCachesIndexes(t *testing.T) {
time.Sleep(2 * time.Second) time.Sleep(2 * time.Second)
idx, err = indexer.AlphabetIndex(context.Background()) idx, err = indexer.AlphabetIndex()
require.NoError(t, err, "failed to get alphabet index") require.NoError(t, err, "failed to get alphabet index")
require.Equal(t, int32(-1), idx, "invalid alphabet index") require.Equal(t, int32(-1), idx, "invalid alphabet index")
idx, err = indexer.InnerRingIndex(context.Background()) idx, err = indexer.InnerRingIndex()
require.NoError(t, err, "failed to get IR index") require.NoError(t, err, "failed to get IR index")
require.Equal(t, int32(-1), idx, "invalid IR index") require.Equal(t, int32(-1), idx, "invalid IR index")
size, err = indexer.InnerRingSize(context.Background()) size, err = indexer.InnerRingSize()
require.NoError(t, err, "failed to get IR size") require.NoError(t, err, "failed to get IR size")
require.Equal(t, int32(0), size, "invalid IR size") require.Equal(t, int32(0), size, "invalid IR size")
@ -166,15 +165,15 @@ func TestIndexerThrowsErrors(t *testing.T) {
indexer := newInnerRingIndexer(cf, irf, key, time.Second) indexer := newInnerRingIndexer(cf, irf, key, time.Second)
idx, err := indexer.AlphabetIndex(context.Background()) idx, err := indexer.AlphabetIndex()
require.ErrorContains(t, err, "test commitee error", "error from commitee not throwed") require.ErrorContains(t, err, "test commitee error", "error from commitee not throwed")
require.Equal(t, int32(0), idx, "invalid alphabet index") require.Equal(t, int32(0), idx, "invalid alphabet index")
idx, err = indexer.InnerRingIndex(context.Background()) idx, err = indexer.InnerRingIndex()
require.ErrorContains(t, err, "test commitee error", "error from IR not throwed") require.ErrorContains(t, err, "test commitee error", "error from IR not throwed")
require.Equal(t, int32(0), idx, "invalid IR index") require.Equal(t, int32(0), idx, "invalid IR index")
size, err := indexer.InnerRingSize(context.Background()) size, err := indexer.InnerRingSize()
require.ErrorContains(t, err, "test commitee error", "error from IR not throwed") require.ErrorContains(t, err, "test commitee error", "error from IR not throwed")
require.Equal(t, int32(0), size, "invalid IR size") require.Equal(t, int32(0), size, "invalid IR size")
@ -190,15 +189,15 @@ func TestIndexerThrowsErrors(t *testing.T) {
indexer = newInnerRingIndexer(cf, irf, key, time.Second) indexer = newInnerRingIndexer(cf, irf, key, time.Second)
idx, err = indexer.AlphabetIndex(context.Background()) idx, err = indexer.AlphabetIndex()
require.ErrorContains(t, err, "test IR error", "error from commitee not throwed") require.ErrorContains(t, err, "test IR error", "error from commitee not throwed")
require.Equal(t, int32(0), idx, "invalid alphabet index") require.Equal(t, int32(0), idx, "invalid alphabet index")
idx, err = indexer.InnerRingIndex(context.Background()) idx, err = indexer.InnerRingIndex()
require.ErrorContains(t, err, "test IR error", "error from IR not throwed") require.ErrorContains(t, err, "test IR error", "error from IR not throwed")
require.Equal(t, int32(0), idx, "invalid IR index") require.Equal(t, int32(0), idx, "invalid IR index")
size, err = indexer.InnerRingSize(context.Background()) size, err = indexer.InnerRingSize()
require.ErrorContains(t, err, "test IR error", "error from IR not throwed") require.ErrorContains(t, err, "test IR error", "error from IR not throwed")
require.Equal(t, int32(0), size, "invalid IR size") require.Equal(t, int32(0), size, "invalid IR size")
} }
@ -220,7 +219,7 @@ type testIRFetcher struct {
calls atomic.Int32 calls atomic.Int32
} }
func (f *testIRFetcher) InnerRingKeys(context.Context) (keys.PublicKeys, error) { func (f *testIRFetcher) InnerRingKeys() (keys.PublicKeys, error) {
f.calls.Add(1) f.calls.Add(1)
return f.keys, f.err return f.keys, f.err
} }

View file

@ -575,19 +575,19 @@ func parseMultinetConfig(cfg *viper.Viper, m metrics.MultinetMetrics) internalNe
func (s *Server) initConfigFromBlockchain(ctx context.Context) error { func (s *Server) initConfigFromBlockchain(ctx context.Context) error {
// get current epoch // get current epoch
epoch, err := s.netmapClient.Epoch(ctx) epoch, err := s.netmapClient.Epoch()
if err != nil { if err != nil {
return fmt.Errorf("can't read epoch number: %w", err) return fmt.Errorf("can't read epoch number: %w", err)
} }
// get current epoch duration // get current epoch duration
epochDuration, err := s.netmapClient.EpochDuration(ctx) epochDuration, err := s.netmapClient.EpochDuration()
if err != nil { if err != nil {
return fmt.Errorf("can't read epoch duration: %w", err) return fmt.Errorf("can't read epoch duration: %w", err)
} }
// get balance precision // get balance precision
balancePrecision, err := s.balanceClient.Decimals(ctx) balancePrecision, err := s.balanceClient.Decimals()
if err != nil { if err != nil {
return fmt.Errorf("can't read balance contract precision: %w", err) return fmt.Errorf("can't read balance contract precision: %w", err)
} }
@ -597,7 +597,7 @@ func (s *Server) initConfigFromBlockchain(ctx context.Context) error {
s.precision.SetBalancePrecision(balancePrecision) s.precision.SetBalancePrecision(balancePrecision)
// get next epoch delta tick // get next epoch delta tick
s.initialEpochTickDelta, err = s.nextEpochBlockDelta(ctx) s.initialEpochTickDelta, err = s.nextEpochBlockDelta()
if err != nil { if err != nil {
return err return err
} }
@ -613,8 +613,8 @@ func (s *Server) initConfigFromBlockchain(ctx context.Context) error {
return nil return nil
} }
func (s *Server) nextEpochBlockDelta(ctx context.Context) (uint32, error) { func (s *Server) nextEpochBlockDelta() (uint32, error) {
epochBlock, err := s.netmapClient.LastEpochBlock(ctx) epochBlock, err := s.netmapClient.LastEpochBlock()
if err != nil { if err != nil {
return 0, fmt.Errorf("can't read last epoch block: %w", err) return 0, fmt.Errorf("can't read last epoch block: %w", err)
} }

View file

@ -1,7 +1,6 @@
package innerring package innerring
import ( import (
"context"
"fmt" "fmt"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/netmap/nodevalidation/state" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/netmap/nodevalidation/state"
@ -18,8 +17,8 @@ type networkSettings netmapclient.Client
// MaintenanceModeAllowed requests network configuration from the Sidechain // MaintenanceModeAllowed requests network configuration from the Sidechain
// and check allowance of storage node's maintenance mode according to it. // and check allowance of storage node's maintenance mode according to it.
// Always returns state.ErrMaintenanceModeDisallowed. // Always returns state.ErrMaintenanceModeDisallowed.
func (s *networkSettings) MaintenanceModeAllowed(ctx context.Context) error { func (s *networkSettings) MaintenanceModeAllowed() error {
allowed, err := (*netmapclient.Client)(s).MaintenanceModeAllowed(ctx) allowed, err := (*netmapclient.Client)(s).MaintenanceModeAllowed()
if err != nil { if err != nil {
return fmt.Errorf("read maintenance mode's allowance from the Sidechain: %w", err) return fmt.Errorf("read maintenance mode's allowance from the Sidechain: %w", err)
} else if allowed { } else if allowed {

View file

@ -279,6 +279,6 @@ type testNetmapClient struct {
netmap *netmap.NetMap netmap *netmap.NetMap
} }
func (c *testNetmapClient) NetMap(context.Context) (*netmap.NetMap, error) { func (c *testNetmapClient) NetMap() (*netmap.NetMap, error) {
return c.netmap, nil return c.netmap, nil
} }

View file

@ -44,7 +44,7 @@ func (ap *Processor) processEmit(ctx context.Context) bool {
return true return true
} }
networkMap, err := ap.netmapClient.NetMap(ctx) networkMap, err := ap.netmapClient.NetMap()
if err != nil { if err != nil {
ap.log.Warn(ctx, logs.AlphabetCantGetNetmapSnapshotToEmitGasToStorageNodes, ap.log.Warn(ctx, logs.AlphabetCantGetNetmapSnapshotToEmitGasToStorageNodes,
zap.Error(err)) zap.Error(err))

View file

@ -36,7 +36,7 @@ type (
} }
netmapClient interface { netmapClient interface {
NetMap(ctx context.Context) (*netmap.NetMap, error) NetMap() (*netmap.NetMap, error)
} }
morphClient interface { morphClient interface {

View file

@ -1,7 +1,6 @@
package container package container
import ( import (
"context"
"crypto/ecdsa" "crypto/ecdsa"
"errors" "errors"
"fmt" "fmt"
@ -46,7 +45,7 @@ type signatureVerificationData struct {
// - v.binPublicKey is a public session key // - v.binPublicKey is a public session key
// - session context corresponds to the container and verb in v // - session context corresponds to the container and verb in v
// - session is "alive" // - session is "alive"
func (cp *Processor) verifySignature(ctx context.Context, v signatureVerificationData) error { func (cp *Processor) verifySignature(v signatureVerificationData) error {
var err error var err error
var key frostfsecdsa.PublicKeyRFC6979 var key frostfsecdsa.PublicKeyRFC6979
keyProvided := v.binPublicKey != nil keyProvided := v.binPublicKey != nil
@ -59,7 +58,7 @@ func (cp *Processor) verifySignature(ctx context.Context, v signatureVerificatio
} }
if len(v.binTokenSession) > 0 { if len(v.binTokenSession) > 0 {
return cp.verifyByTokenSession(ctx, v, &key, keyProvided) return cp.verifyByTokenSession(v, &key, keyProvided)
} }
if keyProvided { if keyProvided {
@ -78,8 +77,8 @@ func (cp *Processor) verifySignature(ctx context.Context, v signatureVerificatio
return errors.New("signature is invalid or calculated with the key not bound to the container owner") return errors.New("signature is invalid or calculated with the key not bound to the container owner")
} }
func (cp *Processor) checkTokenLifetime(ctx context.Context, token session.Container) error { func (cp *Processor) checkTokenLifetime(token session.Container) error {
curEpoch, err := cp.netState.Epoch(ctx) curEpoch, err := cp.netState.Epoch()
if err != nil { if err != nil {
return fmt.Errorf("could not read current epoch: %w", err) return fmt.Errorf("could not read current epoch: %w", err)
} }
@ -91,7 +90,7 @@ func (cp *Processor) checkTokenLifetime(ctx context.Context, token session.Conta
return nil return nil
} }
func (cp *Processor) verifyByTokenSession(ctx context.Context, v signatureVerificationData, key *frostfsecdsa.PublicKeyRFC6979, keyProvided bool) error { func (cp *Processor) verifyByTokenSession(v signatureVerificationData, key *frostfsecdsa.PublicKeyRFC6979, keyProvided bool) error {
var tok session.Container var tok session.Container
err := tok.Unmarshal(v.binTokenSession) err := tok.Unmarshal(v.binTokenSession)
@ -119,7 +118,7 @@ func (cp *Processor) verifyByTokenSession(ctx context.Context, v signatureVerifi
return errors.New("owner differs with token owner") return errors.New("owner differs with token owner")
} }
err = cp.checkTokenLifetime(ctx, tok) err = cp.checkTokenLifetime(tok)
if err != nil { if err != nil {
return fmt.Errorf("check session lifetime: %w", err) return fmt.Errorf("check session lifetime: %w", err)
} }

View file

@ -170,11 +170,11 @@ type testNetworkState struct {
epoch uint64 epoch uint64
} }
func (s *testNetworkState) HomomorphicHashDisabled(context.Context) (bool, error) { func (s *testNetworkState) HomomorphicHashDisabled() (bool, error) {
return s.homHashDisabled, nil return s.homHashDisabled, nil
} }
func (s *testNetworkState) Epoch(context.Context) (uint64, error) { func (s *testNetworkState) Epoch() (uint64, error) {
return s.epoch, nil return s.epoch, nil
} }
@ -187,7 +187,7 @@ func (c *testContainerClient) ContractAddress() util.Uint160 {
return c.contractAddress return c.contractAddress
} }
func (c *testContainerClient) Get(ctx context.Context, cid []byte) (*containercore.Container, error) { func (c *testContainerClient) Get(cid []byte) (*containercore.Container, error) {
key := hex.EncodeToString(cid) key := hex.EncodeToString(cid)
if cont, found := c.get[key]; found { if cont, found := c.get[key]; found {
return cont, nil return cont, nil
@ -237,6 +237,6 @@ func (c *testMorphClient) NotarySignAndInvokeTX(mainTx *transaction.Transaction)
type testFrostFSIDClient struct{} type testFrostFSIDClient struct{}
func (c *testFrostFSIDClient) GetSubject(ctx context.Context, addr util.Uint160) (*frostfsidclient.Subject, error) { func (c *testFrostFSIDClient) GetSubject(addr util.Uint160) (*frostfsidclient.Subject, error) {
return &frostfsidclient.Subject{}, nil return &frostfsidclient.Subject{}, nil
} }

View file

@ -47,7 +47,7 @@ func (cp *Processor) processContainerPut(ctx context.Context, put putEvent) bool
e: put, e: put,
} }
err := cp.checkPutContainer(ctx, pctx) err := cp.checkPutContainer(pctx)
if err != nil { if err != nil {
cp.log.Error(ctx, logs.ContainerPutContainerCheckFailed, cp.log.Error(ctx, logs.ContainerPutContainerCheckFailed,
zap.Error(err), zap.Error(err),
@ -66,8 +66,8 @@ func (cp *Processor) processContainerPut(ctx context.Context, put putEvent) bool
return true return true
} }
func (cp *Processor) checkPutContainer(ctx context.Context, pctx *putContainerContext) error { func (cp *Processor) checkPutContainer(ctx *putContainerContext) error {
binCnr := pctx.e.Container() binCnr := ctx.e.Container()
var cnr containerSDK.Container var cnr containerSDK.Container
err := cnr.Unmarshal(binCnr) err := cnr.Unmarshal(binCnr)
@ -75,12 +75,12 @@ func (cp *Processor) checkPutContainer(ctx context.Context, pctx *putContainerCo
return fmt.Errorf("invalid binary container: %w", err) return fmt.Errorf("invalid binary container: %w", err)
} }
err = cp.verifySignature(ctx, signatureVerificationData{ err = cp.verifySignature(signatureVerificationData{
ownerContainer: cnr.Owner(), ownerContainer: cnr.Owner(),
verb: session.VerbContainerPut, verb: session.VerbContainerPut,
binTokenSession: pctx.e.SessionToken(), binTokenSession: ctx.e.SessionToken(),
binPublicKey: pctx.e.PublicKey(), binPublicKey: ctx.e.PublicKey(),
signature: pctx.e.Signature(), signature: ctx.e.Signature(),
signedData: binCnr, signedData: binCnr,
}) })
if err != nil { if err != nil {
@ -88,13 +88,13 @@ func (cp *Processor) checkPutContainer(ctx context.Context, pctx *putContainerCo
} }
// check homomorphic hashing setting // check homomorphic hashing setting
err = checkHomomorphicHashing(ctx, cp.netState, cnr) err = checkHomomorphicHashing(cp.netState, cnr)
if err != nil { if err != nil {
return fmt.Errorf("incorrect homomorphic hashing setting: %w", err) return fmt.Errorf("incorrect homomorphic hashing setting: %w", err)
} }
// check native name and zone // check native name and zone
err = cp.checkNNS(ctx, pctx, cnr) err = cp.checkNNS(ctx, cnr)
if err != nil { if err != nil {
return fmt.Errorf("NNS: %w", err) return fmt.Errorf("NNS: %w", err)
} }
@ -110,7 +110,7 @@ func (cp *Processor) processContainerDelete(ctx context.Context, e containerEven
return true return true
} }
err := cp.checkDeleteContainer(ctx, e) err := cp.checkDeleteContainer(e)
if err != nil { if err != nil {
cp.log.Error(ctx, logs.ContainerDeleteContainerCheckFailed, cp.log.Error(ctx, logs.ContainerDeleteContainerCheckFailed,
zap.Error(err), zap.Error(err),
@ -130,7 +130,7 @@ func (cp *Processor) processContainerDelete(ctx context.Context, e containerEven
return true return true
} }
func (cp *Processor) checkDeleteContainer(ctx context.Context, e containerEvent.Delete) error { func (cp *Processor) checkDeleteContainer(e containerEvent.Delete) error {
binCnr := e.ContainerID() binCnr := e.ContainerID()
var idCnr cid.ID var idCnr cid.ID
@ -141,12 +141,12 @@ func (cp *Processor) checkDeleteContainer(ctx context.Context, e containerEvent.
} }
// receive owner of the related container // receive owner of the related container
cnr, err := cp.cnrClient.Get(ctx, binCnr) cnr, err := cp.cnrClient.Get(binCnr)
if err != nil { if err != nil {
return fmt.Errorf("could not receive the container: %w", err) return fmt.Errorf("could not receive the container: %w", err)
} }
err = cp.verifySignature(ctx, signatureVerificationData{ err = cp.verifySignature(signatureVerificationData{
ownerContainer: cnr.Value.Owner(), ownerContainer: cnr.Value.Owner(),
verb: session.VerbContainerDelete, verb: session.VerbContainerDelete,
idContainerSet: true, idContainerSet: true,
@ -163,21 +163,21 @@ func (cp *Processor) checkDeleteContainer(ctx context.Context, e containerEvent.
return nil return nil
} }
func (cp *Processor) checkNNS(ctx context.Context, pctx *putContainerContext, cnr containerSDK.Container) error { func (cp *Processor) checkNNS(ctx *putContainerContext, cnr containerSDK.Container) error {
// fetch domain info // fetch domain info
pctx.d = containerSDK.ReadDomain(cnr) ctx.d = containerSDK.ReadDomain(cnr)
// if PutNamed event => check if values in container correspond to args // if PutNamed event => check if values in container correspond to args
if named, ok := pctx.e.(interface { if named, ok := ctx.e.(interface {
Name() string Name() string
Zone() string Zone() string
}); ok { }); ok {
if name := named.Name(); name != pctx.d.Name() { if name := named.Name(); name != ctx.d.Name() {
return fmt.Errorf("names differ %s/%s", name, pctx.d.Name()) return fmt.Errorf("names differ %s/%s", name, ctx.d.Name())
} }
if zone := named.Zone(); zone != pctx.d.Zone() { if zone := named.Zone(); zone != ctx.d.Zone() {
return fmt.Errorf("zones differ %s/%s", zone, pctx.d.Zone()) return fmt.Errorf("zones differ %s/%s", zone, ctx.d.Zone())
} }
} }
@ -186,12 +186,12 @@ func (cp *Processor) checkNNS(ctx context.Context, pctx *putContainerContext, cn
return fmt.Errorf("could not get container owner address: %w", err) return fmt.Errorf("could not get container owner address: %w", err)
} }
subject, err := cp.frostFSIDClient.GetSubject(ctx, addr) subject, err := cp.frostFSIDClient.GetSubject(addr)
if err != nil { if err != nil {
return fmt.Errorf("could not get subject from FrostfsID contract: %w", err) return fmt.Errorf("could not get subject from FrostfsID contract: %w", err)
} }
namespace, hasNamespace := strings.CutSuffix(pctx.d.Zone(), ".ns") namespace, hasNamespace := strings.CutSuffix(ctx.d.Zone(), ".ns")
if !hasNamespace { if !hasNamespace {
return nil return nil
} }
@ -203,8 +203,8 @@ func (cp *Processor) checkNNS(ctx context.Context, pctx *putContainerContext, cn
return nil return nil
} }
func checkHomomorphicHashing(ctx context.Context, ns NetworkState, cnr containerSDK.Container) error { func checkHomomorphicHashing(ns NetworkState, cnr containerSDK.Container) error {
netSetting, err := ns.HomomorphicHashDisabled(ctx) netSetting, err := ns.HomomorphicHashDisabled()
if err != nil { if err != nil {
return fmt.Errorf("could not get setting in contract: %w", err) return fmt.Errorf("could not get setting in contract: %w", err)
} }

View file

@ -25,7 +25,7 @@ type (
ContClient interface { ContClient interface {
ContractAddress() util.Uint160 ContractAddress() util.Uint160
Get(ctx context.Context, cid []byte) (*containercore.Container, error) Get(cid []byte) (*containercore.Container, error)
} }
MorphClient interface { MorphClient interface {
@ -33,7 +33,7 @@ type (
} }
FrostFSIDClient interface { FrostFSIDClient interface {
GetSubject(ctx context.Context, addr util.Uint160) (*frostfsidclient.Subject, error) GetSubject(addr util.Uint160) (*frostfsidclient.Subject, error)
} }
// Processor of events produced by container contract in the sidechain. // Processor of events produced by container contract in the sidechain.
@ -68,7 +68,7 @@ type NetworkState interface {
// //
// Must return any error encountered // Must return any error encountered
// which did not allow reading the value. // which did not allow reading the value.
Epoch(ctx context.Context) (uint64, error) Epoch() (uint64, error)
// HomomorphicHashDisabled must return boolean that // HomomorphicHashDisabled must return boolean that
// represents homomorphic network state: // represents homomorphic network state:
@ -76,7 +76,7 @@ type NetworkState interface {
// * false if hashing is enabled. // * false if hashing is enabled.
// //
// which did not allow reading the value. // which did not allow reading the value.
HomomorphicHashDisabled(ctx context.Context) (bool, error) HomomorphicHashDisabled() (bool, error)
} }
// New creates a container contract processor instance. // New creates a container contract processor instance.

View file

@ -236,7 +236,7 @@ type testIRFetcher struct {
publicKeys keys.PublicKeys publicKeys keys.PublicKeys
} }
func (f *testIRFetcher) InnerRingKeys(context.Context) (keys.PublicKeys, error) { func (f *testIRFetcher) InnerRingKeys() (keys.PublicKeys, error) {
return f.publicKeys, nil return f.publicKeys, nil
} }
@ -266,7 +266,7 @@ type testMainnetClient struct {
designateHash util.Uint160 designateHash util.Uint160
} }
func (c *testMainnetClient) NeoFSAlphabetList(context.Context) (res keys.PublicKeys, err error) { func (c *testMainnetClient) NeoFSAlphabetList() (res keys.PublicKeys, err error) {
return c.alphabetKeys, nil return c.alphabetKeys, nil
} }

View file

@ -25,7 +25,7 @@ func (gp *Processor) processAlphabetSync(ctx context.Context, txHash util.Uint25
return true return true
} }
mainnetAlphabet, err := gp.mainnetClient.NeoFSAlphabetList(ctx) mainnetAlphabet, err := gp.mainnetClient.NeoFSAlphabetList()
if err != nil { if err != nil {
gp.log.Error(ctx, logs.GovernanceCantFetchAlphabetListFromMainNet, gp.log.Error(ctx, logs.GovernanceCantFetchAlphabetListFromMainNet,
zap.Error(err)) zap.Error(err))
@ -95,7 +95,7 @@ func prettyKeys(keys keys.PublicKeys) string {
} }
func (gp *Processor) updateNeoFSAlphabetRoleInSidechain(ctx context.Context, sidechainAlphabet, newAlphabet keys.PublicKeys, txHash util.Uint256) { func (gp *Processor) updateNeoFSAlphabetRoleInSidechain(ctx context.Context, sidechainAlphabet, newAlphabet keys.PublicKeys, txHash util.Uint256) {
innerRing, err := gp.irFetcher.InnerRingKeys(ctx) innerRing, err := gp.irFetcher.InnerRingKeys()
if err != nil { if err != nil {
gp.log.Error(ctx, logs.GovernanceCantFetchInnerRingListFromSideChain, gp.log.Error(ctx, logs.GovernanceCantFetchInnerRingListFromSideChain,
zap.Error(err)) zap.Error(err))

View file

@ -52,7 +52,7 @@ type (
// Implementation must take into account availability of // Implementation must take into account availability of
// the notary contract. // the notary contract.
IRFetcher interface { IRFetcher interface {
InnerRingKeys(ctx context.Context) (keys.PublicKeys, error) InnerRingKeys() (keys.PublicKeys, error)
} }
FrostFSClient interface { FrostFSClient interface {
@ -64,7 +64,7 @@ type (
} }
MainnetClient interface { MainnetClient interface {
NeoFSAlphabetList(context.Context) (res keys.PublicKeys, err error) NeoFSAlphabetList() (res keys.PublicKeys, err error)
GetDesignateHash() util.Uint160 GetDesignateHash() util.Uint160
} }

View file

@ -294,7 +294,7 @@ type testNodeStateSettings struct {
maintAllowed bool maintAllowed bool
} }
func (s *testNodeStateSettings) MaintenanceModeAllowed(context.Context) error { func (s *testNodeStateSettings) MaintenanceModeAllowed() error {
if s.maintAllowed { if s.maintAllowed {
return nil return nil
} }
@ -303,7 +303,7 @@ func (s *testNodeStateSettings) MaintenanceModeAllowed(context.Context) error {
type testValidator struct{} type testValidator struct{}
func (v *testValidator) VerifyAndUpdate(context.Context, *netmap.NodeInfo) error { func (v *testValidator) VerifyAndUpdate(*netmap.NodeInfo) error {
return nil return nil
} }
@ -381,7 +381,7 @@ func (c *testNetmapClient) ContractAddress() util.Uint160 {
return c.contractAddress return c.contractAddress
} }
func (c *testNetmapClient) EpochDuration(context.Context) (uint64, error) { func (c *testNetmapClient) EpochDuration() (uint64, error) {
return c.epochDuration, nil return c.epochDuration, nil
} }
@ -392,7 +392,7 @@ func (c *testNetmapClient) MorphTxHeight(h util.Uint256) (uint32, error) {
return 0, fmt.Errorf("not found") return 0, fmt.Errorf("not found")
} }
func (c *testNetmapClient) NetMap(context.Context) (*netmap.NetMap, error) { func (c *testNetmapClient) NetMap() (*netmap.NetMap, error) {
return c.netmap, nil return c.netmap, nil
} }

View file

@ -1,7 +1,6 @@
package locode package locode
import ( import (
"context"
"errors" "errors"
"fmt" "fmt"
@ -30,7 +29,7 @@ var errMissingRequiredAttr = errors.New("missing required attribute in DB record
// - Continent: R.Continent().String(). // - Continent: R.Continent().String().
// //
// UN-LOCODE attribute remains untouched. // UN-LOCODE attribute remains untouched.
func (v *Validator) VerifyAndUpdate(_ context.Context, n *netmap.NodeInfo) error { func (v *Validator) VerifyAndUpdate(n *netmap.NodeInfo) error {
attrLocode := n.LOCODE() attrLocode := n.LOCODE()
if attrLocode == "" { if attrLocode == "" {
return nil return nil

View file

@ -1,7 +1,6 @@
package locode_test package locode_test
import ( import (
"context"
"errors" "errors"
"fmt" "fmt"
"testing" "testing"
@ -93,7 +92,7 @@ func TestValidator_VerifyAndUpdate(t *testing.T) {
t.Run("w/o locode", func(t *testing.T) { t.Run("w/o locode", func(t *testing.T) {
n := nodeInfoWithSomeAttrs() n := nodeInfoWithSomeAttrs()
err := validator.VerifyAndUpdate(context.Background(), n) err := validator.VerifyAndUpdate(n)
require.NoError(t, err) require.NoError(t, err)
}) })
@ -103,7 +102,7 @@ func TestValidator_VerifyAndUpdate(t *testing.T) {
addLocodeAttrValue(n, "WRONG LOCODE") addLocodeAttrValue(n, "WRONG LOCODE")
err := validator.VerifyAndUpdate(context.Background(), n) err := validator.VerifyAndUpdate(n)
require.Error(t, err) require.Error(t, err)
}) })
@ -112,7 +111,7 @@ func TestValidator_VerifyAndUpdate(t *testing.T) {
addLocodeAttr(n, locodestd.LOCODE{"RU", "SPB"}) addLocodeAttr(n, locodestd.LOCODE{"RU", "SPB"})
err := validator.VerifyAndUpdate(context.Background(), n) err := validator.VerifyAndUpdate(n)
require.Error(t, err) require.Error(t, err)
}) })
@ -120,7 +119,7 @@ func TestValidator_VerifyAndUpdate(t *testing.T) {
addLocodeAttr(n, r.LOCODE) addLocodeAttr(n, r.LOCODE)
err := validator.VerifyAndUpdate(context.Background(), n) err := validator.VerifyAndUpdate(n)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, rec.CountryCode().String(), n.Attribute("CountryCode")) require.Equal(t, rec.CountryCode().String(), n.Attribute("CountryCode"))

View file

@ -1,7 +1,6 @@
package maddress package maddress
import ( import (
"context"
"fmt" "fmt"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network"
@ -9,7 +8,7 @@ import (
) )
// VerifyAndUpdate calls network.VerifyAddress. // VerifyAndUpdate calls network.VerifyAddress.
func (v *Validator) VerifyAndUpdate(_ context.Context, n *netmap.NodeInfo) error { func (v *Validator) VerifyAndUpdate(n *netmap.NodeInfo) error {
err := network.VerifyMultiAddress(*n) err := network.VerifyMultiAddress(*n)
if err != nil { if err != nil {
return fmt.Errorf("could not verify multiaddress: %w", err) return fmt.Errorf("could not verify multiaddress: %w", err)

View file

@ -7,7 +7,6 @@ map candidates.
package state package state
import ( import (
"context"
"errors" "errors"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
@ -24,7 +23,7 @@ type NetworkSettings interface {
// no error if allowed; // no error if allowed;
// ErrMaintenanceModeDisallowed if disallowed; // ErrMaintenanceModeDisallowed if disallowed;
// other error if there are any problems with the check. // other error if there are any problems with the check.
MaintenanceModeAllowed(ctx context.Context) error MaintenanceModeAllowed() error
} }
// NetMapCandidateValidator represents tool which checks state of nodes which // NetMapCandidateValidator represents tool which checks state of nodes which
@ -56,13 +55,13 @@ func (x *NetMapCandidateValidator) SetNetworkSettings(netSettings NetworkSetting
// MUST NOT be called before SetNetworkSettings. // MUST NOT be called before SetNetworkSettings.
// //
// See also netmap.NodeInfo.IsOnline/SetOnline and other similar methods. // See also netmap.NodeInfo.IsOnline/SetOnline and other similar methods.
func (x *NetMapCandidateValidator) VerifyAndUpdate(ctx context.Context, node *netmap.NodeInfo) error { func (x *NetMapCandidateValidator) VerifyAndUpdate(node *netmap.NodeInfo) error {
if node.Status().IsOnline() { if node.Status().IsOnline() {
return nil return nil
} }
if node.Status().IsMaintenance() { if node.Status().IsMaintenance() {
return x.netSettings.MaintenanceModeAllowed(ctx) return x.netSettings.MaintenanceModeAllowed()
} }
return errors.New("invalid status: MUST be either ONLINE or MAINTENANCE") return errors.New("invalid status: MUST be either ONLINE or MAINTENANCE")

View file

@ -1,7 +1,6 @@
package state_test package state_test
import ( import (
"context"
"testing" "testing"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/netmap/nodevalidation/state" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/netmap/nodevalidation/state"
@ -14,7 +13,7 @@ type testNetworkSettings struct {
disallowed bool disallowed bool
} }
func (x testNetworkSettings) MaintenanceModeAllowed(context.Context) error { func (x testNetworkSettings) MaintenanceModeAllowed() error {
if x.disallowed { if x.disallowed {
return state.ErrMaintenanceModeDisallowed return state.ErrMaintenanceModeDisallowed
} }
@ -82,7 +81,7 @@ func TestValidator_VerifyAndUpdate(t *testing.T) {
testCase.validatorPreparer(&v) testCase.validatorPreparer(&v)
} }
err := v.VerifyAndUpdate(context.Background(), &node) err := v.VerifyAndUpdate(&node)
if testCase.valid { if testCase.valid {
require.NoError(t, err, testCase.name) require.NoError(t, err, testCase.name)

View file

@ -1,8 +1,6 @@
package nodevalidation package nodevalidation
import ( import (
"context"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/netmap" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/innerring/processors/netmap"
apinetmap "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap" apinetmap "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
) )
@ -28,9 +26,9 @@ func New(validators ...netmap.NodeValidator) *CompositeValidator {
// VerifyAndUpdate passes apinetmap.NodeInfo to wrapped validators. // VerifyAndUpdate passes apinetmap.NodeInfo to wrapped validators.
// //
// If error appears, returns it immediately. // If error appears, returns it immediately.
func (c *CompositeValidator) VerifyAndUpdate(ctx context.Context, ni *apinetmap.NodeInfo) error { func (c *CompositeValidator) VerifyAndUpdate(ni *apinetmap.NodeInfo) error {
for _, v := range c.validators { for _, v := range c.validators {
if err := v.VerifyAndUpdate(ctx, ni); err != nil { if err := v.VerifyAndUpdate(ni); err != nil {
return err return err
} }
} }

View file

@ -14,7 +14,7 @@ import (
func (np *Processor) processNewEpoch(ctx context.Context, ev netmapEvent.NewEpoch) bool { func (np *Processor) processNewEpoch(ctx context.Context, ev netmapEvent.NewEpoch) bool {
epoch := ev.EpochNumber() epoch := ev.EpochNumber()
epochDuration, err := np.netmapClient.EpochDuration(ctx) epochDuration, err := np.netmapClient.EpochDuration()
if err != nil { if err != nil {
np.log.Warn(ctx, logs.NetmapCantGetEpochDuration, np.log.Warn(ctx, logs.NetmapCantGetEpochDuration,
zap.Error(err)) zap.Error(err))
@ -37,7 +37,7 @@ func (np *Processor) processNewEpoch(ctx context.Context, ev netmapEvent.NewEpoc
} }
// get new netmap snapshot // get new netmap snapshot
networkMap, err := np.netmapClient.NetMap(ctx) networkMap, err := np.netmapClient.NetMap()
if err != nil { if err != nil {
np.log.Warn(ctx, logs.NetmapCantGetNetmapSnapshotToPerformCleanup, np.log.Warn(ctx, logs.NetmapCantGetNetmapSnapshotToPerformCleanup,
zap.Error(err)) zap.Error(err))

View file

@ -39,7 +39,7 @@ func (np *Processor) processAddPeer(ctx context.Context, ev netmapEvent.AddPeer)
} }
// validate and update node info // validate and update node info
err = np.nodeValidator.VerifyAndUpdate(ctx, &nodeInfo) err = np.nodeValidator.VerifyAndUpdate(&nodeInfo)
if err != nil { if err != nil {
np.log.Warn(ctx, logs.NetmapCouldNotVerifyAndUpdateInformationAboutNetworkMapCandidate, np.log.Warn(ctx, logs.NetmapCouldNotVerifyAndUpdateInformationAboutNetworkMapCandidate,
zap.Error(err), zap.Error(err),
@ -108,7 +108,7 @@ func (np *Processor) processUpdatePeer(ctx context.Context, ev netmapEvent.Updat
var err error var err error
if ev.Maintenance() { if ev.Maintenance() {
err = np.nodeStateSettings.MaintenanceModeAllowed(ctx) err = np.nodeStateSettings.MaintenanceModeAllowed()
if err != nil { if err != nil {
np.log.Info(ctx, logs.NetmapPreventSwitchingNodeToMaintenanceState, np.log.Info(ctx, logs.NetmapPreventSwitchingNodeToMaintenanceState,
zap.Error(err), zap.Error(err),

View file

@ -49,15 +49,15 @@ type (
// //
// If no error occurs, the parameter must point to the // If no error occurs, the parameter must point to the
// ready-made NodeInfo structure. // ready-made NodeInfo structure.
VerifyAndUpdate(context.Context, *netmap.NodeInfo) error VerifyAndUpdate(*netmap.NodeInfo) error
} }
Client interface { Client interface {
MorphNotaryInvoke(ctx context.Context, contract util.Uint160, fee fixedn.Fixed8, nonce uint32, vub *uint32, method string, args ...any) error MorphNotaryInvoke(ctx context.Context, contract util.Uint160, fee fixedn.Fixed8, nonce uint32, vub *uint32, method string, args ...any) error
ContractAddress() util.Uint160 ContractAddress() util.Uint160
EpochDuration(ctx context.Context) (uint64, error) EpochDuration() (uint64, error)
MorphTxHeight(h util.Uint256) (res uint32, err error) MorphTxHeight(h util.Uint256) (res uint32, err error)
NetMap(ctx context.Context) (*netmap.NetMap, error) NetMap() (*netmap.NetMap, error)
NewEpoch(ctx context.Context, epoch uint64) error NewEpoch(ctx context.Context, epoch uint64) error
MorphIsValidScript(script []byte, signers []transaction.Signer) (valid bool, err error) MorphIsValidScript(script []byte, signers []transaction.Signer) (valid bool, err error)
MorphNotarySignAndInvokeTX(mainTx *transaction.Transaction) error MorphNotarySignAndInvokeTX(mainTx *transaction.Transaction) error

View file

@ -34,16 +34,16 @@ func (w *netmapClientWrapper) ContractAddress() util.Uint160 {
return w.netmapClient.ContractAddress() return w.netmapClient.ContractAddress()
} }
func (w *netmapClientWrapper) EpochDuration(ctx context.Context) (uint64, error) { func (w *netmapClientWrapper) EpochDuration() (uint64, error) {
return w.netmapClient.EpochDuration(ctx) return w.netmapClient.EpochDuration()
} }
func (w *netmapClientWrapper) MorphTxHeight(h util.Uint256) (res uint32, err error) { func (w *netmapClientWrapper) MorphTxHeight(h util.Uint256) (res uint32, err error) {
return w.netmapClient.Morph().TxHeight(h) return w.netmapClient.Morph().TxHeight(h)
} }
func (w *netmapClientWrapper) NetMap(ctx context.Context) (*netmap.NetMap, error) { func (w *netmapClientWrapper) NetMap() (*netmap.NetMap, error) {
return w.netmapClient.NetMap(ctx) return w.netmapClient.NetMap()
} }
func (w *netmapClientWrapper) NewEpoch(ctx context.Context, epoch uint64) error { func (w *netmapClientWrapper) NewEpoch(ctx context.Context, epoch uint64) error {

View file

@ -60,7 +60,7 @@ func (s *Server) IsAlphabet(ctx context.Context) bool {
// InnerRingIndex is a getter for a global index of node in inner ring list. Negative // InnerRingIndex is a getter for a global index of node in inner ring list. Negative
// index means that node is not in the inner ring list. // index means that node is not in the inner ring list.
func (s *Server) InnerRingIndex(ctx context.Context) int { func (s *Server) InnerRingIndex(ctx context.Context) int {
index, err := s.statusIndex.InnerRingIndex(ctx) index, err := s.statusIndex.InnerRingIndex()
if err != nil { if err != nil {
s.log.Error(ctx, logs.InnerringCantGetInnerRingIndex, zap.Error(err)) s.log.Error(ctx, logs.InnerringCantGetInnerRingIndex, zap.Error(err))
return -1 return -1
@ -72,7 +72,7 @@ func (s *Server) InnerRingIndex(ctx context.Context) int {
// InnerRingSize is a getter for a global size of inner ring list. This value // InnerRingSize is a getter for a global size of inner ring list. This value
// paired with inner ring index. // paired with inner ring index.
func (s *Server) InnerRingSize(ctx context.Context) int { func (s *Server) InnerRingSize(ctx context.Context) int {
size, err := s.statusIndex.InnerRingSize(ctx) size, err := s.statusIndex.InnerRingSize()
if err != nil { if err != nil {
s.log.Error(ctx, logs.InnerringCantGetInnerRingSize, zap.Error(err)) s.log.Error(ctx, logs.InnerringCantGetInnerRingSize, zap.Error(err))
return 0 return 0
@ -84,7 +84,7 @@ func (s *Server) InnerRingSize(ctx context.Context) int {
// AlphabetIndex is a getter for a global index of node in alphabet list. // AlphabetIndex is a getter for a global index of node in alphabet list.
// Negative index means that node is not in the alphabet list. // Negative index means that node is not in the alphabet list.
func (s *Server) AlphabetIndex(ctx context.Context) int { func (s *Server) AlphabetIndex(ctx context.Context) int {
index, err := s.statusIndex.AlphabetIndex(ctx) index, err := s.statusIndex.AlphabetIndex()
if err != nil { if err != nil {
s.log.Error(ctx, logs.InnerringCantGetAlphabetIndex, zap.Error(err)) s.log.Error(ctx, logs.InnerringCantGetAlphabetIndex, zap.Error(err))
return -1 return -1

View file

@ -41,11 +41,8 @@ func (b *Blobovniczas) initializeDBs(ctx context.Context) error {
} }
eg, egCtx := errgroup.WithContext(ctx) eg, egCtx := errgroup.WithContext(ctx)
if b.blzInitWorkerCount > 0 { eg.SetLimit(b.blzInitWorkerCount)
eg.SetLimit(b.blzInitWorkerCount + 1) err = b.iterateIncompletedRebuildDBPaths(egCtx, func(p string) (bool, error) {
}
eg.Go(func() error {
return b.iterateIncompletedRebuildDBPaths(egCtx, func(p string) (bool, error) {
eg.Go(func() error { eg.Go(func() error {
p = strings.TrimSuffix(p, rebuildSuffix) p = strings.TrimSuffix(p, rebuildSuffix)
shBlz := b.getBlobovniczaWithoutCaching(p) shBlz := b.getBlobovniczaWithoutCaching(p)
@ -68,7 +65,11 @@ func (b *Blobovniczas) initializeDBs(ctx context.Context) error {
}) })
return false, nil return false, nil
}) })
}) if err != nil {
_ = eg.Wait()
return err
}
return eg.Wait() return eg.Wait()
} }

View file

@ -2,9 +2,6 @@ package blobovniczatree
import ( import (
"context" "context"
"os"
"path"
"strconv"
"testing" "testing"
objectCore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object" objectCore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
@ -132,34 +129,3 @@ func TestObjectsAvailableAfterDepthAndWidthEdit(t *testing.T) {
require.NoError(t, blz.Close(context.Background())) require.NoError(t, blz.Close(context.Background()))
} }
func TestInitBlobovniczasInitErrorType(t *testing.T) {
t.Parallel()
rootDir := t.TempDir()
for idx := 0; idx < 10; idx++ {
f, err := os.Create(path.Join(rootDir, strconv.FormatInt(int64(idx), 10)+".db"))
require.NoError(t, err)
_, err = f.Write([]byte("invalid db"))
require.NoError(t, err)
require.NoError(t, f.Close())
f, err = os.Create(path.Join(rootDir, strconv.FormatInt(int64(idx), 10)+".db"+rebuildSuffix))
require.NoError(t, err)
require.NoError(t, f.Close())
}
blz := NewBlobovniczaTree(
context.Background(),
WithBlobovniczaShallowDepth(1),
WithBlobovniczaShallowWidth(1),
WithRootPath(rootDir),
)
require.NoError(t, blz.Open(mode.ComponentReadWrite))
err := blz.Init()
require.Contains(t, err.Error(), "open blobovnicza")
require.Contains(t, err.Error(), "invalid database")
require.NoError(t, blz.Close(context.Background()))
}

View file

@ -279,7 +279,7 @@ func (s *containerSource) IsContainerAvailable(ctx context.Context, id cid.ID) (
return true, nil return true, nil
} }
wasRemoved, err := container.WasRemoved(ctx, s.cs, id) wasRemoved, err := container.WasRemoved(s.cs, id)
if err != nil { if err != nil {
return false, err return false, err
} }

View file

@ -425,7 +425,7 @@ func (e *StorageEngine) evacuateShardObjects(ctx context.Context, cancel context
} }
egContainer.Go(func() error { egContainer.Go(func() error {
var skip bool var skip bool
c, err := e.containerSource.Load().cs.Get(ctx, cnt) c, err := e.containerSource.Load().cs.Get(cnt)
if err != nil { if err != nil {
if client.IsErrContainerNotFound(err) { if client.IsErrContainerNotFound(err) {
skip = true skip = true

View file

@ -37,7 +37,7 @@ type containerStorage struct {
latency time.Duration latency time.Duration
} }
func (cs *containerStorage) Get(ctx context.Context, id cid.ID) (*coreContainer.Container, error) { func (cs *containerStorage) Get(id cid.ID) (*coreContainer.Container, error) {
time.Sleep(cs.latency) time.Sleep(cs.latency)
v, ok := cs.cntmap[id] v, ok := cs.cntmap[id]
if !ok { if !ok {
@ -49,7 +49,7 @@ func (cs *containerStorage) Get(ctx context.Context, id cid.ID) (*coreContainer.
return &coreCnt, nil return &coreCnt, nil
} }
func (cs *containerStorage) DeletionInfo(context.Context, cid.ID) (*coreContainer.DelInfo, error) { func (cs *containerStorage) DeletionInfo(cid.ID) (*coreContainer.DelInfo, error) {
return nil, nil return nil, nil
} }

View file

@ -360,7 +360,7 @@ func dropUserAttributes(ctx context.Context, db *bbolt.DB, cs container.InfoProv
return nil return nil
} }
last = keys[len(keys)-1] last = keys[len(keys)-1]
cnt, err := dropNonIndexedUserAttributeBuckets(ctx, db, cs, keys) cnt, err := dropNonIndexedUserAttributeBuckets(db, cs, keys)
if err != nil { if err != nil {
log("deleting user attribute buckets completed with an error:", err) log("deleting user attribute buckets completed with an error:", err)
return err return err
@ -376,8 +376,8 @@ func dropUserAttributes(ctx context.Context, db *bbolt.DB, cs container.InfoProv
} }
} }
func dropNonIndexedUserAttributeBuckets(ctx context.Context, db *bbolt.DB, cs container.InfoProvider, keys [][]byte) (uint64, error) { func dropNonIndexedUserAttributeBuckets(db *bbolt.DB, cs container.InfoProvider, keys [][]byte) (uint64, error) {
keysToDrop, err := selectUserAttributeKeysToDrop(ctx, keys, cs) keysToDrop, err := selectUserAttributeKeysToDrop(keys, cs)
if err != nil { if err != nil {
return 0, fmt.Errorf("select non indexed user attributes: %w", err) return 0, fmt.Errorf("select non indexed user attributes: %w", err)
} }
@ -394,7 +394,7 @@ func dropNonIndexedUserAttributeBuckets(ctx context.Context, db *bbolt.DB, cs co
return uint64(len(keysToDrop)), nil return uint64(len(keysToDrop)), nil
} }
func selectUserAttributeKeysToDrop(ctx context.Context, keys [][]byte, cs container.InfoProvider) ([][]byte, error) { func selectUserAttributeKeysToDrop(keys [][]byte, cs container.InfoProvider) ([][]byte, error) {
var keysToDrop [][]byte var keysToDrop [][]byte
for _, key := range keys { for _, key := range keys {
attr, ok := attributeFromAttributeBucket(key) attr, ok := attributeFromAttributeBucket(key)
@ -409,7 +409,7 @@ func selectUserAttributeKeysToDrop(ctx context.Context, keys [][]byte, cs contai
if !ok { if !ok {
return nil, fmt.Errorf("parse container ID from user attribute bucket key %s", hex.EncodeToString(key)) return nil, fmt.Errorf("parse container ID from user attribute bucket key %s", hex.EncodeToString(key))
} }
info, err := cs.Info(ctx, contID) info, err := cs.Info(contID)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -45,7 +45,7 @@ func TestUpgradeV2ToV3(t *testing.T) {
type testContainerInfoProvider struct{} type testContainerInfoProvider struct{}
func (p *testContainerInfoProvider) Info(ctx context.Context, id cid.ID) (container.Info, error) { func (p *testContainerInfoProvider) Info(id cid.ID) (container.Info, error) {
return container.Info{}, nil return container.Info{}, nil
} }

View file

@ -280,7 +280,7 @@ func (s *Shard) refillObject(ctx context.Context, data []byte, addr oid.Address,
var isIndexedContainer bool var isIndexedContainer bool
if hasIndexedAttribute { if hasIndexedAttribute {
info, err := s.containerInfo.Info(ctx, addr.Container()) info, err := s.containerInfo.Info(addr.Container())
if err != nil { if err != nil {
return err return err
} }

View file

@ -6,13 +6,11 @@ import (
"time" "time"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs" "git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/qos"
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase" meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing" "git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
"git.frostfs.info/TrueCloudLab/frostfs-qos/tagging"
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object" objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id" oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
"go.uber.org/zap" "go.uber.org/zap"
@ -151,7 +149,7 @@ func (gc *gc) init(ctx context.Context) {
if sz > 0 { if sz > 0 {
gc.workerPool = gc.workerPoolInit(sz) gc.workerPool = gc.workerPoolInit(sz)
} }
ctx = tagging.ContextWithIOTag(ctx, qos.IOTagBackground.String())
gc.wg.Add(2) gc.wg.Add(2)
go gc.tickRemover(ctx) go gc.tickRemover(ctx)
go gc.listenEvents(ctx) go gc.listenEvents(ctx)

View file

@ -6,12 +6,10 @@ import (
"sync" "sync"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs" "git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/qos"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor"
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase" meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing" "git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
"git.frostfs.info/TrueCloudLab/frostfs-qos/tagging"
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id" oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
"go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace" "go.opentelemetry.io/otel/trace"
@ -105,7 +103,6 @@ func runRebuild(ctx context.Context, bs *blobstor.BlobStor, mb *meta.DB, log *lo
default: default:
} }
log.Info(ctx, logs.BlobstoreRebuildStarted) log.Info(ctx, logs.BlobstoreRebuildStarted)
ctx = tagging.ContextWithIOTag(ctx, qos.IOTagBackground.String())
if err := bs.Rebuild(ctx, &mbStorageIDUpdate{mb: mb}, limiter, fillPercent); err != nil { if err := bs.Rebuild(ctx, &mbStorageIDUpdate{mb: mb}, limiter, fillPercent); err != nil {
log.Warn(ctx, logs.FailedToRebuildBlobstore, zap.Error(err)) log.Warn(ctx, logs.FailedToRebuildBlobstore, zap.Error(err))
} else { } else {

View file

@ -6,7 +6,6 @@ import (
"time" "time"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs" "git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/qos"
objectCore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object" objectCore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
@ -15,7 +14,6 @@ import (
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase" meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing" "git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
"git.frostfs.info/TrueCloudLab/frostfs-qos/tagging"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object" objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
"go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/attribute"
@ -37,7 +35,6 @@ func (c *cache) runFlushLoop(ctx context.Context) {
if c.disableBackgroundFlush { if c.disableBackgroundFlush {
return return
} }
ctx = tagging.ContextWithIOTag(ctx, qos.IOTagWritecache.String())
fl := newFlushLimiter(c.flushSizeLimit) fl := newFlushLimiter(c.flushSizeLimit)
c.wg.Add(1) c.wg.Add(1)
go func() { go func() {

View file

@ -1,7 +1,6 @@
package balance package balance
import ( import (
"context"
"fmt" "fmt"
"math/big" "math/big"
@ -11,14 +10,17 @@ import (
// BalanceOf receives the amount of funds in the client's account // BalanceOf receives the amount of funds in the client's account
// through the Balance contract call, and returns it. // through the Balance contract call, and returns it.
func (c *Client) BalanceOf(ctx context.Context, id user.ID) (*big.Int, error) { func (c *Client) BalanceOf(id user.ID) (*big.Int, error) {
h := id.ScriptHash() h, err := id.ScriptHash()
if err != nil {
return nil, err
}
invokePrm := client.TestInvokePrm{} invokePrm := client.TestInvokePrm{}
invokePrm.SetMethod(balanceOfMethod) invokePrm.SetMethod(balanceOfMethod)
invokePrm.SetArgs(h) invokePrm.SetArgs(h)
prms, err := c.client.TestInvoke(ctx, invokePrm) prms, err := c.client.TestInvoke(invokePrm)
if err != nil { if err != nil {
return nil, fmt.Errorf("test invoke (%s): %w", balanceOfMethod, err) return nil, fmt.Errorf("test invoke (%s): %w", balanceOfMethod, err)
} else if ln := len(prms); ln != 1 { } else if ln := len(prms); ln != 1 {

View file

@ -1,7 +1,6 @@
package balance package balance
import ( import (
"context"
"fmt" "fmt"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
@ -9,11 +8,11 @@ import (
// Decimals decimal precision of currency transactions // Decimals decimal precision of currency transactions
// through the Balance contract call, and returns it. // through the Balance contract call, and returns it.
func (c *Client) Decimals(ctx context.Context) (uint32, error) { func (c *Client) Decimals() (uint32, error) {
invokePrm := client.TestInvokePrm{} invokePrm := client.TestInvokePrm{}
invokePrm.SetMethod(decimalsMethod) invokePrm.SetMethod(decimalsMethod)
prms, err := c.client.TestInvoke(ctx, invokePrm) prms, err := c.client.TestInvoke(invokePrm)
if err != nil { if err != nil {
return 0, fmt.Errorf("test invoke (%s): %w", decimalsMethod, err) return 0, fmt.Errorf("test invoke (%s): %w", decimalsMethod, err)
} else if ln := len(prms); ln != 1 { } else if ln := len(prms); ln != 1 {

View file

@ -22,15 +22,22 @@ type TransferPrm struct {
// TransferX transfers p.Amount of GASe-12 from p.From to p.To // TransferX transfers p.Amount of GASe-12 from p.From to p.To
// with details p.Details through direct smart contract call. // with details p.Details through direct smart contract call.
func (c *Client) TransferX(ctx context.Context, p TransferPrm) error { func (c *Client) TransferX(ctx context.Context, p TransferPrm) error {
from := p.From.ScriptHash() from, err := p.From.ScriptHash()
to := p.To.ScriptHash() if err != nil {
return err
}
to, err := p.To.ScriptHash()
if err != nil {
return err
}
prm := client.InvokePrm{} prm := client.InvokePrm{}
prm.SetMethod(transferXMethod) prm.SetMethod(transferXMethod)
prm.SetArgs(from, to, p.Amount, p.Details) prm.SetArgs(from, to, p.Amount, p.Details)
prm.InvokePrmOptional = p.InvokePrmOptional prm.InvokePrmOptional = p.InvokePrmOptional
_, err := c.client.Invoke(ctx, prm) _, err = c.client.Invoke(ctx, prm)
if err != nil { if err != nil {
return fmt.Errorf("invoke method (%s): %w", transferXMethod, err) return fmt.Errorf("invoke method (%s): %w", transferXMethod, err)
} }

View file

@ -499,7 +499,7 @@ func (c *Client) TxHeight(h util.Uint256) (res uint32, err error) {
// NeoFSAlphabetList returns keys that stored in NeoFS Alphabet role. Main chain // NeoFSAlphabetList returns keys that stored in NeoFS Alphabet role. Main chain
// stores alphabet node keys of inner ring there, however the sidechain stores both // stores alphabet node keys of inner ring there, however the sidechain stores both
// alphabet and non alphabet node keys of inner ring. // alphabet and non alphabet node keys of inner ring.
func (c *Client) NeoFSAlphabetList(_ context.Context) (res keys.PublicKeys, err error) { func (c *Client) NeoFSAlphabetList() (res keys.PublicKeys, err error) {
c.switchLock.RLock() c.switchLock.RLock()
defer c.switchLock.RUnlock() defer c.switchLock.RUnlock()

View file

@ -1,7 +1,6 @@
package container package container
import ( import (
"context"
"errors" "errors"
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
@ -14,7 +13,7 @@ import (
// to the specified user of FrostFS system. If idUser is nil, returns the list of all containers. // to the specified user of FrostFS system. If idUser is nil, returns the list of all containers.
// //
// If remote RPC does not support neo-go session API, fallback to List() method. // If remote RPC does not support neo-go session API, fallback to List() method.
func (c *Client) ContainersOf(ctx context.Context, idUser *user.ID) ([]cid.ID, error) { func (c *Client) ContainersOf(idUser *user.ID) ([]cid.ID, error) {
var cidList []cid.ID var cidList []cid.ID
var err error var err error
@ -22,7 +21,7 @@ func (c *Client) ContainersOf(ctx context.Context, idUser *user.ID) ([]cid.ID, e
cidList = append(cidList, id) cidList = append(cidList, id)
return nil return nil
} }
if err = c.IterateContainersOf(ctx, idUser, cb); err != nil { if err = c.IterateContainersOf(idUser, cb); err != nil {
return nil, err return nil, err
} }
return cidList, nil return cidList, nil
@ -31,7 +30,7 @@ func (c *Client) ContainersOf(ctx context.Context, idUser *user.ID) ([]cid.ID, e
// iterateContainers iterates over a list of container identifiers // iterateContainers iterates over a list of container identifiers
// belonging to the specified user of FrostFS system and executes // belonging to the specified user of FrostFS system and executes
// `cb` on each element. If idUser is nil, calls it on the list of all containers. // `cb` on each element. If idUser is nil, calls it on the list of all containers.
func (c *Client) IterateContainersOf(ctx context.Context, idUser *user.ID, cb func(item cid.ID) error) error { func (c *Client) IterateContainersOf(idUser *user.ID, cb func(item cid.ID) error) error {
var rawID []byte var rawID []byte
if idUser != nil { if idUser != nil {
rawID = idUser.WalletBytes() rawID = idUser.WalletBytes()
@ -60,7 +59,7 @@ func (c *Client) IterateContainersOf(ctx context.Context, idUser *user.ID, cb fu
cnrHash := c.client.ContractAddress() cnrHash := c.client.ContractAddress()
err := c.client.Morph().TestInvokeIterator(itemCb, batchSize, cnrHash, containersOfMethod, rawID) err := c.client.Morph().TestInvokeIterator(itemCb, batchSize, cnrHash, containersOfMethod, rawID)
if err != nil && errors.Is(err, unwrap.ErrNoSessionID) { if err != nil && errors.Is(err, unwrap.ErrNoSessionID) {
return c.iterate(ctx, idUser, cb) return c.iterate(idUser, cb)
} }
return err return err

View file

@ -1,7 +1,6 @@
package container package container
import ( import (
"context"
"crypto/sha256" "crypto/sha256"
"fmt" "fmt"
"strings" "strings"
@ -15,27 +14,27 @@ import (
"github.com/mr-tron/base58" "github.com/mr-tron/base58"
) )
func (x *containerSource) DeletionInfo(ctx context.Context, cnr cid.ID) (*containercore.DelInfo, error) { func (x *containerSource) DeletionInfo(cnr cid.ID) (*containercore.DelInfo, error) {
return DeletionInfo(ctx, (*Client)(x), cnr) return DeletionInfo((*Client)(x), cnr)
} }
type deletionInfo interface { type deletionInfo interface {
DeletionInfo(ctx context.Context, cid []byte) (*containercore.DelInfo, error) DeletionInfo(cid []byte) (*containercore.DelInfo, error)
} }
func DeletionInfo(ctx context.Context, c deletionInfo, cnr cid.ID) (*containercore.DelInfo, error) { func DeletionInfo(c deletionInfo, cnr cid.ID) (*containercore.DelInfo, error) {
binCnr := make([]byte, sha256.Size) binCnr := make([]byte, sha256.Size)
cnr.Encode(binCnr) cnr.Encode(binCnr)
return c.DeletionInfo(ctx, binCnr) return c.DeletionInfo(binCnr)
} }
func (c *Client) DeletionInfo(ctx context.Context, cid []byte) (*containercore.DelInfo, error) { func (c *Client) DeletionInfo(cid []byte) (*containercore.DelInfo, error) {
prm := client.TestInvokePrm{} prm := client.TestInvokePrm{}
prm.SetMethod(deletionInfoMethod) prm.SetMethod(deletionInfoMethod)
prm.SetArgs(cid) prm.SetArgs(cid)
res, err := c.client.TestInvoke(ctx, prm) res, err := c.client.TestInvoke(prm)
if err != nil { if err != nil {
if strings.Contains(err.Error(), containerContract.NotFoundError) { if strings.Contains(err.Error(), containerContract.NotFoundError) {
return nil, new(apistatus.ContainerNotFound) return nil, new(apistatus.ContainerNotFound)

View file

@ -1,7 +1,6 @@
package container package container
import ( import (
"context"
"crypto/sha256" "crypto/sha256"
"fmt" "fmt"
"strings" "strings"
@ -17,8 +16,8 @@ import (
type containerSource Client type containerSource Client
func (x *containerSource) Get(ctx context.Context, cnr cid.ID) (*containercore.Container, error) { func (x *containerSource) Get(cnr cid.ID) (*containercore.Container, error) {
return Get(ctx, (*Client)(x), cnr) return Get((*Client)(x), cnr)
} }
// AsContainerSource provides container Source interface // AsContainerSource provides container Source interface
@ -28,15 +27,15 @@ func AsContainerSource(w *Client) containercore.Source {
} }
type getContainer interface { type getContainer interface {
Get(ctx context.Context, cid []byte) (*containercore.Container, error) Get(cid []byte) (*containercore.Container, error)
} }
// Get marshals container ID, and passes it to Wrapper's Get method. // Get marshals container ID, and passes it to Wrapper's Get method.
func Get(ctx context.Context, c getContainer, cnr cid.ID) (*containercore.Container, error) { func Get(c getContainer, cnr cid.ID) (*containercore.Container, error) {
binCnr := make([]byte, sha256.Size) binCnr := make([]byte, sha256.Size)
cnr.Encode(binCnr) cnr.Encode(binCnr)
return c.Get(ctx, binCnr) return c.Get(binCnr)
} }
// Get reads the container from FrostFS system by binary identifier // Get reads the container from FrostFS system by binary identifier
@ -44,12 +43,12 @@ func Get(ctx context.Context, c getContainer, cnr cid.ID) (*containercore.Contai
// //
// If an empty slice is returned for the requested identifier, // If an empty slice is returned for the requested identifier,
// storage.ErrNotFound error is returned. // storage.ErrNotFound error is returned.
func (c *Client) Get(ctx context.Context, cid []byte) (*containercore.Container, error) { func (c *Client) Get(cid []byte) (*containercore.Container, error) {
prm := client.TestInvokePrm{} prm := client.TestInvokePrm{}
prm.SetMethod(getMethod) prm.SetMethod(getMethod)
prm.SetArgs(cid) prm.SetArgs(cid)
res, err := c.client.TestInvoke(ctx, prm) res, err := c.client.TestInvoke(prm)
if err != nil { if err != nil {
if strings.Contains(err.Error(), containerContract.NotFoundError) { if strings.Contains(err.Error(), containerContract.NotFoundError) {
return nil, new(apistatus.ContainerNotFound) return nil, new(apistatus.ContainerNotFound)

View file

@ -1,7 +1,6 @@
package container package container
import ( import (
"context"
"fmt" "fmt"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
@ -16,7 +15,7 @@ import (
// //
// Iterates through the identifiers of all FrostFS containers if pointer // Iterates through the identifiers of all FrostFS containers if pointer
// to user identifier is nil. // to user identifier is nil.
func (c *Client) iterate(ctx context.Context, idUser *user.ID, cb func(cid.ID) error) error { func (c *Client) iterate(idUser *user.ID, cb func(cid.ID) error) error {
var rawID []byte var rawID []byte
if idUser != nil { if idUser != nil {
@ -27,7 +26,7 @@ func (c *Client) iterate(ctx context.Context, idUser *user.ID, cb func(cid.ID) e
prm.SetMethod(listMethod) prm.SetMethod(listMethod)
prm.SetArgs(rawID) prm.SetArgs(rawID)
res, err := c.client.TestInvoke(ctx, prm) res, err := c.client.TestInvoke(prm)
if err != nil { if err != nil {
return fmt.Errorf("test invoke (%s): %w", listMethod, err) return fmt.Errorf("test invoke (%s): %w", listMethod, err)
} else if ln := len(res); ln != 1 { } else if ln := len(res); ln != 1 {

View file

@ -1,7 +1,6 @@
package frostfsid package frostfsid
import ( import (
"context"
"fmt" "fmt"
frostfsidclient "git.frostfs.info/TrueCloudLab/frostfs-contract/frostfsid/client" frostfsidclient "git.frostfs.info/TrueCloudLab/frostfs-contract/frostfsid/client"
@ -15,12 +14,12 @@ const (
methodGetSubjectExtended = "getSubjectExtended" methodGetSubjectExtended = "getSubjectExtended"
) )
func (c *Client) GetSubject(ctx context.Context, addr util.Uint160) (*frostfsidclient.Subject, error) { func (c *Client) GetSubject(addr util.Uint160) (*frostfsidclient.Subject, error) {
prm := client.TestInvokePrm{} prm := client.TestInvokePrm{}
prm.SetMethod(methodGetSubject) prm.SetMethod(methodGetSubject)
prm.SetArgs(addr) prm.SetArgs(addr)
res, err := c.client.TestInvoke(ctx, prm) res, err := c.client.TestInvoke(prm)
if err != nil { if err != nil {
return nil, fmt.Errorf("test invoke (%s): %w", methodGetSubject, err) return nil, fmt.Errorf("test invoke (%s): %w", methodGetSubject, err)
} }
@ -38,12 +37,12 @@ func (c *Client) GetSubject(ctx context.Context, addr util.Uint160) (*frostfsidc
return subj, nil return subj, nil
} }
func (c *Client) GetSubjectExtended(ctx context.Context, addr util.Uint160) (*frostfsidclient.SubjectExtended, error) { func (c *Client) GetSubjectExtended(addr util.Uint160) (*frostfsidclient.SubjectExtended, error) {
prm := client.TestInvokePrm{} prm := client.TestInvokePrm{}
prm.SetMethod(methodGetSubjectExtended) prm.SetMethod(methodGetSubjectExtended)
prm.SetArgs(addr) prm.SetArgs(addr)
res, err := c.client.TestInvoke(ctx, prm) res, err := c.client.TestInvoke(prm)
if err != nil { if err != nil {
return nil, fmt.Errorf("test invoke (%s): %w", methodGetSubjectExtended, err) return nil, fmt.Errorf("test invoke (%s): %w", methodGetSubjectExtended, err)
} }

View file

@ -25,8 +25,8 @@ const (
// MaxObjectSize receives max object size configuration // MaxObjectSize receives max object size configuration
// value through the Netmap contract call. // value through the Netmap contract call.
func (c *Client) MaxObjectSize(ctx context.Context) (uint64, error) { func (c *Client) MaxObjectSize() (uint64, error) {
objectSize, err := c.readUInt64Config(ctx, MaxObjectSizeConfig) objectSize, err := c.readUInt64Config(MaxObjectSizeConfig)
if err != nil { if err != nil {
return 0, err return 0, err
} }
@ -35,8 +35,8 @@ func (c *Client) MaxObjectSize(ctx context.Context) (uint64, error) {
} }
// EpochDuration returns number of sidechain blocks per one FrostFS epoch. // EpochDuration returns number of sidechain blocks per one FrostFS epoch.
func (c *Client) EpochDuration(ctx context.Context) (uint64, error) { func (c *Client) EpochDuration() (uint64, error) {
epochDuration, err := c.readUInt64Config(ctx, EpochDurationConfig) epochDuration, err := c.readUInt64Config(EpochDurationConfig)
if err != nil { if err != nil {
return 0, err return 0, err
} }
@ -46,8 +46,8 @@ func (c *Client) EpochDuration(ctx context.Context) (uint64, error) {
// ContainerFee returns fee paid by container owner to each alphabet node // ContainerFee returns fee paid by container owner to each alphabet node
// for container registration. // for container registration.
func (c *Client) ContainerFee(ctx context.Context) (uint64, error) { func (c *Client) ContainerFee() (uint64, error) {
fee, err := c.readUInt64Config(ctx, ContainerFeeConfig) fee, err := c.readUInt64Config(ContainerFeeConfig)
if err != nil { if err != nil {
return 0, err return 0, err
} }
@ -57,8 +57,8 @@ func (c *Client) ContainerFee(ctx context.Context) (uint64, error) {
// ContainerAliasFee returns additional fee paid by container owner to each // ContainerAliasFee returns additional fee paid by container owner to each
// alphabet node for container nice name registration. // alphabet node for container nice name registration.
func (c *Client) ContainerAliasFee(ctx context.Context) (uint64, error) { func (c *Client) ContainerAliasFee() (uint64, error) {
fee, err := c.readUInt64Config(ctx, ContainerAliasFeeConfig) fee, err := c.readUInt64Config(ContainerAliasFeeConfig)
if err != nil { if err != nil {
return 0, err return 0, err
} }
@ -70,14 +70,14 @@ func (c *Client) ContainerAliasFee(ctx context.Context) (uint64, error) {
// settings. // settings.
// //
// Returns (false, nil) if config key is not found in the contract. // Returns (false, nil) if config key is not found in the contract.
func (c *Client) HomomorphicHashDisabled(ctx context.Context) (bool, error) { func (c *Client) HomomorphicHashDisabled() (bool, error) {
return c.readBoolConfig(ctx, HomomorphicHashingDisabledKey) return c.readBoolConfig(HomomorphicHashingDisabledKey)
} }
// InnerRingCandidateFee returns global configuration value of fee paid by // InnerRingCandidateFee returns global configuration value of fee paid by
// node to be in inner ring candidates list. // node to be in inner ring candidates list.
func (c *Client) InnerRingCandidateFee(ctx context.Context) (uint64, error) { func (c *Client) InnerRingCandidateFee() (uint64, error) {
fee, err := c.readUInt64Config(ctx, IrCandidateFeeConfig) fee, err := c.readUInt64Config(IrCandidateFeeConfig)
if err != nil { if err != nil {
return 0, err return 0, err
} }
@ -87,8 +87,8 @@ func (c *Client) InnerRingCandidateFee(ctx context.Context) (uint64, error) {
// WithdrawFee returns global configuration value of fee paid by user to // WithdrawFee returns global configuration value of fee paid by user to
// withdraw assets from FrostFS contract. // withdraw assets from FrostFS contract.
func (c *Client) WithdrawFee(ctx context.Context) (uint64, error) { func (c *Client) WithdrawFee() (uint64, error) {
fee, err := c.readUInt64Config(ctx, WithdrawFeeConfig) fee, err := c.readUInt64Config(WithdrawFeeConfig)
if err != nil { if err != nil {
return 0, err return 0, err
} }
@ -101,12 +101,12 @@ func (c *Client) WithdrawFee(ctx context.Context) (uint64, error) {
// that storage nodes are allowed to switch their state to "maintenance". // that storage nodes are allowed to switch their state to "maintenance".
// //
// By default, maintenance state is disallowed. // By default, maintenance state is disallowed.
func (c *Client) MaintenanceModeAllowed(ctx context.Context) (bool, error) { func (c *Client) MaintenanceModeAllowed() (bool, error) {
return c.readBoolConfig(ctx, MaintenanceModeAllowedConfig) return c.readBoolConfig(MaintenanceModeAllowedConfig)
} }
func (c *Client) readUInt64Config(ctx context.Context, key string) (uint64, error) { func (c *Client) readUInt64Config(key string) (uint64, error) {
v, err := c.config(ctx, []byte(key), IntegerAssert) v, err := c.config([]byte(key), IntegerAssert)
if err != nil { if err != nil {
return 0, fmt.Errorf("read netconfig value '%s': %w", key, err) return 0, fmt.Errorf("read netconfig value '%s': %w", key, err)
} }
@ -117,8 +117,8 @@ func (c *Client) readUInt64Config(ctx context.Context, key string) (uint64, erro
// reads boolean value by the given key from the FrostFS network configuration // reads boolean value by the given key from the FrostFS network configuration
// stored in the Sidechain. Returns false if key is not presented. // stored in the Sidechain. Returns false if key is not presented.
func (c *Client) readBoolConfig(ctx context.Context, key string) (bool, error) { func (c *Client) readBoolConfig(key string) (bool, error) {
v, err := c.config(ctx, []byte(key), BoolAssert) v, err := c.config([]byte(key), BoolAssert)
if err != nil { if err != nil {
if errors.Is(err, ErrConfigNotFound) { if errors.Is(err, ErrConfigNotFound) {
return false, nil return false, nil
@ -199,12 +199,12 @@ type NetworkConfiguration struct {
} }
// ReadNetworkConfiguration reads NetworkConfiguration from the FrostFS Sidechain. // ReadNetworkConfiguration reads NetworkConfiguration from the FrostFS Sidechain.
func (c *Client) ReadNetworkConfiguration(ctx context.Context) (NetworkConfiguration, error) { func (c *Client) ReadNetworkConfiguration() (NetworkConfiguration, error) {
var res NetworkConfiguration var res NetworkConfiguration
prm := client.TestInvokePrm{} prm := client.TestInvokePrm{}
prm.SetMethod(configListMethod) prm.SetMethod(configListMethod)
items, err := c.client.TestInvoke(ctx, prm) items, err := c.client.TestInvoke(prm)
if err != nil { if err != nil {
return res, fmt.Errorf("test invoke (%s): %w", return res, fmt.Errorf("test invoke (%s): %w",
configListMethod, err) configListMethod, err)
@ -285,12 +285,12 @@ var ErrConfigNotFound = errors.New("config value not found")
// method of FrostFS Netmap contract. // method of FrostFS Netmap contract.
// //
// Returns ErrConfigNotFound if config key is not found in the contract. // Returns ErrConfigNotFound if config key is not found in the contract.
func (c *Client) config(ctx context.Context, key []byte, assert func(stackitem.Item) (any, error)) (any, error) { func (c *Client) config(key []byte, assert func(stackitem.Item) (any, error)) (any, error) {
prm := client.TestInvokePrm{} prm := client.TestInvokePrm{}
prm.SetMethod(configMethod) prm.SetMethod(configMethod)
prm.SetArgs(key) prm.SetArgs(key)
items, err := c.client.TestInvoke(ctx, prm) items, err := c.client.TestInvoke(prm)
if err != nil { if err != nil {
return nil, fmt.Errorf("test invoke (%s): %w", return nil, fmt.Errorf("test invoke (%s): %w",
configMethod, err) configMethod, err)

View file

@ -1,7 +1,6 @@
package netmap package netmap
import ( import (
"context"
"fmt" "fmt"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
@ -9,11 +8,11 @@ import (
// Epoch receives number of current FrostFS epoch // Epoch receives number of current FrostFS epoch
// through the Netmap contract call. // through the Netmap contract call.
func (c *Client) Epoch(ctx context.Context) (uint64, error) { func (c *Client) Epoch() (uint64, error) {
prm := client.TestInvokePrm{} prm := client.TestInvokePrm{}
prm.SetMethod(epochMethod) prm.SetMethod(epochMethod)
items, err := c.client.TestInvoke(ctx, prm) items, err := c.client.TestInvoke(prm)
if err != nil { if err != nil {
return 0, fmt.Errorf("test invoke (%s): %w", return 0, fmt.Errorf("test invoke (%s): %w",
epochMethod, err) epochMethod, err)
@ -33,11 +32,11 @@ func (c *Client) Epoch(ctx context.Context) (uint64, error) {
// LastEpochBlock receives block number of current FrostFS epoch // LastEpochBlock receives block number of current FrostFS epoch
// through the Netmap contract call. // through the Netmap contract call.
func (c *Client) LastEpochBlock(ctx context.Context) (uint32, error) { func (c *Client) LastEpochBlock() (uint32, error) {
prm := client.TestInvokePrm{} prm := client.TestInvokePrm{}
prm.SetMethod(lastEpochBlockMethod) prm.SetMethod(lastEpochBlockMethod)
items, err := c.client.TestInvoke(ctx, prm) items, err := c.client.TestInvoke(prm)
if err != nil { if err != nil {
return 0, fmt.Errorf("test invoke (%s): %w", return 0, fmt.Errorf("test invoke (%s): %w",
lastEpochBlockMethod, err) lastEpochBlockMethod, err)

View file

@ -40,11 +40,11 @@ func (c *Client) UpdateInnerRing(ctx context.Context, p UpdateIRPrm) error {
} }
// GetInnerRingList return current IR list. // GetInnerRingList return current IR list.
func (c *Client) GetInnerRingList(ctx context.Context) (keys.PublicKeys, error) { func (c *Client) GetInnerRingList() (keys.PublicKeys, error) {
invokePrm := client.TestInvokePrm{} invokePrm := client.TestInvokePrm{}
invokePrm.SetMethod(innerRingListMethod) invokePrm.SetMethod(innerRingListMethod)
prms, err := c.client.TestInvoke(ctx, invokePrm) prms, err := c.client.TestInvoke(invokePrm)
if err != nil { if err != nil {
return nil, fmt.Errorf("test invoke (%s): %w", innerRingListMethod, err) return nil, fmt.Errorf("test invoke (%s): %w", innerRingListMethod, err)
} }

View file

@ -1,7 +1,6 @@
package netmap package netmap
import ( import (
"context"
"fmt" "fmt"
netmapcontract "git.frostfs.info/TrueCloudLab/frostfs-contract/netmap" netmapcontract "git.frostfs.info/TrueCloudLab/frostfs-contract/netmap"
@ -12,12 +11,12 @@ import (
// GetNetMapByEpoch calls "snapshotByEpoch" method with the given epoch and // GetNetMapByEpoch calls "snapshotByEpoch" method with the given epoch and
// decodes netmap.NetMap from the response. // decodes netmap.NetMap from the response.
func (c *Client) GetNetMapByEpoch(ctx context.Context, epoch uint64) (*netmap.NetMap, error) { func (c *Client) GetNetMapByEpoch(epoch uint64) (*netmap.NetMap, error) {
invokePrm := client.TestInvokePrm{} invokePrm := client.TestInvokePrm{}
invokePrm.SetMethod(epochSnapshotMethod) invokePrm.SetMethod(epochSnapshotMethod)
invokePrm.SetArgs(epoch) invokePrm.SetArgs(epoch)
res, err := c.client.TestInvoke(ctx, invokePrm) res, err := c.client.TestInvoke(invokePrm)
if err != nil { if err != nil {
return nil, fmt.Errorf("test invoke (%s): %w", return nil, fmt.Errorf("test invoke (%s): %w",
epochSnapshotMethod, err) epochSnapshotMethod, err)
@ -35,11 +34,11 @@ func (c *Client) GetNetMapByEpoch(ctx context.Context, epoch uint64) (*netmap.Ne
// GetCandidates calls "netmapCandidates" method and decodes []netmap.NodeInfo // GetCandidates calls "netmapCandidates" method and decodes []netmap.NodeInfo
// from the response. // from the response.
func (c *Client) GetCandidates(ctx context.Context) ([]netmap.NodeInfo, error) { func (c *Client) GetCandidates() ([]netmap.NodeInfo, error) {
invokePrm := client.TestInvokePrm{} invokePrm := client.TestInvokePrm{}
invokePrm.SetMethod(netMapCandidatesMethod) invokePrm.SetMethod(netMapCandidatesMethod)
res, err := c.client.TestInvoke(ctx, invokePrm) res, err := c.client.TestInvoke(invokePrm)
if err != nil { if err != nil {
return nil, fmt.Errorf("test invoke (%s): %w", netMapCandidatesMethod, err) return nil, fmt.Errorf("test invoke (%s): %w", netMapCandidatesMethod, err)
} }
@ -52,11 +51,11 @@ func (c *Client) GetCandidates(ctx context.Context) ([]netmap.NodeInfo, error) {
} }
// NetMap calls "netmap" method and decode netmap.NetMap from the response. // NetMap calls "netmap" method and decode netmap.NetMap from the response.
func (c *Client) NetMap(ctx context.Context) (*netmap.NetMap, error) { func (c *Client) NetMap() (*netmap.NetMap, error) {
invokePrm := client.TestInvokePrm{} invokePrm := client.TestInvokePrm{}
invokePrm.SetMethod(netMapMethod) invokePrm.SetMethod(netMapMethod)
res, err := c.client.TestInvoke(ctx, invokePrm) res, err := c.client.TestInvoke(invokePrm)
if err != nil { if err != nil {
return nil, fmt.Errorf("test invoke (%s): %w", return nil, fmt.Errorf("test invoke (%s): %w",
netMapMethod, err) netMapMethod, err)

View file

@ -1,7 +1,6 @@
package netmap package netmap
import ( import (
"context"
"fmt" "fmt"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
@ -9,12 +8,12 @@ import (
) )
// GetNetMap calls "snapshot" method and decodes netmap.NetMap from the response. // GetNetMap calls "snapshot" method and decodes netmap.NetMap from the response.
func (c *Client) GetNetMap(ctx context.Context, diff uint64) (*netmap.NetMap, error) { func (c *Client) GetNetMap(diff uint64) (*netmap.NetMap, error) {
prm := client.TestInvokePrm{} prm := client.TestInvokePrm{}
prm.SetMethod(snapshotMethod) prm.SetMethod(snapshotMethod)
prm.SetArgs(diff) prm.SetArgs(diff)
res, err := c.client.TestInvoke(ctx, prm) res, err := c.client.TestInvoke(prm)
if err != nil { if err != nil {
return nil, fmt.Errorf("test invoke (%s): %w", snapshotMethod, err) return nil, fmt.Errorf("test invoke (%s): %w", snapshotMethod, err)
} }

View file

@ -4,7 +4,6 @@ import (
"context" "context"
"fmt" "fmt"
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
@ -206,9 +205,7 @@ func (ti *TestInvokePrm) SetArgs(args ...any) {
} }
// TestInvoke calls TestInvoke method of Client with static internal script hash. // TestInvoke calls TestInvoke method of Client with static internal script hash.
func (s StaticClient) TestInvoke(ctx context.Context, prm TestInvokePrm) ([]stackitem.Item, error) { func (s StaticClient) TestInvoke(prm TestInvokePrm) ([]stackitem.Item, error) {
_, span := tracing.StartSpanFromContext(ctx, "Morph.TestInvoke."+prm.method)
defer span.End()
return s.client.TestInvoke( return s.client.TestInvoke(
s.scScriptHash, s.scScriptHash,
prm.method, prm.method,

Some files were not shown because too many files have changed in this diff Show more