From 8988ad9c63838bc17eae220a3edbc7b2161c7efb Mon Sep 17 00:00:00 2001
From: Cyrix126 <58007246+Cyrix126@users.noreply.github.com>
Date: Fri, 7 Feb 2025 21:57:45 +0100
Subject: [PATCH] feat: Node: fast mode support

feat: enable fast mode in simple mode if available memory > 4GB
feat: Node tab advanced sublenu add checkbox to enable fast mode
---
 .github/ISSUE_TEMPLATE/roadmap_release.md | 18 +++++++++++++
 kuno.md                                   | 32 ++++++++++++++++++++++
 log                                       |  0
 log.out                                   |  2 ++
 note_difficulty                           | 33 +++++++++++++++++++++++
 src/app/panels/middle/node.rs             |  5 +++-
 src/disk/state.rs                         |  2 ++
 src/disk/tests.rs                         |  1 +
 src/helper/node.rs                        | 11 ++++++++
 src/utils/constants.rs                    |  1 +
 track_hours                               |  6 +++++
 11 files changed, 110 insertions(+), 1 deletion(-)
 create mode 100644 .github/ISSUE_TEMPLATE/roadmap_release.md
 create mode 100644 kuno.md
 create mode 100644 log
 create mode 100644 log.out
 create mode 100644 note_difficulty
 create mode 100644 track_hours

diff --git a/.github/ISSUE_TEMPLATE/roadmap_release.md b/.github/ISSUE_TEMPLATE/roadmap_release.md
new file mode 100644
index 0000000..00ab178
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/roadmap_release.md
@@ -0,0 +1,18 @@
+# TODO v.x.x.x
+
+*description of release, what it focus on etc*
+
+## UI
+### Common
+*changes applied to the entire UI*
+- [ ] changes, issues related
+### Tab
+*changes applied to specific Tab*
+- [ ] changes, issues related
+## Internal
+*changes to backend*
+### Subject if needed
+- [ ] changes, issues related
+## Fixes
+*fixed issues*
+- [ ] description or direct link to issue
diff --git a/kuno.md b/kuno.md
new file mode 100644
index 0000000..9587822
--- /dev/null
+++ b/kuno.md
@@ -0,0 +1,32 @@
+Gupaxx is a maintained fork of Gupax aiming to make monero easy to mine.
+
+https://github.com/Cyrix126/gupaxx
+
+Goal of Gupaxx:
+
+- Easy UI (for beginners, automate as much as possible)
+- Advanced controls available (for advanced users with complex setup)
+- Decentralized (own node possible, use of p2pool, completely custodial)
+- Efficient (best defaults for xmrig, participation in the P2Pool Bonus Hash Rate Raffle by XMRvsBEAST)
+- Informative (stats/history available)
+- Trustless (include only libre code)
+
+
+ROADMAP:
+https://github.com/Cyrix126/gupaxx/issues/68
+
+IDEAS (probably getting into roadmap):
+https://github.com/Cyrix126/gupaxx/blob/main/IDEAS.md
+
+How the funds are used:
+
+Every monero given will be converted to hours of work. When a goal is attained, a new release will occur, including elements present in the roadmap. A release is about 20 hours of work.
+Bug fixing releases will not wait for a new funding goal to be completed.
+
+Each time a goal is completed, a new goal of the same amount will occur to fund the next release.
+Hours of work can also be used to develop/improve a library/program that will be used directly by Gupaxx. 
+
+
+
+Proof of being Cyrix126:
+The address to funding is the same as in the README of the github repository
diff --git a/log b/log
new file mode 100644
index 0000000..e69de29
diff --git a/log.out b/log.out
new file mode 100644
index 0000000..c939664
--- /dev/null
+++ b/log.out
@@ -0,0 +1,2 @@
+   Compiling gupaxx v1.7.2 (/home/lm/git/gupaxx)
+    Finished `dev` profile [unoptimized + debuginfo] target(s) in 5.01s
diff --git a/note_difficulty b/note_difficulty
new file mode 100644
index 0000000..370a846
--- /dev/null
+++ b/note_difficulty
@@ -0,0 +1,33 @@
+The algo needs a precise estimation of hashrate to make a good decision.
+If the proxy HR estimation deviate too much from the real HR, it could for example change the round target.
+
+Proxy will by default only calculate HR with share accepted from the pool, not sent to miners.
+Add --custom-diff-stats to take into account shares accepted from miners.
+
+to have a more precise value of hashrate from the proxy, it should send a lower difficulty or watch a longer timeframe.
+The downside of looking at a longer timeframe is that it will not be able to react swiftly to variation in hashrate if any.
+A too short timeframe could also make a wrong decision.
+
+Algo watch the timeframe the closer to the time of a decision. 10mn for proxy, 15mn for xmrig, 15mn for p2pool.
+
+Current auto difficulty is set to have a share every 30 seconds.
+Proxy can apply difficulty for miners. P2Pool will set the difficulty sent from miners (-u x+diff) 
+
+
+
+
+The downside of reducing difficulty is that more trafic is necessary between miners and proxy, which lower HR (how much ?)
+Reducing the difficulty to get a share every 10 seconds instead of 30 seems to make much more accurate stats. The HR should not be impacted.
+ 
+
+
+Also:
+If a miner switch pool, it will loose the work that it was doing for a share not completed ? The more the difficulty, the longer the time lost ?
+In this case, a lower diff will make 
+
+
+The shorter the timeframe, the more the algo can adapt quicly to a change in hashrate. 
+
+Solution:
+change code source of proxy to set auto diff to lower value
+watch HR and reproduce auto diff with lower value
diff --git a/src/app/panels/middle/node.rs b/src/app/panels/middle/node.rs
index 767f51d..648c330 100644
--- a/src/app/panels/middle/node.rs
+++ b/src/app/panels/middle/node.rs
@@ -20,7 +20,7 @@ use crate::app::panels::middle::common::header_tab::header_tab;
 use crate::app::panels::middle::common::state_edit_field::{path_db_field, slider_state_field};
 use crate::app::panels::middle::{rpc_bind_field, rpc_port_field, zmq_bind_field, zmq_port_field};
 use crate::{
-    NODE_DNS_BLOCKLIST, NODE_DNS_CHECKPOINT, NODE_INPUT, NODE_PRUNNING, NODE_URL,
+    NODE_DNS_BLOCKLIST, NODE_DNS_CHECKPOINT, NODE_FULL_MEM, NODE_INPUT, NODE_PRUNNING, NODE_URL,
     START_OPTIONS_HOVER,
 };
 use egui::TextStyle;
@@ -99,6 +99,9 @@ impl Node {
                         ui.separator();
                         ui.checkbox(&mut self.disable_dns_checkpoint, "DNS checkpoint")
                             .on_hover_text(NODE_DNS_CHECKPOINT);
+                        ui.separator();
+                        ui.checkbox(&mut self.full_memory, "Fast Mode")
+                            .on_hover_text(NODE_FULL_MEM);
                     });
                 });
 
diff --git a/src/disk/state.rs b/src/disk/state.rs
index 04d6fef..69627f0 100644
--- a/src/disk/state.rs
+++ b/src/disk/state.rs
@@ -338,6 +338,7 @@ pub struct Node {
     pub dns_blocklist: bool,
     pub disable_dns_checkpoint: bool,
     pub path_db: String,
+    pub full_memory: bool,
     pub console_height: u32,
 }
 
@@ -357,6 +358,7 @@ impl Default for Node {
             dns_blocklist: true,
             disable_dns_checkpoint: true,
             path_db: String::new(),
+            full_memory: false,
             console_height: APP_DEFAULT_CONSOLE_HEIGHT,
         }
     }
diff --git a/src/disk/tests.rs b/src/disk/tests.rs
index 43c4719..0947af1 100644
--- a/src/disk/tests.rs
+++ b/src/disk/tests.rs
@@ -179,6 +179,7 @@ mod test {
             dns_blocklist = true
             disable_dns_checkpoint = true
             path_db = ""
+            full_memory = false
             console_height = 360
 
 			[version]
diff --git a/src/helper/node.rs b/src/helper/node.rs
index fc464f0..fc1fc5e 100644
--- a/src/helper/node.rs
+++ b/src/helper/node.rs
@@ -28,6 +28,7 @@ use std::{
     thread,
     time::{Duration, Instant},
 };
+use sysinfo::MemoryRefreshKind;
 use tokio::spawn;
 
 use crate::{
@@ -239,6 +240,16 @@ impl Helper {
         debug!("Node | Creating command...");
         let mut cmd = portable_pty::cmdbuilder::CommandBuilder::new(path.clone());
         cmd.args(args);
+        // if in simple state and enough free memory, enable full memory env
+        if state.simple {
+            let mut sys = sysinfo::System::new();
+            sys.refresh_memory_specifics(MemoryRefreshKind::nothing().with_ram());
+            if sys.available_memory() > 4_000_000_000 {
+                cmd.env("MONERO_RANDOMX_FULL_MEM", "1");
+            }
+        } else if state.full_memory {
+            cmd.env("MONERO_RANDOMX_FULL_MEM", "1");
+        }
         cmd.cwd(path.as_path().parent().unwrap());
         // 1c. Create child
         debug!("Node | Creating child...");
diff --git a/src/utils/constants.rs b/src/utils/constants.rs
index 493cfb9..684d836 100644
--- a/src/utils/constants.rs
+++ b/src/utils/constants.rs
@@ -476,6 +476,7 @@ pub const NODE_API_BIND: &str = "bind address of RPC API";
 pub const NODE_API_PORT: &str = "RPC API listen port";
 pub const NODE_ZMQ_BIND: &str = "bind address of ZMQ API";
 pub const NODE_ZMQ_PORT: &str = "ZMQ API listen port";
+pub const NODE_FULL_MEM: &str = "Use 2GB of RAM insteal of 256MB for faster block verification";
 // XMRig
 pub const XMRIG_API_PORT_DEFAULT: u16 = 18088;
 pub const XMRIG_SIMPLE: &str = r#"Use simple XMRig settings:
diff --git a/track_hours b/track_hours
new file mode 100644
index 0000000..c736ed8
--- /dev/null
+++ b/track_hours
@@ -0,0 +1,6 @@
+fix #73 investigate 0.5h
+fix #76 2.5h
+#77 2h
+#78 0.5h
+crawler monero rust lib 4h30
+920287b 10h30