@@ -31,7 +31,7 @@ use sc_network::multiaddr;
3131use sc_service:: config:: {
3232 DatabaseSource , ExecutorConfiguration , KeystoreConfig , MultiaddrWithPeerId ,
3333 NetworkConfiguration , OffchainWorkerConfig , PruningMode , RpcBatchRequestConfig ,
34- RpcConfiguration , WasmExecutionMethod , WasmtimeInstantiationStrategy ,
34+ RpcConfiguration , RpcEndpoint , WasmExecutionMethod , WasmtimeInstantiationStrategy ,
3535} ;
3636use sc_service:: {
3737 BasePath , BlocksPruning , ChainSpec , Configuration as ServiceConfiguration ,
@@ -48,6 +48,7 @@ use sp_runtime::generic;
4848use sp_runtime:: generic:: SignedPayload ;
4949use sp_runtime:: traits:: { AsSystemOriginSigner , Dispatchable } ;
5050use std:: fmt:: { Debug , Display } ;
51+ use std:: net:: SocketAddr ;
5152use std:: str:: FromStr ;
5253
5354/// The domain id of the evm domain
@@ -72,6 +73,8 @@ pub fn node_config(
7273 role : Role ,
7374 base_path : BasePath ,
7475 chain_spec : Box < dyn ChainSpec > ,
76+ rpc_addr : Option < SocketAddr > ,
77+ rpc_port : Option < u16 > ,
7578) -> Result < ServiceConfiguration , ServiceError > {
7679 let root = base_path. path ( ) . to_path_buf ( ) ;
7780
@@ -104,6 +107,59 @@ pub fn node_config(
104107
105108 network_config. transport = TransportConfig :: MemoryOnly ;
106109
110+ let rpc_configuration = match rpc_addr {
111+ Some ( listen_addr) => {
112+ let port = rpc_port. unwrap_or ( 9945 ) ;
113+ RpcConfiguration {
114+ addr : Some ( vec ! [ RpcEndpoint {
115+ batch_config: RpcBatchRequestConfig :: Disabled ,
116+ max_connections: 10 ,
117+ listen_addr,
118+ rpc_methods: Default :: default ( ) ,
119+ rate_limit: None ,
120+ rate_limit_trust_proxy_headers: false ,
121+ rate_limit_whitelisted_ips: vec![ ] ,
122+ max_payload_in_mb: 15 ,
123+ max_payload_out_mb: 15 ,
124+ max_subscriptions_per_connection: 10 ,
125+ max_buffer_capacity_per_connection: 10 ,
126+ cors: None ,
127+ retry_random_port: true ,
128+ is_optional: false ,
129+ } ] ) ,
130+ max_request_size : 15 ,
131+ max_response_size : 15 ,
132+ id_provider : None ,
133+ max_subs_per_conn : 1024 ,
134+ port,
135+ message_buffer_capacity : 1024 ,
136+ batch_config : RpcBatchRequestConfig :: Disabled ,
137+ max_connections : 1000 ,
138+ cors : None ,
139+ methods : Default :: default ( ) ,
140+ rate_limit : None ,
141+ rate_limit_whitelisted_ips : vec ! [ ] ,
142+ rate_limit_trust_proxy_headers : false ,
143+ }
144+ }
145+ None => RpcConfiguration {
146+ addr : None ,
147+ max_request_size : 0 ,
148+ max_response_size : 0 ,
149+ id_provider : None ,
150+ max_subs_per_conn : 0 ,
151+ port : 0 ,
152+ message_buffer_capacity : 0 ,
153+ batch_config : RpcBatchRequestConfig :: Disabled ,
154+ max_connections : 0 ,
155+ cors : None ,
156+ methods : Default :: default ( ) ,
157+ rate_limit : None ,
158+ rate_limit_whitelisted_ips : vec ! [ ] ,
159+ rate_limit_trust_proxy_headers : false ,
160+ } ,
161+ } ;
162+
107163 Ok ( ServiceConfiguration {
108164 impl_name : "domain-test-node" . to_string ( ) ,
109165 impl_version : "0.1" . to_string ( ) ,
@@ -127,22 +183,7 @@ pub fn node_config(
127183 default_heap_pages : None ,
128184 runtime_cache_size : 2 ,
129185 } ,
130- rpc : RpcConfiguration {
131- addr : None ,
132- max_request_size : 0 ,
133- max_response_size : 0 ,
134- id_provider : None ,
135- max_subs_per_conn : 0 ,
136- port : 0 ,
137- message_buffer_capacity : 0 ,
138- batch_config : RpcBatchRequestConfig :: Disabled ,
139- max_connections : 0 ,
140- cors : None ,
141- methods : Default :: default ( ) ,
142- rate_limit : None ,
143- rate_limit_whitelisted_ips : vec ! [ ] ,
144- rate_limit_trust_proxy_headers : false ,
145- } ,
186+ rpc : rpc_configuration,
146187 prometheus_config : None ,
147188 telemetry_endpoints : None ,
148189 offchain_worker : OffchainWorkerConfig {
0 commit comments