Skip to content

Commit

Permalink
feat: validator node shows its public key on startup (#3734)
Browse files Browse the repository at this point in the history
Description
---

- Displays the validator node network identity information on startup 
- Only resign the node identity if the public address has changed.

Motivation and Context
---
Previously, you would have to look in the logs to obtain this public key 

How Has This Been Tested?
---
Manually

```
🚀 Validator node started!
Public Key: aefbe6559c06bb4a7f7f04307651e9263c15a7f0be3a19a4f59e2c928d5ec333
Node ID: 1bdaf4a679ce426c3178460e7a
Public Address: /onion3/fsag2su6pao5cbosz3wqy6x73x3yb7cinpsqzubrajhhn4emqrzxgvqd:18141
Features: NONE | COMMUNICATION_CLIENT
```
  • Loading branch information
sdbondi authored Jan 24, 2022
1 parent 61e985c commit fc7da51
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
3 changes: 2 additions & 1 deletion applications/tari_collectibles/web-app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

build
build/*
!build/.gitkeep
Empty file.
3 changes: 3 additions & 0 deletions applications/tari_validator_node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ async fn run_node(config: GlobalConfig, create_id: bool) -> Result<(), ExitCodes
)?;
let db_factory = SqliteDbFactory::new(&config);
let mempool_service = MempoolServiceHandle::default();

info!(
target: LOG_TARGET,
"Node starting with pub key: {}, node_id: {}",
Expand Down Expand Up @@ -133,6 +134,8 @@ async fn run_node(config: GlobalConfig, create_id: bool) -> Result<(), ExitCodes
let grpc_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 18144);

task::spawn(run_grpc(grpc_server, grpc_addr, shutdown.to_signal()));
println!("🚀 Validator node started!");
println!("{}", node_identity);
run_dan_node(
shutdown.to_signal(),
config,
Expand Down
15 changes: 12 additions & 3 deletions comms/src/peer_manager/node_identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,19 @@ impl NodeIdentity {
acquire_read_lock!(self.public_address).clone()
}

/// Modify the public address. The account signature will be invalid
/// Modify the public address.
pub fn set_public_address(&self, address: Multiaddr) {
*acquire_write_lock!(self.public_address) = address;
self.sign()
let mut must_sign = false;
{
let mut lock = acquire_write_lock!(self.public_address);
if *lock != address {
*lock = address;
must_sign = true;
}
}
if must_sign {
self.sign()
}
}

/// This returns a random NodeIdentity for testing purposes. This function can panic. If public_address
Expand Down

0 comments on commit fc7da51

Please sign in to comment.