Skip to content

Commit

Permalink
Merge branch 'development' into build-all-leet-win-dep-remove
Browse files Browse the repository at this point in the history
  • Loading branch information
leet4tari committed Nov 22, 2024
2 parents 5a2de7f + d22ef65 commit c76d3a3
Show file tree
Hide file tree
Showing 18 changed files with 359 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .license.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
./applications/minotari_node/assets/tari_logo.rs
./applications/minotari_node/osx-pkg/entitlements.xml
./base_layer/contacts/src/schema.rs
./base_layer/core/src/base_node/tari_pulse_service/20326.rsa
./base_layer/core/src/base_node/tari_pulse_service/38696.rsa
./base_layer/key_manager/src/schema.rs
./base_layer/wallet/src/schema.rs
./docs/src/theme/book.js
Expand Down
3 changes: 3 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions applications/minotari_app_grpc/proto/base_node.proto
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ message TipInfoResponse {
MetaData metadata = 1;
bool initial_sync_achieved = 2;
BaseNodeState base_node_state = 3;
bool failed_checkpoints = 4;
}

enum BaseNodeState{
Expand Down
11 changes: 7 additions & 4 deletions applications/minotari_node/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ use tari_comms::{
};
use tari_comms_dht::Dht;
use tari_core::{
base_node,
base_node::{
self,
chain_metadata_service::ChainMetadataServiceInitializer,
service::BaseNodeServiceInitializer,
state_machine_service::initializer::BaseNodeStateMachineInitializer,
tari_pulse_service::TariPulseServiceInitializer,
LocalNodeCommsInterface,
StateMachineHandle,
},
chain_storage::{async_db::AsyncBlockchainDb, BlockchainBackend, BlockchainDatabase},
consensus::ConsensusManager,
mempool,
mempool::{service::MempoolHandle, Mempool, MempoolServiceInitializer, MempoolSyncInitializer},
mempool::{self, service::MempoolHandle, Mempool, MempoolServiceInitializer, MempoolSyncInitializer},
proof_of_work::randomx_factory::RandomXFactory,
transactions::CryptoFactories,
};
Expand Down Expand Up @@ -170,6 +170,10 @@ where B: BlockchainBackend + 'static
self.randomx_factory,
self.app_config.base_node.bypass_range_proof_verification,
))
.add_initializer(TariPulseServiceInitializer::new(
base_node_config.tari_pulse_interval,
base_node_config.network,
))
.build()
.await?;

Expand Down Expand Up @@ -221,7 +225,6 @@ where B: BlockchainBackend + 'static
};

handles.register(comms);

Ok(handles)
}

Expand Down
11 changes: 10 additions & 1 deletion applications/minotari_node/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ use tari_common::{
use tari_comms::{peer_manager::NodeIdentity, protocol::rpc::RpcServerHandle, CommsNode};
use tari_comms_dht::Dht;
use tari_core::{
base_node::{state_machine_service::states::StatusInfo, LocalNodeCommsInterface, StateMachineHandle},
base_node::{
state_machine_service::states::StatusInfo,
tari_pulse_service::TariPulseHandle,
LocalNodeCommsInterface,
StateMachineHandle,
},
chain_storage::{create_lmdb_database, BlockchainDatabase, ChainStorageError, LMDBDatabase, Validators},
consensus::ConsensusManager,
mempool::{service::LocalMempoolService, Mempool},
Expand Down Expand Up @@ -121,6 +126,10 @@ impl BaseNodeContext {
self.base_node_handles.expect_handle()
}

pub fn tari_pulse(&self) -> TariPulseHandle {
self.base_node_handles.expect_handle()
}

/// Returns a handle to the comms RPC server
pub fn rpc_server(&self) -> RpcServerHandle {
self.base_node_handles.expect_handle()
Expand Down
29 changes: 25 additions & 4 deletions applications/minotari_node/src/commands/cli_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use tokio::{signal, time};
use crate::{
commands::{
cli,
command::{CommandContext, WatchCommand},
command::{Args, CommandContext, WatchCommand},
parser::Parser,
reader::CommandReader,
},
Expand Down Expand Up @@ -87,7 +87,9 @@ impl CliLoop {
} else {
while !self.done {
self.watch_loop().await;
self.execute_command().await;
if !self.done {
self.execute_command().await;
}
}
}
}
Expand Down Expand Up @@ -129,12 +131,19 @@ impl CliLoop {
println!("Wrong command to watch `{}`. Failed with: {}", line, err);
} else {
let mut events = EventStream::new();
loop {
while !self.done {
let interval = time::sleep(interval);
tokio::select! {
_ = interval => {
if let Err(err) = self.context.handle_command_str(line).await {
println!("Watched command `{}` failed: {}", line, err);
} else {
let args: Result<Args, _> = line.parse();
if let Ok(command) = args {
if command.is_quit() {
self.done = true;
}
}
}
continue;
},
Expand All @@ -158,7 +167,9 @@ impl CliLoop {
}
}
}
crossterm::execute!(io::stdout(), cursor::MoveToNextLine(1)).ok();
if !self.done {
crossterm::execute!(io::stdout(), cursor::MoveToNextLine(1)).ok();
}
}
terminal::disable_raw_mode().ok();
}
Expand All @@ -183,6 +194,13 @@ impl CliLoop {
_ = interval => {
if let Err(err) = self.context.handle_command_str(line).await {
println!("Watched command `{}` failed: {}", line, err);
} else {
let args: Result<Args, _> = line.parse();
if let Ok(command) = args {
if command.is_quit() {
self.done = true;
}
}
}
continue;
},
Expand Down Expand Up @@ -242,6 +260,9 @@ impl CliLoop {
} else {
self.done = true;
}
if self.done && !self.shutdown_signal.is_triggered() {
self.context.shutdown.trigger();
}
},
_ = self.shutdown_signal.wait() => {
self.done = true;
Expand Down
6 changes: 6 additions & 0 deletions applications/minotari_node/src/commands/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ pub struct Args {
pub command: Command,
}

impl Args {
pub fn is_quit(&self) -> bool {
matches!(self.command, Command::Quit(_) | Command::Exit(_))
}
}

#[derive(Debug, Subcommand, EnumVariantNames)]
#[strum(serialize_all = "kebab-case")]
pub enum Command {
Expand Down
4 changes: 4 additions & 0 deletions applications/minotari_node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ pub struct BaseNodeConfig {
pub state_machine: BaseNodeStateMachineConfig,
/// Obscure GRPC error responses
pub report_grpc_error: bool,
/// Interval to check if the base node is still in sync with the network
#[serde(with = "serializers::seconds")]
pub tari_pulse_interval: Duration,
}

impl Default for BaseNodeConfig {
Expand Down Expand Up @@ -180,6 +183,7 @@ impl Default for BaseNodeConfig {
metadata_auto_ping_interval: Duration::from_secs(30),
state_machine: Default::default(),
report_grpc_error: false,
tari_pulse_interval: Duration::from_secs(120),
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions applications/minotari_node/src/grpc/base_node_grpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ use tari_core::{
base_node::{
comms_interface::CommsInterfaceError,
state_machine_service::states::StateInfo,
tari_pulse_service::TariPulseHandle,
LocalNodeCommsInterface,
StateMachineHandle,
},
Expand Down Expand Up @@ -114,6 +115,7 @@ pub struct BaseNodeGrpcServer {
comms: CommsNode,
liveness: LivenessHandle,
report_grpc_error: bool,
tari_pulse: TariPulseHandle,
config: BaseNodeConfig,
}

Expand All @@ -129,6 +131,7 @@ impl BaseNodeGrpcServer {
comms: ctx.base_node_comms().clone(),
liveness: ctx.liveness(),
report_grpc_error: ctx.get_report_grpc_error(),
tari_pulse: ctx.tari_pulse(),
config,
}
}
Expand Down Expand Up @@ -1637,6 +1640,7 @@ impl tari_rpc::base_node_server::BaseNode for BaseNodeGrpcServer {
trace!(target: LOG_TARGET, "Incoming GRPC request for BN tip data");

let mut handler = self.node_service.clone();
let failed_checkpoints = *self.tari_pulse.get_failed_checkpoints_notifier();

let meta = handler
.get_metadata()
Expand All @@ -1650,6 +1654,7 @@ impl tari_rpc::base_node_server::BaseNode for BaseNodeGrpcServer {
metadata: Some(meta.into()),
initial_sync_achieved: status_watch.borrow().bootstrapped,
base_node_state: state.into(),
failed_checkpoints,
};

trace!(target: LOG_TARGET, "Sending MetaData response to client");
Expand Down
2 changes: 2 additions & 0 deletions base_layer/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ tiny-keccak = { package = "tari-tiny-keccak", version = "2.0.2", features = [
"keccak",
] }
dirs-next = "1.0.2"
hickory-client = { version = "0.25.0-alpha.2", features = ["dns-over-rustls", "dnssec-openssl"] }
anyhow = "1.0.53"

[dev-dependencies]
criterion = { version = "0.4.0" }
Expand Down
3 changes: 3 additions & 0 deletions base_layer/core/src/base_node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ pub mod proto;

#[cfg(any(feature = "base_node", feature = "base_node_proto"))]
pub mod rpc;

#[cfg(feature = "base_node")]
pub mod tari_pulse_service;
1 change: 1 addition & 0 deletions base_layer/core/src/base_node/tari_pulse_service/20326.rsa
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AwEAAaz/tAm8yTn4Mfeh5eyI96WSVexTBAvkMgJzkKTOiW1vkIbzxeF3+/4RgWOq7HrxRixHlFlExOLAJr5emLvN7SWXgnLh4+B5xQlNVz8Og8kvArMtNROxVQuCaSnIDdD5LKyWbRd2n9WGe2R8PzgCmr3EgVLrjyBxWezF0jLHwVN8efS3rCj/EWgvIWgb9tarpVUDK/b58Da+sqqls3eNbuv7pr+eoZG+SrDK6nWeL3c6H5Apxz7LjVc1uTIdsIXxuOLYA4/ilBmSVIzuDWfdRUfhHdY6+cn8HFRm+2hM8AnXGXws9555KrUB5qihylGa8subX2Nn6UwNR1AkUTV74bU=
1 change: 1 addition & 0 deletions base_layer/core/src/base_node/tari_pulse_service/38696.rsa
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AwEAAa96jeuknZlaeSrvyAJj6ZHv28hhOKkx3rLGXVaC6rXTsDc449/cidltpkyGwCJNnOAlFNKF2jBosZBU5eeHspaQWOmOElZsjICMQMC3aeHbGiShvZsx4wMYSjH8e7Vrhbu6irwCzVBApESjbUdpWWmEnhathWu1jo+siFUiRAAxm9qyJNg/wOZqqzL/dL/q8PkcRU5oUKEpUge71M3ej2/7CPqpdVwuMoTvoB+ZOT4YeGyxMvHmbrxlFzGOHOijtzN+u1TQNatX2XBuzZNQ1K+s2CXkPIZo7s6JgZyvaBevYtxPvYLw4z9mR7K2vaF18UYH9Z9GNUUeayffKC73PYc=</PublicKey>
Loading

0 comments on commit c76d3a3

Please sign in to comment.