Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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.

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
19 changes: 17 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,7 @@ loggers:
tari::ootle:
level: debug
appenders:
- ootle
# - ootle
Comment thread
sdbondi marked this conversation as resolved.
Outdated
- stdout
additive: false

Expand All @@ -160,12 +160,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
6 changes: 5 additions & 1 deletion applications/tari_validator_node/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,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
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
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
63 changes: 15 additions & 48 deletions applications/tari_walletd/src/services/template_monitor.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
// Copyright 2025 The Tari Project
// SPDX-License-Identifier: BSD-3-Clause

use std::{ops::Add, time::Duration};

use anyhow::anyhow;
use log::*;
use tari_ootle_common_types::{optional::Optional, substate_type::SubstateType};
use tari_ootle_wallet_sdk::{models::WalletEvent, network::WalletNetworkInterface, WalletSdk, WalletSdkSpec};
use tari_engine::wasm::WasmModule;
use tari_ootle_common_types::substate_type::SubstateType;
use tari_ootle_wallet_sdk::{models::WalletEvent, WalletSdk, WalletSdkSpec};
use tari_ootle_wallet_sdk_services::notify::Notify;
use tari_shutdown::ShutdownSignal;
use tari_template_abi::TemplateDef;
use tari_template_lib::types::TemplateAddress;

const LOG_TARGET: &str = "tari::ootle_wallet_daemon::services::template_monitor";

Expand All @@ -31,37 +27,6 @@ where TSpec: WalletSdkSpec
}
}

/// Fetching template definition with retry.
async fn fetch_template_definition(&self, template_address: TemplateAddress) -> anyhow::Result<TemplateDef> {
let min_wait_time = Duration::from_millis(100);
let max_wait_time = Duration::from_secs(5);
let wait_step = Duration::from_millis(500);
let mut current_wait_time = min_wait_time;
let network_interface = self.wallet_sdk.get_network_interface();
loop {
match network_interface
.fetch_template_definition(template_address)
.await
.optional()?
{
Some(template_def) => {
info!(target: LOG_TARGET, "Fetched template definition for {template_address}");
return Ok(template_def);
},
None => {
info!(target: LOG_TARGET, "Template definition not found yet. retry after {:.2?}...", current_wait_time);
if self.shutdown_signal.is_triggered() {
return Err(anyhow!("shutdown during fetch template definition"));
}
tokio::time::sleep(current_wait_time).await;
if current_wait_time < max_wait_time {
current_wait_time = current_wait_time.add(wait_step);
}
},
};
}
}

async fn handle_wallet_event(&self, event: WalletEvent) -> anyhow::Result<()> {
if let WalletEvent::TransactionFinalized(event) = event {
let Some(diff) = event.finalize.result.any_accept() else {
Expand All @@ -86,18 +51,20 @@ where TSpec: WalletSdkSpec
error!(target: LOG_TARGET, "Diff contained a template substate ID {id} but the substate was type {}. This should not be possible", SubstateType::from(substate.substate_value()));
continue;
};
let template_definition = match self.fetch_template_definition(template_address.as_hash()).await {
Ok(template_definition) => template_definition,
Err(error) => {
error!(target: LOG_TARGET, "Failed to fetch template definition: {}", error);

match WasmModule::load_template_from_code(&template.binary) {
Ok(loaded) => {
self.wallet_sdk.template_api().add_authored_template(
template.author,
template_address.as_hash(),
loaded.template_def().clone(),
)?;
},
Err(err) => {
error!(target: LOG_TARGET, "Failed to load template {id} from transaction diff: {}", err);
continue;
},
};
self.wallet_sdk.template_api().add_authored_template(
template.author,
template_address.as_hash(),
template_definition,
)?;
}
Comment thread
sdbondi marked this conversation as resolved.
Outdated
Comment thread
sdbondi marked this conversation as resolved.
}
}
Ok(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,18 @@ function NftRow({ nft }: { nft: NonFungibleToken }) {
const mutableData = convertCborValue(nft.mutable_data);
const data = convertCborValue(nft.data);
const imageUrl = mutableData?.image_url;
const originalOwner = data?.original_owner;

const metadata: [string, string][] = [];
if (data && typeof data === "object") {
let limit = 5;
for (const [key, value] of Object.entries(data)) {
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
metadata.push([key, value.toString()]);
limit -= 1;
if (limit === 0) break;
}
}
}
Comment thread
sdbondi marked this conversation as resolved.

return (
<TableRow>
Expand Down Expand Up @@ -137,7 +148,11 @@ function NftRow({ nft }: { nft: NonFungibleToken }) {
</DataTableCell>
<DataTableCell>
<Typography variant="body2">
<CopyAddress address={originalOwner || ""} />
{metadata.map(([key, value], index) => (
<div key={index}>
<strong>{key}:</strong> {value}
</div>
))}
</Typography>
</DataTableCell>
<DataTableCell>
Expand Down
6 changes: 3 additions & 3 deletions clients/tari_indexer_client/src/rest_api_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use tari_engine_types::{
template_lib_models::ResourceAddress,
transaction_receipt::TransactionReceiptAddress,
};
use tari_template_lib_types::TemplateAddress;

use crate::{
error::IndexerRestClientError,
Expand All @@ -26,7 +27,6 @@ use crate::{
GetSubstateResponse,
GetSubstatesRequest,
GetSubstatesResponse,
GetTemplateDefinitionRequest,
GetTemplateDefinitionResponse,
GetTransactionReceiptResponse,
GetTransactionResultRequest,
Expand Down Expand Up @@ -145,9 +145,9 @@ impl IndexerRestApiClient {

pub async fn get_template_definition(
&mut self,
req: GetTemplateDefinitionRequest,
template_address: TemplateAddress,
) -> Result<GetTemplateDefinitionResponse, IndexerRestClientError> {
self.send_get(format!("templates/{}", req.template_address), ()).await
self.send_get(format!("templates/{template_address}"), ()).await
}

// pub async fn get_non_fungibles(
Expand Down
6 changes: 0 additions & 6 deletions clients/tari_indexer_client/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,6 @@ pub struct GetConnectionsResponse {
pub connections: Vec<Connection>,
}

#[derive(Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "ts", derive(ts_rs::TS), ts(export, export_to = "tari-indexer-client/"))]
pub struct GetTemplateDefinitionRequest {
pub template_address: TemplateAddress,
}

#[derive(Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "ts", derive(ts_rs::TS), ts(export, export_to = "tari-indexer-client/"))]
pub struct GetTemplateDefinitionResponse {
Expand Down
2 changes: 1 addition & 1 deletion crates/common_types/src/versioned_substate_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct SubstateRequirement {
}

impl SubstateRequirement {
pub fn new(address: SubstateId, version: Option<u32>) -> Self {
pub const fn new(address: SubstateId, version: Option<u32>) -> Self {
Self {
substate_id: address,
version,
Expand Down
6 changes: 3 additions & 3 deletions crates/consensus/src/hotstuff/block_change_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const MEM_MAX_PROPOSED_UTXO_MINTS_SIZE: usize = 1000;

#[derive(Debug, Clone)]
pub struct BlockDecision {
pub quorum_decision: Option<QuorumDecision>,
pub local_decision: Option<QuorumDecision>,
/// Contains newly-committed non-dummy blocks
pub commit_blocks: Vec<Block>,
pub finalized_transactions: Vec<Vec<TransactionPoolRecord>>,
Expand All @@ -66,7 +66,7 @@ pub struct BlockDecision {

impl BlockDecision {
pub fn is_accept(&self) -> bool {
matches!(self.quorum_decision, Some(QuorumDecision::Accept))
matches!(self.local_decision, Some(QuorumDecision::Accept))
}

pub fn is_committed_epoch_end(&self) -> bool {
Expand All @@ -90,7 +90,7 @@ impl BlockDecision {

pub fn highest_qc_view(&self) -> NodeHeight {
self.high_pc
.block_height()
.height()
.max(self.new_high_tc.as_ref().map_or(NodeHeight(0), |tc| tc.height()))
}
}
Expand Down
Loading
Loading