1212 json_rpc/ rpcproxy, # must be early (compilation annoyance)
1313 json_serialization/ std/ net,
1414 beacon_chain/ conf_light_client,
15- beacon_chain/ nimbus_binary_common
15+ beacon_chain/ nimbus_binary_common,
16+ std/ strutils
1617
1718export net
1819
2526 kind* : Web3UrlKind
2627 web3Url* : string
2728
29+ UrlList * = object
30+ urls* : seq [string ]
31+
2832# !fmt: off
2933type VerifiedProxyConf * = object
3034 # Config
3135 configFile* {.
32- desc : " Loads the configuration from a TOML file"
33- name: " config-file" .}: Option [InputFile ]
36+ desc : " Loads the configuration from a TOML file" ,
37+ name : " config-file"
38+ .}: Option [InputFile ]
3439
3540 # Logging
3641 logLevel* {.
37- desc : " Sets the log level"
38- defaultValue: " INFO"
39- name: " log-level" .}: string
42+ desc : " Sets the log level" ,
43+ defaultValue : " INFO" ,
44+ name : " log-level"
45+ .}: string
4046
4147 logStdout* {.
42- hidden
43- desc : " Specifies what kind of logs should be written to stdout (auto, colors, nocolors, json)"
44- defaultValueDesc: " auto"
45- defaultValue: StdoutLogKind .Auto
46- name: " log-format" .}: StdoutLogKind
48+ hidden ,
49+ desc : " Specifies what kind of logs should be written to stdout (auto, colors, nocolors, json)" ,
50+ defaultValueDesc : " auto" ,
51+ defaultValue : StdoutLogKind .Auto ,
52+ name : " log-format"
53+ .}: StdoutLogKind
4754
4855 # Storage
4956 dataDirFlag* {.
50- desc : " The directory where nimbus will store all blockchain data"
51- abbr: " d"
52- name: " data-dir" .}: Option [OutDir ]
57+ desc : " The directory where nimbus will store all blockchain data" ,
58+ abbr : " d" ,
59+ name : " data-dir"
60+ .}: Option [OutDir ]
5361
5462 # Network
5563 eth2Network* {.
56- desc : " The Eth2 network to join"
57- defaultValueDesc: " mainnet"
58- name: " network" .}: Option [string ]
64+ desc : " The Eth2 network to join" ,
65+ defaultValueDesc : " mainnet" ,
66+ name : " network"
67+ .}: Option [string ]
5968
6069 accountCacheLen* {.
6170 hidden ,
@@ -95,8 +104,9 @@ type VerifiedProxyConf* = object
95104 # Consensus light sync
96105 # No default - Needs to be provided by the user
97106 trustedBlockRoot* {.
98- desc : " Recent trusted finalized block root to initialize light client from"
99- name: " trusted-block-root" .}: Eth2Digest
107+ desc : " Recent trusted finalized block root to initialize light client from" ,
108+ name : " trusted-block-root"
109+ .}: Eth2Digest
100110
101111 # (Untrusted) web3 provider
102112 # No default - Needs to be provided by the user
@@ -116,10 +126,10 @@ type VerifiedProxyConf* = object
116126
117127 # (Untrusted) web3 provider
118128 # No default - Needs to be provided by the user
119- lcEndpoint * {.
129+ lcEndpoints * {.
120130 desc : " command seperated URLs of the light client data provider" ,
121- name : " lc-endpoint "
122- .}: string
131+ name : " lc-endpoints "
132+ .}: UrlList
123133
124134# !fmt: on
125135
@@ -137,9 +147,25 @@ proc parseCmdArg*(T: type Web3Url, p: string): T {.raises: [ValueError].} =
137147 ValueError , " Web3 url should have defined scheme (http/https/ws/wss)"
138148 )
139149
150+ proc parseCmdArg * (T: type UrlList , p: string ): T {.raises : [ValueError ].} =
151+ let urls = p.split (',' )
152+
153+ for u in urls:
154+ let
155+ parsed = parseUri (u)
156+ normalizedScheme = parsed.scheme.toLowerAscii ()
157+
158+ if not (normalizedScheme == " http" or normalizedScheme == " https" ):
159+ raise newException (ValueError , " Light Client Endpoint should be a http(s) url" )
160+
161+ UrlList (urls: urls)
162+
140163proc completeCmdArg * (T: type Web3Url , val: string ): seq [string ] =
141164 return @ []
142165
166+ proc completeCmdArg * (T: type UrlList , val: string ): seq [string ] =
167+ return @ []
168+
143169# TODO : Cannot use ClientConfig in VerifiedProxyConf due to the fact that
144170# it contain `set[TLSFlags]` which does not have proper toml serialization
145171func asClientConfig * (url: Web3Url ): ClientConfig =
0 commit comments