Skip to content

Commit

Permalink
chore!: update feature-dan2
Browse files Browse the repository at this point in the history
  • Loading branch information
sdbondi committed Oct 23, 2024
1 parent c423408 commit 0cb9ec4
Show file tree
Hide file tree
Showing 103 changed files with 2,598 additions and 2,070 deletions.
2,955 changes: 1,556 additions & 1,399 deletions Cargo.lock

Large diffs are not rendered by default.

69 changes: 59 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,35 @@ tari_hashing = { git = "https://github.com/tari-project/tari.git", branch = "fea

# avoid including default features so each crate can choose which ones to import
tari_core = { git = "https://github.com/tari-project/tari.git", branch = "feature-dan2", default-features = false }
tari_crypto = "0.20.0"
tari_key_manager = { git = "https://github.com/tari-project/tari.git", branch = "feature-dan2" }
tari_metrics = { git = "https://github.com/tari-project/tari.git", branch = "feature-dan2" }
tari_mmr = { git = "https://github.com/tari-project/tari.git", branch = "feature-dan2" }
tari_p2p = { git = "https://github.com/tari-project/tari.git", branch = "feature-dan2" }
tari_shutdown = { git = "https://github.com/tari-project/tari.git", branch = "feature-dan2" }
tari_storage = { git = "https://github.com/tari-project/tari.git", branch = "feature-dan2" }
tari_utilities = "0.7.0"

#minotari_app_grpc = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
#minotari_app_utilities = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
#minotari_console_wallet = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
#minotari_node = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
#minotari_node_grpc_client = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
#minotari_wallet = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
#minotari_wallet_grpc_client = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
#tari_common = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
#tari_common_types = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
#tari_hashing = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
#
## avoid including default features so each crate can choose which ones to import
#tari_core = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2", default-features = false }
#tari_key_manager = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
#tari_metrics = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
#tari_mmr = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
#tari_p2p = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
#tari_shutdown = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
#tari_storage = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }

tari_crypto = "0.21.0"
tari_utilities = "0.8.0"

# third-party dependencies
anyhow = "1.0.75"
Expand Down Expand Up @@ -162,8 +183,8 @@ convert_case = "0.6.0"
cucumber = "0.21.0"
d3ne = { git = "https://github.com/stringhandler/d3ne-rs.git", tag = "v0.8.0-pre.3" }
dashmap = "5.5.0"
diesel = { version = "<=2.1.6", default-features = false }
diesel_migrations = "<=2.1.0"
diesel = { version = "2.2.4", default-features = false }
diesel_migrations = "2.2.0"
digest = "0.10"
dirs = "4.0.0"
env_logger = "0.10.0"
Expand All @@ -185,8 +206,8 @@ indoc = "1.0.6"
itertools = "0.11.0"
lazy_static = "1.4.0"
# Use Tari's libp2p fork that adds support for Schnorr-Ristretto
libp2p-identity = { git = "https://github.com/tari-project/rust-libp2p.git", rev = "0dccc6ca09651f6cc76ca08c58c31e34626d26c4" }
libp2p = { git = "https://github.com/tari-project/rust-libp2p.git", rev = "0dccc6ca09651f6cc76ca08c58c31e34626d26c4" }
libp2p-identity = { git = "https://github.com/tari-project/rust-libp2p.git", rev = "3d918ccbf5ae1cbec0815a2156079b0fba4ba558" }
libp2p = { git = "https://github.com/tari-project/rust-libp2p.git", rev = "3d918ccbf5ae1cbec0815a2156079b0fba4ba558" }
#libp2p = "0.53.1"
#libp2p-identity = "0.2.8"
libsqlite3-sys = "0.25"
Expand All @@ -196,7 +217,7 @@ log = "0.4.20"
log4rs = "1.3"
mime_guess = "2.0.4"
mini-moka = "0.10.0"
multiaddr = { git = "https://github.com/tari-project/rust-libp2p.git", rev = "0dccc6ca09651f6cc76ca08c58c31e34626d26c4" }
multiaddr = { git = "https://github.com/tari-project/rust-libp2p.git", rev = "3d918ccbf5ae1cbec0815a2156079b0fba4ba558" }
#multiaddr = "0.18"
newtype-ops = "0.1.4"
once_cell = "1.18.0"
Expand Down Expand Up @@ -226,7 +247,7 @@ time = "0.3.15"
tokio = { version = "1.34", default-features = false }
tokio-stream = "0.1.7"
tokio-util = "0.7.10"
tonic = "0.8.3"
tonic = "0.12.3"
tower = "0.4"
tower-http = { version = "0.4", default-features = false }
tower-layer = "0.3"
Expand All @@ -238,8 +259,8 @@ ts-rs = { version = "7.1", features = [
] }
url = "2.4.1"
urlencoding = "2.1.3"
wasmer = "2.3.0"
wasmer-middlewares = "2.3.0"
wasmer = "4.4.0"
wasmer-middlewares = "4.4.0"
webrtc = "0.9.0"
zeroize = "1"

Expand Down Expand Up @@ -273,3 +294,31 @@ overflow-checks = true
#minotari_app_utilities = { git = "https://github.com/account/tari.git", branch = "my-branch" }
#minotari_node = { git = "https://github.com/account/tari.git", branch = "my-branch" }
#tari_metrics = { git = "https://github.com/account/tari.git", branch = "my-branch" }
#tari_libtor = { git = "https://github.com/account/tari.git", branch = "my-branch" }
#tari_hashing = { git = "https://github.com/account/tari.git", branch = "my-branch" }


[patch."https://github.com/tari-project/tari.git"]
minotari_app_grpc = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
minotari_wallet_grpc_client = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
minotari_node_grpc_client = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
tari_common = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
tari_common_types = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
tari_comms = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
tari_comms_rpc_macros = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
tari_core = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
tari_key_manager = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
tari_mmr = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
tari_p2p = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
tari_shutdown = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
tari_storage = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
tari_script = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
minotari_wallet = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
minotari_console_wallet = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
tari_service_framework = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
tari_comms_dht = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
minotari_app_utilities = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
minotari_node = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
tari_metrics = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
tari_libtor = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
tari_hashing = { git = "https://github.com/sdbondi/tari.git", branch = "update-feature-dan2" }
49 changes: 26 additions & 23 deletions applications/tari_dan_app_utilities/src/configuration.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
// Copyright 2024 The Tari Project
// SPDX-License-Identifier: BSD-3-Clause
// Copyright 2022 The Tari Project
// SPDX-License-Identifier: BSD-3-Clause

use std::{
fs,
fs::File,
io,
io::Write,
path::{Path, PathBuf},
str::FromStr,
};

use config::Config;
Expand All @@ -21,6 +18,7 @@ const LOG_TARGET: &str = "tari::application::configuration";
/// Loads the configuration file from the specified path, or creates a new one with the embedded default presets if it
/// does not. This also prompts the user.
pub fn load_configuration<P: AsRef<Path>, TOverride: ConfigOverrideProvider>(
network_override: Option<Network>,
config_path: P,
create_if_not_exists: bool,
overrides: &TOverride,
Expand All @@ -35,11 +33,12 @@ pub fn load_configuration<P: AsRef<Path>, TOverride: ConfigOverrideProvider>(
write_config_to(&config_path, &sources)?;
}

load_configuration_with_overrides(config_path, overrides)
load_configuration_with_overrides(network_override, config_path, overrides)
}

/// Loads the config at the given path applying all overrides.
pub fn load_configuration_with_overrides<P: AsRef<Path>, TOverride: ConfigOverrideProvider>(
network_override: Option<Network>,
config_path: P,
overrides: &TOverride,
) -> Result<Config, ConfigError> {
Expand All @@ -57,34 +56,38 @@ pub fn load_configuration_with_overrides<P: AsRef<Path>, TOverride: ConfigOverri
.separator("__"),
)
.build()?;
// let network = match cfg.get_string("network") {
// Ok(network) => {
// Network::from_str(&network).map_err(|e| ConfigError::new("Invalid network", Some(e.to_string())))?
// },
// Err(config::ConfigError::NotFound(_)) => {
// debug!(target: LOG_TARGET, "No network configuration found. Using default network '{}'.",
// Network::default()); Network::default()
// },
// Err(e) => {
// return Err(ConfigError::new(
// "Could not get network configuration",
// Some(e.to_string()),
// ));
// },
// };

let mut network = match cfg.get_string("network") {
Ok(network) => {
Network::from_str(&network).map_err(|e| ConfigError::new("Invalid network", Some(e.to_string())))?
},
Err(config::ConfigError::NotFound(_)) => {
debug!(target: LOG_TARGET, "No network configuration found. Using default network '{}'.", Network::default());
Network::default()
},
Err(e) => {
return Err(ConfigError::new(
"Could not get network configuration",
Some(e.to_string()),
));
},
};
let network = network_override.unwrap_or_default();

let overrides = overrides.get_config_property_overrides(&mut network);
if overrides.is_empty() {
return Ok(cfg);
}
let overrides = overrides.get_config_property_overrides(&network);
// if overrides.is_empty() {
// return Ok(cfg);
// }

let mut cfg = Config::builder().add_source(cfg);
for (key, value) in overrides {
cfg = cfg
.set_override(key.as_str(), value.as_str())
.map_err(|ce| ConfigError::new("Could not override config property", Some(ce.to_string())))?;
}
cfg = cfg
.set_override("network", network.to_string())
.map_err(|ce| ConfigError::new("Could not override config property", Some(ce.to_string())))?;
let cfg = cfg
.build()
.map_err(|ce| ConfigError::new("Could not build config", Some(ce.to_string())))?;
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_dan_app_utilities/src/keypair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct KeyPairInner {
/// - `identity_file` - Reference to file path
/// - `public_address` - Network address of the base node
/// - `create_id` - Only applies if the identity_file does not exist or is malformed. If true, a new identity will be
/// created, otherwise the user will be prompted to create a new ID
/// created, otherwise the user will be prompted to create a new ID
/// - `peer_features` - Enables features of the base node
///
/// # Return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use std::{
collections::HashMap,
convert::{TryFrom, TryInto},
fs,
sync::Arc,
};
use std::{collections::HashMap, convert::TryFrom, fs, sync::Arc};

use chrono::Utc;
use log::*;
Expand Down Expand Up @@ -195,7 +190,7 @@ impl<TAddr: NodeAddressable> TemplateManager<TAddr> {
let template = DbTemplate {
template_name: template.template_name,
template_address: template.template_address.into_array().into(),
expected_hash: template.registration.binary_sha.into_vec().try_into()?,
expected_hash: template.registration.binary_sha.as_ref().try_into()?,
url: template.registration.binary_url.into_string(),
height: template.mined_height,
status: TemplateStatus::New,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ impl<TAddr: NodeAddressable + 'static> TemplateManagerService<TAddr> {
TemplateType::Flow => DbTemplateType::Flow,
TemplateType::Manifest => DbTemplateType::Manifest,
};
let expected_binary_hash = FixedHash::try_from(template.registration.binary_sha.clone().into_vec())
let expected_binary_hash = FixedHash::try_from(template.registration.binary_sha.as_ref())
.map_err(|_| TemplateManagerError::InvalidBaseLayerTemplate)?;
self.manager.add_template(template)?;
// We could queue this up much later, at which point we'd update to pending
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl From<TemplateRegistration> for TemplateMetadata {
name: reg.template_name,
address: reg.template_address,
url: reg.registration.binary_url.into_string(),
binary_sha: FixedHash::try_from(reg.registration.binary_sha.into_vec())
binary_sha: FixedHash::try_from(reg.registration.binary_sha.as_ref())
// TODO: impl Fallible conversion
.expect("binary_sha must be 32 bytes long"),
height: reg.mined_height,
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_dan_wallet_daemon/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Cli {
}

impl ConfigOverrideProvider for Cli {
fn get_config_property_overrides(&self, network: &mut Network) -> Vec<(String, String)> {
fn get_config_property_overrides(&self, network: &Network) -> Vec<(String, String)> {
let mut overrides = self.common.get_config_property_overrides(network);
if let Some(json_rpc_address) = self.json_rpc_address {
overrides.push((
Expand Down
10 changes: 9 additions & 1 deletion applications/tari_dan_wallet_daemon/src/handlers/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,13 @@ pub async fn handle_claim_burn(
commitment_substate_address.version,
)
.await?;
let output = output.into_unclaimed_confidential_output().unwrap();
let output = output.into_unclaimed_confidential_output().ok_or_else(|| {
anyhow!(
"Expected the indexer to return an unclaimed confidential output substate for {}, but another substate \
type was returned",
commitment_substate_address.substate_id
)
})?;
let unmasked_output = sdk.confidential_crypto_api().unblind_output(
&output.commitment,
&output.encrypted_data,
Expand All @@ -581,6 +587,8 @@ pub async fn handle_claim_burn(
));
}

// TODO: validate the proof_of_knowledge from the claim before submitting the transaction

let encrypted_data = sdk.confidential_crypto_api().encrypt_value_and_mask(
final_amount.as_u64_checked().unwrap(),
&mask.key,
Expand Down
12 changes: 6 additions & 6 deletions applications/tari_dan_wallet_daemon/src/handlers/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ pub async fn handle_login_request(
) -> Result<AuthLoginResponse, anyhow::Error> {
let jwt = context.wallet_sdk().jwt_api();

let (auth_token, valid_till) =
let (auth_token, valid_for) =
jwt.generate_auth_token(auth_request.permissions.as_slice().try_into()?, auth_request.duration)?;
context.notifier().notify(AuthLoginRequestEvent {
auth_token: auth_token.clone(),
valid_till,
});
Ok(AuthLoginResponse { auth_token })
context.notifier().notify(AuthLoginRequestEvent);
Ok(AuthLoginResponse {
auth_token,
valid_for_secs: valid_for.as_secs(),
})
}

pub async fn handle_login_accept(
Expand Down
17 changes: 7 additions & 10 deletions applications/tari_dan_wallet_daemon/src/jrpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,13 @@ where
.handle(
&context,
token,
value.parse_params().map_err(|e| {
match &e.result {
JsonRpcAnswer::Result(_) => {
unreachable!("parse_params() error should not return a result")
},
JsonRpcAnswer::Error(e) => {
warn!(target: LOG_TARGET, "🌐 JSON-RPC params error: {}", e);
},
}
e
value.parse_params().inspect_err(|e| match &e.result {
JsonRpcAnswer::Result(_) => {
unreachable!("parse_params() error should not return a result")
},
JsonRpcAnswer::Error(e) => {
warn!(target: LOG_TARGET, "🌐 JSON-RPC params error: {}", e);
},
})?,
)
.await
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_dan_wallet_daemon/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async fn main() -> Result<(), anyhow::Error> {
let cli = Cli::init();

let config_path = cli.common.config_path();
let cfg = load_configuration(config_path, true, &cli)?;
let cfg = load_configuration(cli.common.network, config_path, true, &cli)?;
let config = ApplicationConfig::load_from(&cfg)?;

if let Some(index) = cli.derive_secret {
Expand Down
11 changes: 3 additions & 8 deletions applications/tari_dan_wallet_daemon/src/services/events.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright 2023 The Tari Project
// SPDX-License-Identifier: BSD-3-Clause

use std::time::SystemTime;

use tari_dan_wallet_sdk::models::{Account, NewAccountInfo, TransactionStatus};
use tari_engine_types::{commit_result::FinalizeResult, substate::SubstateId};
use tari_template_lib::models::Amount;
Expand All @@ -15,7 +13,7 @@ pub enum WalletEvent {
TransactionInvalid(TransactionInvalidEvent),
AccountCreated(AccountCreatedEvent),
AccountChanged(AccountChangedEvent),
AuthLoginRequest(AuthLoginRequestEvent),
AuthLoginRequest(#[allow(dead_code)] AuthLoginRequestEvent),
}

impl From<TransactionSubmittedEvent> for WalletEvent {
Expand Down Expand Up @@ -72,6 +70,7 @@ pub struct TransactionFinalizedEvent {
#[derive(Debug, Clone)]
pub struct AccountCreatedEvent {
pub account: Account,
#[allow(dead_code)]
pub created_by_tx: TransactionId,
}

Expand All @@ -86,11 +85,7 @@ pub struct TransactionInvalidEvent {
pub status: TransactionStatus,
pub finalize: Option<FinalizeResult>,
pub final_fee: Option<Amount>,
pub is_dry_run: bool,
}

#[derive(Debug, Clone)]
pub struct AuthLoginRequestEvent {
pub auth_token: String,
pub valid_till: SystemTime,
}
pub struct AuthLoginRequestEvent;
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ where
status: transaction.status,
finalize: transaction.finalize,
final_fee: transaction.final_fee,
is_dry_run: transaction.is_dry_run,
}),
}
},
Expand Down
Loading

0 comments on commit 0cb9ec4

Please sign in to comment.