service: move config flags to separate TOML file

This can be useful in the future to expose config.

It also makes it easier to run service by hand when debugging.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2024-05-13 10:30:52 +02:00
parent 1ec3d72aae
commit ebfece8f56
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4
5 changed files with 164 additions and 102 deletions

View File

@ -45,55 +45,57 @@ beacon_node_exec_layer_urls:
```
The order of Web Socket URLs matters. First is the default, the rest are fallbacks.
Most non-sensitive configuration resides in `conf/config.toml` file in service directory.
# Management
## Service
The services are managed using [WinSW](https://github.com/winsw/winsw).
```
admin@windows-01 MINGW64 .../nimbus/beacon-node-prater-stable
$ ls -l
total 665
-rwxr-xr-x 1 admin 197121 655872 Jul 16 14:37 beacon-node-prater-stable.exe*
-rw-r--r-- 1 admin 197121 1358 Oct 26 09:02 beacon-node-prater-stable.yml
drwxr-xr-x 1 admin 197121 0 Oct 21 13:23 bin/
-rwxr-xr-x 1 admin 197121 2639 Oct 7 07:51 build.sh*
drwxr-xr-x 1 admin 197121 0 Jul 16 14:49 data/
drwxr-xr-x 1 admin 197121 0 Oct 26 09:03 logs/
drwxr-xr-x 1 admin 197121 0 Oct 21 13:03 repo/
admin@windows-01 MINGW64 .../nimbus/beacon-node-prater-stable
$ ls -l
total 665
-rwxr-xr-x 1 admin 197121 655872 Jul 16 14:37 beacon-node-prater-stable.exe*
-rw-r--r-- 1 admin 197121 1358 Oct 26 09:02 beacon-node-prater-stable.yml
drwxr-xr-x 1 admin 197121 0 Oct 21 13:23 bin/
-rwxr-xr-x 1 admin 197121 2639 Oct 7 07:51 build.sh*
drwxr-xr-x 1 admin 197121 0 Jul 16 14:49 data/
drwxr-xr-x 1 admin 197121 0 Oct 26 09:03 logs/
drwxr-xr-x 1 admin 197121 0 Oct 21 13:03 repo/
-rwxr-xr-x 1 admin 197121 682 Oct 7 07:51 rpc.sh*
admin@windows-01 MINGW64 .../nimbus/beacon-node-prater-stable
$ ./beacon-node-prater-stable.exe status
Started
admin@windows-01 MINGW64 .../nimbus/beacon-node-prater-stable
$ ./beacon-node-prater-stable.exe restart
2021-09-29 17:33:27,563 INFO - Stopping service 'Beacon Node prater (stale) (beacon-node-prater-stable)'...
2021-09-29 17:33:27,825 INFO - Starting service 'Beacon Node prater (stale) (beacon-node-prater-stable)'...
2021-09-29 17:33:28,366 INFO - Service 'Beacon Node prater (stale) (beacon-node-prater-stable)' restarted successfully.
admin@windows-01 MINGW64 .../nimbus/beacon-node-prater-stable
$ ./beacon-node-prater-stable.exe status
Started
admin@windows-01 MINGW64 .../nimbus/beacon-node-prater-stable
$ ./beacon-node-prater-stable.exe restart
2021-09-29 17:33:27,563 INFO - Stopping service 'Beacon Node prater (stale) (beacon-node-prater-stable)'...
2021-09-29 17:33:27,825 INFO - Starting service 'Beacon Node prater (stale) (beacon-node-prater-stable)'...
2021-09-29 17:33:28,366 INFO - Service 'Beacon Node prater (stale) (beacon-node-prater-stable)' restarted successfully.
```
## Builds
Builds are performed via a Bash `build.sh` script located in the service directory.
```
admin@windows-01 MINGW64 .../nimbus/beacon-node-prater-stable
$ ./build.sh
>>> Fetching changes...
HEAD is now at 9e8081e4 Merge branch 'stable' into unstable
>>> Binaries already built.
>>> No binaries required update.
admin@windows-01 MINGW64 .../nimbus/beacon-node-prater-stable
$ ./build.sh
>>> Fetching changes...
HEAD is now at 9e8081e4 Merge branch 'stable' into unstable
>>> Binaries already built.
>>> No binaries required update.
>>> SUCCESS!
```
The scheduled tasks that trigger node builds can be checked with `Get-ScheduledTask`:
```log
PS C:\Users\admin> Get-ScheduledTask -TaskName 'build-beacon-node*' | ft State,TaskName,Description,Date
State TaskName Description Date
----- -------- ----------- ----
Ready build-beacon-node-prater-stable Daily rebuild of Nimbus beacon node binaries 2021-09-29T13:00:00
Ready build-beacon-node-prater-testing Daily rebuild of Nimbus beacon node binaries 2021-09-29T17:00:00
PS C:\Users\admin> Get-ScheduledTask -TaskName 'build-beacon-node*' | ft State,TaskName,Description,Date
State TaskName Description Date
----- -------- ----------- ----
Ready build-beacon-node-prater-stable Daily rebuild of Nimbus beacon node binaries 2021-09-29T13:00:00
Ready build-beacon-node-prater-testing Daily rebuild of Nimbus beacon node binaries 2021-09-29T17:00:00
Ready build-beacon-node-prater-unstable Daily rebuild of Nimbus beacon node binaries 2021-09-29T15:00:00
```
The task can be started using [`Start-ScheduledTask`](https://docs.microsoft.com/en-us/powershell/module/scheduledtasks/start-scheduledtask) and its logs can be looked up using [`Get-WinEvent`](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.diagnostics/get-winevent):
@ -110,13 +112,13 @@ TimeCreated Message
And the logs from the build script itself can be found in the `logs` directory:
```
admin@windows-01 MINGW64 .../nimbus/beacon-node-prater-stable
$ tail -n5 logs/build.log
>>> Fetching changes...
HEAD is now at 9e8081e4 Merge branch 'stable' into unstable
>>> Binaries already built.
>>> No binaries required update.
>>> SUCCESS!
admin@windows-01 MINGW64 .../nimbus/beacon-node-prater-stable
$ tail -n5 logs/build.log
>>> Fetching changes...
HEAD is now at 9e8081e4 Merge branch 'stable' into unstable
>>> Binaries already built.
>>> No binaries required update.
>>> SUCCESS!
```
# Known Issues

View File

@ -1,10 +1,13 @@
---
beacon_node_service_name: 'beacon-node-{{ beacon_node_network }}-{{ beacon_node_repo_branch }}'
beacon_node_service_user_name: 'nimbus'
beacon_node_service_user_pass: '{{ ansible_date_time.epoch | password_hash("sha512") }}'
beacon_node_service_home: 'C:\Users\{{ beacon_node_service_user_name }}'
beacon_node_service_path: '{{ beacon_node_service_home }}\{{ beacon_node_service_name }}'
beacon_node_data_path: '{{ beacon_node_service_path }}\data'
beacon_node_config_path: '{{ beacon_node_service_path }}\conf'
beacon_node_config_file_path: '{{ beacon_node_config_path }}\config.toml'
beacon_node_netkey_path: '{{ beacon_node_data_path }}\netkey'
beacon_node_era_dir_path: '{{ beacon_node_data_path }}\era'
beacon_node_secrets_path: '{{ beacon_node_data_path }}\secrets'
beacon_node_validators_path: '{{ beacon_node_data_path }}\validators'
@ -28,8 +31,11 @@ beacon_node_network: 'mainnet'
beacon_node_log_level: 'INFO' # TRACE DEBUG INFO NOTICE WARN ERROR FATAL NONE
beacon_node_log_format: 'json' # auto colors nocolors json none
beacon_node_history_retention: 'prune' # archive / prune
beacon_node_sync_light_client: false
beacon_node_subscribe_all: false
beacon_node_doppelganger_detection: true
# Ability to prevernt restarts after service changes.
beacon_node_service_restart: true
beacon_node_extra_flags: []
# Validator Monitoring

View File

@ -5,6 +5,7 @@
state: 'directory'
with_items:
- '{{ beacon_node_service_path }}'
- '{{ beacon_node_config_path }}'
- '{{ beacon_node_service_logs_path }}'
- '{{ beacon_node_data_path }}'
@ -50,3 +51,9 @@
win_owner:
path: '{{ beacon_node_exec_layer_jwt_secret_path }}'
user: '{{ beacon_node_service_user_name }}'
- name: Create node config
win_template:
src: 'config.toml.j2'
dest: '{{ beacon_node_config_file_path }}'
register: beacon_node_config_file

View File

@ -4,74 +4,19 @@
vars:
winsw_service_name: 'Beacon Node {{ beacon_node_network }} ({{ beacon_node_repo_branch }})'
winsw_service_description: 'Nimbus Eth2 Beacon Node running on {{ beacon_node_network }} network using {{ beacon_node_repo_branch }} branch.'
winsw_service_id: '{{ beacon_node_service_name }}'
winsw_service_path: '{{ beacon_node_service_path }}'
winsw_service_user: '{{ beacon_node_service_user_name }}'
winsw_service_logon_enabled: true
winsw_service_id: '{{ beacon_node_service_name }}'
winsw_service_path: '{{ beacon_node_service_path }}'
winsw_service_user: '{{ beacon_node_service_user_name }}'
winsw_service_restart: '{{ beacon_node_config_file.changed }}'
winsw_service_logon_domain: '{{ ansible_netbios_name }}'
winsw_service_logon_pass: '{{ beacon_node_service_user_pass }}'
winsw_service_logon_pass: '{{ beacon_node_service_user_pass }}'
winsw_service_logon_enabled: true
winsw_service_log_size: 1024000
winsw_service_log_keep: 10
winsw_service_log_stderr_disabled: true
winsw_service_exe_path: '{{ beacon_node_service_exe }}'
winsw_service_exe_path: '{{ beacon_node_service_exe }}'
winsw_service_arguments: |
--non-interactive
--network={{ beacon_node_network }}
--data-dir="{{ beacon_node_data_path }}"
--secrets-dir="{{ beacon_node_secrets_path }}"
--validators-dir="{{ beacon_node_validators_path }}"
--era-dir="{{ beacon_node_era_dir_path }}"
--history="{{ beacon_node_history_retention }}"
{% if beacon_node_exec_layer_urls|length == 0 %}
--no-el=true
{% else %}
{% for url in beacon_node_exec_layer_urls | mandatory %}
--el="{{ url | mandatory }}"
{% endfor %}
{% endif %}
{% if beacon_node_exec_layer_jwt_secret is defined %}
--jwt-secret="{{ beacon_node_exec_layer_jwt_secret_path | mandatory }}"
{% endif %}
--config-file={{ beacon_node_config_file_path }}
{% if beacon_node_suggested_fee_recipient is defined %}
--suggested-fee-recipient={{ beacon_node_suggested_fee_recipient | mandatory }}
{% endif %}
--log-format={{ beacon_node_log_format }}
--log-level={{ beacon_node_log_level }}
--nat=extip:{{ beacon_node_public_address }}
--tcp-port={{ beacon_node_listening_port }}
--udp-port={{ beacon_node_discovery_port }}
--max-peers={{ beacon_node_max_peers }}
--num-threads={{ beacon_node_threads }}
--insecure-netkey-password=true
--subscribe-all-subnets={{ beacon_node_subscribe_all | to_json }}
--doppelganger-detection={{ beacon_node_doppelganger_detection | to_json }}
--rest={{ beacon_node_rest_enabled | to_json }}
{% if beacon_node_rest_enabled %}
--rest-address={{ beacon_node_rest_address }}
--rest-port={{ beacon_node_rest_port }}
--rest-max-body-size={{ beacon_node_rest_max_body_size | mandatory }}
--rest-max-headers-size={{ beacon_node_rest_max_headers_size | mandatory }}
{% if beacon_node_rest_allow_origin != '' %}
--rest-allow-origin="{{ beacon_node_rest_allow_origin }}"
{% endif %}
{% endif %}
--metrics={{ beacon_node_metrics_enabled | to_json }}
{% if beacon_node_metrics_enabled %}
--metrics-address={{ beacon_node_metrics_address }}
--metrics-port={{ beacon_node_metrics_port }}
{% endif %}
--validator-monitor-auto={{ beacon_node_validator_monitor_auto | to_json }}
--validator-monitor-details={{ beacon_node_validator_monitor_details | to_json }}
{% for pubkey in beacon_node_validator_monitor_pubkeys %}
--validator-monitor-pubkey={{ pubkey }}
{% endfor %}
{% if beacon_node_light_client_data_enabled %}
--light-client-data-serve={{ beacon_node_light_client_data_serve | to_json }}
--light-client-data-import-mode={{ beacon_node_light_client_data_import_mode }}
{% if beacon_node_light_client_data_max_periods >= 0 %}
--light-client-data-max-periods={{ beacon_node_light_client_data_max_periods }}
{% endif %}
{% endif %}
{% for extra_flag in beacon_node_extra_flags %}
{{ extra_flag }}
{% endfor %}

102
templates/config.toml.j2 Normal file
View File

@ -0,0 +1,102 @@
# Hostname: {{ dns_entry }}
## WARNING: Do not put sensitive configuration here. Use service definition.
### General
network = {{ beacon_node_network | to_json }}
history = {{ beacon_node_history_retention | to_json }}
num-threads = {{ beacon_node_threads }}
sync-light-client = {{ beacon_node_sync_light_client | to_json }}
subscribe-all-subnets = {{ beacon_node_subscribe_all | to_json }}
non-interactive = true
### Logs
log-format = {{ beacon_node_log_format | to_json }}
log-level = {{ beacon_node_log_level | to_json }}
### Network
nat = "extip:{{ beacon_node_public_address }}"
tcp-port = {{ beacon_node_listening_port }}
udp-port = {{ beacon_node_discovery_port }}
max-peers = {{ beacon_node_max_peers }}
### Exec Layer
{% if beacon_node_exec_layer_urls|length == 0 %}
no-el = true
{% else %}
{% if beacon_node_exec_layer_urls %}
el = [
{% for url in beacon_node_exec_layer_urls | mandatory %}
{{ url | mandatory | to_json }},
{% endfor %}]
{% else %}
el = []
{% endif %}
{% endif %}
### Dirs
data-dir = {{ beacon_node_data_path | to_json }}
secrets-dir = {{ beacon_node_secrets_path | to_json }}
validators-dir = {{ beacon_node_validators_path | to_json }}
era-dir = {{ beacon_node_era_dir_path | to_json }}
### Security
netkey-file = {{ beacon_node_netkey_path | to_json }}
{% if beacon_node_exec_layer_jwt_secret is defined %}
jwt-secret = {{ beacon_node_exec_layer_jwt_secret_path | mandatory | to_json }}
{% endif %}
doppelganger-detection = {{ beacon_node_doppelganger_detection | to_json }}
insecure-netkey-password = true
{% if beacon_node_payload_builder_enabled %}
### Payload Builder
payload-builder = {{ beacon_node_payload_builder_enabled | to_json | to_json }}
payload-builder-url = {{ beacon_node_payload_builder_url | mandatory | to_json }}
{% endif %}
### REST API
rest = {{ beacon_node_rest_enabled | to_json }}
{% if beacon_node_rest_enabled %}
rest-address = {{ beacon_node_rest_address | to_json }}
rest-port = {{ beacon_node_rest_port }}
{% if beacon_node_rest_allow_origin != '' %}
rest-allow-origin = {{ beacon_node_rest_allow_origin | to_json }}
{% endif %}
rest-max-body-size = {{ beacon_node_rest_max_body_size | mandatory }}
rest-max-headers-size = {{ beacon_node_rest_max_headers_size | mandatory }}
{% endif %}
### Metrics
metrics = {{ beacon_node_metrics_enabled | to_json }}
{% if beacon_node_metrics_enabled %}
metrics-address = {{ beacon_node_metrics_address | to_json }}
metrics-port = {{ beacon_node_metrics_port }}
{% endif %}
### Monitoring
validator-monitor-auto = {{ beacon_node_validator_monitor_auto | to_json }}
validator-monitor-details = {{ beacon_node_validator_monitor_details | to_json }}
{% if beacon_node_validator_monitor_pubkeys %}
validator-monitor-pubkey = [
{% for pubkey in beacon_node_validator_monitor_pubkeys %}
{{ pubkey | to_json }},
{% endfor %}]
{% else %}
validator-monitor-pubkey = []
{% endif %}
{% if beacon_node_light_client_data_enabled %}
### Light Client
light-client-data-serve = {{ beacon_node_light_client_data_serve | to_json }}
light-client-data-import-mode = {{ beacon_node_light_client_data_import_mode | to_json }}
{% if beacon_node_light_client_data_max_periods >= 0 %}
light-client-data-max-periods = {{ beacon_node_light_client_data_max_periods }}
{% endif %}
{% endif -%}
{% if beacon_node_extra_flags %}
### Extra Flags
{% for key,value in beacon_node_extra_flags %}
{{ key }} = {{ value | to_json }}
{% endfor %}
{% endif %}