Skip to content

Commit

Permalink
merge and fix pubkey
Browse files Browse the repository at this point in the history
  • Loading branch information
shanimal08 committed Nov 5, 2024
2 parents e9788e1 + f116ae1 commit f4d2feb
Show file tree
Hide file tree
Showing 25 changed files with 1,079 additions and 219 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ jobs:
libprotobuf-dev \
protobuf-compiler
- name: install dependencies (linux/OpenCL)
run: |
sudo apt-get install --no-install-recommends --assume-yes \
opencl-headers \
ocl-icd-opencl-dev
- name: Node.js setup
uses: actions/setup-node@v4
with:
Expand All @@ -235,6 +241,6 @@ jobs:
- name: cargo tauri build
working-directory: ./src-tauri
run: |
cargo install tauri-cli --version "1.6.2"
cargo install tauri-cli --version "1.6.4"
cargo tauri --version
cargo tauri build --ci --bundles deb
13 changes: 13 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ jobs:
libprotobuf-dev \
protobuf-compiler
- name: Install dependencies (linux/OpenCL)
if: startsWith(runner.os,'Linux')
run: |
sudo apt-get install --no-install-recommends --assume-yes \
opencl-headers \
ocl-icd-opencl-dev
- name: Install dependencies (macOS)
if: startsWith(runner.os,'macOS')
run: |
Expand All @@ -167,11 +174,17 @@ jobs:
vcpkg.exe install sqlite3:x64-windows zlib:x64-windows
choco upgrade protoc -y
- name: Install dependencies (windows/OpenCL)
if: startsWith(runner.os,'Windows')
run: |
vcpkg.exe --triplet=x64-windows install opencl
- name: Set environment variables (windows)
if: startsWith(runner.os,'Windows')
shell: bash
run: |
echo "SQLITE3_LIB_DIR=C:\vcpkg\installed\x64-windows\lib" >> $GITHUB_ENV
echo "LIB=C:\vcpkg\installed\x64-windows\lib" >> $GITHUB_ENV
- name: Azure code-signing setup (windows only)
if: ${{ ( startsWith(runner.os,'Windows') ) && ( env.AZURE_TENANT_ID != '' ) }}
Expand Down
534 changes: 349 additions & 185 deletions public/assets/glApp.js

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions public/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
"connected-to-tari": "Connected to the Tari Network",
"control-port": "Control Port",
"cpu-mining-enabled": "CPU Mining",
"custom-power-levels": {
"title": "Custom Mode",
"warning": "Warning",
"saved": "Changes saved!",
"gpu-power-level": "GPU Power %",
"cpu-power-level": "CPU Cores",
"choose-gpu-power-level": "Choose how many threads you want your GPU to allocat to mining",
"choose-cpu-power-level": "Choose how many cores from your CPU to be allocated to mining",
"cpu-warning": "High CPU usage can cause overheating, increase energy consumption, and may lead to hardware damage over time. Please monitor usage to ensure safe and efficient operation.",
"gpu-warning": "High GPU usage can cause overheating, increase energy consumption, and may lead to hardware damage over time. Please monitor usage to ensure safe and efficient operation."
},
"debug-info": "Debug",
"disconnect": "Disconnect from Airdrop",
"errors": {
Expand Down
31 changes: 31 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ blake2 = "0.10"
chrono = "0.4.38"
device_query = "2.1.0"
dunce = "1.0.5"
opencl3 = "0.9.5"
flate2 = "1.0.30"
futures-lite = "2.3.0"
futures-util = "0.3.30"
Expand Down
84 changes: 83 additions & 1 deletion src-tauri/src/app_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,19 @@ pub struct AppConfigFromFile {
ludicrous_mode_cpu_threads: Option<isize>,
eco_mode_cpu_options: Vec<String>,
ludicrous_mode_cpu_options: Vec<String>,
custom_mode_cpu_options: Vec<String>,
#[serde(default = "default_false")]
mmproxy_use_monero_fail: bool,
#[serde(default = "default_monero_nodes")]
mmproxy_monero_nodes: Vec<String>,
#[serde(default = "default_custom_max_cpu_usage")]
custom_max_cpu_usage: Option<isize>,
#[serde(default = "default_custom_max_gpu_usage")]
custom_max_gpu_usage: Option<isize>,
#[serde(default = "default_true")]
auto_update: bool,
#[serde(default = "default_false")]
custom_power_levels_enabled: bool,
}

impl Default for AppConfigFromFile {
Expand All @@ -85,17 +92,21 @@ impl Default for AppConfigFromFile {
should_always_use_system_language: false,
should_auto_launch: false,
application_language: default_application_language(),
custom_max_cpu_usage: None,
custom_max_gpu_usage: None,
airdrop_ui_enabled: true,
paper_wallet_enabled: false,
use_tor: true,
eco_mode_cpu_options: Vec::new(),
ludicrous_mode_cpu_options: Vec::new(),
custom_mode_cpu_options: Vec::new(),
eco_mode_cpu_threads: None,
ludicrous_mode_cpu_threads: None,
mmproxy_monero_nodes: vec!["https://xmr-01.tari.com".to_string()],
mmproxy_use_monero_fail: false,
auto_update: true,
reset_earnings: false,
custom_power_levels_enabled: false,
}
}
}
Expand Down Expand Up @@ -130,13 +141,15 @@ impl DisplayMode {
pub enum MiningMode {
Eco,
Ludicrous,
Custom,
}

impl MiningMode {
pub fn from_str(s: &str) -> Option<MiningMode> {
match s {
"Eco" => Some(MiningMode::Eco),
"Ludicrous" => Some(MiningMode::Ludicrous),
"Custom" => Some(MiningMode::Custom),
_ => None,
}
}
Expand All @@ -145,6 +158,7 @@ impl MiningMode {
match m {
MiningMode::Eco => String::from("Eco"),
MiningMode::Ludicrous => String::from("Ludicrous"),
MiningMode::Custom => String::from("Custom"),
}
}
}
Expand Down Expand Up @@ -177,9 +191,13 @@ pub(crate) struct AppConfig {
ludicrous_mode_cpu_threads: Option<isize>,
eco_mode_cpu_options: Vec<String>,
ludicrous_mode_cpu_options: Vec<String>,
custom_mode_cpu_options: Vec<String>,
mmproxy_use_monero_fail: bool,
mmproxy_monero_nodes: Vec<String>,
custom_max_cpu_usage: Option<isize>,
custom_max_gpu_usage: Option<isize>,
auto_update: bool,
custom_power_levels_enabled: bool,
}

impl AppConfig {
Expand All @@ -204,14 +222,18 @@ impl AppConfig {
application_language: default_application_language(),
airdrop_ui_enabled: true,
use_tor: true,
custom_max_cpu_usage: None,
custom_max_gpu_usage: None,
paper_wallet_enabled: false,
reset_earnings: false,
eco_mode_cpu_options: Vec::new(),
ludicrous_mode_cpu_options: Vec::new(),
custom_mode_cpu_options: Vec::new(),
eco_mode_cpu_threads: None,
ludicrous_mode_cpu_threads: None,
mmproxy_use_monero_fail: false,
mmproxy_monero_nodes: vec!["https://xmr-01.tari.com".to_string()],
custom_power_levels_enabled: false,
auto_update: true,
}
}
Expand Down Expand Up @@ -263,9 +285,14 @@ impl AppConfig {
self.eco_mode_cpu_threads = config.eco_mode_cpu_threads;
self.ludicrous_mode_cpu_options = config.ludicrous_mode_cpu_options;
self.ludicrous_mode_cpu_threads = config.ludicrous_mode_cpu_threads;
self.custom_mode_cpu_options = config.custom_mode_cpu_options;
self.mmproxy_monero_nodes = config.mmproxy_monero_nodes;
self.mmproxy_use_monero_fail = config.mmproxy_use_monero_fail;
self.custom_max_cpu_usage = config.custom_max_cpu_usage;
self.custom_max_gpu_usage = config.custom_max_gpu_usage;
self.auto_update = config.auto_update;
self.reset_earnings = config.reset_earnings;
self.custom_power_levels_enabled = config.custom_power_levels_enabled;
if Network::get_current_or_user_setting_or_default() == Network::Esmeralda {
self.reset_earnings = config.reset_earnings;
} else {
Expand Down Expand Up @@ -313,6 +340,11 @@ impl AppConfig {
pub fn ludicrous_mode_cpu_options(&self) -> &Vec<String> {
&self.ludicrous_mode_cpu_options
}

pub fn custom_mode_cpu_options(&self) -> &Vec<String> {
&self.custom_mode_cpu_options
}

pub fn eco_mode_cpu_threads(&self) -> Option<isize> {
self.eco_mode_cpu_threads
}
Expand All @@ -325,14 +357,26 @@ impl AppConfig {
&self.anon_id
}

pub async fn set_mode(&mut self, mode: String) -> Result<(), anyhow::Error> {
pub async fn set_mode(
&mut self,
mode: String,
custom_max_cpu_usage: Option<isize>,
custom_max_gpu_usage: Option<isize>,
) -> Result<(), anyhow::Error> {
let new_mode = match mode.as_str() {
"Eco" => MiningMode::Eco,
"Ludicrous" => MiningMode::Ludicrous,
"Custom" => MiningMode::Custom,
_ => return Err(anyhow!("Invalid mode")),
};
self.mode = new_mode;
self.update_config_file().await?;
if let Some(custom_max_cpu_usage) = custom_max_cpu_usage {
self.set_max_cpu_usage(custom_max_cpu_usage).await?;
}
if let Some(custom_max_gpu_usage) = custom_max_gpu_usage {
self.set_max_gpu_usage(custom_max_gpu_usage).await?;
}
Ok(())
}
pub async fn set_display_mode(&mut self, display_mode: String) -> Result<(), anyhow::Error> {
Expand All @@ -351,6 +395,32 @@ impl AppConfig {
self.mode
}

pub fn custom_gpu_usage(&self) -> Option<isize> {
self.custom_max_cpu_usage
}

pub async fn set_max_gpu_usage(
&mut self,
custom_max_gpu_usage: isize,
) -> Result<(), anyhow::Error> {
self.custom_max_gpu_usage = Some(custom_max_gpu_usage);
self.update_config_file().await?;
Ok(())
}

pub fn custom_cpu_usage(&self) -> Option<isize> {
self.custom_max_cpu_usage
}

pub async fn set_max_cpu_usage(
&mut self,
custom_max_cpu_usage: isize,
) -> Result<(), anyhow::Error> {
self.custom_max_cpu_usage = Some(custom_max_cpu_usage);
self.update_config_file().await?;
Ok(())
}

pub async fn set_cpu_mining_enabled(&mut self, enabled: bool) -> Result<bool, anyhow::Error> {
self.cpu_mining_enabled = enabled;
self.update_config_file().await?;
Expand Down Expand Up @@ -538,15 +608,19 @@ impl AppConfig {
application_language: self.application_language.clone(),
airdrop_ui_enabled: self.airdrop_ui_enabled,
paper_wallet_enabled: self.paper_wallet_enabled,
custom_max_cpu_usage: self.custom_max_cpu_usage,
custom_max_gpu_usage: self.custom_max_gpu_usage,
use_tor: self.use_tor,
reset_earnings: self.reset_earnings,
eco_mode_cpu_options: self.eco_mode_cpu_options.clone(),
ludicrous_mode_cpu_options: self.ludicrous_mode_cpu_options.clone(),
custom_mode_cpu_options: self.custom_mode_cpu_options.clone(),
eco_mode_cpu_threads: self.eco_mode_cpu_threads,
ludicrous_mode_cpu_threads: self.ludicrous_mode_cpu_threads,
mmproxy_monero_nodes: self.mmproxy_monero_nodes.clone(),
mmproxy_use_monero_fail: self.mmproxy_use_monero_fail,
auto_update: self.auto_update,
custom_power_levels_enabled: self.custom_power_levels_enabled,
};
let config = serde_json::to_string(config)?;
debug!(target: LOG_TARGET, "Updating config file: {:?} {:?}", file, self.clone());
Expand All @@ -560,6 +634,14 @@ fn default_version() -> u32 {
10
}

fn default_custom_max_cpu_usage() -> Option<isize> {
None
}

fn default_custom_max_gpu_usage() -> Option<isize> {
None
}

fn default_mode() -> String {
"Eco".to_string()
}
Expand Down
15 changes: 11 additions & 4 deletions src-tauri/src/cpu_miner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use tokio::sync::RwLock;

const RANDOMX_BLOCKS_PER_DAY: u64 = 360;
const LOG_TARGET: &str = "tari::universe::cpu_miner";
const ECO_MODE_CPU_USAGE: isize = 30;

pub(crate) struct CpuMiner {
watcher: Arc<RwLock<ProcessWatcher<XmrigAdapter>>>,
Expand All @@ -38,6 +39,7 @@ impl CpuMiner {
config_path: PathBuf,
log_dir: PathBuf,
mode: MiningMode,
custom_max_cpu_usage: Option<isize>,
) -> Result<(), anyhow::Error> {
let mut lock = self.watcher.write().await;

Expand All @@ -62,11 +64,15 @@ impl CpuMiner {
1
}
};

let eco_mode_isize = cpu_miner_config
.eco_mode_cpu_percentage
.unwrap_or((ECO_MODE_CPU_USAGE * max_cpu_available) / 100isize);

let cpu_max_percentage = match mode {
MiningMode::Eco => cpu_miner_config
.eco_mode_cpu_percentage
.unwrap_or((30 * max_cpu_available) / 100isize),
MiningMode::Ludicrous => cpu_miner_config.ludicrous_mode_cpu_percentage.unwrap_or(-1), // Use all
MiningMode::Eco => eco_mode_isize,
MiningMode::Custom => custom_max_cpu_usage.unwrap_or(eco_mode_isize),
MiningMode::Ludicrous => -1, // Use all
};

lock.adapter.node_connection = Some(xmrig_node_connection);
Expand All @@ -75,6 +81,7 @@ impl CpuMiner {
lock.adapter.extra_options = match mode {
MiningMode::Eco => cpu_miner_config.eco_mode_xmrig_options.clone(),
MiningMode::Ludicrous => cpu_miner_config.ludicrous_mode_xmrig_options.clone(),
MiningMode::Custom => cpu_miner_config.custom_mode_xmrig_options.clone(),
};

lock.start(
Expand Down
Loading

0 comments on commit f4d2feb

Please sign in to comment.