From 7d2b530a20bd4653979277025a8c4f56d637c056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6khan=20=C5=9Eim=C5=9Fek?= Date: Wed, 18 Dec 2024 10:05:57 +0100 Subject: [PATCH 1/3] Changing primary_address to use tcp and adding ip4/ip6/dns support for transport string --- crates/iota/src/validator_commands.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/crates/iota/src/validator_commands.rs b/crates/iota/src/validator_commands.rs index 320cbae07ef..eba2f1d9b4c 100644 --- a/crates/iota/src/validator_commands.rs +++ b/crates/iota/src/validator_commands.rs @@ -6,6 +6,7 @@ use std::{ collections::{BTreeMap, HashSet}, fmt::{self, Debug, Display, Formatter, Write}, fs, + net::{Ipv4Addr, Ipv6Addr}, path::PathBuf, }; @@ -330,6 +331,13 @@ impl IotaValidatorCommand { &authority_keypair, (&account_keypair.public()).into(), ); + let transport_str = if host_name.parse::().is_ok() { + "ip4" + } else if host_name.parse::().is_ok() { + "ip6" + } else { + "dns" + }; let validator_info = GenesisValidatorInfo { info: iota_genesis_builder::validator_info::ValidatorInfo { name, @@ -340,13 +348,16 @@ impl IotaValidatorCommand { gas_price, commission_rate: iota_config::node::DEFAULT_COMMISSION_RATE, network_address: Multiaddr::try_from(format!( - "/dns/{}/tcp/8080/http", - host_name + "/{}/{}/tcp/8080/http", + transport_str, host_name + ))?, + p2p_address: Multiaddr::try_from(format!( + "/{}/{}/udp/8084", + transport_str, host_name ))?, - p2p_address: Multiaddr::try_from(format!("/dns/{}/udp/8084", host_name))?, primary_address: Multiaddr::try_from(format!( - "/dns/{}/udp/8081", - host_name + "/{}/{}/tcp/8081", + transport_str, host_name ))?, description, image_url, From e0e2326b1b7517db9509c742bdc281a086a2c402 Mon Sep 17 00:00:00 2001 From: Chloe Martin Date: Thu, 19 Dec 2024 09:13:41 -0500 Subject: [PATCH 2/3] minor improvements --- crates/iota/src/validator_commands.rs | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/crates/iota/src/validator_commands.rs b/crates/iota/src/validator_commands.rs index eba2f1d9b4c..9a7609e80d1 100644 --- a/crates/iota/src/validator_commands.rs +++ b/crates/iota/src/validator_commands.rs @@ -6,7 +6,7 @@ use std::{ collections::{BTreeMap, HashSet}, fmt::{self, Debug, Display, Formatter, Write}, fs, - net::{Ipv4Addr, Ipv6Addr}, + net::IpAddr, path::PathBuf, }; @@ -331,12 +331,10 @@ impl IotaValidatorCommand { &authority_keypair, (&account_keypair.public()).into(), ); - let transport_str = if host_name.parse::().is_ok() { - "ip4" - } else if host_name.parse::().is_ok() { - "ip6" - } else { - "dns" + let transport_str = match host_name.parse::() { + Ok(IpAddr::V4(_)) => "ip4", + Ok(IpAddr::V6(_)) => "ip6", + Err(_) => "dns", }; let validator_info = GenesisValidatorInfo { info: iota_genesis_builder::validator_info::ValidatorInfo { @@ -348,16 +346,13 @@ impl IotaValidatorCommand { gas_price, commission_rate: iota_config::node::DEFAULT_COMMISSION_RATE, network_address: Multiaddr::try_from(format!( - "/{}/{}/tcp/8080/http", - transport_str, host_name + "/{transport_str}/{host_name}/tcp/8080/http", ))?, p2p_address: Multiaddr::try_from(format!( - "/{}/{}/udp/8084", - transport_str, host_name + "/{transport_str}/{host_name}/udp/8084", ))?, primary_address: Multiaddr::try_from(format!( - "/{}/{}/tcp/8081", - transport_str, host_name + "/{transport_str}/{host_name}/tcp/8081", ))?, description, image_url, @@ -369,10 +364,7 @@ impl IotaValidatorCommand { let validator_info_file_name = dir.join("validator.info"); let validator_info_bytes = serde_yaml::to_string(&validator_info)?; fs::write(validator_info_file_name.clone(), validator_info_bytes)?; - println!( - "Generated validator info file: {:?}.", - validator_info_file_name - ); + println!("Generated validator info file: {validator_info_file_name:?}."); IotaValidatorCommandResponse::MakeValidatorInfo } IotaValidatorCommand::BecomeCandidate { file, gas_budget } => { From c05d7e4ce4bfee70927474215130f0e7af37ae33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6khan=20=C5=9Eim=C5=9Fek?= Date: Fri, 20 Dec 2024 08:07:46 +0100 Subject: [PATCH 3/3] Changing primary_address to use tcp all other places --- crates/iota-core/src/test_utils.rs | 2 +- .../packages/iota-system/tests/iota_system_tests.move | 6 +++--- .../packages/iota-system/tests/validator_tests.move | 4 ++-- crates/iota-genesis-builder/src/lib.rs | 2 +- .../iota-graphql-e2e-tests/tests/transactions/system.exp | 2 +- crates/iota-swarm-config/tests/snapshot_tests.rs | 2 +- ...pshot_tests__populated_genesis_snapshot_matches-2.snap | 2 +- crates/iota/src/fire_drill.rs | 4 ++-- crates/iota/src/generate_genesis_checkpoint.rs | 2 +- crates/iota/src/genesis_ceremony.rs | 2 +- docker/iota-network/genesis/compose-validators.yaml | 8 ++++---- docker/iota-private-network/configs/genesis-template.yaml | 8 ++++---- docs/content/references/cli/validator.mdx | 2 +- 13 files changed, 23 insertions(+), 23 deletions(-) diff --git a/crates/iota-core/src/test_utils.rs b/crates/iota-core/src/test_utils.rs index 4a215adf02a..b88068d38b1 100644 --- a/crates/iota-core/src/test_utils.rs +++ b/crates/iota-core/src/test_utils.rs @@ -235,7 +235,7 @@ async fn init_genesis( commission_rate: 0, network_address: local_ip_utils::new_local_tcp_address_for_testing(), p2p_address: local_ip_utils::new_local_udp_address_for_testing(), - primary_address: local_ip_utils::new_local_udp_address_for_testing(), + primary_address: local_ip_utils::new_local_tcp_address_for_testing(), description: String::new(), image_url: String::new(), project_url: String::new(), diff --git a/crates/iota-framework/packages/iota-system/tests/iota_system_tests.move b/crates/iota-framework/packages/iota-system/tests/iota_system_tests.move index 18d51aaff4b..2173259c6e6 100644 --- a/crates/iota-framework/packages/iota-system/tests/iota_system_tests.move +++ b/crates/iota-framework/packages/iota-system/tests/iota_system_tests.move @@ -365,7 +365,7 @@ module iota_system::iota_system_tests { system_state.update_validator_project_url(b"new_project_url", ctx); system_state.update_candidate_validator_network_address(network_address, ctx); system_state.update_candidate_validator_p2p_address(p2p_address, ctx); - system_state.update_candidate_validator_primary_address(b"/ip4/127.0.0.1/udp/80", ctx); + system_state.update_candidate_validator_primary_address(b"/ip4/127.0.0.1/tcp/80", ctx); system_state.update_candidate_validator_authority_pubkey( authority_pub_key, pop, @@ -428,7 +428,7 @@ module iota_system::iota_system_tests { system_state.update_validator_project_url(b"new_project_url", ctx); system_state.update_validator_next_epoch_network_address(network_address, ctx); system_state.update_validator_next_epoch_p2p_address(p2p_address, ctx); - system_state.update_validator_next_epoch_primary_address(b"/ip4/168.168.168.168/udp/80", ctx); + system_state.update_validator_next_epoch_primary_address(b"/ip4/168.168.168.168/tcp/80", ctx); system_state.update_validator_next_epoch_authority_pubkey( authority_pub_key, pop, @@ -470,7 +470,7 @@ module iota_system::iota_system_tests { // Next epoch assert!(validator.next_epoch_network_address() == &option::some(new_network_address.to_string())); assert!(validator.next_epoch_p2p_address() == &option::some(new_p2p_address.to_string())); - assert!(validator.next_epoch_primary_address() == &option::some(b"/ip4/168.168.168.168/udp/80".to_string())); + assert!(validator.next_epoch_primary_address() == &option::some(b"/ip4/168.168.168.168/tcp/80".to_string())); assert!( validator.next_epoch_authority_pubkey_bytes() == &option::some(new_authority_pub_key), 0 diff --git a/crates/iota-framework/packages/iota-system/tests/validator_tests.move b/crates/iota-framework/packages/iota-system/tests/validator_tests.move index 99e992fd21c..10014877010 100644 --- a/crates/iota-framework/packages/iota-system/tests/validator_tests.move +++ b/crates/iota-framework/packages/iota-system/tests/validator_tests.move @@ -338,7 +338,7 @@ module iota_system::validator_tests { { validator.update_next_epoch_network_address(b"/ip4/192.168.1.1/tcp/80"); validator.update_next_epoch_p2p_address(b"/ip4/192.168.1.1/udp/80"); - validator.update_next_epoch_primary_address(b"/ip4/192.168.1.1/udp/80"); + validator.update_next_epoch_primary_address(b"/ip4/192.168.1.1/tcp/80"); validator.update_next_epoch_authority_pubkey(new_authority_pub_key, new_pop); validator.update_next_epoch_protocol_pubkey(new_protocol_pub_key); validator.update_next_epoch_network_pubkey(new_network_pub_key); @@ -367,7 +367,7 @@ module iota_system::validator_tests { // Next epoch assert!(validator.next_epoch_network_address() == &option::some(b"/ip4/192.168.1.1/tcp/80".to_string())); assert!(validator.next_epoch_p2p_address() == &option::some(b"/ip4/192.168.1.1/udp/80".to_string())); - assert!(validator.next_epoch_primary_address() == &option::some(b"/ip4/192.168.1.1/udp/80".to_string())); + assert!(validator.next_epoch_primary_address() == &option::some(b"/ip4/192.168.1.1/tcp/80".to_string())); assert!( validator.next_epoch_authority_pubkey_bytes() == &option::some(new_authority_pub_key), 0 diff --git a/crates/iota-genesis-builder/src/lib.rs b/crates/iota-genesis-builder/src/lib.rs index ac464c309ce..e72e1d3fd9d 100644 --- a/crates/iota-genesis-builder/src/lib.rs +++ b/crates/iota-genesis-builder/src/lib.rs @@ -1783,7 +1783,7 @@ mod test { commission_rate: DEFAULT_COMMISSION_RATE, network_address: local_ip_utils::new_local_tcp_address_for_testing(), p2p_address: local_ip_utils::new_local_udp_address_for_testing(), - primary_address: local_ip_utils::new_local_udp_address_for_testing(), + primary_address: local_ip_utils::new_local_tcp_address_for_testing(), description: String::new(), image_url: String::new(), project_url: String::new(), diff --git a/crates/iota-graphql-e2e-tests/tests/transactions/system.exp b/crates/iota-graphql-e2e-tests/tests/transactions/system.exp index bdad7857c2f..6ce2c77e8ea 100644 --- a/crates/iota-graphql-e2e-tests/tests/transactions/system.exp +++ b/crates/iota-graphql-e2e-tests/tests/transactions/system.exp @@ -881,7 +881,7 @@ Response: { }, "net_address": "/ip4/127.0.0.1/tcp/8000/http", "p2p_address": "/ip4/127.0.0.1/udp/8001/http", - "primary_address": "/ip4/127.0.0.1/udp/8003/http", + "primary_address": "/ip4/127.0.0.1/tcp/8003/http", "next_epoch_authority_pubkey_bytes": null, "next_epoch_proof_of_possession": null, "next_epoch_network_pubkey_bytes": null, diff --git a/crates/iota-swarm-config/tests/snapshot_tests.rs b/crates/iota-swarm-config/tests/snapshot_tests.rs index 2994f8d0ad1..b9e85083172 100644 --- a/crates/iota-swarm-config/tests/snapshot_tests.rs +++ b/crates/iota-swarm-config/tests/snapshot_tests.rs @@ -75,7 +75,7 @@ fn populated_genesis_snapshot_matches() { commission_rate: DEFAULT_COMMISSION_RATE, network_address: "/ip4/127.0.0.1/tcp/80".parse().unwrap(), p2p_address: "/ip4/127.0.0.1/udp/80".parse().unwrap(), - primary_address: "/ip4/127.0.0.1/udp/80".parse().unwrap(), + primary_address: "/ip4/127.0.0.1/tcp/80".parse().unwrap(), description: String::new(), image_url: String::new(), project_url: String::new(), diff --git a/crates/iota-swarm-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-2.snap b/crates/iota-swarm-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-2.snap index c4a877d419f..740ea824c75 100644 --- a/crates/iota-swarm-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-2.snap +++ b/crates/iota-swarm-config/tests/snapshots/snapshot_tests__populated_genesis_snapshot_matches-2.snap @@ -234,7 +234,7 @@ validators: project_url: "" net_address: /ip4/127.0.0.1/tcp/80 p2p_address: /ip4/127.0.0.1/udp/80 - primary_address: /ip4/127.0.0.1/udp/80 + primary_address: /ip4/127.0.0.1/tcp/80 next_epoch_authority_pubkey_bytes: ~ next_epoch_proof_of_possession: ~ next_epoch_network_pubkey_bytes: ~ diff --git a/crates/iota/src/fire_drill.rs b/crates/iota/src/fire_drill.rs index 371ccc33407..8ca23f6bafb 100644 --- a/crates/iota/src/fire_drill.rs +++ b/crates/iota/src/fire_drill.rs @@ -203,10 +203,10 @@ async fn update_next_epoch_metadata( let mut new_primary_addresses = Multiaddr::try_from(self_validator.primary_address.clone()).unwrap(); info!("Current primary address: {:?}", new_primary_addresses); - // pop out udp + // pop out tcp new_primary_addresses.pop().unwrap(); let new_port = local_ip_utils::get_available_port(&localhost); - new_primary_addresses.push(Protocol::Udp(new_port)); + new_primary_addresses.push(Protocol::Tcp(new_port)); info!("New primary address: {:?}", new_primary_addresses); // Save new config diff --git a/crates/iota/src/generate_genesis_checkpoint.rs b/crates/iota/src/generate_genesis_checkpoint.rs index 3f73081f419..d5ca0009a86 100644 --- a/crates/iota/src/generate_genesis_checkpoint.rs +++ b/crates/iota/src/generate_genesis_checkpoint.rs @@ -35,7 +35,7 @@ async fn main() { commission_rate: iota_config::node::DEFAULT_COMMISSION_RATE, network_address: local_ip_utils::new_local_tcp_address_for_testing(), p2p_address: local_ip_utils::new_local_udp_address_for_testing(), - primary_address: local_ip_utils::new_local_udp_address_for_testing(), + primary_address: local_ip_utils::new_local_tcp_address_for_testing(), description: String::new(), image_url: String::new(), project_url: String::new(), diff --git a/crates/iota/src/genesis_ceremony.rs b/crates/iota/src/genesis_ceremony.rs index 162acf416ce..105c23cab51 100644 --- a/crates/iota/src/genesis_ceremony.rs +++ b/crates/iota/src/genesis_ceremony.rs @@ -390,7 +390,7 @@ mod test { commission_rate: iota_config::node::DEFAULT_COMMISSION_RATE, network_address: local_ip_utils::new_local_tcp_address_for_testing(), p2p_address: local_ip_utils::new_local_udp_address_for_testing(), - primary_address: local_ip_utils::new_local_udp_address_for_testing(), + primary_address: local_ip_utils::new_local_tcp_address_for_testing(), description: String::new(), image_url: String::new(), project_url: String::new(), diff --git a/docker/iota-network/genesis/compose-validators.yaml b/docker/iota-network/genesis/compose-validators.yaml index 0c6fab83fc7..55c36dcc207 100644 --- a/docker/iota-network/genesis/compose-validators.yaml +++ b/docker/iota-network/genesis/compose-validators.yaml @@ -17,7 +17,7 @@ validator_config_info: - commission_rate: 0 gas_price: 1000 name: validator1 - primary_address: /dns/validator1/udp/8081 + primary_address: /dns/validator1/tcp/8081 network_address: /dns/validator1/tcp/8080/http p2p_address: /dns/validator1/udp/8084 stake: 20000000000000000 @@ -26,21 +26,21 @@ validator_config_info: - commission_rate: 0 gas_price: 1000 name: validator2 - primary_address: /dns/validator2/udp/8081 + primary_address: /dns/validator2/tcp/8081 network_address: /dns/validator2/tcp/8080/http p2p_address: /dns/validator2/udp/8084 stake: 20000000000000000 - commission_rate: 0 gas_price: 1000 name: validator3 - primary_address: /dns/validator3/udp/8081 + primary_address: /dns/validator3/tcp/8081 network_address: /dns/validator3/tcp/8080/http p2p_address: /dns/validator3/udp/8084 stake: 20000000000000000 - commission_rate: 0 gas_price: 1000 name: validator4 - primary_address: /dns/validator4/udp/8081 + primary_address: /dns/validator4/tcp/8081 network_address: /dns/validator4/tcp/8080/http p2p_address: /dns/validator4/udp/8084 stake: 20000000000000000 diff --git a/docker/iota-private-network/configs/genesis-template.yaml b/docker/iota-private-network/configs/genesis-template.yaml index 1650e388275..c0cefce1ad9 100644 --- a/docker/iota-private-network/configs/genesis-template.yaml +++ b/docker/iota-private-network/configs/genesis-template.yaml @@ -20,28 +20,28 @@ validator_config_info: - commission_rate: 0 gas_price: 1000 name: validator-1 - primary_address: /dns/validator-1/udp/8081 + primary_address: /dns/validator-1/tcp/8081 network_address: /dns/validator-1/tcp/8080/http p2p_address: /dns/validator-1/udp/8084 stake: 20000000000000000 - commission_rate: 0 gas_price: 1000 name: validator-2 - primary_address: /dns/validator-2/udp/8081 + primary_address: /dns/validator-2/tcp/8081 network_address: /dns/validator-2/tcp/8080/http p2p_address: /dns/validator-2/udp/8084 stake: 20000000000000000 - commission_rate: 0 gas_price: 1000 name: validator-3 - primary_address: /dns/validator-3/udp/8081 + primary_address: /dns/validator-3/tcp/8081 network_address: /dns/validator-3/tcp/8080/http p2p_address: /dns/validator-3/udp/8084 stake: 20000000000000000 - commission_rate: 0 gas_price: 1000 name: validator-4 - primary_address: /dns/validator-4/udp/8081 + primary_address: /dns/validator-4/tcp/8081 network_address: /dns/validator-4/tcp/8080/http p2p_address: /dns/validator-4/udp/8084 stake: 20000000000000000 diff --git a/docs/content/references/cli/validator.mdx b/docs/content/references/cli/validator.mdx index e2764f8e699..f6953d33abe 100644 --- a/docs/content/references/cli/validator.mdx +++ b/docs/content/references/cli/validator.mdx @@ -179,7 +179,7 @@ $ iota validator display-metadata 0x8359fff1dc629bad933cf1781564a6d98a7277ac391e "projectUrl": "", "netAddress": "/dns/validator-2.r.iota-rebased-testnet.iota.cafe/tcp/8080/http", "p2pAddress": "/dns/validator-2.r.iota-rebased-testnet.iota.cafe/udp/8084", - "primaryAddress": "/dns/validator-2.r.iota-rebased-testnet.iota.cafe/udp/8081", + "primaryAddress": "/dns/validator-2.r.iota-rebased-testnet.iota.cafe/tcp/8081", "nextEpochAuthorityPubkeyBytes": null, "nextEpochProofOfPossession": null, "nextEpochNetworkPubkeyBytes": null,