forked from TrueCloudLab/frostfs-node
[#738] neofs-adm: Set more network configuration values
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
3a34e4a48e
commit
37cc702271
3 changed files with 41 additions and 25 deletions
|
@ -19,6 +19,11 @@ type configTemplate struct {
|
||||||
AlphabetDir string
|
AlphabetDir string
|
||||||
MaxObjectSize int
|
MaxObjectSize int
|
||||||
EpochDuration int
|
EpochDuration int
|
||||||
|
BasicIncomeRate int
|
||||||
|
AuditFee int
|
||||||
|
CandidateFee int
|
||||||
|
ContainerFee int
|
||||||
|
WithdrawFee int
|
||||||
Glagolitics []string
|
Glagolitics []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +32,12 @@ alphabet-wallets: {{ .AlphabetDir}}
|
||||||
network:
|
network:
|
||||||
max_object_size: {{ .MaxObjectSize}}
|
max_object_size: {{ .MaxObjectSize}}
|
||||||
epoch_duration: {{ .EpochDuration}}
|
epoch_duration: {{ .EpochDuration}}
|
||||||
|
basic_income_rate: {{ .BasicIncomeRate}}
|
||||||
|
fee:
|
||||||
|
audit: {{ .AuditFee}}
|
||||||
|
candidate: {{ .CandidateFee}}
|
||||||
|
container: {{ .ContainerFee}}
|
||||||
|
withdraw: {{ .WithdrawFee}}
|
||||||
# if credentials section is omitted, then neofs-adm will require manual password input
|
# if credentials section is omitted, then neofs-adm will require manual password input
|
||||||
credentials:{{ range.Glagolitics}}
|
credentials:{{ range.Glagolitics}}
|
||||||
{{.}}: password{{end}}
|
{{.}}: password{{end}}
|
||||||
|
@ -92,10 +103,15 @@ func defaultConfigPath() (string, error) {
|
||||||
// want to order records in specific order in file and, probably, provide
|
// want to order records in specific order in file and, probably, provide
|
||||||
// some comments as well.
|
// some comments as well.
|
||||||
func generateConfigExample(appDir string, credSize int) (string, error) {
|
func generateConfigExample(appDir string, credSize int) (string, error) {
|
||||||
input := configTemplate{
|
tmpl := configTemplate{
|
||||||
Endpoint: "https://neo.rpc.node:30333",
|
Endpoint: "https://neo.rpc.node:30333",
|
||||||
MaxObjectSize: 67108864, // 64 MiB
|
MaxObjectSize: 67108864, // 64 MiB
|
||||||
EpochDuration: 240, // 1 hour with 15s per block
|
EpochDuration: 240, // 1 hour with 15s per block
|
||||||
|
BasicIncomeRate: 1_0000_0000, // 0.0001 GAS per GiB (Fixed12)
|
||||||
|
AuditFee: 1_0000, // 0.00000001 GAS per audit (Fixed12)
|
||||||
|
CandidateFee: 100_0000_0000, // 100.0 GAS (Fixed8)
|
||||||
|
ContainerFee: 1000, // 0.000000001 * 7 GAS per container (Fixed12)
|
||||||
|
WithdrawFee: 1_0000_0000, // 1.0 GAS (Fixed8)
|
||||||
Glagolitics: make([]string, 0, credSize),
|
Glagolitics: make([]string, 0, credSize),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,11 +119,11 @@ func generateConfigExample(appDir string, credSize int) (string, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("making absolute path for %s: %w", appDir, err)
|
return "", fmt.Errorf("making absolute path for %s: %w", appDir, err)
|
||||||
}
|
}
|
||||||
input.AlphabetDir = path.Join(appDir, "alphabet-wallets")
|
tmpl.AlphabetDir = path.Join(appDir, "alphabet-wallets")
|
||||||
|
|
||||||
var i innerring.GlagoliticLetter
|
var i innerring.GlagoliticLetter
|
||||||
for i = 0; i < innerring.GlagoliticLetter(credSize); i++ {
|
for i = 0; i < innerring.GlagoliticLetter(credSize); i++ {
|
||||||
input.Glagolitics = append(input.Glagolitics, i.String())
|
tmpl.Glagolitics = append(tmpl.Glagolitics, i.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
t, err := template.New("config.yml").Parse(configTxtTemplate)
|
t, err := template.New("config.yml").Parse(configTxtTemplate)
|
||||||
|
@ -117,7 +133,7 @@ func generateConfigExample(appDir string, credSize int) (string, error) {
|
||||||
|
|
||||||
buf := bytes.NewBuffer(nil)
|
buf := bytes.NewBuffer(nil)
|
||||||
|
|
||||||
err = t.Execute(buf, input)
|
err = t.Execute(buf, tmpl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("generating config from tempalte: %w", err)
|
return "", fmt.Errorf("generating config from tempalte: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,11 @@ func TestGenerateConfigExample(t *testing.T) {
|
||||||
require.Equal(t, path.Join(appDir, "alphabet-wallets"), v.GetString("alphabet-wallets"))
|
require.Equal(t, path.Join(appDir, "alphabet-wallets"), v.GetString("alphabet-wallets"))
|
||||||
require.Equal(t, 67108864, v.GetInt("network.max_object_size"))
|
require.Equal(t, 67108864, v.GetInt("network.max_object_size"))
|
||||||
require.Equal(t, 240, v.GetInt("network.epoch_duration"))
|
require.Equal(t, 240, v.GetInt("network.epoch_duration"))
|
||||||
|
require.Equal(t, 100000000, v.GetInt("network.basic_income_rate"))
|
||||||
|
require.Equal(t, 10000, v.GetInt("network.fee.audit"))
|
||||||
|
require.Equal(t, 10000000000, v.GetInt("network.fee.candidate"))
|
||||||
|
require.Equal(t, 1000, v.GetInt("network.fee.container"))
|
||||||
|
require.Equal(t, 100000000, v.GetInt("network.fee.withdraw"))
|
||||||
|
|
||||||
var i innerring.GlagoliticLetter
|
var i innerring.GlagoliticLetter
|
||||||
for i = 0; i < innerring.GlagoliticLetter(n); i++ {
|
for i = 0; i < innerring.GlagoliticLetter(n); i++ {
|
||||||
|
|
|
@ -43,13 +43,8 @@ const (
|
||||||
netmapInnerRingCandidateFeeKey = "InnerRingCandidateFee"
|
netmapInnerRingCandidateFeeKey = "InnerRingCandidateFee"
|
||||||
netmapWithdrawFeeKey = "WithdrawFee"
|
netmapWithdrawFeeKey = "WithdrawFee"
|
||||||
|
|
||||||
defaultAuditFee = 10000
|
|
||||||
defaultContainerFee = 1000
|
|
||||||
defaultEigenTrustIterations = 4
|
defaultEigenTrustIterations = 4
|
||||||
defaultEigenTrustAlpha = "0.1"
|
defaultEigenTrustAlpha = "0.1"
|
||||||
defaultBasicIncomeRate = 100000000
|
|
||||||
defaultInnerRingCandidateFee = 10000000000
|
|
||||||
defaultWithdrawFee = 100000000
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var contractList = []string{
|
var contractList = []string{
|
||||||
|
@ -272,19 +267,19 @@ func (c *initializeContext) getContractDeployData(ctrName string, keysParam []sm
|
||||||
{Type: smartcontract.StringType, Value: netmapMaxObjectSizeKey},
|
{Type: smartcontract.StringType, Value: netmapMaxObjectSizeKey},
|
||||||
{Type: smartcontract.IntegerType, Value: viper.GetInt64(maxObjectSizeInitFlag)},
|
{Type: smartcontract.IntegerType, Value: viper.GetInt64(maxObjectSizeInitFlag)},
|
||||||
{Type: smartcontract.StringType, Value: netmapAuditFeeKey},
|
{Type: smartcontract.StringType, Value: netmapAuditFeeKey},
|
||||||
{Type: smartcontract.IntegerType, Value: int64(defaultAuditFee)},
|
{Type: smartcontract.IntegerType, Value: viper.GetInt64(auditFeeInitFlag)},
|
||||||
{Type: smartcontract.StringType, Value: netmapContainerFeeKey},
|
{Type: smartcontract.StringType, Value: netmapContainerFeeKey},
|
||||||
{Type: smartcontract.IntegerType, Value: int64(defaultContainerFee)},
|
{Type: smartcontract.IntegerType, Value: viper.GetInt64(containerFeeInitFlag)},
|
||||||
{Type: smartcontract.StringType, Value: netmapEigenTrustIterationsKey},
|
{Type: smartcontract.StringType, Value: netmapEigenTrustIterationsKey},
|
||||||
{Type: smartcontract.IntegerType, Value: int64(defaultEigenTrustIterations)},
|
{Type: smartcontract.IntegerType, Value: int64(defaultEigenTrustIterations)},
|
||||||
{Type: smartcontract.StringType, Value: netmapEigenTrustAlphaKey},
|
{Type: smartcontract.StringType, Value: netmapEigenTrustAlphaKey},
|
||||||
{Type: smartcontract.StringType, Value: defaultEigenTrustAlpha},
|
{Type: smartcontract.StringType, Value: defaultEigenTrustAlpha},
|
||||||
{Type: smartcontract.StringType, Value: netmapBasicIncomeRateKey},
|
{Type: smartcontract.StringType, Value: netmapBasicIncomeRateKey},
|
||||||
{Type: smartcontract.IntegerType, Value: int64(defaultBasicIncomeRate)},
|
{Type: smartcontract.IntegerType, Value: viper.GetInt64(incomeRateInitFlag)},
|
||||||
{Type: smartcontract.StringType, Value: netmapInnerRingCandidateFeeKey},
|
{Type: smartcontract.StringType, Value: netmapInnerRingCandidateFeeKey},
|
||||||
{Type: smartcontract.IntegerType, Value: int64(defaultInnerRingCandidateFee)},
|
{Type: smartcontract.IntegerType, Value: viper.GetInt64(candidateFeeInitFlag)},
|
||||||
{Type: smartcontract.StringType, Value: netmapWithdrawFeeKey},
|
{Type: smartcontract.StringType, Value: netmapWithdrawFeeKey},
|
||||||
{Type: smartcontract.IntegerType, Value: int64(defaultWithdrawFee)},
|
{Type: smartcontract.IntegerType, Value: viper.GetInt64(withdrawFeeInitFlag)},
|
||||||
}
|
}
|
||||||
items = append(items,
|
items = append(items,
|
||||||
newContractParameter(smartcontract.Hash160Type, c.Contracts[balanceContract].Hash),
|
newContractParameter(smartcontract.Hash160Type, c.Contracts[balanceContract].Hash),
|
||||||
|
|
Loading…
Reference in a new issue