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

feat: validate blockchain fetch from DNS server with local state #6658

Merged
merged 14 commits into from
Nov 19, 2024
Merged
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: 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
3 changes: 3 additions & 0 deletions applications/minotari_node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ 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
pub tari_pulse_interval: Duration,
}

impl Default for BaseNodeConfig {
Expand Down Expand Up @@ -180,6 +182,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;
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=
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
Loading