@@ -62,6 +62,7 @@ pub struct LocalKubernetesNetConfig {
6262 pub num_other_initial_chains : u32 ,
6363 pub initial_amount : Amount ,
6464 pub num_initial_validators : usize ,
65+ pub num_proxies : usize ,
6566 pub num_shards : usize ,
6667 pub binaries : BuildArg ,
6768 pub no_build : bool ,
@@ -90,6 +91,7 @@ pub struct LocalKubernetesNet {
9091 kubectl_instance : Arc < Mutex < KubectlInstance > > ,
9192 kind_clusters : Vec < KindCluster > ,
9293 num_initial_validators : usize ,
94+ num_proxies : usize ,
9395 num_shards : usize ,
9496 dual_store : bool ,
9597}
@@ -120,6 +122,7 @@ impl SharedLocalKubernetesNetTestingConfig {
120122 num_other_initial_chains : 2 ,
121123 initial_amount : Amount :: from_tokens ( 2000 ) ,
122124 num_initial_validators : 4 ,
125+ num_proxies : 1 ,
123126 num_shards : 4 ,
124127 binaries,
125128 no_build : false ,
@@ -158,6 +161,7 @@ impl LineraNetConfig for LocalKubernetesNetConfig {
158161 KubectlInstance :: new ( Vec :: new ( ) ) ,
159162 clusters,
160163 self . num_initial_validators ,
164+ self . num_proxies ,
161165 self . num_shards ,
162166 self . dual_store ,
163167 ) ?;
@@ -338,6 +342,7 @@ impl LocalKubernetesNet {
338342 kubectl_instance : KubectlInstance ,
339343 kind_clusters : Vec < KindCluster > ,
340344 num_initial_validators : usize ,
345+ num_proxies : usize ,
341346 num_shards : usize ,
342347 dual_store : bool ,
343348 ) -> Result < Self > {
@@ -353,6 +358,7 @@ impl LocalKubernetesNet {
353358 kubectl_instance : Arc :: new ( Mutex :: new ( kubectl_instance) ) ,
354359 kind_clusters,
355360 num_initial_validators,
361+ num_proxies,
356362 num_shards,
357363 dual_store,
358364 } )
@@ -365,40 +371,47 @@ impl LocalKubernetesNet {
365371 Ok ( command)
366372 }
367373
368- fn configuration_string ( & self , server_number : usize ) -> Result < String > {
369- let n = server_number;
370- let path = self . tmp_dir . path ( ) . join ( format ! ( "validator_{n}.toml" ) ) ;
371- let port = 19100 + server_number;
372- let internal_port = 20100 ;
374+ fn configuration_string ( & self , validator_number : usize ) -> Result < String > {
375+ let path = self
376+ . tmp_dir
377+ . path ( )
378+ . join ( format ! ( "validator_{validator_number}.toml" ) ) ;
379+ let public_port = 19100 ;
380+ let private_port = 20100 ;
373381 let metrics_port = 21100 ;
382+ let protocol = self . network . toml ( ) ;
383+ let host = self . network . localhost ( ) ;
374384 let mut content = format ! (
375385 r#"
376- server_config_path = "server_{n}.json"
377- host = "127.0.0.1"
378- port = {port}
379- [external_protocol]
380- Grpc = "ClearText"
381- [internal_protocol]
382- Grpc = "ClearText"
383-
384- [[proxies]]
385- host = "proxy-0.proxy-internal.default.svc.cluster.local"
386- public_port = {port}
387- private_port = {internal_port}
388- metrics_port = {metrics_port}
386+ server_config_path = "server_{validator_number}.json"
387+ host = "{host}"
388+ port = {public_port}
389+ external_protocol = {protocol}
390+ internal_protocol = {protocol}
391+
389392 "#
390393 ) ;
391394
392- for k in 0 ..self . num_shards {
393- let shard_port = 19100 ;
394- let shard_metrics_port = 21100 ;
395+ for proxy_id in 0 ..self . num_proxies {
396+ content. push_str ( & format ! (
397+ r#"
398+ [[proxies]]
399+ host = "proxy-{proxy_id}.proxy-internal.default.svc.cluster.local"
400+ public_port = {public_port}
401+ private_port = {private_port}
402+ metrics_port = {metrics_port}
403+ "#
404+ ) ) ;
405+ }
406+
407+ for shard_id in 0 ..self . num_shards {
395408 content. push_str ( & format ! (
396409 r#"
397410
398411 [[shards]]
399- host = "shards-{k }.shards.default.svc.cluster.local"
400- port = {shard_port }
401- metrics_port = {shard_metrics_port }
412+ host = "shards-{shard_id }.shards.default.svc.cluster.local"
413+ port = {public_port }
414+ metrics_port = {metrics_port }
402415 "#
403416 ) ) ;
404417 }
@@ -419,8 +432,8 @@ impl LocalKubernetesNet {
419432 self . testing_prng_seed = Some ( seed + 1 ) ;
420433 }
421434 command. arg ( "--validators" ) ;
422- for i in 0 ..self . num_initial_validators {
423- command. arg ( & self . configuration_string ( i ) ?) ;
435+ for validator_number in 0 ..self . num_initial_validators {
436+ command. arg ( & self . configuration_string ( validator_number ) ?) ;
424437 }
425438 command
426439 . args ( [ "--committee" , "committee.json" ] )
@@ -457,10 +470,11 @@ impl LocalKubernetesNet {
457470
458471 let kubectl_instance_clone = self . kubectl_instance . clone ( ) ;
459472 let tmp_dir_path_clone = self . tmp_dir . path ( ) . to_path_buf ( ) ;
473+ let num_proxies = self . num_proxies ;
460474 let num_shards = self . num_shards ;
461475
462476 let mut validators_initialization_futures = Vec :: new ( ) ;
463- for ( i , kind_cluster) in self . kind_clusters . iter ( ) . cloned ( ) . enumerate ( ) {
477+ for ( validator_number , kind_cluster) in self . kind_clusters . iter ( ) . cloned ( ) . enumerate ( ) {
464478 let base_dir = base_dir. clone ( ) ;
465479 let github_root = github_root. clone ( ) ;
466480
@@ -473,15 +487,16 @@ impl LocalKubernetesNet {
473487 let cluster_id = kind_cluster. id ( ) ;
474488 kind_cluster. load_docker_image ( & docker_image_name) . await ?;
475489
476- let server_config_filename = format ! ( "server_{}.json" , i ) ;
490+ let server_config_filename = format ! ( "server_{}.json" , validator_number ) ;
477491 fs_err:: copy (
478492 tmp_dir_path. join ( & server_config_filename) ,
479493 base_dir. join ( & server_config_filename) ,
480494 ) ?;
481495
482496 HelmFile :: sync (
483- i ,
497+ validator_number ,
484498 & github_root,
499+ num_proxies,
485500 num_shards,
486501 cluster_id,
487502 docker_image_name,
@@ -492,7 +507,7 @@ impl LocalKubernetesNet {
492507 let mut kubectl_instance = kubectl_instance. lock ( ) . await ;
493508 let proxy_service = "svc/proxy" ;
494509
495- let local_port = 19100 + i ;
510+ let local_port = 19100 + validator_number ;
496511 kubectl_instance. port_forward (
497512 proxy_service,
498513 & format ! ( "{local_port}:19100" ) ,
0 commit comments