@@ -21,8 +21,13 @@ import (
21
21
22
22
// checks whether Inner Ring app is configured to initialize underlying NeoFS
23
23
// 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
26
31
}
27
32
28
33
// 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
209
214
return c , nil
210
215
}
211
216
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
345
232
}
346
233
347
234
type nnsConfig struct {
0 commit comments