Skip to content

Commit

Permalink
fix: remove is_synced check for transaction validation (#3459)
Browse files Browse the repository at this point in the history
Description
---
Remove the check that aborts transactions validation if the base node is not synced.

Motivation and Context
---
With this check in place, if the base node is syncing even one block when the wallet asks, it will abort the check. There most likely no relation between the block that the base node is syncing and the data that the wallet is asking for, and the base node may still be able to respond correctly. The logic in tx_validation already handles the fact that a base node may be in progress with a sync, and aborting it early is not necessary.

How Has This Been Tested?
---
Manually
  • Loading branch information
stringhandler authored Oct 18, 2021
1 parent db9eb96 commit 53989f4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,6 @@ where
})
.await?;

if !batch_response.is_synced {
info!(
target: LOG_TARGET,
"Base Node reports not being synced, aborting transaction validation"
);
return Err(TransactionServiceError::BaseNodeNotSynced);
}

for response_proto in batch_response.responses {
let response = TxQueryBatchResponse::try_from(response_proto)
.map_err(TransactionServiceError::ProtobufConversionError)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ use tari_wallet::{
storage::sqlite_utilities::run_migration_and_create_sqlite_connection,
transaction_service::{
config::TransactionServiceConfig,
error::{TransactionServiceError, TransactionServiceProtocolError},
error::TransactionServiceError,
handle::{TransactionEvent, TransactionEventReceiver, TransactionEventSender},
protocols::{
transaction_broadcast_protocol::TransactionBroadcastProtocol,
Expand Down Expand Up @@ -781,33 +781,6 @@ async fn tx_validation_protocol_tx_becomes_mined_unconfirmed_then_confirmed() {

rpc_service_state.set_transaction_query_batch_responses(batch_query_response.clone());

rpc_service_state.set_is_synced(false);

wallet_connectivity.notify_base_node_set(server_node_identity.to_peer());

let protocol = TransactionValidationProtocol::new(
1,
resources.db.clone(),
wallet_connectivity.clone(),
resources.config.clone(),
resources.event_publisher.clone(),
resources.output_manager_service.clone(),
);

let join_handle = task::spawn(protocol.execute());

// Check that the protocol ends with error due to base node not being synced
let result = join_handle.await.unwrap();
assert!(matches!(
result,
Err(TransactionServiceProtocolError {
id: 1,
error: TransactionServiceError::BaseNodeNotSynced,
})
));

rpc_service_state.set_is_synced(true);

let protocol = TransactionValidationProtocol::new(
2,
resources.db.clone(),
Expand Down

0 comments on commit 53989f4

Please sign in to comment.