Skip to content
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
3 changes: 2 additions & 1 deletion Cargo.lock

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

6 changes: 0 additions & 6 deletions applications/tari_indexer/src/network_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ where
}

pub async fn submit_transaction(&self, transaction: Transaction) -> Result<TransactionId, NetworkClientError> {
if !transaction.has_inputs() {
return Err(NetworkClientError::NoInputsProvided);
}

// Ensure initial scanning has completed to ensure an accurate epoch
self.epoch_manager.wait_for_initial_scanning_to_complete().await?;

Expand Down Expand Up @@ -210,6 +206,4 @@ pub enum NetworkClientError {
},
#[error("No committee at present. Try again later")]
NoCommitteeMembers,
#[error("No inputs provided in transaction.")]
NoInputsProvided,
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ pub async fn submit_transaction(
transaction_id,
details,
} => ErrorResponse::bad_request(format!("Transaction {} is invalid: {}", transaction_id, details)),
TransactionManagerError::NetworkClientError(NetworkClientError::NoInputsProvided) => {
ErrorResponse::bad_request("Transaction has no inputs".to_string())
},
e => ErrorResponse::anyhow(e),
})?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export interface NftData {
address: string;
version: number;
nft: NonFungibleSubstate;
original_owner?: string;
amount?: number;
}

Expand All @@ -59,10 +58,6 @@ function NftRow({ nftData }: { nftData: NftData }) {
</Typography>
<Stack direction="row" alignItems="baseline" spacing={1}>
<Typography variant="body2">Original Owner:</Typography>
<Typography variant="body2" color="text.secondary">
{nftData.original_owner ? shortenString(nftData.original_owner) : "No owner"}
{nftData.original_owner && <CopyToClipboard copy={nftData.original_owner} />}
</Typography>
</Stack>
<Stack direction="row" alignItems="baseline" spacing={1}>
<Typography variant="body2">Version:</Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function Resources() {
console.error("Error converting mutable CBOR value:", e);
}

const { name, original_owner, amount } = nftData;
const { name, amount } = nftData;
const { image_url } = mutableData || {};
const nftId = nft.address.id;
const key = Object.keys(nftId)[0];
Expand All @@ -115,7 +115,6 @@ function Resources() {
address,
version: nft.version,
nft,
original_owner,
amount,
});
}
Expand Down
18 changes: 16 additions & 2 deletions applications/tari_validator_node/log4rs_sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ loggers:
tari::ootle:
level: debug
appenders:
- ootle
- stdout
additive: false

Expand All @@ -160,12 +159,27 @@ loggers:
appenders:
- consensus

tari::consensus:
level: debug
appenders:
- consensus

tari::ootle::storage:
level: debug
appenders:
- consensus

tari::ootle::consensus:
level: debug
appenders:
- consensus

tari::ootle::networking:
tari::ootle::hotstuff:
level: debug
appenders:
- consensus

tari::networking:
level: debug
appenders:
- network
Expand Down
12 changes: 7 additions & 5 deletions applications/tari_validator_node/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ use crate::{
},
state_store_template_provider::StateStoreTemplateProvider,
transaction_validators::{
BasicValidations,
EpochRangeValidator,
FeeTransactionValidator,
IsShardApplicable,
TemplateExistsValidator,
TransactionDryRunValidator,
TransactionNetworkValidator,
Expand Down Expand Up @@ -214,7 +213,11 @@ pub async fn spawn_services(

info!(target: LOG_TARGET, "State store initializing");

let state_store = ValidatorNodeStateStore::open(&config.validator_node.state_db_path, DatabaseOptions::default())?;
let state_store = ValidatorNodeStateStore::open(
&config.validator_node.state_db_path,
// TODO: just enable it always for now, later make it configurable and default to true for testnets
DatabaseOptions::default().with_debugging_data(true),
)?;

state_store.with_write_tx(|tx| create_genesis_state(tx, config.network, consensus_constants.num_preshards))?;

Expand Down Expand Up @@ -445,8 +448,7 @@ pub fn create_mempool_transaction_validator<TProvider: TemplateProvider>(
) -> impl Validator<Transaction, Context = (), Error = TransactionValidationError> {
TransactionNetworkValidator::new(network)
.and_then(TransactionDryRunValidator)
.and_then(IsShardApplicable::new())
.and_then(FeeTransactionValidator)
.and_then(BasicValidations::new())
.and_then(TransactionSignatureValidator)
.and_then(TemplateExistsValidator::new(template_manager))
}
Expand Down
4 changes: 2 additions & 2 deletions applications/tari_validator_node/src/p2p/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

mod block_sync_task;
mod service_impl;
mod rpc_impl;
mod state_sync_task;

pub use service_impl::ValidatorNodeRpcServiceImpl;
pub use rpc_impl::ValidatorNodeRpcServiceImpl;
use tari_epoch_manager::service::EpochManagerHandle;
use tari_ootle_common_types::PeerAddress;
use tari_ootle_storage::StateStore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ impl<TStateStore: StateStore + Clone + Send + Sync + 'static> ValidatorNodeRpcSe

let value_filter_flags = SubstateValueFilterFlags::from_bits_truncate(req.value_filters);

info!(
debug!(
target: LOG_TARGET,
"🌍 peer initiated sync with this node (start: v{}, {}) to {} (values: {:?})",
req.start_state_version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl<TStateStore: StateStore> StateSyncTask<TStateStore> {
// ))))
// .await?;

info!(target: LOG_TARGET, "🌍sync complete ({}). {} update(s) sent.", current_state_version, counter);
debug!(target: LOG_TARGET, "🌍sync complete ({}). {} update(s) sent.", current_state_version, counter);
// Finished
return Ok(());
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,6 @@ where
return Err(e.into());
}

if !transaction.has_inputs() {
warn!(target: LOG_TARGET, "⚠ No involved shards for transaction {tx_id}");
return Err(MempoolError::TransactionValidationError(
TransactionValidationError::NoInvolvedShards { transaction_id: tx_id },
));
}

let current_epoch = self.consensus_handle.current_view().get_epoch();

let local_committee_shard = self.epoch_manager.get_local_committee_info(current_epoch).await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,32 @@ use crate::{transaction_validators::TransactionValidationError, validator::Valid

const LOG_TARGET: &str = "tari::ootle::mempool::validators::is_shard_applicable";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Update the LOG_TARGET constant to reflect the renamed struct.

The LOG_TARGET still references "is_shard_applicable" but the struct has been renamed to BasicValidations. This inconsistency could make debugging confusing.

Apply this diff:

-const LOG_TARGET: &str = "tari::ootle::mempool::validators::is_shard_applicable";
+const LOG_TARGET: &str = "tari::ootle::mempool::validators::basic_validations";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const LOG_TARGET: &str = "tari::ootle::mempool::validators::is_shard_applicable";
const LOG_TARGET: &str = "tari::ootle::mempool::validators::basic_validations";
🤖 Prompt for AI Agents
In applications/tari_validator_node/src/transaction_validators/basic.rs around
line 9, the LOG_TARGET constant still references
"tari::ootle::mempool::validators::is_shard_applicable" which is inconsistent
with the renamed struct BasicValidations; change the LOG_TARGET value to a name
that matches the struct (for example
"tari::ootle::mempool::validators::basic_validations") so logs reflect the
correct component and reduce confusion when debugging.


/// Refuse to process the transaction if it does not apply to any shard (i.e. does not have any inputs or claim burn
/// tombstones).
/// Basic validations for a transaction:
/// - Has at least one fee instruction
#[derive(Debug, Clone, Default)]
pub struct IsShardApplicable;
pub struct BasicValidations;

impl IsShardApplicable {
impl BasicValidations {
pub fn new() -> Self {
Self
}
}

impl Validator<Transaction> for IsShardApplicable {
impl Validator<Transaction> for BasicValidations {
type Context = ();
type Error = TransactionValidationError;

fn validate(&self, _context: &(), transaction: &Transaction) -> Result<(), Self::Error> {
if !transaction.has_inputs() {
warn!(target: LOG_TARGET, "HasInputs - FAIL: No input shards");
return Err(TransactionValidationError::NoInputs {
if transaction.fee_instructions().is_empty() {
warn!(target: LOG_TARGET, "BasicValidations - FAIL: No fee instructions");
return Err(TransactionValidationError::NoFeeInstructions {
transaction_id: transaction.calculate_id(),
});
}

debug!(target: LOG_TARGET, "HasInputs - OK");
// TODO: additional checks?

debug!(target: LOG_TARGET, "BasicValidations - OK");
Ok(())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ pub enum TransactionValidationError {
// TODO: move these to MempoolValidationError type
#[error("Template not found: {address}")]
TemplateNotFound { address: TemplateAddress },
#[error("No fee instructions")]
NoFeeInstructions,
#[error("{transaction_id} has no fee instructions")]
NoFeeInstructions { transaction_id: TransactionId },
#[error("Output substate exists in transaction {transaction_id}")]
OutputSubstateExists { transaction_id: TransactionId },
#[error("Validator fee claim instruction in transaction {transaction_id} contained invalid epoch {given_epoch}")]
Expand All @@ -32,10 +32,6 @@ pub enum TransactionValidationError {
CurrentEpochLessThanMinimum { current_epoch: Epoch, min_epoch: Epoch },
#[error("Current epoch ({current_epoch}) is greater than maximum epoch ({max_epoch}) required for transaction")]
CurrentEpochGreaterThanMaximum { current_epoch: Epoch, max_epoch: Epoch },
#[error("Transaction {transaction_id} does not have any inputs")]
NoInputs { transaction_id: TransactionId },
#[error("Executed transaction {transaction_id} does not involved any shards")]
NoInvolvedShards { transaction_id: TransactionId },
#[error("Invalid transaction signature")]
InvalidSignature,
#[error("Transaction {transaction_id} has no main signer")]
Expand Down
25 changes: 0 additions & 25 deletions applications/tari_validator_node/src/transaction_validators/fee.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
// Copyright 2022 The Tari Project
// SPDX-License-Identifier: BSD-3-Clause

mod basic;
mod epoch_range;
mod fee;
mod is_shard_applicable;
mod network;
mod signature;
mod template_exists;

mod dry_run;

pub use basic::*;
pub use dry_run::*;
pub use epoch_range::*;
pub use fee::*;
pub use is_shard_applicable::*;
pub use network::*;
pub use signature::*;
pub use template_exists::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,22 @@ impl Validator<Transaction> for TransactionNetworkValidator {
type Context = ();
type Error = TransactionValidationError;

fn validate(&self, _context: &Self::Context, input: &Transaction) -> Result<(), Self::Error> {
match input {
Transaction::V1(tx) => {
let tx_network = Network::try_from(tx.network()).map_err(|error| Self::Error::UnknownNetwork {
byte: tx.network(),
details: error.to_string(),
})?;
if tx_network == self.network {
Ok(())
} else {
warn!(target: LOG_TARGET, "TransactionNetworkValidator - FAIL: mismatching networks: TX: {} != Current: {}", tx_network, self.network);
Err(Self::Error::NetworkMismatch {
actual: self.network,
expected: tx_network,
})
}
},
fn validate(&self, _context: &Self::Context, tx: &Transaction) -> Result<(), Self::Error> {
let tx_network =
Network::try_from(tx.network()).map_err(|error| TransactionValidationError::UnknownNetwork {
byte: tx.network(),
details: error.to_string(),
})?;

if tx_network != self.network {
warn!(target: LOG_TARGET, "TransactionNetworkValidator - FAIL: mismatching networks: TX: {} != Current: {}", tx_network, self.network);
return Err(Self::Error::NetworkMismatch {
actual: self.network,
expected: tx_network,
});
}
Comment on lines +34 to 40

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Fix swapped actual and expected fields in error construction.

The actual and expected fields in the NetworkMismatch error are semantically reversed:

  • tx_network is what was provided in the transaction (actual)
  • self.network is what the validator expects (expected)

The warning message confirms this interpretation: "TX: {} != Current: {}" where TX is the actual network and Current is the expected network.

Apply this diff to correct the field assignment:

         if tx_network != self.network {
             warn!(target: LOG_TARGET, "TransactionNetworkValidator - FAIL: mismatching networks: TX: {} != Current: {}", tx_network, self.network);
             return Err(Self::Error::NetworkMismatch {
-                actual: self.network,
-                expected: tx_network,
+                actual: tx_network,
+                expected: self.network,
             });
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if tx_network != self.network {
warn!(target: LOG_TARGET, "TransactionNetworkValidator - FAIL: mismatching networks: TX: {} != Current: {}", tx_network, self.network);
return Err(Self::Error::NetworkMismatch {
actual: self.network,
expected: tx_network,
});
}
if tx_network != self.network {
warn!(target: LOG_TARGET, "TransactionNetworkValidator - FAIL: mismatching networks: TX: {} != Current: {}", tx_network, self.network);
return Err(Self::Error::NetworkMismatch {
actual: tx_network,
expected: self.network,
});
}
🤖 Prompt for AI Agents
In applications/tari_validator_node/src/transaction_validators/network.rs around
lines 34 to 40, the NetworkMismatch error constructs its fields reversed: swap
the values so actual = tx_network and expected = self.network; update the
Err(...) to pass actual: tx_network, expected: self.network to match the warning
message and semantics.


Ok(())
}
}

Expand Down
2 changes: 1 addition & 1 deletion applications/tari_walletd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ tari_ootle_wallet_sdk_services = { workspace = true, features = ["indexer_client
tari_ootle_wallet_storage_sqlite = { workspace = true }
tari_transaction = { workspace = true }
tari_ootle_common_types = { workspace = true }
tari_engine = { workspace = true }
tari_engine_types = { workspace = true }
tari_wallet_daemon_client = { workspace = true }
tari_template_builtin = { workspace = true }
# TODO: Ideally we should not have to include the WASM template lib, we should perhaps extract the address types into a separate crate (e.g. template_types)
tari_template_lib = { workspace = true }
tari_template_abi = { workspace = true }
tari_transaction_manifest = { workspace = true }

async-trait = { workspace = true }
Expand Down
1 change: 0 additions & 1 deletion applications/tari_walletd/src/handlers/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,6 @@ pub async fn handle_claim_burn(
.claim_burn(claim_proof, output_data)
.pay_fee_stealth(pay_fee_and_mint_output)
})
.add_input(XTR)
.build();

let transaction = sdk.signer_api().sign(public_signer_key.key_id, transaction)?;
Expand Down
2 changes: 0 additions & 2 deletions applications/tari_walletd/src/handlers/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use log::*;
use tari_engine_types::{substate::SubstateId, ToByteType};
use tari_ootle_common_types::{derive_fee_pool_address, SubstateAddress, SubstateRequirement};
use tari_ootle_wallet_sdk::models::{KeyBranch, KeyId};
use tari_template_lib::constants::XTR;
use tari_transaction::args;
use tari_wallet_daemon_client::{
permissions::JrpcPermission,
Expand Down Expand Up @@ -177,7 +176,6 @@ pub async fn handle_claim_validator_fees(
})
.with_inputs(inputs.into_iter().map(|input| input.into_unversioned()))
.with_inputs(fee_pool_addresses.map(SubstateRequirement::unversioned))
.add_input(XTR)
.map(|builder| {
if let Some(index) = req.claim_key_index {
if claim_public_key == *account.address.account_public_key() {
Expand Down
Loading
Loading