Skip to content

Commit ad4333f

Browse files
committed
ir: Use default network settings for auto-deploy and drop configuration
Network settings configuration did not justify itself because used only when initializing the FS chain. Use default network settings during the FS chain auto-deployment (same ones used by the NeoFS ADM tool). Introduce `fschain_autodeploy` config flag that replaces mode tuning previously based on `network_settings` section presence. Closes #2660. Signed-off-by: Leonard Lyubich <[email protected]>
1 parent 4509f93 commit ad4333f

File tree

4 files changed

+70
-380
lines changed

4 files changed

+70
-380
lines changed

config/example/ir.yaml

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -76,44 +76,9 @@ morph:
7676
interval: 30s # Optional time period between pings. Defaults to 30s. Must not be negative
7777
timeout: 90s # Optional time period to wait for pong. Defaults to 1m. Must not be negative
7878

79-
network_settings: # NeoFS network settings managed in the Netmap contract
80-
epoch_duration: 240 # Time interval (approximate) between two adjacent NeoFS epochs measured in Sidechain blocks.
81-
# Must be an integer in range [1, 18446744073709551615]
82-
max_object_size: 67108864 # [bytes] Maximum size of physically stored NeoFS objects. Note that this applies
83-
# only to objects located on storage nodes: user objects have no restrictions and, if necessary, are sliced.
84-
# Must be an integer in range [1, 18446744073709551615]
85-
require_homomorphic_hashing: true # Toggles the requirement for homomorphic hashing of object payloads.
86-
# Must be 'true' or 'false'
87-
allow_maintenance_mode: true # Toggles permission to transition storage nodes to maintenance state.
88-
# Must be 'true' or 'false'
89-
eigen_trust:
90-
alpha: 0.1 # Alpha parameter of EigenTrust algorithm used in the Reputation system.
91-
# Must be a floating point number in range [0, 1].
92-
iterations_number: 4 # Number of EigenTrust algorithm iterations to pass in the Reputation system.
93-
# Must be an integer in range [1, 18446744073709551615]
94-
price: # Price settings. NEOFS means NeoFS Balance contract tokens (usually GASe-12).
95-
storage: 100000000 # [NEOFS] Price for 1GB of data paid every epoch by data owner to storage nodes.
96-
# Must be an integer in range [0, 18446744073709551615]
97-
fee:
98-
ir_candidate: 100 # [GASe-8] Contribution from the new candidate to the Inner Ring. Must be non-negative integer
99-
# Must be an integer in range [0, 18446744073709551615]
100-
withdraw: 100000000 # [GASe-8] Fee paid by the user account to;
101-
# - NeoFS Processing contract (if Notary service is enabled in the NeoFS Mainchain)
102-
# - each Alphabet member (otherwise)
103-
# Must be an integer in range [0, 18446744073709551615]
104-
audit: 10000 # [NEOFS] Fee for data audit paid by storage group owner to the auditor (Inner Ring member).
105-
# Must be an integer in range [0, 18446744073709551615]
106-
new_container: 1000 # [NEOFS] Fee for new container paid by creator to each Alphabet member.
107-
# Must be an integer in range [0, 18446744073709551615]
108-
container_domain: 500 # [NEOFS] Fee for container's NNS domain paid by container creator to each Alphabet member.
109-
# Must be a non-negative integer
110-
custom: # Optional list of custom key-value pairs to be set in the network configuration. Forbidden keys:
111-
# [AuditFee, BasicIncomeRate, ContainerAliasFee, ContainerFee, EigenTrustAlpha, EigenTrustIterations, EpochDuration,
112-
# HomomorphicHashingDisabled, InnerRingCandidateFee, MaintenanceModeAllowed, MaxObjectSize, WithdrawFee]
113-
# Note that this list can be extended in the future, so, to avoid potential collision, it is recommended
114-
# to use the most specific keys.
115-
- my_custom_key1=val1
116-
- my_custom_key2=val2
79+
fschain_autodeploy: true # Optional flag to run auto-deployment procedure of the FS chain. By default,
80+
# the chain is expected to be deployed/updated in the background (e.g. via NeoFS ADM tool).
81+
# If set, must be 'true' or 'false'.
11782

11883
nns:
11984
system_email: [email protected]

pkg/innerring/config.go

Lines changed: 22 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ import (
2121

2222
// checks whether Inner Ring app is configured to initialize underlying NeoFS
2323
// Sidechain or await for a background deployment.
24-
func isAutoDeploymentMode(cfg *viper.Viper) bool {
25-
return cfg.IsSet("network_settings")
24+
func isAutoDeploymentMode(cfg *viper.Viper) (bool, error) {
25+
res, err := parseConfigBool(cfg, "fschain_autodeploy", "flag to auto-deploy the FS chain")
26+
if err != nil && !errors.Is(err, errMissingConfig) {
27+
return false, err
28+
}
29+
30+
return res, nil
2631
}
2732

2833
// checks if Inner Ring app is configured to be launched in local consensus
@@ -209,139 +214,21 @@ func parseBlockchainConfig(v *viper.Viper, _logger *zap.Logger) (c blockchain.Co
209214
return c, nil
210215
}
211216

212-
const networkSettingsConfigSection = "network_settings"
213-
214-
func parseNetworkSettingsConfig(v *viper.Viper) (c netmap.NetworkConfiguration, err error) {
215-
if !v.IsSet(networkSettingsConfigSection) {
216-
return c, fmt.Errorf("missing root section '%s'", networkSettingsConfigSection)
217-
}
218-
219-
c.EpochDuration, err = parseConfigUint64Range(v, networkSettingsConfigSection+".epoch_duration", "epoch duration", 1, math.MaxUint32)
220-
if err != nil {
221-
return
222-
}
223-
224-
c.MaxObjectSize, err = parseConfigUint64Range(v, networkSettingsConfigSection+".max_object_size", "max object size", 1, math.MaxUint64)
225-
if err != nil {
226-
return
227-
}
228-
229-
requireHomoHash, err := parseConfigBool(v, networkSettingsConfigSection+".require_homomorphic_hashing", "is homomorphic hashing required")
230-
if err != nil {
231-
return
232-
}
233-
234-
c.HomomorphicHashingDisabled = !requireHomoHash
235-
236-
c.MaintenanceModeAllowed, err = parseConfigBool(v, networkSettingsConfigSection+".allow_maintenance_mode", "is maintenance mode allowed")
237-
if err != nil {
238-
return
239-
}
240-
241-
const eigenTrustSection = networkSettingsConfigSection + ".eigen_trust"
242-
if !v.IsSet(eigenTrustSection) {
243-
return c, fmt.Errorf("missing EigenTrust section '%s'", eigenTrustSection)
244-
}
245-
246-
c.EigenTrustAlpha, err = parseConfigFloatRange(v, eigenTrustSection+".alpha", "EigenTrust alpha parameter", 0, 1)
247-
if err != nil {
248-
return
249-
}
250-
251-
c.EigenTrustIterations, err = parseConfigUint64Range(v, eigenTrustSection+".iterations_number", "number of EigenTrust iterations", 1, math.MaxUint64)
252-
if err != nil {
253-
return
254-
}
255-
256-
const priceSection = networkSettingsConfigSection + ".price"
257-
if !v.IsSet(priceSection) {
258-
return c, fmt.Errorf("missing price section '%s'", priceSection)
259-
}
260-
261-
c.StoragePrice, err = parseConfigUint64Max(v, priceSection+".storage", "storage price", math.MaxUint64)
262-
if err != nil {
263-
return
264-
}
265-
266-
const feeSection = priceSection + ".fee"
267-
if !v.IsSet(feeSection) {
268-
return c, fmt.Errorf("missing fee section '%s'", feeSection)
269-
}
270-
271-
c.IRCandidateFee, err = parseConfigUint64Max(v, feeSection+".ir_candidate", "Inner Ring candidate fee", math.MaxUint64)
272-
if err != nil {
273-
return
274-
}
275-
276-
c.WithdrawalFee, err = parseConfigUint64Max(v, feeSection+".withdraw", "withdrawal fee", math.MaxUint64)
277-
if err != nil {
278-
return
279-
}
280-
281-
c.AuditFee, err = parseConfigUint64Max(v, feeSection+".audit", "data audit fee", math.MaxUint64)
282-
if err != nil {
283-
return
284-
}
285-
286-
c.ContainerFee, err = parseConfigUint64Max(v, feeSection+".new_container", "container creation fee", math.MaxUint64)
287-
if err != nil {
288-
return
289-
}
290-
291-
c.ContainerAliasFee, err = parseConfigUint64Max(v, feeSection+".container_domain", "container domain fee", math.MaxUint64)
292-
if err != nil {
293-
return
294-
}
295-
296-
customSettingsKey := networkSettingsConfigSection + ".custom"
297-
if v.IsSet(customSettingsKey) {
298-
var sss []string
299-
sss, err = parseConfigStrings(v, customSettingsKey, "custom settings")
300-
if err != nil {
301-
return
302-
}
303-
304-
if len(sss) == 0 {
305-
return c, fmt.Errorf("missing custom settings '%s'", customSettingsKey)
306-
}
307-
308-
c.Raw = make([]netmap.RawNetworkParameter, len(sss))
309-
310-
for i := range sss {
311-
const sep = "="
312-
ss := strings.Split(sss[i], sep)
313-
if len(ss) != 2 {
314-
return c, fmt.Errorf("invalid %s '%s' (%s-separated key-value): failed to parse element #%d", customSettingsKey, ss[i], sep, i)
315-
}
316-
317-
switch ss[0] {
318-
default:
319-
for j := 0; j < i; j++ {
320-
if ss[0] == c.Raw[j].Name {
321-
return c, fmt.Errorf("duplicated custom network setting '%s' in '%s'", ss[0], customSettingsKey)
322-
}
323-
}
324-
case "AuditFee",
325-
"BasicIncomeRate",
326-
"ContainerAliasFee",
327-
"ContainerFee",
328-
"EigenTrustAlpha",
329-
"EigenTrustIterations",
330-
"EpochDuration",
331-
"HomomorphicHashingDisabled",
332-
"InnerRingCandidateFee",
333-
"MaintenanceModeAllowed",
334-
"MaxObjectSize",
335-
"WithdrawFee":
336-
return c, fmt.Errorf("invalid %s '%s' (%s-separated key-value): key to element #%d is forbidden", customSettingsKey, ss[i], sep, i)
337-
}
338-
339-
c.Raw[i].Name = ss[0]
340-
c.Raw[i].Value = []byte(ss[1])
341-
}
342-
}
343-
344-
return
217+
// sets NeoFS network settings to be used for the NeoFS Sidechain
218+
// auto-deployment.
219+
func setNetworkSettingsDefaults(netCfg *netmap.NetworkConfiguration) {
220+
netCfg.MaxObjectSize = 64 << 20 // 64MB of object payload
221+
netCfg.EpochDuration = 240 // in NeoFS Sidechain blocks (e.g. ~1h for 15s block interval)
222+
netCfg.StoragePrice = 0 // in GAS per 1GB (NeoFS Balance contract's decimals)
223+
netCfg.AuditFee = 0 // in GAS per audit (NeoFS Balance contract's decimals)
224+
netCfg.ContainerFee = 1000 // in GAS per container (NeoFS Balance contract's decimals)
225+
netCfg.ContainerAliasFee = 500 // in GAS per container (NeoFS Balance contract's decimals)
226+
netCfg.IRCandidateFee = 100_0000_0000 // in GAS per candidate (Fixed8)
227+
netCfg.WithdrawalFee = 1_0000_0000 // in GAS per withdrawal (Fixed8)
228+
netCfg.EigenTrustIterations = 4
229+
netCfg.EigenTrustAlpha = 0.1
230+
netCfg.HomomorphicHashingDisabled = false
231+
netCfg.MaintenanceModeAllowed = false
345232
}
346233

347234
type nnsConfig struct {

0 commit comments

Comments
 (0)