Compare commits

..

4 commits

Author SHA1 Message Date
9f28e2bf0c [#XX] Fix sdk client
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
2023-02-21 15:27:46 +03:00
Denis Kirillov
6f991ab762 services/tree: Use bearer owner as signer
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
2023-02-21 12:21:46 +03:00
fe56f11edc Disable container owner check in tree service
Signed-off-by: Alex Vanin <a.vanin@yadro.com>
2023-02-21 11:47:30 +03:00
56f12c77b9 Allow Impersonate
Signed-off-by: Alex Vanin <a.vanin@yadro.com>
2023-02-21 11:47:28 +03:00
98 changed files with 310 additions and 317 deletions

2
.github/CODEOWNERS vendored
View file

@ -1 +1 @@
* @TrueCloudLab/storage-core @TrueCloudLab/committers * @carpawell @fyrchik @acid-ant

View file

@ -12,7 +12,6 @@ Changelog for FrostFS Node
- `object.delete.tombstone_lifetime` config parameter to set tombstone lifetime in the DELETE service (#2246) - `object.delete.tombstone_lifetime` config parameter to set tombstone lifetime in the DELETE service (#2246)
- Reload config for pprof and metrics on SIGHUP in `neofs-node` (#1868) - Reload config for pprof and metrics on SIGHUP in `neofs-node` (#1868)
- Multiple configs support (#44) - Multiple configs support (#44)
- Parameters `nns-name` and `nns-zone` for command `frostfs-cli container create` (#37)
### Changed ### Changed
- Change `frostfs_node_engine_container_size` to counting sizes of logical objects - Change `frostfs_node_engine_container_size` to counting sizes of logical objects
@ -43,8 +42,6 @@ Changelog for FrostFS Node
- `neo-go` client deadlock on subscription restoration (#2244) - `neo-go` client deadlock on subscription restoration (#2244)
- Possible panic during write-cache initialization (#2234) - Possible panic during write-cache initialization (#2234)
- Do not fetch an object if `meta` is missing it (#61) - Do not fetch an object if `meta` is missing it (#61)
- Create contract wallet only by `init` and `update-config` command (#63)
- Actually use `object.put.pool_size_local` and independent pool for local puts (#64).
### Removed ### Removed
### Updated ### Updated
@ -54,7 +51,6 @@ Changelog for FrostFS Node
- `golang.org/x/term` to `v0.3.0` - `golang.org/x/term` to `v0.3.0`
- `google.golang.org/grpc` to `v1.51.0` - `google.golang.org/grpc` to `v1.51.0`
- `github.com/nats-io/nats.go` to `v1.22.1` - `github.com/nats-io/nats.go` to `v1.22.1`
- `github.com/TrueCloudLab/hrw` to `v.1.1.1`
- Minimum go version to v1.18 - Minimum go version to v1.18
### Updating from v0.35.0 ### Updating from v0.35.0

View file

@ -140,14 +140,14 @@ func setConfigCmd(cmd *cobra.Command, args []string) error {
return wCtx.awaitTx() return wCtx.awaitTx()
} }
func parseConfigPair(kvStr string, force bool) (key string, val any, err error) { func parseConfigPair(kvStr string, force bool) (key string, val interface{}, err error) {
k, v, found := strings.Cut(kvStr, "=") kv := strings.SplitN(kvStr, "=", 2)
if !found { if len(kv) != 2 {
return "", nil, fmt.Errorf("invalid parameter format: must be 'key=val', got: %s", kvStr) return "", nil, fmt.Errorf("invalid parameter format: must be 'key=val', got: %s", kvStr)
} }
key = k key = kv[0]
valRaw := v valRaw := kv[1]
switch key { switch key {
case netmapAuditFeeKey, netmapBasicIncomeRateKey, case netmapAuditFeeKey, netmapBasicIncomeRateKey,
@ -162,7 +162,7 @@ func parseConfigPair(kvStr string, force bool) (key string, val any, err error)
case netmapEigenTrustAlphaKey: case netmapEigenTrustAlphaKey:
// just check that it could // just check that it could
// be parsed correctly // be parsed correctly
_, err = strconv.ParseFloat(v, 64) _, err = strconv.ParseFloat(kv[1], 64)
if err != nil { if err != nil {
err = fmt.Errorf("could not parse %s's value '%s' as float: %w", key, valRaw, err) err = fmt.Errorf("could not parse %s's value '%s' as float: %w", key, valRaw, err)
} }

View file

@ -115,10 +115,8 @@ func newInitializeContext(cmd *cobra.Command, v *viper.Viper) (*initializeContex
return nil, err return nil, err
} }
needContracts := cmd.Name() == "update-contracts" || cmd.Name() == "init"
var w *wallet.Wallet var w *wallet.Wallet
if needContracts { if cmd.Name() != "deploy" {
w, err = openContractWallet(v, cmd, walletDir) w, err = openContractWallet(v, cmd, walletDir)
if err != nil { if err != nil {
return nil, err return nil, err
@ -159,6 +157,7 @@ func newInitializeContext(cmd *cobra.Command, v *viper.Viper) (*initializeContex
} }
} }
needContracts := cmd.Name() == "update-contracts" || cmd.Name() == "init"
if needContracts { if needContracts {
ctrPath, err = cmd.Flags().GetString(contractsInitFlag) ctrPath, err = cmd.Flags().GetString(contractsInitFlag)
if err != nil { if err != nil {

View file

@ -167,7 +167,7 @@ func (c *initializeContext) updateContracts() error {
w := io2.NewBufBinWriter() w := io2.NewBufBinWriter()
var keysParam []any var keysParam []interface{}
// Update script size for a single-node committee is close to the maximum allowed size of 65535. // Update script size for a single-node committee is close to the maximum allowed size of 65535.
// Because of this we want to reuse alphabet contract NEF and manifest for different updates. // Because of this we want to reuse alphabet contract NEF and manifest for different updates.
@ -299,7 +299,7 @@ func (c *initializeContext) updateContracts() error {
func (c *initializeContext) deployContracts() error { func (c *initializeContext) deployContracts() error {
alphaCs := c.getContract(alphabetContract) alphaCs := c.getContract(alphabetContract)
var keysParam []any var keysParam []interface{}
baseGroups := alphaCs.Manifest.Groups baseGroups := alphaCs.Manifest.Groups
@ -510,12 +510,12 @@ func readContractsFromArchive(file io.Reader, names []string) (map[string]*contr
return m, nil return m, nil
} }
func getContractDeployParameters(cs *contractState, deployData []any) []any { func getContractDeployParameters(cs *contractState, deployData []interface{}) []interface{} {
return []any{cs.RawNEF, cs.RawManifest, deployData} return []interface{}{cs.RawNEF, cs.RawManifest, deployData}
} }
func (c *initializeContext) getContractDeployData(ctrName string, keysParam []any) []any { func (c *initializeContext) getContractDeployData(ctrName string, keysParam []interface{}) []interface{} {
items := make([]any, 1, 6) items := make([]interface{}, 1, 6)
items[0] = false // notaryDisabled is false items[0] = false // notaryDisabled is false
switch ctrName { switch ctrName {
@ -551,7 +551,7 @@ func (c *initializeContext) getContractDeployData(ctrName string, keysParam []an
c.Contracts[netmapContract].Hash, c.Contracts[netmapContract].Hash,
c.Contracts[containerContract].Hash) c.Contracts[containerContract].Hash)
case netmapContract: case netmapContract:
configParam := []any{ configParam := []interface{}{
netmapEpochKey, viper.GetInt64(epochDurationInitFlag), netmapEpochKey, viper.GetInt64(epochDurationInitFlag),
netmapMaxObjectSizeKey, viper.GetInt64(maxObjectSizeInitFlag), netmapMaxObjectSizeKey, viper.GetInt64(maxObjectSizeInitFlag),
netmapAuditFeeKey, viper.GetInt64(auditFeeInitFlag), netmapAuditFeeKey, viper.GetInt64(auditFeeInitFlag),
@ -580,8 +580,8 @@ func (c *initializeContext) getContractDeployData(ctrName string, keysParam []an
return items return items
} }
func (c *initializeContext) getAlphabetDeployItems(i, n int) []any { func (c *initializeContext) getAlphabetDeployItems(i, n int) []interface{} {
items := make([]any, 6) items := make([]interface{}, 6)
items[0] = false items[0] = false
items[1] = c.Contracts[netmapContract].Hash items[1] = c.Contracts[netmapContract].Hash
items[2] = c.Contracts[proxyContract].Hash items[2] = c.Contracts[proxyContract].Hash

View file

@ -281,7 +281,7 @@ func nnsIsAvailable(c Client, nnsHash util.Uint160, name string) (bool, error) {
case *rpcclient.Client: case *rpcclient.Client:
return ct.NNSIsAvailable(nnsHash, name) return ct.NNSIsAvailable(nnsHash, name)
default: default:
b, err := unwrap.Bool(invokeFunction(c, nnsHash, "isAvailable", []any{name}, nil)) b, err := unwrap.Bool(invokeFunction(c, nnsHash, "isAvailable", []interface{}{name}, nil))
if err != nil { if err != nil {
return false, fmt.Errorf("`isAvailable`: invalid response: %w", err) return false, fmt.Errorf("`isAvailable`: invalid response: %w", err)
} }

View file

@ -16,7 +16,7 @@ func (c *initializeContext) setNotaryAndAlphabetNodes() error {
return err return err
} }
var pubs []any var pubs []interface{}
for _, acc := range c.Accounts { for _, acc := range c.Accounts {
pubs = append(pubs, acc.PrivateKey().PublicKey().Bytes()) pubs = append(pubs, acc.PrivateKey().PublicKey().Bytes())
} }

View file

@ -190,7 +190,7 @@ func (l *localClient) GetCommittee() (keys.PublicKeys, error) {
func (l *localClient) InvokeFunction(h util.Uint160, method string, sPrm []smartcontract.Parameter, ss []transaction.Signer) (*result.Invoke, error) { func (l *localClient) InvokeFunction(h util.Uint160, method string, sPrm []smartcontract.Parameter, ss []transaction.Signer) (*result.Invoke, error) {
var err error var err error
pp := make([]any, len(sPrm)) pp := make([]interface{}, len(sPrm))
for i, p := range sPrm { for i, p := range sPrm {
pp[i], err = smartcontract.ExpandParameterToEmitable(p) pp[i], err = smartcontract.ExpandParameterToEmitable(p)
if err != nil { if err != nil {
@ -346,7 +346,7 @@ func getSigners(sender *wallet.Account, cosigners []rpcclient.SignerAccount) ([]
} }
func (l *localClient) NEP17BalanceOf(h util.Uint160, acc util.Uint160) (int64, error) { func (l *localClient) NEP17BalanceOf(h util.Uint160, acc util.Uint160) (int64, error) {
res, err := invokeFunction(l, h, "balanceOf", []any{acc}, nil) res, err := invokeFunction(l, h, "balanceOf", []interface{}{acc}, nil)
if err != nil { if err != nil {
return 0, err return 0, err
} }
@ -451,7 +451,7 @@ func (l *localClient) putTransactions() error {
return l.bc.AddBlock(b) return l.bc.AddBlock(b)
} }
func invokeFunction(c Client, h util.Uint160, method string, parameters []any, signers []transaction.Signer) (*result.Invoke, error) { func invokeFunction(c Client, h util.Uint160, method string, parameters []interface{}, signers []transaction.Signer) (*result.Invoke, error) {
w := io.NewBufBinWriter() w := io.NewBufBinWriter()
emit.Array(w.BinWriter, parameters...) emit.Array(w.BinWriter, parameters...)
emit.AppCallNoArgs(w.BinWriter, h, method, callflag.All) emit.AppCallNoArgs(w.BinWriter, h, method, callflag.All)

View file

@ -111,7 +111,7 @@ func depositNotary(cmd *cobra.Command, _ []string) error {
accHash, accHash,
notary.Hash, notary.Hash,
big.NewInt(int64(gasAmount)), big.NewInt(int64(gasAmount)),
[]any{nil, int64(height) + till}, []interface{}{nil, int64(height) + till},
) )
if err != nil { if err != nil {
return fmt.Errorf("could not send tx: %w", err) return fmt.Errorf("could not send tx: %w", err)

View file

@ -27,23 +27,23 @@ func setPolicyCmd(cmd *cobra.Command, args []string) error {
bw := io.NewBufBinWriter() bw := io.NewBufBinWriter()
for i := range args { for i := range args {
k, v, found := strings.Cut(args[i], "=") kv := strings.SplitN(args[i], "=", 2)
if !found { if len(kv) != 2 {
return fmt.Errorf("invalid parameter format, must be Parameter=Value") return fmt.Errorf("invalid parameter format, must be Parameter=Value")
} }
switch k { switch kv[0] {
case execFeeParam, storagePriceParam, setFeeParam: case execFeeParam, storagePriceParam, setFeeParam:
default: default:
return fmt.Errorf("parameter must be one of %s, %s and %s", execFeeParam, storagePriceParam, setFeeParam) return fmt.Errorf("parameter must be one of %s, %s and %s", execFeeParam, storagePriceParam, setFeeParam)
} }
value, err := strconv.ParseUint(v, 10, 32) value, err := strconv.ParseUint(kv[1], 10, 32)
if err != nil { if err != nil {
return fmt.Errorf("can't parse parameter value '%s': %w", args[1], err) return fmt.Errorf("can't parse parameter value '%s': %w", args[1], err)
} }
emit.AppCall(bw.BinWriter, policy.Hash, "set"+k, callflag.All, int64(value)) emit.AppCall(bw.BinWriter, policy.Hash, "set"+kv[0], callflag.All, int64(value))
} }
if err := wCtx.sendCommitteeTx(bw.Bytes(), false); err != nil { if err := wCtx.sendCommitteeTx(bw.Bytes(), false); err != nil {

View file

@ -340,7 +340,7 @@ func manageSubnetAdmins(cmd *cobra.Command, rm bool) error {
} }
// prepare call parameters // prepare call parameters
prm := make([]any, 0, 3) prm := make([]interface{}, 0, 3)
prm = append(prm, id.Marshal()) prm = append(prm, id.Marshal())
var method string var method string
@ -742,7 +742,7 @@ func init() {
) )
} }
func testInvokeMethod(key keys.PrivateKey, method string, args ...any) ([]stackitem.Item, error) { func testInvokeMethod(key keys.PrivateKey, method string, args ...interface{}) ([]stackitem.Item, error) {
c, err := getN3Client(viper.GetViper()) c, err := getN3Client(viper.GetViper())
if err != nil { if err != nil {
return nil, fmt.Errorf("morph client creation: %w", err) return nil, fmt.Errorf("morph client creation: %w", err)
@ -780,7 +780,7 @@ func testInvokeMethod(key keys.PrivateKey, method string, args ...any) ([]stacki
return res.Stack, nil return res.Stack, nil
} }
func invokeMethod(key keys.PrivateKey, tryNotary bool, method string, args ...any) error { func invokeMethod(key keys.PrivateKey, tryNotary bool, method string, args ...interface{}) error {
c, err := getN3Client(viper.GetViper()) c, err := getN3Client(viper.GetViper())
if err != nil { if err != nil {
return fmt.Errorf("morph client creation: %w", err) return fmt.Errorf("morph client creation: %w", err)
@ -821,7 +821,7 @@ func invokeMethod(key keys.PrivateKey, tryNotary bool, method string, args ...an
return nil return nil
} }
func invokeNonNotary(c Client, key keys.PrivateKey, method string, args ...any) error { func invokeNonNotary(c Client, key keys.PrivateKey, method string, args ...interface{}) error {
nnsCs, err := c.GetContractStateByID(1) nnsCs, err := c.GetContractStateByID(1)
if err != nil { if err != nil {
return fmt.Errorf("NNS contract resolving: %w", err) return fmt.Errorf("NNS contract resolving: %w", err)
@ -868,7 +868,7 @@ func invokeNonNotary(c Client, key keys.PrivateKey, method string, args ...any)
return nil return nil
} }
func invokeNotary(c Client, key keys.PrivateKey, method string, notaryHash util.Uint160, args ...any) error { func invokeNotary(c Client, key keys.PrivateKey, method string, notaryHash util.Uint160, args ...interface{}) error {
nnsCs, err := c.GetContractStateByID(1) nnsCs, err := c.GetContractStateByID(1)
if err != nil { if err != nil {
return fmt.Errorf("NNS contract resolving: %w", err) return fmt.Errorf("NNS contract resolving: %w", err)

View file

@ -48,7 +48,7 @@ func GetSDKClient(cmd *cobra.Command, key *ecdsa.PrivateKey, addr network.Addres
) )
prmInit.SetDefaultPrivateKey(*key) prmInit.SetDefaultPrivateKey(*key)
prmInit.ResolveNeoFSFailures() prmInit.ResolveFrostFSFailures()
prmDial.SetServerURI(addr.URIAddr()) prmDial.SetServerURI(addr.URIAddr())
if timeout := viper.GetDuration(commonflags.Timeout); timeout > 0 { if timeout := viper.GetDuration(commonflags.Timeout); timeout > 0 {
// In CLI we can only set a timeout for the whole operation. // In CLI we can only set a timeout for the whole operation.

View file

@ -12,7 +12,7 @@ import (
) )
// PrintVerbose prints to the stdout if the commonflags.Verbose flag is on. // PrintVerbose prints to the stdout if the commonflags.Verbose flag is on.
func PrintVerbose(cmd *cobra.Command, format string, a ...any) { func PrintVerbose(cmd *cobra.Command, format string, a ...interface{}) {
if viper.GetBool(commonflags.Verbose) { if viper.GetBool(commonflags.Verbose) {
cmd.Printf(format+"\n", a...) cmd.Printf(format+"\n", a...)
} }

View file

@ -7,7 +7,6 @@ import (
"strings" "strings"
"time" "time"
containerApi "github.com/TrueCloudLab/frostfs-api-go/v2/container"
internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client" internalclient "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client"
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common" "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common"
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags" "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags"
@ -27,8 +26,6 @@ var (
containerAttributes []string containerAttributes []string
containerAwait bool containerAwait bool
containerName string containerName string
containerNnsName string
containerNnsZone string
containerNoTimestamp bool containerNoTimestamp bool
containerSubnet string containerSubnet string
force bool force bool
@ -163,8 +160,6 @@ func initContainerCreateCmd() {
flags.StringSliceVarP(&containerAttributes, "attributes", "a", nil, "Comma separated pairs of container attributes in form of Key1=Value1,Key2=Value2") flags.StringSliceVarP(&containerAttributes, "attributes", "a", nil, "Comma separated pairs of container attributes in form of Key1=Value1,Key2=Value2")
flags.BoolVar(&containerAwait, "await", false, "Block execution until container is persisted") flags.BoolVar(&containerAwait, "await", false, "Block execution until container is persisted")
flags.StringVar(&containerName, "name", "", "Container name attribute") flags.StringVar(&containerName, "name", "", "Container name attribute")
flags.StringVar(&containerNnsName, "nns-name", "", "Container nns name attribute")
flags.StringVar(&containerNnsZone, "nns-zone", "", "Container nns zone attribute")
flags.BoolVar(&containerNoTimestamp, "disable-timestamp", false, "Disable timestamp container attribute") flags.BoolVar(&containerNoTimestamp, "disable-timestamp", false, "Disable timestamp container attribute")
flags.StringVar(&containerSubnet, "subnet", "", "String representation of container subnetwork") flags.StringVar(&containerSubnet, "subnet", "", "String representation of container subnetwork")
flags.BoolVarP(&force, commonflags.ForceFlag, commonflags.ForceFlagShorthand, false, flags.BoolVarP(&force, commonflags.ForceFlag, commonflags.ForceFlagShorthand, false,
@ -202,12 +197,12 @@ func parseContainerPolicy(cmd *cobra.Command, policyString string) (*netmap.Plac
func parseAttributes(dst *container.Container, attributes []string) error { func parseAttributes(dst *container.Container, attributes []string) error {
for i := range attributes { for i := range attributes {
k, v, found := strings.Cut(attributes[i], attributeDelimiter) kvPair := strings.Split(attributes[i], attributeDelimiter)
if !found { if len(kvPair) != 2 {
return errors.New("invalid container attribute") return errors.New("invalid container attribute")
} }
dst.SetAttribute(k, v) dst.SetAttribute(kvPair[0], kvPair[1])
} }
if !containerNoTimestamp { if !containerNoTimestamp {
@ -218,12 +213,5 @@ func parseAttributes(dst *container.Container, attributes []string) error {
container.SetName(dst, containerName) container.SetName(dst, containerName)
} }
if containerNnsName != "" {
dst.SetAttribute(containerApi.SysAttributeName, containerNnsName)
}
if containerNnsZone != "" {
dst.SetAttribute(containerApi.SysAttributeZone, containerNnsZone)
}
return nil return nil
} }

View file

@ -58,9 +58,9 @@ func listShards(cmd *cobra.Command, _ []string) {
} }
func prettyPrintShardsJSON(cmd *cobra.Command, ii []*control.ShardInfo) { func prettyPrintShardsJSON(cmd *cobra.Command, ii []*control.ShardInfo) {
out := make([]map[string]any, 0, len(ii)) out := make([]map[string]interface{}, 0, len(ii))
for _, i := range ii { for _, i := range ii {
out = append(out, map[string]any{ out = append(out, map[string]interface{}{
"shard_id": base58.Encode(i.Shard_ID), "shard_id": base58.Encode(i.Shard_ID),
"mode": shardModeToString(i.GetMode()), "mode": shardModeToString(i.GetMode()),
"metabase": i.GetMetabasePath(), "metabase": i.GetMetabasePath(),

View file

@ -179,12 +179,12 @@ func parseObjectAttrs(cmd *cobra.Command) ([]object.Attribute, error) {
attrs := make([]object.Attribute, len(rawAttrs), len(rawAttrs)+2) // name + timestamp attributes attrs := make([]object.Attribute, len(rawAttrs), len(rawAttrs)+2) // name + timestamp attributes
for i := range rawAttrs { for i := range rawAttrs {
k, v, found := strings.Cut(rawAttrs[i], "=") kv := strings.SplitN(rawAttrs[i], "=", 2)
if !found { if len(kv) != 2 {
return nil, fmt.Errorf("invalid attribute format: %s", rawAttrs[i]) return nil, fmt.Errorf("invalid attribute format: %s", rawAttrs[i])
} }
attrs[i].SetKey(k) attrs[i].SetKey(kv[0])
attrs[i].SetValue(v) attrs[i].SetValue(kv[1])
} }
disableFilename, _ := cmd.Flags().GetBool("disable-filename") disableFilename, _ := cmd.Flags().GetBool("disable-filename")
@ -218,26 +218,26 @@ func parseObjectNotifications(cmd *cobra.Command) (*object.NotificationInfo, err
return nil, nil return nil, nil
} }
before, after, found := strings.Cut(raw, separator) rawSlice := strings.SplitN(raw, separator, 2)
if !found { if len(rawSlice) != 2 {
return nil, fmt.Errorf("notification must be in the form of: *epoch*%s*topic*, got %s", separator, raw) return nil, fmt.Errorf("notification must be in the form of: *epoch*%s*topic*, got %s", separator, raw)
} }
ni := new(object.NotificationInfo) ni := new(object.NotificationInfo)
epoch, err := strconv.ParseUint(before, 10, 64) epoch, err := strconv.ParseUint(rawSlice[0], 10, 64)
if err != nil { if err != nil {
return nil, fmt.Errorf("could not parse notification epoch %s: %w", before, err) return nil, fmt.Errorf("could not parse notification epoch %s: %w", rawSlice[0], err)
} }
ni.SetEpoch(epoch) ni.SetEpoch(epoch)
if after == "" { if rawSlice[1] == "" {
return nil, fmt.Errorf("incorrect empty topic: use %s to force using default topic", useDefaultTopic) return nil, fmt.Errorf("incorrect empty topic: use %s to force using default topic", useDefaultTopic)
} }
if after != useDefaultTopic { if rawSlice[1] != useDefaultTopic {
ni.SetTopic(after) ni.SetTopic(rawSlice[1])
} }
return ni, nil return ni, nil

View file

@ -154,16 +154,16 @@ func getRangeList(cmd *cobra.Command) ([]*object.Range, error) {
vs := strings.Split(v, ",") vs := strings.Split(v, ",")
rs := make([]*object.Range, len(vs)) rs := make([]*object.Range, len(vs))
for i := range vs { for i := range vs {
before, after, found := strings.Cut(vs[i], rangeSep) r := strings.Split(vs[i], rangeSep)
if !found { if len(r) != 2 {
return nil, fmt.Errorf("invalid range specifier: %s", vs[i]) return nil, fmt.Errorf("invalid range specifier: %s", vs[i])
} }
offset, err := strconv.ParseUint(before, 10, 64) offset, err := strconv.ParseUint(r[0], 10, 64)
if err != nil { if err != nil {
return nil, fmt.Errorf("invalid '%s' range offset specifier: %w", vs[i], err) return nil, fmt.Errorf("invalid '%s' range offset specifier: %w", vs[i], err)
} }
length, err := strconv.ParseUint(after, 10, 64) length, err := strconv.ParseUint(r[1], 10, 64)
if err != nil { if err != nil {
return nil, fmt.Errorf("invalid '%s' range length specifier: %w", vs[i], err) return nil, fmt.Errorf("invalid '%s' range length specifier: %w", vs[i], err)
} }

View file

@ -63,12 +63,12 @@ func parseXHeaders(cmd *cobra.Command) []string {
xs := make([]string, 0, 2*len(xHeaders)) xs := make([]string, 0, 2*len(xHeaders))
for i := range xHeaders { for i := range xHeaders {
k, v, found := strings.Cut(xHeaders[i], "=") kv := strings.SplitN(xHeaders[i], "=", 2)
if !found { if len(kv) != 2 {
panic(fmt.Errorf("invalid X-Header format: %s", xHeaders[i])) panic(fmt.Errorf("invalid X-Header format: %s", xHeaders[i]))
} }
xs = append(xs, k, v) xs = append(xs, kv[0], kv[1])
} }
return xs return xs

View file

@ -127,7 +127,7 @@ type sgHeadReceiver struct {
prm internalclient.HeadObjectPrm prm internalclient.HeadObjectPrm
} }
func (c sgHeadReceiver) Head(addr oid.Address) (any, error) { func (c sgHeadReceiver) Head(addr oid.Address) (interface{}, error) {
c.prm.SetAddress(addr) c.prm.SetAddress(addr)
res, err := internalclient.HeadObject(c.prm) res, err := internalclient.HeadObject(c.prm)

View file

@ -79,14 +79,14 @@ func parseMeta(cmd *cobra.Command) ([]*tree.KeyValue, error) {
pairs := make([]*tree.KeyValue, 0, len(raws)) pairs := make([]*tree.KeyValue, 0, len(raws))
for i := range raws { for i := range raws {
k, v, found := strings.Cut(raws[i], "=") kv := strings.SplitN(raws[i], "=", 2)
if !found { if len(kv) != 2 {
return nil, fmt.Errorf("invalid meta pair format: %s", raws[i]) return nil, fmt.Errorf("invalid meta pair format: %s", raws[i])
} }
var pair tree.KeyValue var pair tree.KeyValue
pair.Key = k pair.Key = kv[0]
pair.Value = []byte(v) pair.Value = []byte(kv[1])
pairs = append(pairs, &pair) pairs = append(pairs, &pair)
} }

View file

@ -226,32 +226,35 @@ func parseEACLTable(tb *eacl.Table, args []string) error {
func parseEACLRecord(args []string) (*eacl.Record, error) { func parseEACLRecord(args []string) (*eacl.Record, error) {
r := new(eacl.Record) r := new(eacl.Record)
for _, arg := range args { for i := range args {
before, after, found := strings.Cut(arg, ":") ss := strings.SplitN(args[i], ":", 2)
switch prefix := strings.ToLower(before); prefix { switch prefix := strings.ToLower(ss[0]); prefix {
case "req", "obj": // filters case "req", "obj": // filters
if !found { if len(ss) != 2 {
return nil, fmt.Errorf("invalid filter or target: %s", arg) return nil, fmt.Errorf("invalid filter or target: %s", args[i])
}
i := strings.Index(ss[1], "=")
if i < 0 {
return nil, fmt.Errorf("invalid filter key-value pair: %s", ss[1])
} }
var key, value string var key, value string
var op eacl.Match var op eacl.Match
var f bool
key, value, f = strings.Cut(after, "!=") if 0 < i && ss[1][i-1] == '!' {
if f { key = ss[1][:i-1]
op = eacl.MatchStringNotEqual op = eacl.MatchStringNotEqual
} else { } else {
key, value, f = strings.Cut(after, "=") key = ss[1][:i]
if !f {
return nil, fmt.Errorf("invalid filter key-value pair: %s", after)
}
op = eacl.MatchStringEqual op = eacl.MatchStringEqual
} }
value = ss[1][i+1:]
typ := eacl.HeaderFromRequest typ := eacl.HeaderFromRequest
if before == "obj" { if ss[0] == "obj" {
typ = eacl.HeaderFromObject typ = eacl.HeaderFromObject
} }
@ -260,8 +263,8 @@ func parseEACLRecord(args []string) (*eacl.Record, error) {
var err error var err error
var pubs []ecdsa.PublicKey var pubs []ecdsa.PublicKey
if found { if len(ss) == 2 {
pubs, err = parseKeyList(after) pubs, err = parseKeyList(ss[1])
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -278,7 +281,7 @@ func parseEACLRecord(args []string) (*eacl.Record, error) {
eacl.AddFormedTarget(r, role, pubs...) eacl.AddFormedTarget(r, role, pubs...)
default: default:
return nil, fmt.Errorf("invalid prefix: %s", before) return nil, fmt.Errorf("invalid prefix: %s", ss[0])
} }
} }

View file

@ -496,10 +496,6 @@ type cfgObjectRoutines struct {
putRemoteCapacity int putRemoteCapacity int
putLocal *ants.Pool
putLocalCapacity int
replicatorPoolSize int replicatorPoolSize int
replication *ants.Pool replication *ants.Pool
@ -838,11 +834,8 @@ func initObjectPool(cfg *config.Config) (pool cfgObjectRoutines) {
optNonBlocking := ants.WithNonblocking(true) optNonBlocking := ants.WithNonblocking(true)
pool.putRemoteCapacity = objectconfig.Put(cfg).PoolSizeRemote() pool.putRemoteCapacity = objectconfig.Put(cfg).PoolSizeRemote()
pool.putRemote, err = ants.NewPool(pool.putRemoteCapacity, optNonBlocking)
fatalOnErr(err)
pool.putLocalCapacity = objectconfig.Put(cfg).PoolSizeLocal() pool.putRemote, err = ants.NewPool(pool.putRemoteCapacity, optNonBlocking)
pool.putLocal, err = ants.NewPool(pool.putLocalCapacity, optNonBlocking)
fatalOnErr(err) fatalOnErr(err)
pool.replicatorPoolSize = replicatorconfig.PoolSize(cfg) pool.replicatorPoolSize = replicatorconfig.PoolSize(cfg)

View file

@ -37,7 +37,7 @@ func (x *Config) Sub(name string) *Config {
// recommended. // recommended.
// //
// Returns nil if config is nil. // Returns nil if config is nil.
func (x *Config) Value(name string) any { func (x *Config) Value(name string) interface{} {
value := x.v.Get(strings.Join(append(x.path, name), separator)) value := x.v.Get(strings.Join(append(x.path, name), separator))
if value != nil || x.defaultPath == nil { if value != nil || x.defaultPath == nil {
return value return value

View file

@ -39,15 +39,3 @@ func (g PutConfig) PoolSizeRemote() int {
return PutPoolSizeDefault return PutPoolSizeDefault
} }
// PoolSizeLocal returns the value of "pool_size_local" config parameter.
//
// Returns PutPoolSizeDefault if the value is not a positive number.
func (g PutConfig) PoolSizeLocal() int {
v := config.Int(g.cfg, "pool_size_local")
if v > 0 {
return int(v)
}
return PutPoolSizeDefault
}

View file

@ -14,7 +14,6 @@ func TestObjectSection(t *testing.T) {
empty := configtest.EmptyConfig() empty := configtest.EmptyConfig()
require.Equal(t, objectconfig.PutPoolSizeDefault, objectconfig.Put(empty).PoolSizeRemote()) require.Equal(t, objectconfig.PutPoolSizeDefault, objectconfig.Put(empty).PoolSizeRemote())
require.Equal(t, objectconfig.PutPoolSizeDefault, objectconfig.Put(empty).PoolSizeLocal())
require.EqualValues(t, objectconfig.DefaultTombstoneLifetime, objectconfig.TombstoneLifetime(empty)) require.EqualValues(t, objectconfig.DefaultTombstoneLifetime, objectconfig.TombstoneLifetime(empty))
}) })
@ -22,7 +21,6 @@ func TestObjectSection(t *testing.T) {
var fileConfigTest = func(c *config.Config) { var fileConfigTest = func(c *config.Config) {
require.Equal(t, 100, objectconfig.Put(c).PoolSizeRemote()) require.Equal(t, 100, objectconfig.Put(c).PoolSizeRemote())
require.Equal(t, 200, objectconfig.Put(c).PoolSizeLocal())
require.EqualValues(t, 10, objectconfig.TombstoneLifetime(c)) require.EqualValues(t, 10, objectconfig.TombstoneLifetime(c))
} }

View file

@ -65,14 +65,14 @@ func loadEnv(path string) {
scanner := bufio.NewScanner(f) scanner := bufio.NewScanner(f)
for scanner.Scan() { for scanner.Scan() {
k, v, found := strings.Cut(scanner.Text(), "=") pair := strings.SplitN(scanner.Text(), "=", 2)
if !found { if len(pair) != 2 {
continue continue
} }
v = strings.Trim(v, `"`) pair[1] = strings.Trim(pair[1], `"`)
err = os.Setenv(k, v) err = os.Setenv(pair[0], pair[1])
if err != nil { if err != nil {
panic("can't set environment variable") panic("can't set environment variable")
} }

View file

@ -275,7 +275,7 @@ func initObjectService(c *cfg) {
putsvc.WithNetworkMapSource(c.netMapSource), putsvc.WithNetworkMapSource(c.netMapSource),
putsvc.WithNetmapKeys(c), putsvc.WithNetmapKeys(c),
putsvc.WithNetworkState(c.cfgNetmap.state), putsvc.WithNetworkState(c.cfgNetmap.state),
putsvc.WithWorkerPools(c.cfgObject.pool.putRemote, c.cfgObject.pool.putLocal), putsvc.WithWorkerPools(c.cfgObject.pool.putRemote),
putsvc.WithLogger(c.log), putsvc.WithLogger(c.log),
) )

View file

@ -50,6 +50,6 @@ func (*OnlyKeyRemoteServerInfo) ExternalAddresses() []string {
const invalidPrmValFmt = "invalid parameter %s (%T):%v" const invalidPrmValFmt = "invalid parameter %s (%T):%v"
func PanicOnPrmValue(n string, v any) { func PanicOnPrmValue(n string, v interface{}) {
panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) panic(fmt.Sprintf(invalidPrmValFmt, n, v, v))
} }

View file

@ -85,7 +85,6 @@ FROSTFS_REPLICATOR_POOL_SIZE=10
# Object service section # Object service section
FROSTFS_OBJECT_PUT_POOL_SIZE_REMOTE=100 FROSTFS_OBJECT_PUT_POOL_SIZE_REMOTE=100
FROSTFS_OBJECT_PUT_POOL_SIZE_LOCAL=200
FROSTFS_OBJECT_DELETE_TOMBSTONE_LIFETIME=10 FROSTFS_OBJECT_DELETE_TOMBSTONE_LIFETIME=10
# Storage engine section # Storage engine section

View file

@ -132,8 +132,7 @@
"tombstone_lifetime": 10 "tombstone_lifetime": 10
}, },
"put": { "put": {
"pool_size_remote": 100, "pool_size_remote": 100
"pool_size_local": 200
} }
}, },
"storage": { "storage": {

View file

@ -111,7 +111,6 @@ object:
tombstone_lifetime: 10 # tombstone "local" lifetime in epochs tombstone_lifetime: 10 # tombstone "local" lifetime in epochs
put: put:
pool_size_remote: 100 # number of async workers for remote PUT operations pool_size_remote: 100 # number of async workers for remote PUT operations
pool_size_local: 200 # number of async workers for local PUT operations
storage: storage:
# note: shard configuration can be omitted for relay node (see `node.relay`) # note: shard configuration can be omitted for relay node (see `node.relay`)

View file

@ -427,4 +427,3 @@ object:
|-----------------------------|-------|---------------|------------------------------------------------------------------------------------------------| |-----------------------------|-------|---------------|------------------------------------------------------------------------------------------------|
| `delete.tombstone_lifetime` | `int` | `5` | Tombstone lifetime for removed objects in epochs. | | `delete.tombstone_lifetime` | `int` | `5` | Tombstone lifetime for removed objects in epochs. |
| `put.pool_size_remote` | `int` | `10` | Max pool size for performing remote `PUT` operations. Used by Policer and Replicator services. | | `put.pool_size_remote` | `int` | `10` | Max pool size for performing remote `PUT` operations. Used by Policer and Replicator services. |
| `put.pool_size_local` | `int` | `10` | Max pool size for performing local `PUT` operations. Used by Policer and Replicator services. |

14
go.mod
View file

@ -6,7 +6,7 @@ require (
github.com/TrueCloudLab/frostfs-api-go/v2 v2.0.0-20221212144048-1351b6656d68 github.com/TrueCloudLab/frostfs-api-go/v2 v2.0.0-20221212144048-1351b6656d68
github.com/TrueCloudLab/frostfs-contract v0.0.0-20221213081248-6c805c1b4e42 github.com/TrueCloudLab/frostfs-contract v0.0.0-20221213081248-6c805c1b4e42
github.com/TrueCloudLab/frostfs-sdk-go v0.0.0-20221214065929-4c779423f556 github.com/TrueCloudLab/frostfs-sdk-go v0.0.0-20221214065929-4c779423f556
github.com/TrueCloudLab/hrw v1.1.1-0.20230227111858-79b208bebf52 github.com/TrueCloudLab/hrw v1.1.0
github.com/TrueCloudLab/tzhash v1.7.0 github.com/TrueCloudLab/tzhash v1.7.0
github.com/cheggaaa/pb v1.0.29 github.com/cheggaaa/pb v1.0.29
github.com/chzyer/readline v1.5.1 github.com/chzyer/readline v1.5.1
@ -39,10 +39,15 @@ require (
gopkg.in/yaml.v3 v3.0.1 gopkg.in/yaml.v3 v3.0.1
) )
replace (
github.com/TrueCloudLab/frostfs-api-go/v2 v2.0.0-20221212144048-1351b6656d68 => github.com/KirillovDenis/frostfs-api-go/v2 v2.11.2-0.20230221082308-ac00938fa447
github.com/TrueCloudLab/frostfs-sdk-go v0.0.0-20221214065929-4c779423f556 => github.com/KirillovDenis/frostfs-sdk-go v0.0.0-20230221122223-9424a67fb108
)
require ( require (
github.com/TrueCloudLab/frostfs-crypto v0.5.0 // indirect github.com/TrueCloudLab/frostfs-crypto v0.5.0 // indirect
github.com/TrueCloudLab/rfc6979 v0.3.0 // indirect github.com/TrueCloudLab/rfc6979 v0.3.0 // indirect
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20221202181307-76fa05c21b12 // indirect
github.com/benbjohnson/clock v1.1.0 // indirect github.com/benbjohnson/clock v1.1.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect
@ -54,7 +59,7 @@ require (
github.com/golang/snappy v0.0.3 // indirect github.com/golang/snappy v0.0.3 // indirect
github.com/google/go-querystring v1.1.0 // indirect github.com/google/go-querystring v1.1.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect github.com/gorilla/websocket v1.4.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/hashicorp/golang-lru v0.6.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect
github.com/holiman/uint256 v1.2.0 // indirect github.com/holiman/uint256 v1.2.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect github.com/inconshreveable/mousetrap v1.0.1 // indirect
@ -89,8 +94,9 @@ require (
github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954 // indirect github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954 // indirect
github.com/twmb/murmur3 v1.1.5 // indirect github.com/twmb/murmur3 v1.1.5 // indirect
github.com/urfave/cli v1.22.5 // indirect github.com/urfave/cli v1.22.5 // indirect
go.uber.org/multierr v1.8.0 // indirect go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.4.0 // indirect golang.org/x/crypto v0.4.0 // indirect
golang.org/x/exp v0.0.0-20221227203929-1b447090c38c // indirect
golang.org/x/net v0.4.0 // indirect golang.org/x/net v0.4.0 // indirect
golang.org/x/sync v0.1.0 // indirect golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.3.0 // indirect golang.org/x/sys v0.3.0 // indirect

27
go.sum
View file

@ -42,18 +42,16 @@ github.com/CityOfZion/neo-go v0.62.1-pre.0.20191114145240-e740fbe708f8/go.mod h1
github.com/CityOfZion/neo-go v0.70.1-pre.0.20191209120015-fccb0085941e/go.mod h1:0enZl0az8xA6PVkwzEOwPWVJGqlt/GO4hA4kmQ5Xzig= github.com/CityOfZion/neo-go v0.70.1-pre.0.20191209120015-fccb0085941e/go.mod h1:0enZl0az8xA6PVkwzEOwPWVJGqlt/GO4hA4kmQ5Xzig=
github.com/CityOfZion/neo-go v0.70.1-pre.0.20191212173117-32ac01130d4c/go.mod h1:JtlHfeqLywZLswKIKFnAp+yzezY4Dji9qlfQKB2OD/I= github.com/CityOfZion/neo-go v0.70.1-pre.0.20191212173117-32ac01130d4c/go.mod h1:JtlHfeqLywZLswKIKFnAp+yzezY4Dji9qlfQKB2OD/I=
github.com/CityOfZion/neo-go v0.71.1-pre.0.20200129171427-f773ec69fb84/go.mod h1:FLI526IrRWHmcsO+mHsCbj64pJZhwQFTLJZu+A4PGOA= github.com/CityOfZion/neo-go v0.71.1-pre.0.20200129171427-f773ec69fb84/go.mod h1:FLI526IrRWHmcsO+mHsCbj64pJZhwQFTLJZu+A4PGOA=
github.com/TrueCloudLab/frostfs-api-go/v2 v2.0.0-20221212144048-1351b6656d68 h1:mwZr15qCuIcWojIOmH6LILPohbWIkknZe9vhBRapmfQ= github.com/KirillovDenis/frostfs-api-go/v2 v2.11.2-0.20230221082308-ac00938fa447 h1:8PH1Wdzdk96XwMQheflK9uS9lsSDtLaE9Wfr1sBq+Ng=
github.com/TrueCloudLab/frostfs-api-go/v2 v2.0.0-20221212144048-1351b6656d68/go.mod h1:u3P6aL/NpAIY5IFRsJhmV+61Q3pJ3BkLENqySkf5zZQ= github.com/KirillovDenis/frostfs-api-go/v2 v2.11.2-0.20230221082308-ac00938fa447/go.mod h1:u3P6aL/NpAIY5IFRsJhmV+61Q3pJ3BkLENqySkf5zZQ=
github.com/KirillovDenis/frostfs-sdk-go v0.0.0-20230221122223-9424a67fb108 h1:EbH3LgjwB+XuaICaWnK/ZnecSzfGSUBlwJ+kT4uOq68=
github.com/KirillovDenis/frostfs-sdk-go v0.0.0-20230221122223-9424a67fb108/go.mod h1:kEJuY2GhRZ3MFBwZvTLMlA2D5mrjjoB+g/Q2Lz1dwyQ=
github.com/TrueCloudLab/frostfs-contract v0.0.0-20221213081248-6c805c1b4e42 h1:P/gisZxTzJ9R3tuYDaQWe0tY6m1Zea3gzdPpNYK+NP4= github.com/TrueCloudLab/frostfs-contract v0.0.0-20221213081248-6c805c1b4e42 h1:P/gisZxTzJ9R3tuYDaQWe0tY6m1Zea3gzdPpNYK+NP4=
github.com/TrueCloudLab/frostfs-contract v0.0.0-20221213081248-6c805c1b4e42/go.mod h1:qmf648elr+FWBZH3hqND8KVrXMnqu/e0z48k+sX8C2s= github.com/TrueCloudLab/frostfs-contract v0.0.0-20221213081248-6c805c1b4e42/go.mod h1:qmf648elr+FWBZH3hqND8KVrXMnqu/e0z48k+sX8C2s=
github.com/TrueCloudLab/frostfs-crypto v0.5.0 h1:ZoLjixSkQv3j1EwZ1WJzMEJY2NR+9nO4Pd8WSyM/RRI= github.com/TrueCloudLab/frostfs-crypto v0.5.0 h1:ZoLjixSkQv3j1EwZ1WJzMEJY2NR+9nO4Pd8WSyM/RRI=
github.com/TrueCloudLab/frostfs-crypto v0.5.0/go.mod h1:775MUewpH8AWpXrimAG2NYWOXB6lpKOI5kqgu+eI5zs= github.com/TrueCloudLab/frostfs-crypto v0.5.0/go.mod h1:775MUewpH8AWpXrimAG2NYWOXB6lpKOI5kqgu+eI5zs=
github.com/TrueCloudLab/frostfs-sdk-go v0.0.0-20221214065929-4c779423f556 h1:Cc1jjYxKPfyw7TIJh3Bje7m8DOSn2dx+2zmr0yusWGw=
github.com/TrueCloudLab/frostfs-sdk-go v0.0.0-20221214065929-4c779423f556/go.mod h1:4ZiG4jNLzrqeJbmZUrPI7wDZhQVPaf0zEIWa/eBsqBg=
github.com/TrueCloudLab/hrw v1.1.0 h1:2U69PpUX1UtMWgh/RAg6D8mQW+/WsxbLNE+19EUhLhY= github.com/TrueCloudLab/hrw v1.1.0 h1:2U69PpUX1UtMWgh/RAg6D8mQW+/WsxbLNE+19EUhLhY=
github.com/TrueCloudLab/hrw v1.1.0/go.mod h1:Pzi8Hy3qx12cew+ajVxgbtDVM4sRG9/gJnJLcL/yRyY= github.com/TrueCloudLab/hrw v1.1.0/go.mod h1:Pzi8Hy3qx12cew+ajVxgbtDVM4sRG9/gJnJLcL/yRyY=
github.com/TrueCloudLab/hrw v1.1.1-0.20230227111858-79b208bebf52 h1:fBeG0EkL7Pa2D0SIiZt3yQYGpP/IvrXg4xEPAZ4Jjys=
github.com/TrueCloudLab/hrw v1.1.1-0.20230227111858-79b208bebf52/go.mod h1:BG6NztCuNc0UFr6MWJ4MM1sUl9lxx6PBRwLmTxdre20=
github.com/TrueCloudLab/rfc6979 v0.3.0 h1:0SYMAfQWh/TjnofqYQHy+s3rmQ5gi0fvOaDbqd60/Ic= github.com/TrueCloudLab/rfc6979 v0.3.0 h1:0SYMAfQWh/TjnofqYQHy+s3rmQ5gi0fvOaDbqd60/Ic=
github.com/TrueCloudLab/rfc6979 v0.3.0/go.mod h1:qylxFXFQ/sMvpZC/8JyWp+mfzk5Zj/KDT5FAbekhobc= github.com/TrueCloudLab/rfc6979 v0.3.0/go.mod h1:qylxFXFQ/sMvpZC/8JyWp+mfzk5Zj/KDT5FAbekhobc=
github.com/TrueCloudLab/tzhash v1.7.0 h1:btGORepc7Dg+n4MxgJxv73c9eYhwSBI5HqsqUBRmJiw= github.com/TrueCloudLab/tzhash v1.7.0 h1:btGORepc7Dg+n4MxgJxv73c9eYhwSBI5HqsqUBRmJiw=
@ -72,8 +70,8 @@ github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGn
github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk= github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521073959-f0d4d129b7f1/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210521073959-f0d4d129b7f1/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY=
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 h1:yL7+Jz0jTC6yykIK/Wh74gnTJnrGr5AyrNMXuA0gves= github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20221202181307-76fa05c21b12 h1:npHgfD4Tl2WJS3AJaMUi5ynGDPUBfkg3U3fCzDyXZ+4=
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20221202181307-76fa05c21b12/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
@ -243,8 +241,9 @@ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/golang-lru v0.6.0 h1:uL2shRDx7RTrOrTCUZEGP/wJUFiUI8QT6E7z5o8jga4=
github.com/hashicorp/golang-lru v0.6.0/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/golang-lru/v2 v2.0.1 h1:5pv5N1lT1fjLg2VQ5KWc7kmucp2x/kvFOnxuVTqZ6x4= github.com/hashicorp/golang-lru/v2 v2.0.1 h1:5pv5N1lT1fjLg2VQ5KWc7kmucp2x/kvFOnxuVTqZ6x4=
github.com/hashicorp/golang-lru/v2 v2.0.1/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/golang-lru/v2 v2.0.1/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
@ -513,8 +512,8 @@ go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
@ -546,6 +545,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20221227203929-1b447090c38c h1:Govq2W3bnHJimHT2ium65kXcI7ZzTniZHcFATnLJM0Q=
golang.org/x/exp v0.0.0-20221227203929-1b447090c38c/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@ -570,7 +571,7 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I=
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@ -778,7 +779,7 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

View file

@ -41,7 +41,7 @@ type (
} }
) )
func panicOnPrmValue(n string, v any) { func panicOnPrmValue(n string, v interface{}) {
panic(fmt.Sprintf("invalid parameter %s (%T):%v", n, v, v)) panic(fmt.Sprintf("invalid parameter %s (%T):%v", n, v, v))
} }

View file

@ -73,18 +73,18 @@ func stringifyAddress(addr oid.Address) string {
} }
func addressFromString(s string) (oid.Address, error) { func addressFromString(s string) (oid.Address, error) {
before, after, found := strings.Cut(s, ".") i := strings.IndexByte(s, '.')
if !found { if i == -1 {
return oid.Address{}, errors.New("invalid address") return oid.Address{}, errors.New("invalid address")
} }
var obj oid.ID var obj oid.ID
if err := obj.DecodeString(before); err != nil { if err := obj.DecodeString(s[:i]); err != nil {
return oid.Address{}, err return oid.Address{}, err
} }
var cnr cid.ID var cnr cid.ID
if err := cnr.DecodeString(after); err != nil { if err := cnr.DecodeString(s[i+1:]); err != nil {
return oid.Address{}, err return oid.Address{}, err
} }

View file

@ -87,7 +87,7 @@ func TestDeleteBigObject(t *testing.T) {
} }
} }
func checkGetError(t *testing.T, e *StorageEngine, addr oid.Address, expected any) { func checkGetError(t *testing.T, e *StorageEngine, addr oid.Address, expected interface{}) {
var getPrm GetPrm var getPrm GetPrm
getPrm.WithAddress(addr) getPrm.WithAddress(addr)

View file

@ -19,7 +19,7 @@ type StorageEngine struct {
mtx *sync.RWMutex mtx *sync.RWMutex
shards map[string]hashedShard shards map[string]shardWrapper
shardPools map[string]util.WorkerPool shardPools map[string]util.WorkerPool
@ -223,7 +223,7 @@ func New(opts ...Option) *StorageEngine {
return &StorageEngine{ return &StorageEngine{
cfg: c, cfg: c,
mtx: new(sync.RWMutex), mtx: new(sync.RWMutex),
shards: make(map[string]hashedShard), shards: make(map[string]shardWrapper),
shardPools: make(map[string]util.WorkerPool), shardPools: make(map[string]util.WorkerPool),
closeCh: make(chan struct{}), closeCh: make(chan struct{}),
setModeCh: make(chan setModeRequest), setModeCh: make(chan setModeRequest),

View file

@ -21,7 +21,6 @@ import (
oidtest "github.com/TrueCloudLab/frostfs-sdk-go/object/id/test" oidtest "github.com/TrueCloudLab/frostfs-sdk-go/object/id/test"
usertest "github.com/TrueCloudLab/frostfs-sdk-go/user/test" usertest "github.com/TrueCloudLab/frostfs-sdk-go/user/test"
"github.com/TrueCloudLab/frostfs-sdk-go/version" "github.com/TrueCloudLab/frostfs-sdk-go/version"
"github.com/TrueCloudLab/hrw"
"github.com/TrueCloudLab/tzhash/tz" "github.com/TrueCloudLab/tzhash/tz"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -87,12 +86,9 @@ func testNewEngineWithShards(shards ...*shard.Shard) *StorageEngine {
panic(err) panic(err)
} }
engine.shards[s.ID().String()] = hashedShard{ engine.shards[s.ID().String()] = shardWrapper{
shardWrapper: shardWrapper{ errorCount: atomic.NewUint32(0),
errorCount: atomic.NewUint32(0), Shard: s,
Shard: s,
},
hash: hrw.Hash([]byte(s.ID().String())),
} }
engine.shardPools[s.ID().String()] = pool engine.shardPools[s.ID().String()] = pool
} }

View file

@ -151,7 +151,7 @@ mainLoop:
return res, err return res, err
} }
hrw.SortHasherSliceByWeightValue(shards, weights, hrw.Hash([]byte(addr.EncodeToString()))) hrw.SortSliceByWeightValue(shards, weights, hrw.Hash([]byte(addr.EncodeToString())))
for j := range shards { for j := range shards {
if _, ok := shardMap[shards[j].ID().String()]; ok { if _, ok := shardMap[shards[j].ID().String()]; ok {
continue continue

View file

@ -16,10 +16,7 @@ import (
var errShardNotFound = logicerr.New("shard not found") var errShardNotFound = logicerr.New("shard not found")
type hashedShard struct { type hashedShard shardWrapper
shardWrapper
hash uint64
}
type metricsWithID struct { type metricsWithID struct {
id string id string
@ -130,12 +127,9 @@ func (e *StorageEngine) addShard(sh *shard.Shard) error {
return fmt.Errorf("shard with id %s was already added", strID) return fmt.Errorf("shard with id %s was already added", strID)
} }
e.shards[strID] = hashedShard{ e.shards[strID] = shardWrapper{
shardWrapper: shardWrapper{ errorCount: atomic.NewUint32(0),
errorCount: atomic.NewUint32(0), Shard: sh,
Shard: sh,
},
hash: hrw.Hash([]byte(strID)),
} }
e.shardPools[strID] = pool e.shardPools[strID] = pool
@ -150,7 +144,7 @@ func (e *StorageEngine) removeShards(ids ...string) {
return return
} }
ss := make([]hashedShard, 0, len(ids)) ss := make([]shardWrapper, 0, len(ids))
e.mtx.Lock() e.mtx.Lock()
for _, id := range ids { for _, id := range ids {
@ -216,7 +210,7 @@ func (e *StorageEngine) sortShardsByWeight(objAddr interface{ EncodeToString() s
weights = append(weights, e.shardWeight(sh.Shard)) weights = append(weights, e.shardWeight(sh.Shard))
} }
hrw.SortHasherSliceByWeightValue(shards, weights, hrw.Hash([]byte(objAddr.EncodeToString()))) hrw.SortSliceByWeightValue(shards, weights, hrw.Hash([]byte(objAddr.EncodeToString())))
return shards return shards
} }
@ -282,5 +276,7 @@ func (e *StorageEngine) HandleNewEpoch(epoch uint64) {
} }
func (s hashedShard) Hash() uint64 { func (s hashedShard) Hash() uint64 {
return s.hash return hrw.Hash(
[]byte(s.Shard.ID().String()),
)
} }

View file

@ -16,7 +16,7 @@ func Write(logger *logger.Logger, fields ...zap.Field) {
// AddressField returns logger's field for object address. // AddressField returns logger's field for object address.
// //
// Address should be type of *object.Address or string. // Address should be type of *object.Address or string.
func AddressField(addr any) zap.Field { func AddressField(addr interface{}) zap.Field {
return zap.Any("address", addr) return zap.Any("address", addr)
} }

View file

@ -179,7 +179,7 @@ func wrapFrostFSError(err error) error {
// Invoke invokes contract method by sending transaction into blockchain. // Invoke invokes contract method by sending transaction into blockchain.
// Supported args types: int64, string, util.Uint160, []byte and bool. // Supported args types: int64, string, util.Uint160, []byte and bool.
func (c *Client) Invoke(contract util.Uint160, fee fixedn.Fixed8, method string, args ...any) error { func (c *Client) Invoke(contract util.Uint160, fee fixedn.Fixed8, method string, args ...interface{}) error {
c.switchLock.RLock() c.switchLock.RLock()
defer c.switchLock.RUnlock() defer c.switchLock.RUnlock()
@ -202,7 +202,7 @@ func (c *Client) Invoke(contract util.Uint160, fee fixedn.Fixed8, method string,
// TestInvoke invokes contract method locally in neo-go node. This method should // TestInvoke invokes contract method locally in neo-go node. This method should
// be used to read data from smart-contract. // be used to read data from smart-contract.
func (c *Client) TestInvoke(contract util.Uint160, method string, args ...any) (res []stackitem.Item, err error) { func (c *Client) TestInvoke(contract util.Uint160, method string, args ...interface{}) (res []stackitem.Item, err error) {
c.switchLock.RLock() c.switchLock.RLock()
defer c.switchLock.RUnlock() defer c.switchLock.RUnlock()
@ -384,7 +384,7 @@ func (c *Client) roleList(r noderoles.Role) (keys.PublicKeys, error) {
// tries to resolve sc.Parameter from the arg. // tries to resolve sc.Parameter from the arg.
// //
// Wraps any error to frostfsError. // Wraps any error to frostfsError.
func toStackParameter(value any) (sc.Parameter, error) { func toStackParameter(value interface{}) (sc.Parameter, error) {
var result = sc.Parameter{ var result = sc.Parameter{
Value: value, Value: value,
} }

View file

@ -10,9 +10,9 @@ import (
func TestToStackParameter(t *testing.T) { func TestToStackParameter(t *testing.T) {
items := []struct { items := []struct {
value any value interface{}
expType sc.ParamType expType sc.ParamType
expVal any expVal interface{}
}{ }{
{ {
value: []byte{1, 2, 3}, value: []byte{1, 2, 3},

View file

@ -191,7 +191,7 @@ func (c *Client) readBoolConfig(key string) (bool, error) {
type SetConfigPrm struct { type SetConfigPrm struct {
id []byte id []byte
key []byte key []byte
value any value interface{}
client.InvokePrmOptional client.InvokePrmOptional
} }
@ -207,7 +207,7 @@ func (s *SetConfigPrm) SetKey(key []byte) {
} }
// SetValue sets value of the config value. // SetValue sets value of the config value.
func (s *SetConfigPrm) SetValue(value any) { func (s *SetConfigPrm) SetValue(value interface{}) {
s.value = value s.value = value
} }
@ -359,7 +359,7 @@ 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(key []byte, assert func(stackitem.Item) (any, error)) (any, error) { func (c *Client) config(key []byte, assert func(stackitem.Item) (interface{}, error)) (interface{}, error) {
prm := client.TestInvokePrm{} prm := client.TestInvokePrm{}
prm.SetMethod(configMethod) prm.SetMethod(configMethod)
prm.SetArgs(key) prm.SetArgs(key)
@ -383,17 +383,17 @@ func (c *Client) config(key []byte, assert func(stackitem.Item) (any, error)) (a
} }
// IntegerAssert converts stack item to int64. // IntegerAssert converts stack item to int64.
func IntegerAssert(item stackitem.Item) (any, error) { func IntegerAssert(item stackitem.Item) (interface{}, error) {
return client.IntFromStackItem(item) return client.IntFromStackItem(item)
} }
// StringAssert converts stack item to string. // StringAssert converts stack item to string.
func StringAssert(item stackitem.Item) (any, error) { func StringAssert(item stackitem.Item) (interface{}, error) {
return client.StringFromStackItem(item) return client.StringFromStackItem(item)
} }
// BoolAssert converts stack item to bool. // BoolAssert converts stack item to bool.
func BoolAssert(item stackitem.Item) (any, error) { func BoolAssert(item stackitem.Item) (interface{}, error) {
return client.BoolFromStackItem(item) return client.BoolFromStackItem(item)
} }

View file

@ -194,7 +194,7 @@ func (c *Client) depositNotary(amount fixedn.Fixed8, till int64) (res util.Uint2
c.accAddr, c.accAddr,
c.notary.notary, c.notary.notary,
big.NewInt(int64(amount)), big.NewInt(int64(amount)),
[]any{c.acc.PrivateKey().GetScriptHash(), till}) []interface{}{c.acc.PrivateKey().GetScriptHash(), till})
if err != nil { if err != nil {
if !errors.Is(err, neorpc.ErrAlreadyExists) { if !errors.Is(err, neorpc.ErrAlreadyExists) {
return util.Uint256{}, fmt.Errorf("can't make notary deposit: %w", err) return util.Uint256{}, fmt.Errorf("can't make notary deposit: %w", err)
@ -354,7 +354,7 @@ func (c *Client) UpdateNeoFSAlphabetList(prm UpdateAlphabetListPrm) error {
// it fallbacks to a simple `Invoke()`. // it fallbacks to a simple `Invoke()`.
// //
// `nonce` and `vub` are used only if notary is enabled. // `nonce` and `vub` are used only if notary is enabled.
func (c *Client) NotaryInvoke(contract util.Uint160, fee fixedn.Fixed8, nonce uint32, vub *uint32, method string, args ...any) error { func (c *Client) NotaryInvoke(contract util.Uint160, fee fixedn.Fixed8, nonce uint32, vub *uint32, method string, args ...interface{}) error {
c.switchLock.RLock() c.switchLock.RLock()
defer c.switchLock.RUnlock() defer c.switchLock.RUnlock()
@ -374,7 +374,7 @@ func (c *Client) NotaryInvoke(contract util.Uint160, fee fixedn.Fixed8, nonce ui
// not expected to be signed by the current node. // not expected to be signed by the current node.
// //
// Considered to be used by non-IR nodes. // Considered to be used by non-IR nodes.
func (c *Client) NotaryInvokeNotAlpha(contract util.Uint160, fee fixedn.Fixed8, method string, args ...any) error { func (c *Client) NotaryInvokeNotAlpha(contract util.Uint160, fee fixedn.Fixed8, method string, args ...interface{}) error {
c.switchLock.RLock() c.switchLock.RLock()
defer c.switchLock.RUnlock() defer c.switchLock.RUnlock()
@ -440,12 +440,12 @@ func (c *Client) NotarySignAndInvokeTX(mainTx *transaction.Transaction) error {
return nil return nil
} }
func (c *Client) notaryInvokeAsCommittee(method string, nonce, vub uint32, args ...any) error { func (c *Client) notaryInvokeAsCommittee(method string, nonce, vub uint32, args ...interface{}) error {
designate := c.GetDesignateHash() designate := c.GetDesignateHash()
return c.notaryInvoke(true, true, designate, nonce, &vub, method, args...) return c.notaryInvoke(true, true, designate, nonce, &vub, method, args...)
} }
func (c *Client) notaryInvoke(committee, invokedByAlpha bool, contract util.Uint160, nonce uint32, vub *uint32, method string, args ...any) error { func (c *Client) notaryInvoke(committee, invokedByAlpha bool, contract util.Uint160, nonce uint32, vub *uint32, method string, args ...interface{}) error {
alphabetList, err := c.notary.alphabetSource() // prepare arguments for test invocation alphabetList, err := c.notary.alphabetSource() // prepare arguments for test invocation
if err != nil { if err != nil {
return err return err
@ -750,7 +750,7 @@ func (c *Client) depositExpirationOf() (int64, error) {
return currentTillBig.Int64(), nil return currentTillBig.Int64(), nil
} }
func invocationParams(args ...any) ([]sc.Parameter, error) { func invocationParams(args ...interface{}) ([]sc.Parameter, error) {
params := make([]sc.Parameter, 0, len(args)) params := make([]sc.Parameter, 0, len(args))
for i := range args { for i := range args {

View file

@ -151,7 +151,7 @@ func (s StaticClient) Invoke(prm InvokePrm) error {
// TestInvokePrm groups parameters of the TestInvoke operation. // TestInvokePrm groups parameters of the TestInvoke operation.
type TestInvokePrm struct { type TestInvokePrm struct {
method string method string
args []any args []interface{}
} }
// SetMethod sets method of the contract to call. // SetMethod sets method of the contract to call.
@ -160,7 +160,7 @@ func (ti *TestInvokePrm) SetMethod(method string) {
} }
// SetArgs sets arguments of the contact call. // SetArgs sets arguments of the contact call.
func (ti *TestInvokePrm) SetArgs(args ...any) { func (ti *TestInvokePrm) SetArgs(args ...interface{}) {
ti.args = args ti.args = args
} }

View file

@ -52,7 +52,7 @@ type ManageAdminsRes struct{}
func (x Client) ManageAdmins(prm ManageAdminsPrm) (*ManageAdminsPrm, error) { func (x Client) ManageAdmins(prm ManageAdminsPrm) (*ManageAdminsPrm, error) {
var method string var method string
args := make([]any, 1, 3) args := make([]interface{}, 1, 3)
args[0] = prm.subnet args[0] = prm.subnet
if prm.client { if prm.client {

View file

@ -8,7 +8,7 @@ import (
// UserAllowedPrm groups parameters of UserAllowed method of Subnet contract. // UserAllowedPrm groups parameters of UserAllowed method of Subnet contract.
type UserAllowedPrm struct { type UserAllowedPrm struct {
args [2]any args [2]interface{}
} }
// SetID sets identifier of the subnet in a binary FrostFS API protocol format. // SetID sets identifier of the subnet in a binary FrostFS API protocol format.
@ -64,7 +64,7 @@ type ManageClientsPrm struct {
// remove or add client // remove or add client
rm bool rm bool
args [3]any args [3]interface{}
} }
// SetRemove marks client to be removed. By default, client is added. // SetRemove marks client to be removed. By default, client is added.

View file

@ -9,7 +9,7 @@ import (
type DeletePrm struct { type DeletePrm struct {
cliPrm client.InvokePrm cliPrm client.InvokePrm
args [1]any args [1]interface{}
} }
// SetTxHash sets hash of the transaction which spawned the notification. // SetTxHash sets hash of the transaction which spawned the notification.

View file

@ -8,7 +8,7 @@ import (
// GetPrm groups parameters of Get method of Subnet contract. // GetPrm groups parameters of Get method of Subnet contract.
type GetPrm struct { type GetPrm struct {
args [1]any args [1]interface{}
} }
// SetID sets identifier of the subnet to be read in a binary FrostFS API protocol format. // SetID sets identifier of the subnet to be read in a binary FrostFS API protocol format.

View file

@ -10,7 +10,7 @@ import (
type NodeAllowedPrm struct { type NodeAllowedPrm struct {
cliPrm client.TestInvokePrm cliPrm client.TestInvokePrm
args [2]any args [2]interface{}
} }
// SetID sets identifier of the subnet of the node in a binary FrostFS API protocol format. // SetID sets identifier of the subnet of the node in a binary FrostFS API protocol format.

View file

@ -9,7 +9,7 @@ type ManageNodesPrm struct {
// remove or add node // remove or add node
rm bool rm bool
args [2]any args [2]interface{}
} }
// SetRemove marks node to be removed. By default, node is added. // SetRemove marks node to be removed. By default, node is added.

View file

@ -9,7 +9,7 @@ import (
type PutPrm struct { type PutPrm struct {
cliPrm client.InvokePrm cliPrm client.InvokePrm
args [3]any args [3]interface{}
} }
// SetTxHash sets hash of the transaction which spawned the notification. // SetTxHash sets hash of the transaction which spawned the notification.

View file

@ -341,7 +341,7 @@ func TestPrepare_CorrectNR(t *testing.T) {
tests := []struct { tests := []struct {
hash util.Uint160 hash util.Uint160
method string method string
args []any args []interface{}
}{ }{
{ {
scriptHash, scriptHash,
@ -351,10 +351,10 @@ func TestPrepare_CorrectNR(t *testing.T) {
{ {
scriptHash, scriptHash,
"test2", "test2",
[]any{ []interface{}{
int64(4), int64(4),
"test", "test",
[]any{ []interface{}{
int64(4), int64(4),
false, false,
true, true,
@ -416,7 +416,7 @@ func alphaKeysSource() client.AlphabetKeys {
} }
} }
func script(hash util.Uint160, method string, args ...any) []byte { func script(hash util.Uint160, method string, args ...interface{}) []byte {
bw := io.NewBufBinWriter() bw := io.NewBufBinWriter()
if len(args) > 0 { if len(args) > 0 {

View file

@ -25,7 +25,7 @@ func NewResponseService(accSvc Server, respSvc *response.Service) Server {
func (s *responseService) Balance(ctx context.Context, req *accounting.BalanceRequest) (*accounting.BalanceResponse, error) { func (s *responseService) Balance(ctx context.Context, req *accounting.BalanceRequest) (*accounting.BalanceResponse, error) {
resp, err := s.respSvc.HandleUnaryRequest(ctx, req, resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.Balance(ctx, req.(*accounting.BalanceRequest)) return s.svc.Balance(ctx, req.(*accounting.BalanceRequest))
}, },
) )

View file

@ -23,7 +23,7 @@ func NewSignService(key *ecdsa.PrivateKey, svc Server) Server {
func (s *signService) Balance(ctx context.Context, req *accounting.BalanceRequest) (*accounting.BalanceResponse, error) { func (s *signService) Balance(ctx context.Context, req *accounting.BalanceRequest) (*accounting.BalanceResponse, error) {
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.Balance(ctx, req.(*accounting.BalanceRequest)) return s.svc.Balance(ctx, req.(*accounting.BalanceRequest))
}, },
func() util.ResponseMessage { func() util.ResponseMessage {

View file

@ -57,7 +57,7 @@ type Controller struct {
const invalidPrmValFmt = "invalid parameter %s (%T):%v" const invalidPrmValFmt = "invalid parameter %s (%T):%v"
func panicOnPrmValue(n string, v any) { func panicOnPrmValue(n string, v interface{}) {
panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) panic(fmt.Sprintf(invalidPrmValFmt, n, v, v))
} }

View file

@ -27,7 +27,7 @@ type Builder struct {
const invalidPrmValFmt = "invalid parameter %s (%T):%v" const invalidPrmValFmt = "invalid parameter %s (%T):%v"
func panicOnPrmValue(n string, v any) { func panicOnPrmValue(n string, v interface{}) {
panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) panic(fmt.Sprintf(invalidPrmValFmt, n, v, v))
} }

View file

@ -51,7 +51,7 @@ type Router struct {
const invalidPrmValFmt = "invalid parameter %s (%T):%v" const invalidPrmValFmt = "invalid parameter %s (%T):%v"
func panicOnPrmValue(n string, v any) { func panicOnPrmValue(n string, v interface{}) {
panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) panic(fmt.Sprintf(invalidPrmValFmt, n, v, v))
} }

View file

@ -25,7 +25,7 @@ func NewResponseService(cnrSvc Server, respSvc *response.Service) Server {
func (s *responseService) Put(ctx context.Context, req *container.PutRequest) (*container.PutResponse, error) { func (s *responseService) Put(ctx context.Context, req *container.PutRequest) (*container.PutResponse, error) {
resp, err := s.respSvc.HandleUnaryRequest(ctx, req, resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.Put(ctx, req.(*container.PutRequest)) return s.svc.Put(ctx, req.(*container.PutRequest))
}, },
) )
@ -38,7 +38,7 @@ func (s *responseService) Put(ctx context.Context, req *container.PutRequest) (*
func (s *responseService) Delete(ctx context.Context, req *container.DeleteRequest) (*container.DeleteResponse, error) { func (s *responseService) Delete(ctx context.Context, req *container.DeleteRequest) (*container.DeleteResponse, error) {
resp, err := s.respSvc.HandleUnaryRequest(ctx, req, resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.Delete(ctx, req.(*container.DeleteRequest)) return s.svc.Delete(ctx, req.(*container.DeleteRequest))
}, },
) )
@ -51,7 +51,7 @@ func (s *responseService) Delete(ctx context.Context, req *container.DeleteReque
func (s *responseService) Get(ctx context.Context, req *container.GetRequest) (*container.GetResponse, error) { func (s *responseService) Get(ctx context.Context, req *container.GetRequest) (*container.GetResponse, error) {
resp, err := s.respSvc.HandleUnaryRequest(ctx, req, resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.Get(ctx, req.(*container.GetRequest)) return s.svc.Get(ctx, req.(*container.GetRequest))
}, },
) )
@ -64,7 +64,7 @@ func (s *responseService) Get(ctx context.Context, req *container.GetRequest) (*
func (s *responseService) List(ctx context.Context, req *container.ListRequest) (*container.ListResponse, error) { func (s *responseService) List(ctx context.Context, req *container.ListRequest) (*container.ListResponse, error) {
resp, err := s.respSvc.HandleUnaryRequest(ctx, req, resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.List(ctx, req.(*container.ListRequest)) return s.svc.List(ctx, req.(*container.ListRequest))
}, },
) )
@ -77,7 +77,7 @@ func (s *responseService) List(ctx context.Context, req *container.ListRequest)
func (s *responseService) SetExtendedACL(ctx context.Context, req *container.SetExtendedACLRequest) (*container.SetExtendedACLResponse, error) { func (s *responseService) SetExtendedACL(ctx context.Context, req *container.SetExtendedACLRequest) (*container.SetExtendedACLResponse, error) {
resp, err := s.respSvc.HandleUnaryRequest(ctx, req, resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.SetExtendedACL(ctx, req.(*container.SetExtendedACLRequest)) return s.svc.SetExtendedACL(ctx, req.(*container.SetExtendedACLRequest))
}, },
) )
@ -90,7 +90,7 @@ func (s *responseService) SetExtendedACL(ctx context.Context, req *container.Set
func (s *responseService) GetExtendedACL(ctx context.Context, req *container.GetExtendedACLRequest) (*container.GetExtendedACLResponse, error) { func (s *responseService) GetExtendedACL(ctx context.Context, req *container.GetExtendedACLRequest) (*container.GetExtendedACLResponse, error) {
resp, err := s.respSvc.HandleUnaryRequest(ctx, req, resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.GetExtendedACL(ctx, req.(*container.GetExtendedACLRequest)) return s.svc.GetExtendedACL(ctx, req.(*container.GetExtendedACLRequest))
}, },
) )
@ -103,7 +103,7 @@ func (s *responseService) GetExtendedACL(ctx context.Context, req *container.Get
func (s *responseService) AnnounceUsedSpace(ctx context.Context, req *container.AnnounceUsedSpaceRequest) (*container.AnnounceUsedSpaceResponse, error) { func (s *responseService) AnnounceUsedSpace(ctx context.Context, req *container.AnnounceUsedSpaceRequest) (*container.AnnounceUsedSpaceResponse, error) {
resp, err := s.respSvc.HandleUnaryRequest(ctx, req, resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.AnnounceUsedSpace(ctx, req.(*container.AnnounceUsedSpaceRequest)) return s.svc.AnnounceUsedSpace(ctx, req.(*container.AnnounceUsedSpaceRequest))
}, },
) )

View file

@ -23,7 +23,7 @@ func NewSignService(key *ecdsa.PrivateKey, svc Server) Server {
func (s *signService) Put(ctx context.Context, req *container.PutRequest) (*container.PutResponse, error) { func (s *signService) Put(ctx context.Context, req *container.PutRequest) (*container.PutResponse, error) {
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.Put(ctx, req.(*container.PutRequest)) return s.svc.Put(ctx, req.(*container.PutRequest))
}, },
func() util.ResponseMessage { func() util.ResponseMessage {
@ -39,7 +39,7 @@ func (s *signService) Put(ctx context.Context, req *container.PutRequest) (*cont
func (s *signService) Delete(ctx context.Context, req *container.DeleteRequest) (*container.DeleteResponse, error) { func (s *signService) Delete(ctx context.Context, req *container.DeleteRequest) (*container.DeleteResponse, error) {
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.Delete(ctx, req.(*container.DeleteRequest)) return s.svc.Delete(ctx, req.(*container.DeleteRequest))
}, },
func() util.ResponseMessage { func() util.ResponseMessage {
@ -55,7 +55,7 @@ func (s *signService) Delete(ctx context.Context, req *container.DeleteRequest)
func (s *signService) Get(ctx context.Context, req *container.GetRequest) (*container.GetResponse, error) { func (s *signService) Get(ctx context.Context, req *container.GetRequest) (*container.GetResponse, error) {
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.Get(ctx, req.(*container.GetRequest)) return s.svc.Get(ctx, req.(*container.GetRequest))
}, },
func() util.ResponseMessage { func() util.ResponseMessage {
@ -71,7 +71,7 @@ func (s *signService) Get(ctx context.Context, req *container.GetRequest) (*cont
func (s *signService) List(ctx context.Context, req *container.ListRequest) (*container.ListResponse, error) { func (s *signService) List(ctx context.Context, req *container.ListRequest) (*container.ListResponse, error) {
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.List(ctx, req.(*container.ListRequest)) return s.svc.List(ctx, req.(*container.ListRequest))
}, },
func() util.ResponseMessage { func() util.ResponseMessage {
@ -87,7 +87,7 @@ func (s *signService) List(ctx context.Context, req *container.ListRequest) (*co
func (s *signService) SetExtendedACL(ctx context.Context, req *container.SetExtendedACLRequest) (*container.SetExtendedACLResponse, error) { func (s *signService) SetExtendedACL(ctx context.Context, req *container.SetExtendedACLRequest) (*container.SetExtendedACLResponse, error) {
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.SetExtendedACL(ctx, req.(*container.SetExtendedACLRequest)) return s.svc.SetExtendedACL(ctx, req.(*container.SetExtendedACLRequest))
}, },
func() util.ResponseMessage { func() util.ResponseMessage {
@ -103,7 +103,7 @@ func (s *signService) SetExtendedACL(ctx context.Context, req *container.SetExte
func (s *signService) GetExtendedACL(ctx context.Context, req *container.GetExtendedACLRequest) (*container.GetExtendedACLResponse, error) { func (s *signService) GetExtendedACL(ctx context.Context, req *container.GetExtendedACLRequest) (*container.GetExtendedACLResponse, error) {
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.GetExtendedACL(ctx, req.(*container.GetExtendedACLRequest)) return s.svc.GetExtendedACL(ctx, req.(*container.GetExtendedACLRequest))
}, },
func() util.ResponseMessage { func() util.ResponseMessage {
@ -119,7 +119,7 @@ func (s *signService) GetExtendedACL(ctx context.Context, req *container.GetExte
func (s *signService) AnnounceUsedSpace(ctx context.Context, req *container.AnnounceUsedSpaceRequest) (*container.AnnounceUsedSpaceResponse, error) { func (s *signService) AnnounceUsedSpace(ctx context.Context, req *container.AnnounceUsedSpaceRequest) (*container.AnnounceUsedSpaceResponse, error) {
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.AnnounceUsedSpace(ctx, req.(*container.AnnounceUsedSpaceRequest)) return s.svc.AnnounceUsedSpace(ctx, req.(*container.AnnounceUsedSpaceRequest))
}, },
func() util.ResponseMessage { func() util.ResponseMessage {

View file

@ -15,7 +15,7 @@ type Server struct {
allowedKeys [][]byte allowedKeys [][]byte
} }
func panicOnPrmValue(n string, v any) { func panicOnPrmValue(n string, v interface{}) {
const invalidPrmValFmt = "invalid %s parameter (%T): %v" const invalidPrmValFmt = "invalid %s parameter (%T): %v"
panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) panic(fmt.Sprintf(invalidPrmValFmt, n, v, v))
} }

View file

@ -25,7 +25,7 @@ func NewResponseService(nmSvc Server, respSvc *response.Service) Server {
func (s *responseService) LocalNodeInfo(ctx context.Context, req *netmap.LocalNodeInfoRequest) (*netmap.LocalNodeInfoResponse, error) { func (s *responseService) LocalNodeInfo(ctx context.Context, req *netmap.LocalNodeInfoRequest) (*netmap.LocalNodeInfoResponse, error) {
resp, err := s.respSvc.HandleUnaryRequest(ctx, req, resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.LocalNodeInfo(ctx, req.(*netmap.LocalNodeInfoRequest)) return s.svc.LocalNodeInfo(ctx, req.(*netmap.LocalNodeInfoRequest))
}, },
) )
@ -38,7 +38,7 @@ func (s *responseService) LocalNodeInfo(ctx context.Context, req *netmap.LocalNo
func (s *responseService) NetworkInfo(ctx context.Context, req *netmap.NetworkInfoRequest) (*netmap.NetworkInfoResponse, error) { func (s *responseService) NetworkInfo(ctx context.Context, req *netmap.NetworkInfoRequest) (*netmap.NetworkInfoResponse, error) {
resp, err := s.respSvc.HandleUnaryRequest(ctx, req, resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.NetworkInfo(ctx, req.(*netmap.NetworkInfoRequest)) return s.svc.NetworkInfo(ctx, req.(*netmap.NetworkInfoRequest))
}, },
) )
@ -51,7 +51,7 @@ func (s *responseService) NetworkInfo(ctx context.Context, req *netmap.NetworkIn
func (s *responseService) Snapshot(ctx context.Context, req *netmap.SnapshotRequest) (*netmap.SnapshotResponse, error) { func (s *responseService) Snapshot(ctx context.Context, req *netmap.SnapshotRequest) (*netmap.SnapshotResponse, error) {
resp, err := s.respSvc.HandleUnaryRequest(ctx, req, resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.Snapshot(ctx, req.(*netmap.SnapshotRequest)) return s.svc.Snapshot(ctx, req.(*netmap.SnapshotRequest))
}, },
) )

View file

@ -25,7 +25,7 @@ func (s *signService) LocalNodeInfo(
ctx context.Context, ctx context.Context,
req *netmap.LocalNodeInfoRequest) (*netmap.LocalNodeInfoResponse, error) { req *netmap.LocalNodeInfoRequest) (*netmap.LocalNodeInfoResponse, error) {
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.LocalNodeInfo(ctx, req.(*netmap.LocalNodeInfoRequest)) return s.svc.LocalNodeInfo(ctx, req.(*netmap.LocalNodeInfoRequest))
}, },
func() util.ResponseMessage { func() util.ResponseMessage {
@ -41,7 +41,7 @@ func (s *signService) LocalNodeInfo(
func (s *signService) NetworkInfo(ctx context.Context, req *netmap.NetworkInfoRequest) (*netmap.NetworkInfoResponse, error) { func (s *signService) NetworkInfo(ctx context.Context, req *netmap.NetworkInfoRequest) (*netmap.NetworkInfoResponse, error) {
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.NetworkInfo(ctx, req.(*netmap.NetworkInfoRequest)) return s.svc.NetworkInfo(ctx, req.(*netmap.NetworkInfoRequest))
}, },
func() util.ResponseMessage { func() util.ResponseMessage {
@ -57,7 +57,7 @@ func (s *signService) NetworkInfo(ctx context.Context, req *netmap.NetworkInfoRe
func (s *signService) Snapshot(ctx context.Context, req *netmap.SnapshotRequest) (*netmap.SnapshotResponse, error) { func (s *signService) Snapshot(ctx context.Context, req *netmap.SnapshotRequest) (*netmap.SnapshotResponse, error) {
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.Snapshot(ctx, req.(*netmap.SnapshotRequest)) return s.svc.Snapshot(ctx, req.(*netmap.SnapshotRequest))
}, },
func() util.ResponseMessage { func() util.ResponseMessage {

View file

@ -52,7 +52,7 @@ type Notificator struct {
// Panics if any field of the passed Prm structure is not set/set // Panics if any field of the passed Prm structure is not set/set
// to nil. // to nil.
func New(prm *Prm) *Notificator { func New(prm *Prm) *Notificator {
panicOnNil := func(v any, name string) { panicOnNil := func(v interface{}, name string) {
if v == nil { if v == nil {
panic(fmt.Sprintf("Notificator constructor: %s is nil\n", name)) panic(fmt.Sprintf("Notificator constructor: %s is nil\n", name))
} }

View file

@ -71,7 +71,7 @@ var (
// NewChecker creates Checker. // NewChecker creates Checker.
// Panics if at least one of the parameter is nil. // Panics if at least one of the parameter is nil.
func NewChecker(prm *CheckerPrm) *Checker { func NewChecker(prm *CheckerPrm) *Checker {
panicOnNil := func(fieldName string, field any) { panicOnNil := func(fieldName string, field interface{}) {
if field == nil { if field == nil {
panic(fmt.Sprintf("incorrect field %s (%T): %v", fieldName, field, field)) panic(fmt.Sprintf("incorrect field %s (%T): %v", fieldName, field, field))
} }
@ -118,21 +118,23 @@ func (c *Checker) StickyBitCheck(info v2.RequestInfo, owner user.ID) bool {
} }
// CheckEACL is a main check function for extended ACL. // CheckEACL is a main check function for extended ACL.
func (c *Checker) CheckEACL(msg any, reqInfo v2.RequestInfo) error { func (c *Checker) CheckEACL(msg interface{}, reqInfo v2.RequestInfo) error {
basicACL := reqInfo.BasicACL() basicACL := reqInfo.BasicACL()
if !basicACL.Extendable() { if !basicACL.Extendable() {
return nil return nil
} }
bearerTok := reqInfo.Bearer()
impersonate := bearerTok != nil && bearerTok.Impersonate()
// if bearer token is not allowed, then ignore it // if bearer token is not allowed, then ignore it
if !basicACL.AllowedBearerRules(reqInfo.Operation()) { if impersonate || !basicACL.AllowedBearerRules(reqInfo.Operation()) {
reqInfo.CleanBearer() reqInfo.CleanBearer()
} }
var table eaclSDK.Table var table eaclSDK.Table
cnr := reqInfo.ContainerID() cnr := reqInfo.ContainerID()
bearerTok := reqInfo.Bearer()
if bearerTok == nil { if bearerTok == nil {
eaclInfo, err := c.eaclSrc.GetEACL(cnr) eaclInfo, err := c.eaclSrc.GetEACL(cnr)
if err != nil { if err != nil {

View file

@ -2,6 +2,7 @@ package v2
import ( import (
"crypto/ecdsa" "crypto/ecdsa"
"crypto/elliptic"
"fmt" "fmt"
sessionV2 "github.com/TrueCloudLab/frostfs-api-go/v2/session" sessionV2 "github.com/TrueCloudLab/frostfs-api-go/v2/session"
@ -32,7 +33,7 @@ type RequestInfo struct {
bearer *bearer.Token // bearer token of request bearer *bearer.Token // bearer token of request
srcRequest any srcRequest interface{}
} }
func (r *RequestInfo) SetBasicACL(basicACL acl.Basic) { func (r *RequestInfo) SetBasicACL(basicACL acl.Basic) {
@ -48,7 +49,7 @@ func (r *RequestInfo) SetSenderKey(senderKey []byte) {
} }
// Request returns raw API request. // Request returns raw API request.
func (r RequestInfo) Request() any { func (r RequestInfo) Request() interface{} {
return r.srcRequest return r.srcRequest
} }
@ -103,7 +104,7 @@ type MetaWithToken struct {
vheader *sessionV2.RequestVerificationHeader vheader *sessionV2.RequestVerificationHeader
token *sessionSDK.Object token *sessionSDK.Object
bearer *bearer.Token bearer *bearer.Token
src any src interface{}
} }
// RequestOwner returns ownerID and its public key // RequestOwner returns ownerID and its public key
@ -113,6 +114,12 @@ func (r MetaWithToken) RequestOwner() (*user.ID, *keys.PublicKey, error) {
return nil, nil, errEmptyVerificationHeader return nil, nil, errEmptyVerificationHeader
} }
if r.bearer != nil && r.bearer.Impersonate() {
issuer := bearer.ResolveIssuer(*r.bearer)
pubKey, err := keys.NewPublicKeyFromBytes(r.bearer.SigningKeyBytes(), elliptic.P256())
return &issuer, pubKey, err
}
// if session token is presented, use it as truth source // if session token is presented, use it as truth source
if r.token != nil { if r.token != nil {
// verify signature of session token // verify signature of session token

View file

@ -86,7 +86,7 @@ func New(opts ...Option) Service {
opts[i](cfg) opts[i](cfg)
} }
panicOnNil := func(v any, name string) { panicOnNil := func(v interface{}, name string) {
if v == nil { if v == nil {
panic(fmt.Sprintf("ACL service: %s is nil", name)) panic(fmt.Sprintf("ACL service: %s is nil", name))
} }

View file

@ -12,7 +12,7 @@ type ACLChecker interface {
CheckBasicACL(RequestInfo) bool CheckBasicACL(RequestInfo) bool
// CheckEACL must return non-nil error if request // CheckEACL must return non-nil error if request
// doesn't pass extended ACL validation. // doesn't pass extended ACL validation.
CheckEACL(any, RequestInfo) error CheckEACL(interface{}, RequestInfo) error
// StickyBitCheck must return true only if sticky bit // StickyBitCheck must return true only if sticky bit
// is disabled or enabled but request contains correct // is disabled or enabled but request contains correct
// owner field. // owner field.

View file

@ -20,7 +20,7 @@ import (
var errMissingContainerID = errors.New("missing container ID") var errMissingContainerID = errors.New("missing container ID")
func getContainerIDFromRequest(req any) (cid.ID, error) { func getContainerIDFromRequest(req interface{}) (cid.ID, error) {
var idV2 *refsV2.ContainerID var idV2 *refsV2.ContainerID
var id cid.ID var id cid.ID

View file

@ -7,7 +7,7 @@ import (
const defaultAllocSize = 1024 const defaultAllocSize = 1024
var putBytesPool = &sync.Pool{ var putBytesPool = &sync.Pool{
New: func() any { return make([]byte, 0, defaultAllocSize) }, New: func() interface{} { return make([]byte, 0, defaultAllocSize) },
} }
func getPayload() []byte { func getPayload() []byte {

View file

@ -116,9 +116,9 @@ func WithNetworkMapSource(v netmap.Source) Option {
} }
} }
func WithWorkerPools(remote, local util.WorkerPool) Option { func WithWorkerPools(remote util.WorkerPool) Option {
return func(c *cfg) { return func(c *cfg) {
c.remotePool, c.localPool = remote, local c.remotePool = remote
} }
} }

View file

@ -80,7 +80,7 @@ func (s *ResponseService) Put(ctx context.Context) (PutObjectStream, error) {
return &putStreamResponser{ return &putStreamResponser{
stream: s.respSvc.CreateRequestStreamer( stream: s.respSvc.CreateRequestStreamer(
func(req any) error { func(req interface{}) error {
return stream.Send(req.(*object.PutRequest)) return stream.Send(req.(*object.PutRequest))
}, },
func() (util.ResponseMessage, error) { func() (util.ResponseMessage, error) {
@ -92,7 +92,7 @@ func (s *ResponseService) Put(ctx context.Context) (PutObjectStream, error) {
func (s *ResponseService) Head(ctx context.Context, req *object.HeadRequest) (*object.HeadResponse, error) { func (s *ResponseService) Head(ctx context.Context, req *object.HeadRequest) (*object.HeadResponse, error) {
resp, err := s.respSvc.HandleUnaryRequest(ctx, req, resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.Head(ctx, req.(*object.HeadRequest)) return s.svc.Head(ctx, req.(*object.HeadRequest))
}, },
) )
@ -118,7 +118,7 @@ func (s *ResponseService) Search(req *object.SearchRequest, stream SearchStream)
func (s *ResponseService) Delete(ctx context.Context, req *object.DeleteRequest) (*object.DeleteResponse, error) { func (s *ResponseService) Delete(ctx context.Context, req *object.DeleteRequest) (*object.DeleteResponse, error) {
resp, err := s.respSvc.HandleUnaryRequest(ctx, req, resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.Delete(ctx, req.(*object.DeleteRequest)) return s.svc.Delete(ctx, req.(*object.DeleteRequest))
}, },
) )
@ -144,7 +144,7 @@ func (s *ResponseService) GetRange(req *object.GetRangeRequest, stream GetObject
func (s *ResponseService) GetRangeHash(ctx context.Context, req *object.GetRangeHashRequest) (*object.GetRangeHashResponse, error) { func (s *ResponseService) GetRangeHash(ctx context.Context, req *object.GetRangeHashRequest) (*object.GetRangeHashResponse, error) {
resp, err := s.respSvc.HandleUnaryRequest(ctx, req, resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.GetRangeHash(ctx, req.(*object.GetRangeHashRequest)) return s.svc.GetRangeHash(ctx, req.(*object.GetRangeHashRequest))
}, },
) )

View file

@ -91,7 +91,7 @@ func (s *SignService) Put(ctx context.Context) (PutObjectStream, error) {
return &putStreamSigner{ return &putStreamSigner{
stream: s.sigSvc.CreateRequestStreamer( stream: s.sigSvc.CreateRequestStreamer(
func(req any) error { func(req interface{}) error {
return stream.Send(req.(*object.PutRequest)) return stream.Send(req.(*object.PutRequest))
}, },
func() (util.ResponseMessage, error) { func() (util.ResponseMessage, error) {
@ -106,7 +106,7 @@ func (s *SignService) Put(ctx context.Context) (PutObjectStream, error) {
func (s *SignService) Head(ctx context.Context, req *object.HeadRequest) (*object.HeadResponse, error) { func (s *SignService) Head(ctx context.Context, req *object.HeadRequest) (*object.HeadResponse, error) {
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.Head(ctx, req.(*object.HeadRequest)) return s.svc.Head(ctx, req.(*object.HeadRequest))
}, },
func() util.ResponseMessage { func() util.ResponseMessage {
@ -157,7 +157,7 @@ func (s *SignService) Search(req *object.SearchRequest, stream SearchStream) err
func (s *SignService) Delete(ctx context.Context, req *object.DeleteRequest) (*object.DeleteResponse, error) { func (s *SignService) Delete(ctx context.Context, req *object.DeleteRequest) (*object.DeleteResponse, error) {
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.Delete(ctx, req.(*object.DeleteRequest)) return s.svc.Delete(ctx, req.(*object.DeleteRequest))
}, },
func() util.ResponseMessage { func() util.ResponseMessage {
@ -194,7 +194,7 @@ func (s *SignService) GetRange(req *object.GetRangeRequest, stream GetObjectRang
func (s *SignService) GetRangeHash(ctx context.Context, req *object.GetRangeHashRequest) (*object.GetRangeHashResponse, error) { func (s *SignService) GetRangeHash(ctx context.Context, req *object.GetRangeHashRequest) (*object.GetRangeHashResponse, error) {
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.GetRangeHash(ctx, req.(*object.GetRangeHashRequest)) return s.svc.GetRangeHash(ctx, req.(*object.GetRangeHashRequest))
}, },
func() util.ResponseMessage { func() util.ResponseMessage {

View file

@ -14,7 +14,7 @@ type HeadReceiver interface {
// Head must return one of: // Head must return one of:
// * object header (*object.Object); // * object header (*object.Object);
// * structured information about split-chain (*object.SplitInfo). // * structured information about split-chain (*object.SplitInfo).
Head(id oid.Address) (any, error) Head(id oid.Address) (interface{}, error)
} }
// SplitMemberHandler is a handler of next split-chain element. // SplitMemberHandler is a handler of next split-chain element.

View file

@ -40,7 +40,7 @@ func NewChecker(oo ...Option) *ExpirationChecker {
o(cfg) o(cfg)
} }
panicOnNil := func(v any, name string) { panicOnNil := func(v interface{}, name string) {
if v == nil { if v == nil {
panic(fmt.Sprintf("tombstone getter constructor: %s is nil", name)) panic(fmt.Sprintf("tombstone getter constructor: %s is nil", name))
} }

View file

@ -93,7 +93,7 @@ func (mb *managerBuilder) BuildManagers(epoch uint64, p apireputation.PeerID) ([
copy(nodes, nmNodes) copy(nodes, nmNodes)
hrw.SortHasherSliceByValue(nodes, epoch) hrw.SortSliceByValue(nodes, epoch)
for i := range nodes { for i := range nodes {
if apireputation.ComparePeerKey(p, nodes[i].PublicKey()) { if apireputation.ComparePeerKey(p, nodes[i].PublicKey()) {

View file

@ -52,7 +52,7 @@ type Router struct {
const invalidPrmValFmt = "invalid parameter %s (%T):%v" const invalidPrmValFmt = "invalid parameter %s (%T):%v"
func panicOnPrmValue(n string, v any) { func panicOnPrmValue(n string, v interface{}) {
panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) panic(fmt.Sprintf(invalidPrmValFmt, n, v, v))
} }

View file

@ -51,7 +51,7 @@ type Calculator struct {
const invalidPrmValFmt = "invalid parameter %s (%T):%v" const invalidPrmValFmt = "invalid parameter %s (%T):%v"
func panicOnPrmValue(n string, v any) { func panicOnPrmValue(n string, v interface{}) {
panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) panic(fmt.Sprintf(invalidPrmValFmt, n, v, v))
} }

View file

@ -52,7 +52,7 @@ type Controller struct {
const invalidPrmValFmt = "invalid parameter %s (%T):%v" const invalidPrmValFmt = "invalid parameter %s (%T):%v"
func panicOnPrmValue(n string, v any) { func panicOnPrmValue(n string, v interface{}) {
panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) panic(fmt.Sprintf(invalidPrmValFmt, n, v, v))
} }

View file

@ -34,7 +34,7 @@ type Builder struct {
const invalidPrmValFmt = "invalid parameter %s (%T):%v" const invalidPrmValFmt = "invalid parameter %s (%T):%v"
func panicOnPrmValue(n string, v any) { func panicOnPrmValue(n string, v interface{}) {
panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) panic(fmt.Sprintf(invalidPrmValFmt, n, v, v))
} }

View file

@ -52,7 +52,7 @@ type Controller struct {
const invalidPrmValFmt = "invalid parameter %s (%T):%v" const invalidPrmValFmt = "invalid parameter %s (%T):%v"
func panicOnPrmValue(n string, v any) { func panicOnPrmValue(n string, v interface{}) {
panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) panic(fmt.Sprintf(invalidPrmValFmt, n, v, v))
} }

View file

@ -34,7 +34,7 @@ type Builder struct {
const invalidPrmValFmt = "invalid parameter %s (%T):%v" const invalidPrmValFmt = "invalid parameter %s (%T):%v"
func panicOnPrmValue(n string, v any) { func panicOnPrmValue(n string, v interface{}) {
panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) panic(fmt.Sprintf(invalidPrmValFmt, n, v, v))
} }

View file

@ -25,7 +25,7 @@ func NewResponseService(cnrSvc Server, respSvc *response.Service) Server {
func (s *responseService) AnnounceLocalTrust(ctx context.Context, req *reputation.AnnounceLocalTrustRequest) (*reputation.AnnounceLocalTrustResponse, error) { func (s *responseService) AnnounceLocalTrust(ctx context.Context, req *reputation.AnnounceLocalTrustRequest) (*reputation.AnnounceLocalTrustResponse, error) {
resp, err := s.respSvc.HandleUnaryRequest(ctx, req, resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.AnnounceLocalTrust(ctx, req.(*reputation.AnnounceLocalTrustRequest)) return s.svc.AnnounceLocalTrust(ctx, req.(*reputation.AnnounceLocalTrustRequest))
}, },
) )
@ -38,7 +38,7 @@ func (s *responseService) AnnounceLocalTrust(ctx context.Context, req *reputatio
func (s *responseService) AnnounceIntermediateResult(ctx context.Context, req *reputation.AnnounceIntermediateResultRequest) (*reputation.AnnounceIntermediateResultResponse, error) { func (s *responseService) AnnounceIntermediateResult(ctx context.Context, req *reputation.AnnounceIntermediateResultRequest) (*reputation.AnnounceIntermediateResultResponse, error) {
resp, err := s.respSvc.HandleUnaryRequest(ctx, req, resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.AnnounceIntermediateResult(ctx, req.(*reputation.AnnounceIntermediateResultRequest)) return s.svc.AnnounceIntermediateResult(ctx, req.(*reputation.AnnounceIntermediateResultRequest))
}, },
) )

View file

@ -23,7 +23,7 @@ func NewSignService(key *ecdsa.PrivateKey, svc Server) Server {
func (s *signService) AnnounceLocalTrust(ctx context.Context, req *reputation.AnnounceLocalTrustRequest) (*reputation.AnnounceLocalTrustResponse, error) { func (s *signService) AnnounceLocalTrust(ctx context.Context, req *reputation.AnnounceLocalTrustRequest) (*reputation.AnnounceLocalTrustResponse, error) {
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.AnnounceLocalTrust(ctx, req.(*reputation.AnnounceLocalTrustRequest)) return s.svc.AnnounceLocalTrust(ctx, req.(*reputation.AnnounceLocalTrustRequest))
}, },
func() util.ResponseMessage { func() util.ResponseMessage {
@ -39,7 +39,7 @@ func (s *signService) AnnounceLocalTrust(ctx context.Context, req *reputation.An
func (s *signService) AnnounceIntermediateResult(ctx context.Context, req *reputation.AnnounceIntermediateResultRequest) (*reputation.AnnounceIntermediateResultResponse, error) { func (s *signService) AnnounceIntermediateResult(ctx context.Context, req *reputation.AnnounceIntermediateResultRequest) (*reputation.AnnounceIntermediateResultResponse, error) {
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.AnnounceIntermediateResult(ctx, req.(*reputation.AnnounceIntermediateResultRequest)) return s.svc.AnnounceIntermediateResult(ctx, req.(*reputation.AnnounceIntermediateResultRequest))
}, },
func() util.ResponseMessage { func() util.ResponseMessage {

View file

@ -25,7 +25,7 @@ func NewResponseService(ssSvc Server, respSvc *response.Service) Server {
func (s *responseService) Create(ctx context.Context, req *session.CreateRequest) (*session.CreateResponse, error) { func (s *responseService) Create(ctx context.Context, req *session.CreateRequest) (*session.CreateResponse, error) {
resp, err := s.respSvc.HandleUnaryRequest(ctx, req, resp, err := s.respSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.Create(ctx, req.(*session.CreateRequest)) return s.svc.Create(ctx, req.(*session.CreateRequest))
}, },
) )

View file

@ -23,7 +23,7 @@ func NewSignService(key *ecdsa.PrivateKey, svc Server) Server {
func (s *signService) Create(ctx context.Context, req *session.CreateRequest) (*session.CreateResponse, error) { func (s *signService) Create(ctx context.Context, req *session.CreateRequest) (*session.CreateResponse, error) {
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
func(ctx context.Context, req any) (util.ResponseMessage, error) { func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
return s.svc.Create(ctx, req.(*session.CreateRequest)) return s.svc.Create(ctx, req.(*session.CreateRequest))
}, },
func() util.ResponseMessage { func() util.ResponseMessage {

View file

@ -56,7 +56,23 @@ func (s *Service) verifyClient(req message, cid cidSDK.ID, rawBearer []byte, op
return fmt.Errorf("can't get container %s: %w", cid, err) return fmt.Errorf("can't get container %s: %w", cid, err)
} }
role, err := roleFromReq(cnr, req) eaclOp := eACLOp(op)
var bt *bearer.Token
if len(rawBearer) > 0 {
bt = new(bearer.Token)
if err = bt.Unmarshal(rawBearer); err != nil {
return eACLErr(eaclOp, fmt.Errorf("invalid bearer token: %w", err))
}
if !bt.VerifySignature() {
return eACLErr(eaclOp, errBearerSignature)
}
if !bt.AssertContainer(cid) {
return eACLErr(eaclOp, errBearerWrongContainer)
}
}
role, err := roleFromReq(cnr, req, bt)
if err != nil { if err != nil {
return fmt.Errorf("can't get request role: %w", err) return fmt.Errorf("can't get request role: %w", err)
} }
@ -71,8 +87,6 @@ func (s *Service) verifyClient(req message, cid cidSDK.ID, rawBearer []byte, op
return nil return nil
} }
eaclOp := eACLOp(op)
var tableFromBearer bool var tableFromBearer bool
if len(rawBearer) != 0 { if len(rawBearer) != 0 {
if !basicACL.AllowedBearerRules(op) { if !basicACL.AllowedBearerRules(op) {
@ -86,22 +100,25 @@ func (s *Service) verifyClient(req message, cid cidSDK.ID, rawBearer []byte, op
} }
var tb eacl.Table var tb eacl.Table
signer := req.GetSignature().GetKey()
if tableFromBearer { if tableFromBearer {
var bt bearer.Token if bt.Impersonate() {
if err = bt.Unmarshal(rawBearer); err != nil { tbCore, err := s.eaclSource.GetEACL(cid)
return eACLErr(eaclOp, fmt.Errorf("invalid bearer token: %w", err)) if err != nil {
} if client.IsErrEACLNotFound(err) {
if !bearer.ResolveIssuer(bt).Equals(cnr.Value.Owner()) { return nil
return eACLErr(eaclOp, errBearerWrongOwner) }
}
if !bt.AssertContainer(cid) {
return eACLErr(eaclOp, errBearerWrongContainer)
}
if !bt.VerifySignature() {
return eACLErr(eaclOp, errBearerSignature)
}
tb = bt.EACLTable() return fmt.Errorf("get eACL table: %w", err)
}
tb = *tbCore.Value
signer = bt.SigningKeyBytes()
} else {
if !bearer.ResolveIssuer(*bt).Equals(cnr.Value.Owner()) {
return eACLErr(eaclOp, errBearerWrongOwner)
}
tb = bt.EACLTable()
}
} else { } else {
tbCore, err := s.eaclSource.GetEACL(cid) tbCore, err := s.eaclSource.GetEACL(cid)
if err != nil { if err != nil {
@ -115,7 +132,7 @@ func (s *Service) verifyClient(req message, cid cidSDK.ID, rawBearer []byte, op
tb = *tbCore.Value tb = *tbCore.Value
} }
return checkEACL(tb, req.GetSignature().GetKey(), eACLRole(role), eaclOp) return checkEACL(tb, signer, eACLRole(role), eaclOp)
} }
func verifyMessage(m message) error { func verifyMessage(m message) error {
@ -168,7 +185,7 @@ func SignMessage(m message, key *ecdsa.PrivateKey) error {
return nil return nil
} }
func roleFromReq(cnr *core.Container, req message) (acl.Role, error) { func roleFromReq(cnr *core.Container, req message, bt *bearer.Token) (acl.Role, error) {
role := acl.RoleOthers role := acl.RoleOthers
owner := cnr.Value.Owner() owner := cnr.Value.Owner()
@ -177,6 +194,13 @@ func roleFromReq(cnr *core.Container, req message) (acl.Role, error) {
return role, fmt.Errorf("invalid public key: %w", err) return role, fmt.Errorf("invalid public key: %w", err)
} }
if bt != nil && bt.Impersonate() {
pub, err = keys.NewPublicKeyFromBytes(bt.SigningKeyBytes(), elliptic.P256())
if err != nil {
return role, fmt.Errorf("invalid public key: %w", err)
}
}
var reqSigner user.ID var reqSigner user.ID
user.IDFromKey(&reqSigner, (ecdsa.PublicKey)(*pub)) user.IDFromKey(&reqSigner, (ecdsa.PublicKey)(*pub))

View file

@ -17,7 +17,7 @@ type ClientMessageStreamer struct {
} }
// Send calls send method of internal streamer. // Send calls send method of internal streamer.
func (s *ClientMessageStreamer) Send(req any) error { func (s *ClientMessageStreamer) Send(req interface{}) error {
if err := s.send(req); err != nil { if err := s.send(req); err != nil {
return fmt.Errorf("(%T) could not send the request: %w", s, err) return fmt.Errorf("(%T) could not send the request: %w", s, err)
} }

View file

@ -8,7 +8,7 @@ import (
) )
// HandleUnaryRequest call passes request to handler, sets response meta header values and returns it. // HandleUnaryRequest call passes request to handler, sets response meta header values and returns it.
func (s *Service) HandleUnaryRequest(ctx context.Context, req any, handler util.UnaryHandler) (util.ResponseMessage, error) { func (s *Service) HandleUnaryRequest(ctx context.Context, req interface{}, handler util.UnaryHandler) (util.ResponseMessage, error) {
// process request // process request
resp, err := handler(ctx, req) resp, err := handler(ctx, req)
if err != nil { if err != nil {

View file

@ -21,7 +21,7 @@ type ResponseMessage interface {
SetMetaHeader(*session.ResponseMetaHeader) SetMetaHeader(*session.ResponseMetaHeader)
} }
type UnaryHandler func(context.Context, any) (ResponseMessage, error) type UnaryHandler func(context.Context, interface{}) (ResponseMessage, error)
type SignService struct { type SignService struct {
key *ecdsa.PrivateKey key *ecdsa.PrivateKey
@ -29,7 +29,7 @@ type SignService struct {
type ResponseMessageWriter func(ResponseMessage) error type ResponseMessageWriter func(ResponseMessage) error
type ServerStreamHandler func(context.Context, any) (ResponseMessageReader, error) type ServerStreamHandler func(context.Context, interface{}) (ResponseMessageReader, error)
type ResponseMessageReader func() (ResponseMessage, error) type ResponseMessageReader func() (ResponseMessage, error)
@ -37,7 +37,7 @@ var ErrAbortStream = errors.New("abort message stream")
type ResponseConstructor func() ResponseMessage type ResponseConstructor func() ResponseMessage
type RequestMessageWriter func(any) error type RequestMessageWriter func(interface{}) error
type ClientStreamCloser func() (ResponseMessage, error) type ClientStreamCloser func() (ResponseMessage, error)
@ -61,7 +61,7 @@ func NewUnarySignService(key *ecdsa.PrivateKey) *SignService {
} }
} }
func (s *RequestMessageStreamer) Send(req any) error { func (s *RequestMessageStreamer) Send(req interface{}) error {
// req argument should be strengthen with type RequestMessage // req argument should be strengthen with type RequestMessage
s.statusSupported = isStatusSupported(req.(RequestMessage)) // panic is OK here for now s.statusSupported = isStatusSupported(req.(RequestMessage)) // panic is OK here for now
@ -130,7 +130,7 @@ func (s *SignService) CreateRequestStreamer(sender RequestMessageWriter, closer
} }
func (s *SignService) HandleServerStreamRequest( func (s *SignService) HandleServerStreamRequest(
req any, req interface{},
respWriter ResponseMessageWriter, respWriter ResponseMessageWriter,
blankResp ResponseConstructor, blankResp ResponseConstructor,
respWriterCaller func(ResponseMessageWriter) error, respWriterCaller func(ResponseMessageWriter) error,
@ -172,7 +172,7 @@ func (s *SignService) HandleServerStreamRequest(
return nil return nil
} }
func (s *SignService) HandleUnaryRequest(ctx context.Context, req any, handler UnaryHandler, blankResp ResponseConstructor) (ResponseMessage, error) { func (s *SignService) HandleUnaryRequest(ctx context.Context, req interface{}, handler UnaryHandler, blankResp ResponseConstructor) (ResponseMessage, error) {
// handle protocol versions <=2.10 (API statuses was introduced in 2.11 only) // handle protocol versions <=2.10 (API statuses was introduced in 2.11 only)
// req argument should be strengthen with type RequestMessage // req argument should be strengthen with type RequestMessage
@ -233,7 +233,7 @@ func setStatusV2(resp ResponseMessage, err error) {
// The signature error affects the result depending on the protocol version: // The signature error affects the result depending on the protocol version:
// - if status return is supported, panics since we cannot return the failed status, because it will not be signed; // - if status return is supported, panics since we cannot return the failed status, because it will not be signed;
// - otherwise, returns error in order to transport it directly. // - otherwise, returns error in order to transport it directly.
func signResponse(key *ecdsa.PrivateKey, resp any, statusSupported bool) error { func signResponse(key *ecdsa.PrivateKey, resp interface{}, statusSupported bool) error {
err := signature.SignServiceMessage(key, resp) err := signature.SignServiceMessage(key, resp)
if err != nil { if err != nil {
err = fmt.Errorf("could not sign response: %w", err) err = fmt.Errorf("could not sign response: %w", err)

View file

@ -19,29 +19,29 @@ func ReadNodeAttributes(dst *netmap.NodeInfo, attrs []string) error {
for i := range attrs { for i := range attrs {
line := replaceEscaping(attrs[i], false) // replaced escaped symbols with non-printable symbols line := replaceEscaping(attrs[i], false) // replaced escaped symbols with non-printable symbols
k, v, found := strings.Cut(line, keyValueSeparator) words := strings.Split(line, keyValueSeparator)
if !found { if len(words) != 2 {
return errors.New("missing attribute key and/or value") return errors.New("missing attribute key and/or value")
} }
_, ok := cache[k] _, ok := cache[words[0]]
if ok { if ok {
return fmt.Errorf("duplicated keys %s", k) return fmt.Errorf("duplicated keys %s", words[0])
} }
cache[k] = struct{}{} cache[words[0]] = struct{}{}
// replace non-printable symbols with escaped symbols without escape character // replace non-printable symbols with escaped symbols without escape character
k = replaceEscaping(k, true) words[0] = replaceEscaping(words[0], true)
v = replaceEscaping(v, true) words[1] = replaceEscaping(words[1], true)
if k == "" { if words[0] == "" {
return errors.New("empty key") return errors.New("empty key")
} else if v == "" { } else if words[1] == "" {
return errors.New("empty value") return errors.New("empty value")
} }
dst.SetAttribute(k, v) dst.SetAttribute(words[0], words[1])
} }
return nil return nil

View file

@ -37,15 +37,15 @@ type Server struct {
const invalidValFmt = "invalid %s %s (%T): %v" const invalidValFmt = "invalid %s %s (%T): %v"
func panicOnPrmValue(n string, v any) { func panicOnPrmValue(n string, v interface{}) {
panicOnValue("parameter", n, v) panicOnValue("parameter", n, v)
} }
func panicOnOptValue(n string, v any) { func panicOnOptValue(n string, v interface{}) {
panicOnValue("option", n, v) panicOnValue("option", n, v)
} }
func panicOnValue(t, n string, v any) { func panicOnValue(t, n string, v interface{}) {
panic(fmt.Sprintf(invalidValFmt, t, n, v, v)) panic(fmt.Sprintf(invalidValFmt, t, n, v, v))
} }

View file

@ -46,7 +46,7 @@ type pathMode struct {
const invalidPrmValFmt = "invalid parameter %s (%T):%v" const invalidPrmValFmt = "invalid parameter %s (%T):%v"
func panicOnPrmValue(n string, v any) { func panicOnPrmValue(n string, v interface{}) {
panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) panic(fmt.Sprintf(invalidPrmValFmt, n, v, v))
} }

View file

@ -43,7 +43,7 @@ type DB struct {
const invalidPrmValFmt = "invalid parameter %s (%T):%v" const invalidPrmValFmt = "invalid parameter %s (%T):%v"
func panicOnPrmValue(n string, v any) { func panicOnPrmValue(n string, v interface{}) {
panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) panic(fmt.Sprintf(invalidPrmValFmt, n, v, v))
} }

View file

@ -35,7 +35,7 @@ type DB struct {
const invalidPrmValFmt = "invalid parameter %s (%T):%v" const invalidPrmValFmt = "invalid parameter %s (%T):%v"
func panicOnPrmValue(n string, v any) { func panicOnPrmValue(n string, v interface{}) {
panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) panic(fmt.Sprintf(invalidPrmValFmt, n, v, v))
} }

View file

@ -43,7 +43,7 @@ type Table struct {
const invalidPrmValFmt = "invalid parameter %s (%T):%v" const invalidPrmValFmt = "invalid parameter %s (%T):%v"
func panicOnPrmValue(n string, v any) { func panicOnPrmValue(n string, v interface{}) {
panic(fmt.Sprintf(invalidPrmValFmt, n, v, v)) panic(fmt.Sprintf(invalidPrmValFmt, n, v, v))
} }