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

11 changes: 11 additions & 0 deletions applications/tari_indexer/src/json_rpc/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,17 @@ impl JsonRpcHandlers {
),
)
},
TransactionManagerError::InvalidTransaction {
transaction_id,
details,
} => JsonRpcResponse::error(
answer_id,
JsonRpcError::new(
JsonRpcErrorReason::ApplicationError(400),
format!("Transaction {} is invalid: {}", transaction_id, details),
json::Value::Null,
),
),
e => Self::internal_error(answer_id, e),
})?;

Expand Down
6 changes: 6 additions & 0 deletions applications/tari_indexer/src/transaction_manager/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
use tari_indexer_lib::error::IndexerError;
use tari_ootle_common_types::optional::IsNotFoundError;
use tari_ootle_storage::StorageError;
use tari_transaction::TransactionId;

use crate::network_client::NetworkClientError;

#[derive(Debug, thiserror::Error)]
pub enum TransactionManagerError {
#[error("Transaction {transaction_id} is invalid: {details}")]
InvalidTransaction {
transaction_id: TransactionId,
details: String,
},
#[error(transparent)]
NetworkClientError(#[from] NetworkClientError),
#[error("{entity} not found: {key}")]
Expand Down
8 changes: 8 additions & 0 deletions applications/tari_indexer/src/transaction_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ where
}

pub async fn submit_transaction(&self, transaction: Transaction) -> Result<TransactionId, TransactionManagerError> {
if !transaction.verify_all_signatures() {
// DEV note: If signatures are invalid here (but they should be valid), this probably indicates an issue
// with the JSON decoding (crates/engine_types/src/argument_parser.rs)
return Err(TransactionManagerError::InvalidTransaction {
transaction_id: transaction.calculate_id(),
details: "Transaction has one or more invalid signature(s)".to_string(),
});
}
self.store
.with_write_tx(|tx| tx.insert_or_ignore_transaction(&transaction))?;
let id = self.network_client.submit_transaction(transaction).await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ interface FeeInformationProps extends FeeReceipt {
}

function FeeInformation({
total_fee_payment,
total_fees_paid,
cost_breakdown,
expandAllTrigger = 0,
collapseAllTrigger = 0,
onExpandedChange,
}: FeeInformationProps) {
total_fee_payment,
total_fees_paid,
total_fee_overcharge,
cost_breakdown,
expandAllTrigger = 0,
collapseAllTrigger = 0,
onExpandedChange,
}: FeeInformationProps) {
const [expanded, setExpanded] = useState(false);

useEffect(() => {
Expand Down Expand Up @@ -91,7 +92,7 @@ function FeeInformation({
</TableRow>
<TableRow>
<TableCell>Total Fees Paid</TableCell>
<DataTableCell>{formatXTM(total_fees_paid)}</DataTableCell>
<DataTableCell>{formatXTM(total_fees_paid)}{total_fee_overcharge > 0 ? ` Overcharge: ${total_fee_overcharge}` : ""}</DataTableCell>
</TableRow>
<TableRow>
<TableCell>Cost Breakdown</TableCell>
Expand All @@ -105,7 +106,7 @@ function FeeInformation({
variant="filled"
color="default"
/>
)
),
)}
</Stack>
</DataTableCell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { validateHash } from "../../../utils/helpers";

// Type guard to check if result is finalized
const isFinalized = (
result: IndexerTransactionFinalizedResult
result: IndexerTransactionFinalizedResult,
): result is { Finalized: any } => {
return typeof result === "object" && result !== null && "Finalized" in result;
};
Expand All @@ -59,7 +59,7 @@ function Result({ transaction_id }: IndexerGetTransactionResultRequest) {
const normalizedTransactionId = transaction_id.toLowerCase();
const isValidHash = validateHash(normalizedTransactionId);
const { data, isLoading, error, isError } = useGetTransactionResult(
normalizedTransactionId
normalizedTransactionId,
);

if (!isValidHash) {
Expand Down Expand Up @@ -105,12 +105,12 @@ function Result({ transaction_id }: IndexerGetTransactionResultRequest) {
<DataTableCell>
{data.result.Finalized.execution_result?.execution_time
? `${
data.result.Finalized.execution_result
.execution_time.secs
}s ${Math.round(
data.result.Finalized.execution_result
.execution_time.nanos / 1000000
)}ms`
data.result.Finalized.execution_result
.execution_time.secs
}s ${Math.round(
data.result.Finalized.execution_result
.execution_time.nanos / 1000000,
)}ms`
: "N/A"}
</DataTableCell>
</TableRow>
Expand All @@ -121,10 +121,7 @@ function Result({ transaction_id }: IndexerGetTransactionResultRequest) {
<AccordionGroup>
{data.result.Finalized.execution_result?.finalize
?.fee_receipt && (
<FeeInformation
{...data.result.Finalized.execution_result.finalize
.fee_receipt}
/>
<FeeInformation {...data.result.Finalized.execution_result.finalize.fee_receipt} />
)}

<Events
Expand All @@ -142,7 +139,7 @@ function Result({ transaction_id }: IndexerGetTransactionResultRequest) {

{data.result.Finalized.execution_result?.finalize?.result &&
isAcceptResult(
data.result.Finalized.execution_result.finalize.result
data.result.Finalized.execution_result.finalize.result,
) && (
<SubstateChanges
result={
Expand Down
1 change: 1 addition & 0 deletions applications/tari_swarm_daemon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ tari_wallet_daemon_client = { workspace = true }
tari_engine = { workspace = true }
tari_template_lib_types = { workspace = true }
tari_ootle_app_utilities = { workspace = true }
tari_ootle_wallet_sdk = { workspace = true }

anyhow = { workspace = true }
async-trait = { workspace = true }
Expand Down
8 changes: 6 additions & 2 deletions applications/tari_swarm_daemon/src/process_manager/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use tari_ootle_common_types::Network;
use tari_shutdown::ShutdownSignal;
use tari_template_lib_types::TemplateAddress;
use tari_validator_node_client::types::{AddPeerRequest, GetTemplatesRequest};
use tari_wallet_daemon_client::types::ExtClaimBurnProof;
use tokio::{sync::mpsc, time, time::sleep};
use url::Url;

Expand Down Expand Up @@ -603,7 +604,7 @@ impl ProcessManager {
"No wallet daemon instances {wallet_instance_id} found. Please start a wallet before burning funds"
)
})?;
let claim_public_key = wallet.get_account_public_key(account_name.clone(), None).await?;
let (claim_public_key, nonce_key_index) = wallet.create_nonce_key().await?;
let wallet = self
.instance_manager
.minotari_wallets()
Expand All @@ -615,7 +616,10 @@ impl ProcessManager {
let file_name = PathBuf::from(format!("burn_proof-{}.json", proof.tx_id));
let path = out_path.join(&file_name);
let mut file = File::create(path)?;
serde_json::to_writer_pretty(&mut file, &proof)?;
serde_json::to_writer_pretty(&mut file, &ExtClaimBurnProof {
claim_proof: proof.claim_proof,
owner_nonce_key_index: nonce_key_index,
})?;

info!("🔥 Burned {amount} Tari to account {account_name}");
Ok(file_name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@
// SPDX-License-Identifier: BSD-3-Clause

use anyhow::anyhow;
use tari_ootle_wallet_sdk::apis::key_manager::KeyBranch;
use tari_template_lib_types::crypto::RistrettoPublicKeyBytes;
use tari_wallet_daemon_client::{
types::{
AccountGetResponse,
AuthLoginAcceptRequest,
AuthLoginRequest,
AuthLoginResponse,
WebauthnFinishAuthRequest,
},
types::{AuthLoginAcceptRequest, AuthLoginRequest, AuthLoginResponse, WebauthnFinishAuthRequest},
WalletDaemonClient,
};

Expand Down Expand Up @@ -53,14 +48,10 @@ impl WalletDaemonProcess {
Ok(client)
}

pub async fn get_account_public_key(
&self,
name: String,
webauthn_finish_auth_request: Option<WebauthnFinishAuthRequest>,
) -> anyhow::Result<RistrettoPublicKeyBytes> {
let mut client = self.connect_client(webauthn_finish_auth_request).await?;
let AccountGetResponse { public_key, .. } = client.accounts_get(name.into()).await?;
Ok(public_key)
pub async fn create_nonce_key(&self) -> anyhow::Result<(RistrettoPublicKeyBytes, u64)> {
let mut client = self.connect_client(None).await?;
let response = client.create_key(KeyBranch::Nonce).await.map_err(|e| anyhow!(e))?;
Ok((response.public_key, response.id))
}

pub fn instance(&self) -> &Instance {
Expand Down
32 changes: 20 additions & 12 deletions applications/tari_validator_node/src/state_bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ use tari_state_tree::Version;
use tari_template_lib::{
auth::{ComponentAccessRules, OwnerRule, ResourceAccessRules},
constants::{
CONFIDENTIAL_TARI_RESOURCE_ADDRESS,
NFT_FAUCET_COMPONENT_ADDRESS,
NFT_FAUCET_RESOURCE_ADDRESS,
PUBLIC_IDENTITY_RESOURCE_ADDRESS,
STEALTH_TARI_RESOURCE_ADDRESS,
XTR_FAUCET_COMPONENT_ADDRESS,
XTR_FAUCET_VAULT_ADDRESS,
},
models::Metadata,
prelude::ResourceType,
prelude::{ResourceManager, ResourceType},
resource::TOKEN_SYMBOL,
rule,
types::EntityId,
Expand Down Expand Up @@ -80,15 +80,21 @@ where
let is_testnet = !matches!(network, Network::MainNet);
let symbol = if is_testnet { "tXTR" } else { "XTR" };
let xtr_resource = Resource::new(
ResourceType::Confidential,
ResourceType::Stealth,
None,
OwnerRule::None,
ResourceAccessRules::new(),
ResourceAccessRules::new()
// These are defaults, but just for explicitness
.mintable(rule!(deny_all))
.burnable(rule!(deny_all))
.recallable(rule!(deny_all))
.freezable(rule!(deny_all))
.update_access_rules(rule!(deny_all)),
Metadata::from([(TOKEN_SYMBOL, symbol)]),
None,
None,
6,
false,
true,
);

if is_testnet {
Expand All @@ -98,7 +104,7 @@ where
create_nft_faucet(tx, num_preshards)?;
}

create_substate(tx, num_preshards, CONFIDENTIAL_TARI_RESOURCE_ADDRESS, xtr_resource)?;
create_substate(tx, num_preshards, STEALTH_TARI_RESOURCE_ADDRESS, xtr_resource)?;

Ok(())
}
Expand All @@ -117,18 +123,20 @@ where
access_rules: ComponentAccessRules::allow_all(),
entity_id: EntityId::default(),
body: ComponentBody {
state: cbor!({"vault" => XTR_FAUCET_VAULT_ADDRESS}).unwrap(),
state: cbor!({
"vault" => XTR_FAUCET_VAULT_ADDRESS,
"resource_manager" => ResourceManager::get(STEALTH_TARI_RESOURCE_ADDRESS)
})
.unwrap(),
},
};
create_substate(tx, num_preshards, XTR_FAUCET_COMPONENT_ADDRESS, value)?;

let value = Vault::new(ResourceContainer::Confidential {
address: CONFIDENTIAL_TARI_RESOURCE_ADDRESS,
commitments: Default::default(),
let value = Vault::new(ResourceContainer::Stealth {
address: STEALTH_TARI_RESOURCE_ADDRESS,
// just under 18.5 trillion tXTR
revealed_amount: u64::MAX.into(),
locked_commitments: Default::default(),
locked_revealed_amount: Default::default(),
locked_amount: Default::default(),
});

create_substate(tx, num_preshards, XTR_FAUCET_VAULT_ADDRESS, value)?;
Expand Down
Loading
Loading