Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] fix(node): Fix output of iota validator make-validator-info #4571

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/iota-core/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/iota-genesis-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion crates/iota-swarm-config/tests/snapshot_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: ~
Expand Down
4 changes: 2 additions & 2 deletions crates/iota/src/fire_drill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/iota/src/generate_genesis_checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion crates/iota/src/genesis_ceremony.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
21 changes: 12 additions & 9 deletions crates/iota/src/validator_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{
collections::{BTreeMap, HashSet},
fmt::{self, Debug, Display, Formatter, Write},
fs,
net::IpAddr,
path::PathBuf,
};

Expand Down Expand Up @@ -330,6 +331,11 @@ impl IotaValidatorCommand {
&authority_keypair,
(&account_keypair.public()).into(),
);
let transport_str = match host_name.parse::<IpAddr>() {
Ok(IpAddr::V4(_)) => "ip4",
Ok(IpAddr::V6(_)) => "ip6",
Err(_) => "dns",
};
let validator_info = GenesisValidatorInfo {
info: iota_genesis_builder::validator_info::ValidatorInfo {
name,
Expand All @@ -340,13 +346,13 @@ impl IotaValidatorCommand {
gas_price,
commission_rate: iota_config::node::DEFAULT_COMMISSION_RATE,
network_address: Multiaddr::try_from(format!(
"/dns/{}/tcp/8080/http",
host_name
"/{transport_str}/{host_name}/tcp/8080/http",
))?,
p2p_address: Multiaddr::try_from(format!(
"/{transport_str}/{host_name}/udp/8084",
))?,
p2p_address: Multiaddr::try_from(format!("/dns/{}/udp/8084", host_name))?,
primary_address: Multiaddr::try_from(format!(
"/dns/{}/udp/8081",
host_name
"/{transport_str}/{host_name}/tcp/8081",
))?,
description,
image_url,
Expand All @@ -358,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 } => {
Expand Down
8 changes: 4 additions & 4 deletions docker/iota-network/genesis/compose-validators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
8 changes: 4 additions & 4 deletions docker/iota-private-network/configs/genesis-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/content/references/cli/validator.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading