Skip to content

Commit

Permalink
narwhal: require udp multiaddrs for primary and worker addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill committed Dec 1, 2022
1 parent f4a8316 commit fae9b0f
Show file tree
Hide file tree
Showing 19 changed files with 122 additions and 118 deletions.
8 changes: 4 additions & 4 deletions crates/sui-config/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,11 +641,11 @@ mod test {
delegation: 0,
gas_price: 1,
commission_rate: 0,
network_address: utils::new_network_address(),
narwhal_primary_address: utils::new_network_address(),
narwhal_worker_address: utils::new_network_address(),
network_address: utils::new_tcp_network_address(),
narwhal_primary_address: utils::new_udp_network_address(),
narwhal_worker_address: utils::new_udp_network_address(),
narwhal_internal_worker_address: None,
narwhal_consensus_address: utils::new_network_address(),
narwhal_consensus_address: utils::new_tcp_network_address(),
};
let pop = generate_proof_of_possession(&key, account_key.public().into());
let builder = Builder::new()
Expand Down
20 changes: 11 additions & 9 deletions crates/sui-config/src/genesis_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ impl ValidatorGenesisInfo {
worker_key_pair,
account_key_pair,
network_key_pair,
network_address: utils::new_network_address(),
network_address: utils::new_tcp_network_address(),
stake: DEFAULT_STAKE,
gas_price: DEFAULT_GAS_PRICE,
commission_rate: DEFAULT_COMMISSION_RATE,
narwhal_primary_address: utils::new_network_address(),
narwhal_worker_address: utils::new_network_address(),
narwhal_primary_address: utils::new_udp_network_address(),
narwhal_worker_address: utils::new_udp_network_address(),
narwhal_internal_worker_address: None,
narwhal_consensus_address: utils::new_network_address(),
narwhal_consensus_address: utils::new_tcp_network_address(),
}
}

Expand All @@ -144,22 +144,24 @@ impl ValidatorGenesisInfo {
) -> Self {
assert!(port_offset < 1000);
let port_offset: u16 = port_offset.try_into().unwrap();
let make_addr =
let make_tcp_addr =
|port: u16| -> Multiaddr { format!("/ip4/{}/tcp/{}/http", ip, port).parse().unwrap() };
let make_udp_addr =
|port: u16| -> Multiaddr { format!("/ip4/{}/udp/{}", ip, port).parse().unwrap() };

ValidatorGenesisInfo {
key_pair,
worker_key_pair,
account_key_pair,
network_key_pair,
network_address: make_addr(1000 + port_offset),
network_address: make_tcp_addr(1000 + port_offset),
stake: DEFAULT_STAKE,
gas_price: DEFAULT_GAS_PRICE,
commission_rate: DEFAULT_COMMISSION_RATE,
narwhal_primary_address: make_addr(2000 + port_offset),
narwhal_worker_address: make_addr(3000 + port_offset),
narwhal_primary_address: make_udp_addr(2000 + port_offset),
narwhal_worker_address: make_udp_addr(3000 + port_offset),
narwhal_internal_worker_address: None,
narwhal_consensus_address: make_addr(4000 + port_offset),
narwhal_consensus_address: make_tcp_addr(4000 + port_offset),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-config/src/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl NetworkConfig {
FULL_NODE_DB_PATH.to_string()
};

let network_address = utils::new_network_address();
let network_address = utils::new_tcp_network_address();
let p2p_config = P2pConfig {
listen_address: utils::available_local_socket_address(),
..Default::default()
Expand Down
82 changes: 41 additions & 41 deletions crates/sui-config/src/test_gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
delegation: 0
gas-price: 1
network-address: /dns/ny2-suival-1.testnet.sui.io/tcp/8080/http
narwhal-primary-address: /dns/ny2-suival-1.testnet.sui.io/tcp/8081/http
narwhal-worker-address: /dns/ny2-suival-1.testnet.sui.io/tcp/8082/http
narwhal-primary-address: /dns/ny2-suival-1.testnet.sui.io/udp/8081
narwhal-worker-address: /dns/ny2-suival-1.testnet.sui.io/udp/8082
narwhal-consensus-address: /ip4/127.0.0.1/tcp/8083/http
- name: validator-14
account-key: APxJHKslYpWYWmMIlpKfzBTj9K5I84diueoJ4sWHwjmS
Expand All @@ -22,8 +22,8 @@
delegation: 0
gas-price: 1
network-address: /dns/mh1-suival-2.testnet.sui.io/tcp/8080/http
narwhal-primary-address: /dns/mh1-suival-2.testnet.sui.io/tcp/8081/http
narwhal-worker-address: /dns/mh1-suival-2.testnet.sui.io/tcp/8082/http
narwhal-primary-address: /dns/mh1-suival-2.testnet.sui.io/udp/8081
narwhal-worker-address: /dns/mh1-suival-2.testnet.sui.io/udp/8082
narwhal-consensus-address: /ip4/127.0.0.1/tcp/8083/http
- name: validator-13
account-key: AF7odQ5Mwj8PBN/7LYTqyB/gS1OywSBOcKuCS/+VNyLd
Expand All @@ -34,8 +34,8 @@
delegation: 0
gas-price: 1
network-address: /dns/mh1-suival-1.testnet.sui.io/tcp/8080/http
narwhal-primary-address: /dns/mh1-suival-1.testnet.sui.io/tcp/8081/http
narwhal-worker-address: /dns/mh1-suival-1.testnet.sui.io/tcp/8082/http
narwhal-primary-address: /dns/mh1-suival-1.testnet.sui.io/udp/8081
narwhal-worker-address: /dns/mh1-suival-1.testnet.sui.io/udp/8082
narwhal-consensus-address: /ip4/127.0.0.1/tcp/8083/http
- name: validator-17
account-key: AO6lcah9+F9DfVBwE5+30kmi8pkw7nHPeolO0LNIJUQi
Expand All @@ -46,8 +46,8 @@
delegation: 0
gas-price: 1
network-address: /dns/ty6-suival-1.testnet.sui.io/tcp/8080/http
narwhal-primary-address: /dns/ty6-suival-1.testnet.sui.io/tcp/8081/http
narwhal-worker-address: /dns/ty6-suival-1.testnet.sui.io/tcp/8082/http
narwhal-primary-address: /dns/ty6-suival-1.testnet.sui.io/udp/8081
narwhal-worker-address: /dns/ty6-suival-1.testnet.sui.io/udp/8082
narwhal-consensus-address: /ip4/127.0.0.1/tcp/8083/http
- name: validator-10
account-key: AEM7kl/d6VlBG1IgY+lHdxzudYT6ZhtXiYBh3kCxLZCq
Expand All @@ -58,8 +58,8 @@
delegation: 0
gas-price: 1
network-address: /dns/ny2-suival-2.testnet.sui.io/tcp/8080/http
narwhal-primary-address: /dns/ny2-suival-2.testnet.sui.io/tcp/8081/http
narwhal-worker-address: /dns/ny2-suival-2.testnet.sui.io/tcp/8082/http
narwhal-primary-address: /dns/ny2-suival-2.testnet.sui.io/udp/8081
narwhal-worker-address: /dns/ny2-suival-2.testnet.sui.io/udp/8082
narwhal-consensus-address: /ip4/127.0.0.1/tcp/8083/http
- name: validator-7
account-key: ALO4VmUJME24oEDq0tzE7MRi+83HZE3UCuLTVPIE4ZQK
Expand All @@ -70,8 +70,8 @@
delegation: 0
gas-price: 1
network-address: /dns/dal2-suival-3.testnet.sui.io/tcp/8080/http
narwhal-primary-address: /dns/dal2-suival-3.testnet.sui.io/tcp/8081/http
narwhal-worker-address: /dns/dal2-suival-3.testnet.sui.io/tcp/8082/http
narwhal-primary-address: /dns/dal2-suival-3.testnet.sui.io/udp/8081
narwhal-worker-address: /dns/dal2-suival-3.testnet.sui.io/udp/8082
narwhal-consensus-address: /ip4/127.0.0.1/tcp/8083/http
- name: validator-8
account-key: AJN7LZADOBBRulSlRjE0HJs3YR8I3WPwg2ejh4HbDmIS
Expand All @@ -82,8 +82,8 @@
delegation: 0
gas-price: 1
network-address: /dns/ny2-suival-0.testnet.sui.io/tcp/8080/http
narwhal-primary-address: /dns/ny2-suival-0.testnet.sui.io/tcp/8081/http
narwhal-worker-address: /dns/ny2-suival-0.testnet.sui.io/tcp/8082/http
narwhal-primary-address: /dns/ny2-suival-0.testnet.sui.io/udp/8081
narwhal-worker-address: /dns/ny2-suival-0.testnet.sui.io/udp/8082
narwhal-consensus-address: /ip4/127.0.0.1/tcp/8083/http
- name: validator-4
account-key: ACfae1xB9WlL4aSAEbIeTzHSK70s6pUFK4MWerGsas0i
Expand All @@ -94,8 +94,8 @@
delegation: 0
gas-price: 1
network-address: /dns/dal2-suival-0.testnet.sui.io/tcp/8080/http
narwhal-primary-address: /dns/dal2-suival-0.testnet.sui.io/tcp/8081/http
narwhal-worker-address: /dns/dal2-suival-0.testnet.sui.io/tcp/8082/http
narwhal-primary-address: /dns/dal2-suival-0.testnet.sui.io/udp/8081
narwhal-worker-address: /dns/dal2-suival-0.testnet.sui.io/udp/8082
narwhal-consensus-address: /ip4/127.0.0.1/tcp/8083/http
- name: validator-18
account-key: AE6+TGtd9SgOFPJh7sswMd8YDf7G080NeGYwzuIS3/zM
Expand All @@ -106,8 +106,8 @@
delegation: 0
gas-price: 1
network-address: /dns/ty6-suival-2.testnet.sui.io/tcp/8080/http
narwhal-primary-address: /dns/ty6-suival-2.testnet.sui.io/tcp/8081/http
narwhal-worker-address: /dns/ty6-suival-2.testnet.sui.io/tcp/8082/http
narwhal-primary-address: /dns/ty6-suival-2.testnet.sui.io/udp/8081
narwhal-worker-address: /dns/ty6-suival-2.testnet.sui.io/udp/8082
narwhal-consensus-address: /ip4/127.0.0.1/tcp/8083/http
- name: validator-2
account-key: AGhrMVMiJ67VCxth8gWXNFOLnFuNkIMjV0GK3EFBfaio
Expand All @@ -118,8 +118,8 @@
delegation: 0
gas-price: 1
network-address: /dns/la2-suival-2.testnet.sui.io/tcp/8080/http
narwhal-primary-address: /dns/la2-suival-2.testnet.sui.io/tcp/8081/http
narwhal-worker-address: /dns/la2-suival-2.testnet.sui.io/tcp/8082/http
narwhal-primary-address: /dns/la2-suival-2.testnet.sui.io/udp/8081
narwhal-worker-address: /dns/la2-suival-2.testnet.sui.io/udp/8082
narwhal-consensus-address: /ip4/127.0.0.1/tcp/8083/http
- name: validator-11
account-key: AK6LecW3y0UyqzCHu3lUgffRyhGrxEQPjaHRxCilP6Rp
Expand All @@ -130,8 +130,8 @@
delegation: 0
gas-price: 1
network-address: /dns/ny2-suival-3.testnet.sui.io/tcp/8080/http
narwhal-primary-address: /dns/ny2-suival-3.testnet.sui.io/tcp/8081/http
narwhal-worker-address: /dns/ny2-suival-3.testnet.sui.io/tcp/8082/http
narwhal-primary-address: /dns/ny2-suival-3.testnet.sui.io/udp/8081
narwhal-worker-address: /dns/ny2-suival-3.testnet.sui.io/udp/8082
narwhal-consensus-address: /ip4/127.0.0.1/tcp/8083/http
- name: validator-16
account-key: AImuNvQVTUSNUQrsBSi7dzT+a+wVsSQM5fQMfdQ1CTZ0
Expand All @@ -142,8 +142,8 @@
delegation: 0
gas-price: 1
network-address: /dns/ty6-suival-0.testnet.sui.io/tcp/8080/http
narwhal-primary-address: /dns/ty6-suival-0.testnet.sui.io/tcp/8081/http
narwhal-worker-address: /dns/ty6-suival-0.testnet.sui.io/tcp/8082/http
narwhal-primary-address: /dns/ty6-suival-0.testnet.sui.io/udp/8081
narwhal-worker-address: /dns/ty6-suival-0.testnet.sui.io/udp/8082
narwhal-consensus-address: /ip4/127.0.0.1/tcp/8083/http
- name: validator-15
account-key: AFDDthZ/GakRrsI2QZJ8gQFEt+fJvKwpJJoYm+p/NW07
Expand All @@ -154,8 +154,8 @@
delegation: 0
gas-price: 1
network-address: /dns/mh1-suival-3.testnet.sui.io/tcp/8080/http
narwhal-primary-address: /dns/mh1-suival-3.testnet.sui.io/tcp/8081/http
narwhal-worker-address: /dns/mh1-suival-3.testnet.sui.io/tcp/8082/http
narwhal-primary-address: /dns/mh1-suival-3.testnet.sui.io/udp/8081
narwhal-worker-address: /dns/mh1-suival-3.testnet.sui.io/udp/8082
narwhal-consensus-address: /ip4/127.0.0.1/tcp/8083/http
- name: validator-5
account-key: ALaZN89Ud2dli3QScggR+9+2CqSkct2f7qMXQ1osFaBd
Expand All @@ -166,8 +166,8 @@
delegation: 0
gas-price: 1
network-address: /dns/dal2-suival-1.testnet.sui.io/tcp/8080/http
narwhal-primary-address: /dns/dal2-suival-1.testnet.sui.io/tcp/8081/http
narwhal-worker-address: /dns/dal2-suival-1.testnet.sui.io/tcp/8082/http
narwhal-primary-address: /dns/dal2-suival-1.testnet.sui.io/udp/8081
narwhal-worker-address: /dns/dal2-suival-1.testnet.sui.io/udp/8082
narwhal-consensus-address: /ip4/127.0.0.1/tcp/8083/http
- name: validator-19
account-key: AFhY6i8XnpRoImndz7kj+M6mjIpZz1248oyO5Ou/ajG8
Expand All @@ -178,8 +178,8 @@
delegation: 0
gas-price: 1
network-address: /dns/ty6-suival-3.testnet.sui.io/tcp/8080/http
narwhal-primary-address: /dns/ty6-suival-3.testnet.sui.io/tcp/8081/http
narwhal-worker-address: /dns/ty6-suival-3.testnet.sui.io/tcp/8082/http
narwhal-primary-address: /dns/ty6-suival-3.testnet.sui.io/udp/8081
narwhal-worker-address: /dns/ty6-suival-3.testnet.sui.io/udp/8082
narwhal-consensus-address: /ip4/127.0.0.1/tcp/8083/http
- name: validator-12
account-key: AAYmiOgJnOyXfMPEwP49TUUUTw4dlIA/8IXeKEv8M4RK
Expand All @@ -190,8 +190,8 @@
delegation: 0
gas-price: 1
network-address: /dns/mh1-suival-0.testnet.sui.io/tcp/8080/http
narwhal-primary-address: /dns/mh1-suival-0.testnet.sui.io/tcp/8081/http
narwhal-worker-address: /dns/mh1-suival-0.testnet.sui.io/tcp/8082/http
narwhal-primary-address: /dns/mh1-suival-0.testnet.sui.io/udp/8081
narwhal-worker-address: /dns/mh1-suival-0.testnet.sui.io/udp/8082
narwhal-consensus-address: /ip4/127.0.0.1/tcp/8083/http
- name: validator-3
account-key: AIyUji/hvun9TdRLQXpN8UNgn3sIjSosETJWkPSwDzHr
Expand All @@ -202,8 +202,8 @@
delegation: 0
gas-price: 1
network-address: /dns/la2-suival-3.testnet.sui.io/tcp/8080/http
narwhal-primary-address: /dns/la2-suival-3.testnet.sui.io/tcp/8081/http
narwhal-worker-address: /dns/la2-suival-3.testnet.sui.io/tcp/8082/http
narwhal-primary-address: /dns/la2-suival-3.testnet.sui.io/udp/8081
narwhal-worker-address: /dns/la2-suival-3.testnet.sui.io/udp/8082
narwhal-consensus-address: /ip4/127.0.0.1/tcp/8083/http
- name: validator-1
account-key: AG+M0+OIB31YRR/FQKdzt7aP4qUPBQSMyCWK+Da9Zmax
Expand All @@ -214,8 +214,8 @@
delegation: 0
gas-price: 1
network-address: /dns/la2-suival-1.testnet.sui.io/tcp/8080/http
narwhal-primary-address: /dns/la2-suival-1.testnet.sui.io/tcp/8081/http
narwhal-worker-address: /dns/la2-suival-1.testnet.sui.io/tcp/8082/http
narwhal-primary-address: /dns/la2-suival-1.testnet.sui.io/udp/8081
narwhal-worker-address: /dns/la2-suival-1.testnet.sui.io/udp/8082
narwhal-consensus-address: /ip4/127.0.0.1/tcp/8083/http
- name: validator-6
account-key: AGq4caYZr20U1EM7WkRo6CYVuKfjWmda1b5AGdgaSN2s
Expand All @@ -226,8 +226,8 @@
delegation: 0
gas-price: 1
network-address: /dns/dal2-suival-2.testnet.sui.io/tcp/8080/http
narwhal-primary-address: /dns/dal2-suival-2.testnet.sui.io/tcp/8081/http
narwhal-worker-address: /dns/dal2-suival-2.testnet.sui.io/tcp/8082/http
narwhal-primary-address: /dns/dal2-suival-2.testnet.sui.io/udp/8081
narwhal-worker-address: /dns/dal2-suival-2.testnet.sui.io/udp/8082
narwhal-consensus-address: /ip4/127.0.0.1/tcp/8083/http
- name: validator-0
account-key: APlYeKnmB0RcPB5cYaII7aAvjjAt19cVt3d9eJBCQwjX
Expand All @@ -238,8 +238,8 @@
delegation: 0
gas-price: 1
network-address: /dns/la2-suival-0.testnet.sui.io/tcp/8080/http
narwhal-primary-address: /dns/la2-suival-0.testnet.sui.io/tcp/8081/http
narwhal-worker-address: /dns/la2-suival-0.testnet.sui.io/tcp/8082/http
narwhal-primary-address: /dns/la2-suival-0.testnet.sui.io/udp/8081
narwhal-worker-address: /dns/la2-suival-0.testnet.sui.io/udp/8082
narwhal-consensus-address: /ip4/127.0.0.1/tcp/8083/http
send_timeout:
secs: 30
Expand All @@ -248,4 +248,4 @@
secs: 30
nanos: 0
buffer_size: 650000
db_folder_path: /data/gateway_client_db
db_folder_path: /data/gateway_client_db
8 changes: 7 additions & 1 deletion crates/sui-config/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ fn get_ephemeral_port() -> std::io::Result<u16> {
Ok(addr.port())
}

pub fn new_network_address() -> multiaddr::Multiaddr {
pub fn new_tcp_network_address() -> multiaddr::Multiaddr {
format!("/ip4/127.0.0.1/tcp/{}/http", get_available_port())
.parse()
.unwrap()
}

pub fn new_udp_network_address() -> multiaddr::Multiaddr {
format!("/ip4/127.0.0.1/udp/{}", get_available_port())
.parse()
.unwrap()
}

pub fn available_local_socket_address() -> std::net::SocketAddr {
format!("127.0.0.1:{}", get_available_port())
.parse()
Expand Down
8 changes: 4 additions & 4 deletions crates/sui-core/src/unit_tests/authority_aggregator_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ pub async fn init_local_authorities(
delegation: 0,
gas_price: 1,
commission_rate: 0,
network_address: sui_config::utils::new_network_address(),
narwhal_primary_address: sui_config::utils::new_network_address(),
narwhal_worker_address: sui_config::utils::new_network_address(),
network_address: sui_config::utils::new_tcp_network_address(),
narwhal_primary_address: sui_config::utils::new_udp_network_address(),
narwhal_worker_address: sui_config::utils::new_udp_network_address(),
narwhal_internal_worker_address: None,
narwhal_consensus_address: sui_config::utils::new_network_address(),
narwhal_consensus_address: sui_config::utils::new_tcp_network_address(),
};
let pop = generate_proof_of_possession(&key_pair, (&account_key_pair.public()).into());
builder = builder.add_validator(validator_info, pop);
Expand Down
8 changes: 4 additions & 4 deletions crates/sui/src/genesis_ceremony.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,11 @@ mod test {
delegation: 0,
gas_price: 1,
commission_rate: 0,
network_address: utils::new_network_address(),
narwhal_primary_address: utils::new_network_address(),
narwhal_worker_address: utils::new_network_address(),
network_address: utils::new_tcp_network_address(),
narwhal_primary_address: utils::new_udp_network_address(),
narwhal_worker_address: utils::new_udp_network_address(),
narwhal_internal_worker_address: None,
narwhal_consensus_address: utils::new_network_address(),
narwhal_consensus_address: utils::new_tcp_network_address(),
};
let key_file = dir.path().join(format!("{}-0.key", info.name));
write_authority_keypair_to_file(&keypair, &key_file).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions narwhal/Docker/scripts/gen.committee.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def main():
temp[k['name']] = {
"network_key": nk['name'],
"primary": {
"primary_to_primary": "/dns/primary_{:02d}/tcp/3000/http".format(i),
"worker_to_primary": "/dns/primary_{:02d}/tcp/3001/http".format(i)
"primary_to_primary": "/dns/primary_{:02d}/udp/3000".format(i),
"worker_to_primary": "/dns/primary_{:02d}/udp/3001".format(i)
},
"stake": 1,
}
Expand Down
2 changes: 1 addition & 1 deletion narwhal/Docker/scripts/gen.workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def main():
for j in range(args.nw):
workers[j] = {
"transactions": "/dns/worker_{:02d}/tcp/{}/http".format(i, port+1),
"worker_address": "/dns/worker_{:02d}/tcp/{}/http".format(i, port+2)
"worker_address": "/dns/worker_{:02d}/udp/{}".format(i, port+2)
}
port += 3
temp[k['name']] = workers
Expand Down
Loading

0 comments on commit fae9b0f

Please sign in to comment.