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

fix: fix panic when no public addresses #5367

Merged
Merged
Show file tree
Hide file tree
Changes from 5 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
15 changes: 2 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion applications/tari_app_grpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2018"
tari_common_types = { path = "../../base_layer/common_types" }
tari_comms = { path = "../../comms/core" }
tari_core = { path = "../../base_layer/core" }
tari_crypto = { version = "0.16.12"}
tari_crypto = { version = "0.16"}
tari_script = { path = "../../infrastructure/tari_script" }
tari_utilities = { version = "0.4.10"}

Expand Down
2 changes: 1 addition & 1 deletion applications/tari_app_utilities/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tari_utilities = { version = "0.4.10"}

clap = { version = "3.2.0", features = ["derive", "env"] }
futures = { version = "^0.3.16", default-features = false, features = ["alloc"] }
json5 = "0.2.2"
json5 = "0.4"
log = { version = "0.4.8", features = ["std"] }
rand = "0.7.3"
tokio = { version = "1.23", features = ["signal"] }
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_base_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tari_comms = { path = "../../comms/core", features = ["rpc"] }
tari_common_types = { path = "../../base_layer/common_types" }
tari_comms_dht = { path = "../../comms/dht" }
tari_core = { path = "../../base_layer/core", default-features = false, features = ["transactions"] }
tari_crypto = { version = "0.16.12"}
tari_crypto = { version = "0.16"}
tari_libtor = { path = "../../infrastructure/libtor", optional = true }
tari_p2p = { path = "../../base_layer/p2p", features = ["auto-update"] }
tari_storage = {path="../../infrastructure/storage"}
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_console_wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ tari_common_types = { path = "../../base_layer/common_types" }
tari_comms = { path = "../../comms/core" }
tari_comms_dht = { path = "../../comms/dht" }
tari_contacts = { path = "../../base_layer/contacts" }
tari_crypto = { version = "0.16.12"}
tari_crypto = { version = "0.16"}
tari_key_manager = { path = "../../base_layer/key_manager" }
tari_libtor = { path = "../../infrastructure/libtor", optional = true }
tari_p2p = { path = "../../base_layer/p2p", features = ["auto-update"] }
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_miner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tari_common_types = { path = "../../base_layer/common_types" }
tari_comms = { path = "../../comms/core" }
tari_app_utilities = { path = "../tari_app_utilities" }
tari_app_grpc = { path = "../tari_app_grpc" }
tari_crypto = { version = "0.16.12"}
tari_crypto = { version = "0.16"}
tari_utilities = "0.4.10"

borsh = "0.9.3"
Expand Down
2 changes: 1 addition & 1 deletion base_layer/common_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version = "0.50.0-pre.0"
edition = "2018"

[dependencies]
tari_crypto = { version = "0.16.12"}
tari_crypto = { version = "0.16"}
tari_utilities = "0.4.10"
# TODO: remove this dependency and move Network into tari_common_types
tari_common = { path = "../../common" }
Expand Down
4 changes: 2 additions & 2 deletions base_layer/contacts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tari_common_sqlite = { path = "../../common_sqlite" }
tari_common_types = { path = "../../base_layer/common_types" }
tari_comms = { path = "../../comms/core" }
tari_comms_dht = { path = "../../comms/dht" }
tari_crypto = { version = "0.16.12"}
tari_crypto = { version = "0.16"}
tari_p2p = { path = "../p2p", features = ["auto-update"] }
tari_service_framework = { path = "../service_framework" }
tari_shutdown = { path = "../../infrastructure/shutdown" }
Expand All @@ -30,7 +30,7 @@ rand = "0.7.3"
thiserror = "1.0.26"
tokio = { version = "1.23", features = ["sync", "macros"] }
tower = "0.4"
uuid = { version = "1.3.1", features = ["v4"] }
uuid = { version = "1.3", features = ["v4"] }

[dev-dependencies]
tari_comms_dht = { path = "../../comms/dht", features = ["test-mocks"] }
Expand Down
2 changes: 1 addition & 1 deletion base_layer/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ tari_common_types = { path = "../../base_layer/common_types" }
tari_comms = { path = "../../comms/core" }
tari_comms_dht = { path = "../../comms/dht" }
tari_comms_rpc_macros = { path = "../../comms/rpc_macros" }
tari_crypto = { version = "0.16.12", features = ["borsh"] }
tari_crypto = { version = "0.16", features = ["borsh"] }
tari_metrics = { path = "../../infrastructure/metrics" }
tari_mmr = { path = "../../base_layer/mmr", optional = true, features = ["native_bitmap"] }
tari_p2p = { path = "../../base_layer/p2p" }
Expand Down
2 changes: 1 addition & 1 deletion base_layer/key_manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ crate-type = ["lib", "cdylib"]

# NB: All dependencies must support or be gated for the WASM target.
[dependencies]
tari_crypto = {version = "0.16.12"}
tari_crypto = {version = "0.16"}
tari_utilities = "0.4.10"
tari_common_sqlite = { path = "../../common_sqlite" }
tari_common_types = { path = "../../base_layer/common_types"}
Expand Down
2 changes: 1 addition & 1 deletion base_layer/mmr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ benches = ["criterion"]

[dependencies]
tari_utilities = "0.4.10"
tari_crypto = { version = "0.16.12"}
tari_crypto = { version = "0.16"}
tari_common = {path = "../../common"}
thiserror = "1.0.26"
borsh = "0.9.3"
Expand Down
2 changes: 1 addition & 1 deletion base_layer/p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ edition = "2018"
tari_comms = { path = "../../comms/core" }
tari_comms_dht = { path = "../../comms/dht" }
tari_common = { path = "../../common" }
tari_crypto = { version = "0.16.12"}
tari_crypto = { version = "0.16"}
tari_service_framework = { path = "../service_framework" }
tari_shutdown = { path = "../../infrastructure/shutdown" }
tari_storage = { path = "../../infrastructure/storage" }
Expand Down
2 changes: 1 addition & 1 deletion base_layer/p2p/src/initialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub async fn initialize_local_test_comms<P: AsRef<Path>>(

let comms = CommsBuilder::new()
.allow_test_addresses()
.with_listener_address(node_identity.first_public_address())
.with_listener_address(node_identity.first_public_address().unwrap())
SWvheerden marked this conversation as resolved.
Show resolved Hide resolved
.with_listener_liveness_max_sessions(1)
.with_node_identity(node_identity)
.with_user_agent(&"/test/1.0")
Expand Down
2 changes: 1 addition & 1 deletion base_layer/tari_mining_helper_ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"

[dependencies]
tari_comms = { path = "../../comms/core" }
tari_crypto = { version = "0.16.12"}
tari_crypto = { version = "0.16"}
tari_common = { path = "../../common" }
tari_core = { path = "../core", default-features = false, features = ["transactions"]}
tari_utilities = "0.4.10"
Expand Down
2 changes: 1 addition & 1 deletion base_layer/wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tari_common = { path = "../../common" }
tari_common_types = { path = "../../base_layer/common_types" }
tari_comms = { path = "../../comms/core" }
tari_comms_dht = { path = "../../comms/dht" }
tari_crypto = { version = "0.16.12"}
tari_crypto = { version = "0.16"}
tari_key_manager = { path = "../key_manager", features = ["key_manager_service"] }
tari_p2p = { path = "../p2p", features = ["auto-update"] }
tari_script = { path = "../../infrastructure/tari_script" }
Expand Down
2 changes: 2 additions & 0 deletions base_layer/wallet/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ pub enum WalletError {
TransportChannelError(#[from] TransportChannelError),
#[error("Unexpected API Response while calling method `{method}` on `{api}`")]
UnexpectedApiResponse { method: String, api: String },
#[error("Public address not set for this wallet")]
PublicAddressNotSet,
}

pub const LOG_TARGET: &str = "tari::application";
Expand Down
7 changes: 6 additions & 1 deletion base_layer/wallet/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,12 @@ where

// Persist the comms node address and features after it has been spawned to capture any modifications made
// during comms startup. In the case of a Tor Transport the public address could have been generated
wallet_database.set_node_address(comms.node_identity().first_public_address())?;
wallet_database.set_node_address(
comms
.node_identity()
.first_public_address()
.ok_or(WalletError::PublicAddressNotSet)?,
)?;
wallet_database.set_node_features(comms.node_identity().features())?;
let identity_sig = comms.node_identity().identity_signature_read().as_ref().cloned();
if let Some(identity_sig) = identity_sig {
Expand Down
2 changes: 1 addition & 1 deletion base_layer/wallet_ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tari_common = { path="../../common" }
tari_common_types = { path="../common_types" }
tari_comms = { path = "../../comms/core", features = ["c_integration"]}
tari_comms_dht = { path = "../../comms/dht", default-features = false }
tari_crypto = { version = "0.16.12"}
tari_crypto = { version = "0.16"}
tari_key_manager = { path = "../key_manager" }
tari_p2p = { path = "../p2p" }
tari_script = { path = "../../infrastructure/tari_script" }
Expand Down
2 changes: 1 addition & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build = ["toml", "prost-build"]
static-application-info = ["git2"]

[dependencies]
tari_crypto = { version = "0.16.12"}
tari_crypto = { version = "0.16"}

anyhow = "1.0.53"
config = { version = "0.13.0", default_features = false, features = ["toml"] }
Expand Down
2 changes: 1 addition & 1 deletion comms/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ version = "0.50.0-pre.0"
edition = "2018"

[dependencies]
tari_crypto = { version = "0.16.12"}
tari_crypto = { version = "0.16"}
tari_metrics = { path = "../../infrastructure/metrics" }
tari_storage = { path = "../../infrastructure/storage" }
tari_shutdown = { path = "../../infrastructure/shutdown" }
Expand Down
19 changes: 8 additions & 11 deletions comms/core/src/builder/comms_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,14 @@ impl UnspawnedCommsNode {
);

// Spawn liveness check now that we have the final address
let liveness_watch = connection_manager_config
.liveness_self_check_interval
.map(|interval| {
LivenessCheck::spawn(
transport,
node_identity.first_public_address(),
interval,
shutdown_signal.clone(),
)
})
.unwrap_or_else(|| watch::channel(LivenessStatus::Disabled).1);
let liveness_watch = if let Some(public_address) = node_identity.first_public_address() {
connection_manager_config
.liveness_self_check_interval
.map(|interval| LivenessCheck::spawn(transport, public_address, interval, shutdown_signal.clone()))
.unwrap_or_else(|| watch::channel(LivenessStatus::Disabled).1)
} else {
watch::channel(LivenessStatus::Disabled).1
};

Ok(CommsNode {
shutdown_signal,
Expand Down
4 changes: 2 additions & 2 deletions comms/core/src/peer_manager/node_identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ impl NodeIdentity {
acquire_read_lock!(self.public_addresses).clone()
}

pub fn first_public_address(&self) -> Multiaddr {
acquire_read_lock!(self.public_addresses)[0].clone()
pub fn first_public_address(&self) -> Option<Multiaddr> {
acquire_read_lock!(self.public_addresses).get(0).cloned()
}

/// Modify the public address.
Expand Down
2 changes: 1 addition & 1 deletion comms/dht/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ edition = "2018"
tari_comms = { path = "../core", features = ["rpc"] }
tari_common = { path = "../../common" }
tari_comms_rpc_macros = { path = "../rpc_macros" }
tari_crypto = { version = "0.16.12"}
tari_crypto = { version = "0.16.2"}
tari_utilities = "0.4.10"
tari_shutdown = { path = "../../infrastructure/shutdown" }
tari_storage = { path = "../../infrastructure/storage" }
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/tari_script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ readme = "README.md"
license = "BSD-3-Clause"

[dependencies]
tari_crypto = { version = "0.16.12"}
tari_crypto = { version = "0.16"}
tari_utilities = "0.4.10"

blake2 = "0.9"
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ tari_base_node = { path = "../applications/tari_base_node" }
tari_base_node_grpc_client = { path = "../clients/rust/base_node_grpc_client" }
tari_chat_client = { path = "../base_layer/contacts/examples/chat_client" }
tari_chat_ffi = { path = "../base_layer/chat_ffi" }
tari_crypto = "0.16.12"
tari_crypto = "0.16"
tari_common = { path = "../common" }
tari_common_types = { path = "../base_layer/common_types" }
tari_comms = { path = "../comms/core" }
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/src/chat_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ fn test_config(name: &str, port: u64, identity: &NodeIdentity) -> P2pConfig {
..DhtConfig::default_local_test()
},
transport: TransportConfig::new_tcp(TcpTransportConfig {
listener_address: identity.first_public_address(),
listener_address: identity.first_public_address().expect("No public address"),
..TcpTransportConfig::default()
}),
allow_test_addresses: true,
public_addresses: MultiaddrList::from(vec![identity.first_public_address()]),
public_addresses: MultiaddrList::from(vec![identity.first_public_address().expect("No public address")]),
user_agent: "tari/chat-client/0.0.1".to_string(),
..P2pConfig::default()
};
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/src/chat_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ fn test_config(base_dir: &PathBuf, identity: &NodeIdentity) -> P2pConfig {
..DhtConfig::default_local_test()
},
transport: TransportConfig::new_tcp(TcpTransportConfig {
listener_address: identity.first_public_address(),
listener_address: identity.first_public_address().expect("No public address"),
..TcpTransportConfig::default()
}),
allow_test_addresses: true,
public_addresses: MultiaddrList::from(vec![identity.first_public_address()]),
public_addresses: MultiaddrList::from(vec![identity.first_public_address().expect("No public address")]),
user_agent: "tari/chat-client/0.0.1".to_string(),
..P2pConfig::default()
};
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub async fn get_peer_addresses(world: &TariWorld, peers: &Vec<String>) -> Vec<S
peer_addresses.push(format!(
"{}::{}",
peer.identity.public_key(),
peer.identity.first_public_address()
peer.identity.first_public_address().expect("No public addresses")
));
}

Expand Down