2023-04-13 14:42:59 +00:00
|
|
|
package morph
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
2023-04-11 11:59:24 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap"
|
2023-04-13 14:42:59 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
)
|
|
|
|
|
|
|
|
func getDefaultNetmapContractConfigMap() map[string]any {
|
|
|
|
m := make(map[string]any)
|
2023-04-11 11:59:24 +00:00
|
|
|
m[netmap.EpochDurationConfig] = viper.GetInt64(epochDurationInitFlag)
|
|
|
|
m[netmap.MaxObjectSizeConfig] = viper.GetInt64(maxObjectSizeInitFlag)
|
|
|
|
m[netmap.AuditFeeConfig] = viper.GetInt64(auditFeeInitFlag)
|
|
|
|
m[netmap.ContainerFeeConfig] = viper.GetInt64(containerFeeInitFlag)
|
|
|
|
m[netmap.ContainerAliasFeeConfig] = viper.GetInt64(containerAliasFeeInitFlag)
|
|
|
|
m[netmap.EtIterationsConfig] = int64(defaultEigenTrustIterations)
|
|
|
|
m[netmap.EtAlphaConfig] = defaultEigenTrustAlpha
|
|
|
|
m[netmap.BasicIncomeRateConfig] = viper.GetInt64(incomeRateInitFlag)
|
|
|
|
m[netmap.IrCandidateFeeConfig] = viper.GetInt64(candidateFeeInitFlag)
|
|
|
|
m[netmap.WithdrawFeeConfig] = viper.GetInt64(withdrawFeeInitFlag)
|
|
|
|
m[netmap.HomomorphicHashingDisabledKey] = viper.GetBool(homomorphicHashDisabledInitFlag)
|
|
|
|
m[netmap.MaintenanceModeAllowedConfig] = viper.GetBool(maintenanceModeAllowedInitFlag)
|
2023-04-13 14:42:59 +00:00
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func parseConfigFromNetmapContract(arr []stackitem.Item) (map[string][]byte, error) {
|
|
|
|
m := make(map[string][]byte, len(arr))
|
|
|
|
for _, param := range arr {
|
|
|
|
tuple, ok := param.Value().([]stackitem.Item)
|
|
|
|
if !ok || len(tuple) != 2 {
|
|
|
|
return nil, errors.New("invalid ListConfig response from netmap contract")
|
|
|
|
}
|
|
|
|
|
|
|
|
k, err := tuple[0].TryBytes()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errors.New("invalid config key from netmap contract")
|
|
|
|
}
|
|
|
|
|
|
|
|
v, err := tuple[1].TryBytes()
|
|
|
|
if err != nil {
|
|
|
|
return nil, invalidConfigValueErr(string(k))
|
|
|
|
}
|
|
|
|
m[string(k)] = v
|
|
|
|
}
|
|
|
|
return m, nil
|
|
|
|
}
|