From 94ca4371802cceb1cd8e33259f7dbbbd747334ff Mon Sep 17 00:00:00 2001
From: Pavel Karpy <p.karpy@yadro.com>
Date: Thu, 24 Nov 2022 20:53:59 +0300
Subject: [PATCH] [#241] ir: Provide common params with `.yml` file

Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
---
 services/ir/.ir.env            | 39 -----------------
 services/ir/cfg/config.yml     | 76 ++++++++++++++++++++++++++++++++++
 services/ir/docker-compose.yml |  6 +--
 3 files changed, 78 insertions(+), 43 deletions(-)
 create mode 100644 services/ir/cfg/config.yml

diff --git a/services/ir/.ir.env b/services/ir/.ir.env
index ddc40e6..ce4e331 100644
--- a/services/ir/.ir.env
+++ b/services/ir/.ir.env
@@ -1,42 +1,3 @@
-NEOFS_IR_LOGGER_LEVEL=debug
-
-# Profiler section
-NEOFS_IR_PPROF_ENABLED=true
-## Server address. Empty value disables profiler
-NEOFS_IR_PPROF_ADDRESS=:6060
-## Timeout to shut down the HTTP server
-## Default: 30s
-#NEOFS_IR_PROFILER_SHUTDOWN_TIMEOUT=1m
-
-# Application metrics section
-NEOFS_IR_PROMETHEUS_ENABLED=true
-## Server address. Empty value disables metrics gathering
-NEOFS_IR_PROMETHEUS_ADDRESS=:9090
-## Timeout to shut down the HTTP server
-## Default: 30s
-#NEOFS_IR_METRICS_SHUTDOWN_TIMEOUT=1m
-
-# Toggling the sidechain-only mode
-NEOFS_IR_WITHOUT_MAINNET=true
-
-NEOFS_IR_MORPH_ENDPOINT_CLIENT_0_ADDRESS=ws://morph-chain:30333/ws
-NEOFS_IR_TIMERS_EMIT=50
-NEOFS_IR_TIMERS_STOP_ESTIMATION_DIV=4
-NEOFS_IR_TIMERS_COLLECT_BASIC_INCOME_DIV=2
-NEOFS_IR_TIMERS_DISTRIBUTE_BASIC_INCOME_MUL=3
-NEOFS_IR_TIMERS_DISTRIBUTE_BASIC_INCOME_DIV=4
-
-NEOFS_IR_EMIT_STORAGE_AMOUNT=1000000000
-NEOFS_IR_NETMAP_CLEANER_ENABLED=true
-
 NEOFS_IR_CONTRACTS_FROSTFSID=1943e9bb78a0fe2fe0c95fd2677eec2da6aa4aa5
 
-NEOFS_IR_MORPH_VALIDATORS=02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
-NEOFS_IR_AUDIT_PDP_MAX_SLEEP_INTERVAL=100ms
-
-NEOFS_IR_SETTLEMENT_BASIC_INCOME_RATE=100000000
-NEOFS_IR_SETTLEMENT_AUDIT_FEE=100000
-
-NEOFS_IR_LOCODE_DB_PATH=/locode/db
-
 NEOFS_IR_CONTROL_GRPC_ENDPOINT=127.0.0.1:16512
diff --git a/services/ir/cfg/config.yml b/services/ir/cfg/config.yml
new file mode 100644
index 0000000..bb15b3b
--- /dev/null
+++ b/services/ir/cfg/config.yml
@@ -0,0 +1,76 @@
+# Logger section
+logger:
+  level: debug  # Minimum enabled logging level
+
+# Wallet settings
+wallet:
+  path: /wallet.json  # Path to NEP-6 NEO wallet file
+  address: Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn  # Account address in the wallet; ignore to use default address
+  password: one  # Account password in the wallet
+
+# Profiler section
+pprof:
+  enabled: true
+  address: :6060  # Endpoint for application pprof profiling; disabled by default
+  shutdown_timeout: 30s  # Timeout for profiling HTTP server graceful shutdown
+
+# Application metrics section
+prometheus:
+  enabled: true
+  address: :9090  # Endpoint for application prometheus metrics; disabled by default
+  shutdown_timeout: 30s  # Timeout for metrics HTTP server graceful shutdown
+
+# Toggling the sidechain-only mode
+without_mainnet: true
+
+# Neo main chain RPC settings
+mainnet:
+  endpoint:
+    client:  # List of websocket RPC endpoints in mainchain; ignore if mainchain is disabled
+      - address: ws://main-chain:30333/ws
+
+# Neo side chain RPC settings
+morph:
+  endpoint:
+    client:  # List of websocket RPC endpoints in sidechain
+      - address: ws://morph-chain:30333/ws
+  validators:  # List of hex-encoded 33-byte public keys of sidechain validators to vote for at application startup
+    - 02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2
+
+# Network time settings
+timers:
+  emit: 50  # Number of sidechain blocks between GAS emission cycles; disabled by default
+  stop_estimation:
+    mul: 1  # Multiplier in x/y relation of when to stop basic income estimation within the epoch
+    div: 4  # Divider in x/y relation of when to stop basic income estimation within the epoch
+  collect_basic_income:
+    mul: 1  # Multiplier in x/y relation of when to start basic income asset collection within the epoch
+    div: 2  # Divider in x/y relation of when to start basic income asset collecting within the epoch
+  distribute_basic_income:
+    mul: 3  # Multiplier in x/y relation of when to start basic income asset distribution within the epoch
+    div: 4  # Divider in x/y relation of when to start basic income asset distribution within the epoch
+
+# Storage node GAS emission settings
+emit:
+  storage:
+    amount: 1000000000  # Fixed8 value of sidechain GAS emitted to all storage nodes once per GAS emission cycle; disabled by default
+  
+# Storage node removal settings
+netmap_cleaner:
+  enabled: true  # Enable voting for removing stale storage nodes from network map
+  threshold: 3  # Number of FrostFS epoch without bootstrap request from storage node before it considered stale
+  
+# Audit settings
+audit:
+  pdp:
+    max_sleep_interval: 100ms  # Maximum timeout between object.RangeHash requests to the storage node
+    
+# Settlement settings
+settlement:
+  basic_income_rate: 100000000  # Optional: override basic income rate value from network config; applied only in debug mode
+  audit_fee: 100000  # Optional: override audit fee value from network config; applied only in debug mode
+
+# LOCODE database
+locode:
+  db:
+    path: /locode/db  # Path to UN/LOCODE database file
diff --git a/services/ir/docker-compose.yml b/services/ir/docker-compose.yml
index cf23e22..77ec50d 100644
--- a/services/ir/docker-compose.yml
+++ b/services/ir/docker-compose.yml
@@ -21,11 +21,9 @@ services:
       - ./../../vendor/locode_db:/locode/db
       - ./../../vendor/frostfs-cli:/frostfs-cli
       - ./healthcheck.sh:/healthcheck.sh
+      - ./cfg:/etc/frostfs/ir
     env_file: [ ".env", ".ir.env", ".int_test.env" ]
-    environment:
-    - NEOFS_IR_WALLET_PATH=/wallet.json
-    - NEOFS_IR_WALLET_ADDRESS=Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn
-    - NEOFS_IR_WALLET_PASSWORD=one
+    command: [ "frostfs-ir", "--config", "/etc/frostfs/ir/config.yml" ]
     healthcheck:
       test: ["CMD-SHELL", "/healthcheck.sh"]
       interval: 2s