Skip to content

Commit

Permalink
chore!: update feature-dan2 (#1184)
Browse files Browse the repository at this point in the history
Description
---
chore!: update feature-dan2
chore: update to wasmer 4
chore: update to rust stable

Motivation and Context
---
Requires PR tari-project/tari#6644

Allow us to use rust > 1.77 by updating wasmer. We can remove various
locks in the Runtime after this change but this is left for another PR.

How Has This Been Tested?
---
Manually

What process can a PR reviewer use to test or verify this change?
---


Breaking Changes
---

- [ ] None
- [x] Requires data directory to be deleted
- [ ] Other - Please specify
  • Loading branch information
sdbondi authored Oct 24, 2024
1 parent 1d4e316 commit 35f69f5
Show file tree
Hide file tree
Showing 125 changed files with 2,816 additions and 2,209 deletions.
3,014 changes: 1,596 additions & 1,418 deletions Cargo.lock

Large diffs are not rendered by default.

44 changes: 34 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,6 @@ 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" }

20 changes: 9 additions & 11 deletions applications/tari_dan_app_utilities/src/base_layer_scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ impl<TAddr: NodeAddressable + 'static> BaseLayerScanner<TAddr> {
output_hash,
output.commitment.as_public_key()
);
self.register_burnt_utxo(&output, &block_info).await?;
self.register_burnt_utxo(output, &block_info).await?;
},
}
}
Expand Down Expand Up @@ -432,7 +432,7 @@ impl<TAddr: NodeAddressable + 'static> BaseLayerScanner<TAddr> {

async fn register_burnt_utxo(
&mut self,
output: &TransactionOutput,
output: TransactionOutput,
block_info: &BlockInfo,
) -> Result<(), BaseLayerScannerError> {
let substate_id = SubstateId::UnclaimedConfidentialOutput(
Expand All @@ -458,18 +458,16 @@ impl<TAddr: NodeAddressable + 'static> BaseLayerScanner<TAddr> {
return Ok(());
}

let encrypted_data_bytes = output.encrypted_data.as_bytes();
if encrypted_data_bytes.len() < EncryptedData::size() {
return Err(BaseLayerScannerError::InvalidSideChainUtxoResponse(
"Encrypted data is the incorrect size".to_string(),
));
}
let encrypted_data_bytes = output.encrypted_data.into_byte_vec();
let encrypted_data = EncryptedData::try_from(encrypted_data_bytes).map_err(|len| {
BaseLayerScannerError::InvalidSideChainUtxoResponse(format!(
"Encrypted data incorrect length of bytes: {len}"
))
})?;

let substate = SubstateValue::UnclaimedConfidentialOutput(UnclaimedConfidentialOutput {
commitment: output.commitment.clone(),
encrypted_data: EncryptedData::try_from(&encrypted_data_bytes[..EncryptedData::size()]).map_err(|_| {
BaseLayerScannerError::InvalidSideChainUtxoResponse("Encrypted data has too few bytes".to_string())
})?,
encrypted_data,
});

info!(
Expand Down
44 changes: 23 additions & 21 deletions applications/tari_dan_app_utilities/src/configuration.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// 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,
Expand All @@ -24,6 +22,7 @@ pub fn load_configuration<P: AsRef<Path>, TOverride: ConfigOverrideProvider>(
config_path: P,
create_if_not_exists: bool,
overrides: &TOverride,
network_override: Option<Network>,
) -> Result<Config, ConfigError> {
debug!(
target: LOG_TARGET,
Expand All @@ -35,13 +34,14 @@ 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(config_path, overrides, network_override)
}

/// Loads the config at the given path applying all overrides.
pub fn load_configuration_with_overrides<P: AsRef<Path>, TOverride: ConfigOverrideProvider>(
config_path: P,
overrides: &TOverride,
network_override: Option<Network>,
) -> Result<Config, ConfigError> {
let filename = config_path
.as_ref()
Expand All @@ -57,34 +57,36 @@ pub fn load_configuration_with_overrides<P: AsRef<Path>, TOverride: ConfigOverri
.separator("__"),
)
.build()?;

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 = match network_override {
Some(network) => network,
None => 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 overrides = overrides.get_config_property_overrides(&mut network);
if overrides.is_empty() {
return Ok(cfg);
}
let overrides = overrides.get_config_property_overrides(&network);

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
4 changes: 2 additions & 2 deletions applications/tari_dan_app_utilities/src/json_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ fn fix_invalid_object_keys(value: &CborValue) -> CborValue {
mod tests {
use tari_common_types::types::Commitment;
use tari_engine_types::{confidential::ConfidentialOutput, resource_container::ResourceContainer, vault::Vault};
use tari_template_lib::models::{Amount, ResourceAddress};
use tari_template_lib::models::{Amount, EncryptedData, ResourceAddress};

use super::*;

Expand All @@ -173,7 +173,7 @@ mod tests {
let confidential_output = ConfidentialOutput {
commitment: commitment.clone(),
stealth_public_nonce: commitment.as_public_key().clone(),
encrypted_data: Default::default(),
encrypted_data: EncryptedData::try_from(vec![0; EncryptedData::min_size()]).unwrap(),
minimum_value_promise: 0,
viewable_balance: None,
};
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(config_path, true, &cli, cli.common.network)?;
let config = ApplicationConfig::load_from(&cfg)?;

if let Some(index) = cli.derive_secret {
Expand Down
Loading

0 comments on commit 35f69f5

Please sign in to comment.