Skip to content

Commit

Permalink
Merge branch 'main' into release-notes-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
peps authored Nov 19, 2024
2 parents 564b774 + 5b614b5 commit b057d72
Show file tree
Hide file tree
Showing 29 changed files with 856 additions and 34 deletions.
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ coverage
# Ignore all HTML files:
**/*.html

# Ignore all JSON files in locales:
**/locales/**/*.json

# Logs
logs
*.log
Expand Down
530 changes: 530 additions & 0 deletions ci/windows-dev-environment-notes.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions public/locales/af/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"importing-wallet": "Beursie invoer",
"invalid-seed-words": "Voer 24 woorde in, geskei deur spasies",
"inviteCode": "Uitnodigingskode",
"is-on-orphan-chain": "You seem to be connected to a fork, and not the main chain. Any blocks you win might be invalidated.",
"last-block-added-time": "Tyd toe laaste blok by ketting gevoeg was",
"logs": "Verslae",
"low-hash-rate-warning": "Jou hash rate is baie laag. Probeer om alle toepassings behalwe Tari Universe te sluit",
Expand Down
1 change: 1 addition & 0 deletions public/locales/cn/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"importing-wallet": "正在导入钱包",
"invalid-seed-words": "输入24个用空格分隔的单词",
"inviteCode": "邀请代码",
"is-on-orphan-chain": "You seem to be connected to a fork, and not the main chain. Any blocks you win might be invalidated.",
"last-block-added-time": "最后添加到链的块时间",
"logs": "日志",
"low-hash-rate-warning": "您的哈希率非常低。尝试关闭除Tari Universe以外的所有应用程序",
Expand Down
1 change: 1 addition & 0 deletions public/locales/de/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"importing-wallet": "Wallet wird importiert",
"invalid-seed-words": "Geben Sie 24 Wörter ein, getrennt durch Leerzeichen",
"inviteCode": "Einladungscode",
"is-on-orphan-chain": "You seem to be connected to a fork, and not the main chain. Any blocks you win might be invalidated.",
"last-block-added-time": "Letzte Blockzeit, die zur Kette hinzugefügt wurde",
"logs": "Protokolle",
"low-hash-rate-warning": "Ihre Hashrate ist sehr niedrig. Versuchen Sie, alle Apps außer Tari Universe zu schließen",
Expand Down
1 change: 1 addition & 0 deletions public/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"importing-wallet": "Importing wallet",
"invalid-seed-words": "Enter 24 words separated by spaces",
"inviteCode": "Invite Code",
"is-on-orphan-chain": "You seem to be connected to a fork, and not the main chain. Any blocks you win might be invalidated.",
"last-block-added-time": "Last block added to chain time",
"logs": "Logs",
"low-hash-rate-warning": "Your hash rate is very low. Try closing all apps other than Tari Universe",
Expand Down
1 change: 1 addition & 0 deletions public/locales/fr/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"importing-wallet": "Importation du portefeuille",
"invalid-seed-words": "Entrez 24 mots séparés par des espaces",
"inviteCode": "Code d\"invitation",
"is-on-orphan-chain": "You seem to be connected to a fork, and not the main chain. Any blocks you win might be invalidated.",
"last-block-added-time": "Heure du dernier bloc ajouté à la chaîne",
"logs": "Journaux",
"low-hash-rate-warning": "Votre hashrate est très bas. Essayez de fermer toutes les applications sauf Tari Universe",
Expand Down
1 change: 1 addition & 0 deletions public/locales/hi/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"importing-wallet": "वॉलेट आयात किया जा रहा है",
"invalid-seed-words": "24 शब्दों को स्पेस से अलग करके दर्ज करें",
"inviteCode": "आमंत्रण कोड",
"is-on-orphan-chain": "You seem to be connected to a fork, and not the main chain. Any blocks you win might be invalidated.",
"last-block-added-time": "श्रृंखला में जोड़ा गया अंतिम ब्लॉक समय",
"logs": "लॉग्स",
"low-hash-rate-warning": "आपकी हैश रेट बहुत कम है। Tari Universe के अलावा सभी ऐप्स को बंद करने का प्रयास करें",
Expand Down
1 change: 1 addition & 0 deletions public/locales/id/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"importing-wallet": "Mengimpor dompet",
"invalid-seed-words": "Masukkan 24 kata yang dipisahkan oleh spasi",
"inviteCode": "Kode Undangan",
"is-on-orphan-chain": "You seem to be connected to a fork, and not the main chain. Any blocks you win might be invalidated.",
"last-block-added-time": "Waktu blok terakhir ditambahkan ke rantai",
"logs": "Log",
"low-hash-rate-warning": "Hashrate Anda sangat rendah. Coba tutup semua aplikasi selain Tari Universe",
Expand Down
1 change: 1 addition & 0 deletions public/locales/ja/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"importing-wallet": "ウォレットのインポート",
"invalid-seed-words": "スペースで区切って24の単語を入力してください",
"inviteCode": "招待コード",
"is-on-orphan-chain": "You seem to be connected to a fork, and not the main chain. Any blocks you win might be invalidated.",
"last-block-added-time": "最後のブロックがチェーンに追加された時間",
"logs": "ログ",
"low-hash-rate-warning": "ハッシュレートが非常に低いです。Tari Universe以外のすべてのアプリを閉じてみてください",
Expand Down
1 change: 1 addition & 0 deletions public/locales/ko/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"importing-wallet": "지갑 가져오기",
"invalid-seed-words": "공백으로 구분된 24개의 단어를 입력하세요",
"inviteCode": "초대 코드",
"is-on-orphan-chain": "You seem to be connected to a fork, and not the main chain. Any blocks you win might be invalidated.",
"last-block-added-time": "마지막 블록 체인 추가 시간",
"logs": "로그",
"low-hash-rate-warning": "해시레이트가 매우 낮습니다. Tari Universe 외의 모든 앱을 닫아보세요",
Expand Down
1 change: 1 addition & 0 deletions public/locales/pl/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"importing-wallet": "Importowanie portfela",
"invalid-seed-words": "Wprowadź 24 słowa oddzielone spacjami",
"inviteCode": "Kod Zaproszenia",
"is-on-orphan-chain": "You seem to be connected to a fork, and not the main chain. Any blocks you win might be invalidated.",
"last-block-added-time": "Czas dodania ostatniego bloku do łańcucha",
"logs": "Logi",
"low-hash-rate-warning": "Twój hash rate jest bardzo niski. Spróbuj zamknąć wszystkie aplikacje poza Tari Universe",
Expand Down
1 change: 1 addition & 0 deletions public/locales/ru/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"importing-wallet": "Импорт кошелька",
"invalid-seed-words": "Введите 24 слова, разделенные пробелами",
"inviteCode": "Код приглашения",
"is-on-orphan-chain": "You seem to be connected to a fork, and not the main chain. Any blocks you win might be invalidated.",
"last-block-added-time": "Время добавления последнего блока в цепь",
"logs": "Логи",
"low-hash-rate-warning": "Ваш хешрейт очень низкий. Попробуйте закрыть все приложения, кроме Tari Universe",
Expand Down
1 change: 1 addition & 0 deletions public/locales/tr/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"importing-wallet": "Cüzdan İçe Aktarılıyor",
"invalid-seed-words": "Boşluklarla ayrılmış 24 kelime girin",
"inviteCode": "Davet Kodu",
"is-on-orphan-chain": "You seem to be connected to a fork, and not the main chain. Any blocks you win might be invalidated.",
"last-block-added-time": "Zincir zamanına eklenen son blok",
"logs": "Günlükler",
"low-hash-rate-warning": "Hashrate\"iniz çok düşük. Tari Evreni dışındaki tüm uygulamaları kapatmayı deneyin",
Expand Down
10 changes: 5 additions & 5 deletions src-tauri/binaries_versions_esmeralda.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"binaries": {
"xmrig": "=6.22.0",
"mmproxy": "=1.8.0-pre.0",
"minotari_node": "=1.8.0-pre.0",
"wallet": "=1.8.0-pre.0",
"sha-p2pool": "=0.8.0",
"xtrgpuminer": "=0.1.17",
"mmproxy": "=1.9.0-pre.0",
"minotari_node": "=1.9.0-pre.0",
"wallet": "=1.9.0-pre.0",
"sha-p2pool": "=0.9.0",
"xtrgpuminer": "=0.1.22",
"tor": "=13.5.7"
}
}
10 changes: 5 additions & 5 deletions src-tauri/binaries_versions_nextnet.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"binaries": {
"xmrig": "=6.22.0",
"mmproxy": "=1.8.0-rc.0",
"minotari_node": "=1.8.0-rc.0",
"wallet": "=1.8.0-rc.0",
"sha-p2pool": "=0.8.0",
"xtrgpuminer": "=0.1.17",
"mmproxy": "=1.9.0-rc.0",
"minotari_node": "=1.9.0-rc.0",
"wallet": "=1.9.0-rc.0",
"sha-p2pool": "=0.9.0",
"xtrgpuminer": "=0.1.22",
"tor": "=13.5.7"
}
}
16 changes: 16 additions & 0 deletions src-tauri/src/external_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,22 @@ impl ExternalDependencies {
) -> Result<(), Error> {
info!(target: LOG_TARGET, "Installing missing dependency: {}", missing_dependency.display_name);
let installer_path = self.download_installer(&missing_dependency).await?;

#[cfg(target_os = "windows")]
use crate::consts::PROCESS_CREATION_NO_WINDOW;
#[cfg(target_os = "windows")]
let mut thread = tokio::process::Command::new(installer_path)
.creation_flags(PROCESS_CREATION_NO_WINDOW)
.spawn()
.map_err(|e| {
anyhow!(
"Failed to start installer for {}: {}",
missing_dependency.display_name,
e
)
})?;

#[cfg(not(target_os = "windows"))]
let mut thread = tokio::process::Command::new(installer_path)
.spawn()
.map_err(|e| {
Expand Down
27 changes: 27 additions & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use external_dependencies::{ExternalDependencies, ExternalDependency, RequiredEx
use hardware::hardware_status_monitor::{HardwareStatusMonitor, PublicDeviceProperties};
use log::trace;
use log::{debug, error, info, warn};
use process_utils::set_interval;

use log4rs::config::RawConfig;
use regex::Regex;
Expand Down Expand Up @@ -71,6 +72,7 @@ mod hardware_monitor;
mod internal_wallet;
mod mm_proxy_adapter;
mod mm_proxy_manager;
mod network_utils;
mod node_adapter;
mod node_manager;
mod p2pool;
Expand Down Expand Up @@ -951,6 +953,14 @@ async fn setup_inner(
.inspect_err(|e| error!(target: LOG_TARGET, "Could not emit event 'message': {:?}", e)),
);

let app_handle_clone: tauri::AppHandle = app.clone();
tauri::async_runtime::spawn(async move {
set_interval(
move || check_if_is_orphan_chain(app_handle_clone.clone()),
Duration::from_secs(30),
);
});

Ok(())
}

Expand Down Expand Up @@ -1593,6 +1603,23 @@ async fn get_app_config(
Ok(state.config.read().await.clone())
}

async fn check_if_is_orphan_chain(app_handle: tauri::AppHandle) {
let state = app_handle.state::<UniverseAppState>().inner();
let check_if_orphan = state.node_manager.check_if_is_orphan_chain().await;
match check_if_orphan {
Ok(is_stuck) => {
if is_stuck {
error!(target: LOG_TARGET, "Miner is stuck on orphan chain");
drop(app_handle.emit_all("is_stuck", is_stuck));
}
}
Err(e) => {
error!(target: LOG_TARGET, "{}", e);
drop(app_handle.emit_all("is_stuck", true));
}
}
}

#[allow(clippy::too_many_lines)]
#[tauri::command]
async fn get_tor_entry_guards(
Expand Down
103 changes: 103 additions & 0 deletions src-tauri/src/network_utils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
use serde::Deserialize;
use std::fmt::Write as _;
use tari_common::configuration::Network;

fn get_text_explore_blocks_url(network: Network, block_height: u64) -> String {
match network {
Network::StageNet => format!(
"https://textexplore-stagenet.tari.com/blocks/{}?json",
block_height
),
Network::NextNet => format!(
"https://textexplore-nextnet.tari.com/blocks/{}?json",
block_height
),
Network::Esmeralda => format!(
"https://textexplore-esmeralda.tari.com/blocks/{}?json",
block_height
),
_ => format!(
"https://textexplore-esmeralda.tari.com/blocks/{}?json",
block_height
),
}
}

fn get_text_explore_url(network: Network) -> String {
match network {
Network::StageNet => "https://textexplore-stagenet.tari.com/?json".to_string(),
Network::NextNet => "https://textexplore-nextnet.tari.com/?json".to_string(),
Network::Esmeralda => "https://textexplore-esmeralda.tari.com/?json".to_string(),
_ => "https://textexplore-esmeralda.tari.com/?json".to_string(),
}
}

pub(crate) async fn get_best_block_from_block_scan(network: Network) -> Result<u64, anyhow::Error> {
#[derive(Deserialize)]
struct BlockScanResponse {
#[serde(rename = "tipInfo")]
tip_info: TipInfo,
}

#[derive(Deserialize)]
struct TipInfo {
metadata: Metadata,
}

#[derive(Deserialize)]
struct Metadata {
best_block_height: String,
}

let response = reqwest::get(&get_text_explore_url(network))
.await?
.json::<BlockScanResponse>()
.await?;

let best_block_height = response
.tip_info
.metadata
.best_block_height
.parse::<u64>()?;

Ok(best_block_height)
}

pub(crate) async fn get_block_info_from_block_scan(
network: Network,
block_height: &u64,
) -> Result<(u64, String), anyhow::Error> {
#[derive(Deserialize)]
struct BlockHeader {
hash: HashData,
height: String,
}

#[derive(Deserialize)]
struct HashData {
data: Vec<u8>,
}

#[derive(Deserialize)]
struct BlockResponse {
header: BlockHeader,
}

let response = reqwest::get(&get_text_explore_blocks_url(network, *block_height))
.await?
.json::<BlockResponse>()
.await?;

let hash = response
.header
.hash
.data
.iter()
.fold(String::new(), |mut acc, x| {
write!(acc, "{:02x}", x).expect("Unable to write");
acc
});
let height = response.header.height.parse::<u64>()?;

Ok((height, hash))
}
36 changes: 34 additions & 2 deletions src-tauri/src/node_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ use anyhow::{anyhow, Error};
use async_trait::async_trait;
use log::info;
use minotari_node_grpc_client::grpc::{
Empty, HeightRequest, NewBlockTemplateRequest, Peer, PowAlgo, SyncState,
BlockHeader, Empty, GetBlocksRequest, HeightRequest, NewBlockTemplateRequest, Peer, PowAlgo,
SyncState,
};
use minotari_node_grpc_client::BaseNodeGrpcClient;
use std::collections::HashMap;
use std::fmt::Write as _;
use std::path::PathBuf;
use tari_core::transactions::tari_amount::MicroMinotari;
use tari_crypto::ristretto::RistrettoPublicKey;
Expand Down Expand Up @@ -98,7 +100,7 @@ impl ProcessAdapter for MinotariNodeAdapter {
self.required_initial_peers
),
"-p".to_string(),
"base_node.grpc_server_allow_methods=\"list_connected_peers\"".to_string(),
"base_node.grpc_server_allow_methods=\"list_connected_peers, get_blocks\"".to_string(),
"-p".to_string(),
"base_node.p2p.allow_test_addresses=true".to_string(),
];
Expand Down Expand Up @@ -328,6 +330,36 @@ impl MinotariNodeStatusMonitor {
Ok(result?)
}

pub async fn get_historical_blocks(
&self,
heights: Vec<u64>,
) -> Result<Vec<(u64, String)>, Error> {
let mut client =
BaseNodeGrpcClient::connect(format!("http://127.0.0.1:{}", self.grpc_port)).await?;

let mut res = client
.get_blocks(GetBlocksRequest { heights })
.await?
.into_inner();

let mut blocks: Vec<(u64, String)> = Vec::new();
while let Some(block) = res.message().await? {
let BlockHeader { height, hash, .. } = block
.block
.clone()
.expect("Failed to get block data")
.header
.expect("Failed to get block header data");
let hash: String = hash.iter().fold(String::new(), |mut acc, x| {
write!(acc, "{:02x}", x).expect("Unable to write");
acc
});

blocks.push((height, hash));
}
Ok(blocks)
}

pub async fn get_identity(&self) -> Result<NodeIdentity, Error> {
let mut client =
BaseNodeGrpcClient::connect(format!("http://127.0.0.1:{}", self.grpc_port)).await?;
Expand Down
Loading

0 comments on commit b057d72

Please sign in to comment.