BitMaker-hub / NerdMiner_v2

Improved version of first ESP32 NerdMiner
Other
1.38k stars 252 forks source link

Password is hardcoded #219

Open PSLLSP opened 8 months ago

PSLLSP commented 8 months ago

Password is hardcoded to x. That is good default but advanced user should be able to configure password. For example, zergpool uses password to define mining parameters, like miner ID, mined coin, etc. Other pools use password to define WorkerID. So, there are cases where user want to configure password...

I see that password is hardcoded, file src/mining.cpp

      strcpy(mWorker.wName, Settings.BtcWallet);
      strcpy(mWorker.wPass, "x");

It means that new field has to be added to WiFi configuration form, to JSON configuration and to structure "Settings"...

BitMaker-hub commented 8 months ago

Hi, yes that was considered for new updates. Today not really needed because current supported mmining pools doesn't need

PSLLSP commented 8 months ago

Today not really needed because current supported mining pools doesn't need it

This is a wrong assumption... Default password "x" is a good option but don't hardcode it and allow users to define their own password, it should be configurable. I assume you believe that the only pool with support for NerdMiner is public-pool.io. Please, do not limit NerdMiner design to this limitation...

BitMaker-hub commented 7 months ago

YOu can setup password on new update

PSLLSP commented 7 months ago

I test firmware 1.6.3 with T-Display and I cannot confirm that this was fixed. Please, reopen the issue... I updated firmware with WebFlasher

1) I cannot see new field in WiFiManager, field for Pool Password (http://192.168.4.1/wifi, http://192.168.4.1/param) 2) I tried to configure password with "curl" and doesn't take visible effect, I cannot see in the "test" pool that NerdMiner sends password

I am going to update "curl script" in issue #218 with PoolPassword field...

Firmware v1.6.3 increases hashrate from about 55 kHps to about 78 kHps, that is COOL!!


UPDATE. There is a bug in code related to password. That code was never tested. This is a fix:

diff --git a/src/wManager.cpp b/src/wManager.cpp
index 6b7e98f..c861a89 100644
--- a/src/wManager.cpp
+++ b/src/wManager.cpp
@@ -151,7 +151,7 @@ void init_WifiManager()
   }
   WiFiManagerParameter save_stats_to_nvs("SaveStatsToNVS", "Track Uptime, Best Diff, Total Hashes in device Flash memory. (Experimental)", "T", 2, checkboxParams, WFM_LABEL_AFTER);
   // Text box (String) - 80 characters maximum
-  WiFiManagerParameter password_text_box("Poolpassword - Optionl", "Pool password", Settings.PoolPassword, 80);
+  WiFiManagerParameter password_text_box("Poolpassword", "Pool password - optional", Settings.PoolPassword, 80);

   // Add all defined parameters
   wm.addParameter(&pool_text_box);
PSLLSP commented 7 months ago

Configuration to test mining with "advanced" password. NerdMiner will mine CHTA in solo mode and there is a small change that block could be found, because this coin has low hashrate and could be mined with cpuminer or Android phone...

Mining status, status shows NerdMiner version, password; good pool for troubleshooting stratum protocol...

{
  "SSID": "myNerdAP",
  "WifiPW": "mySECRET",
  "PoolUrl": "bowserlab.ddns.net",
  "PoolPort": 3333,
  "PoolPassword": "c=CHTA,m=solo,d=1",
  "BtcWallet": "CSZfdb1ZPWT746iYkwtubLqStK1n5pL6k8.TEST",
  "Timezone": 0,
  "SaveStats": false
}

The same config for cpuminer:

#!/bin/sh

# https://bowserlab.ddns.net:8080/
# https://bowserlab.ddns.net:8080/?address=CSZfdb1ZPWT746iYkwtubLqStK1n5pL6k8
# https://bowserlab.ddns.net:8080/api/walletEx?address=CSZfdb1ZPWT746iYkwtubLqStK1n5pL6k8

WORKER="TEST-CPU"
WALLET="CSZfdb1ZPWT746iYkwtubLqStK1n5pL6k8"

POOL="stratum+tcp://bowserlab.ddns.net:3333"
USER="$WALLET.$WORKER"
PASS="c=CHTA,m=solo,d=1"

OPTS="-t1"

cat <<EOF
REST API status https://bowserlab.ddns.net:8080/api/walletEx?address=$WALLET
$(curl -s "https://bowserlab.ddns.net:8080/api/walletEx?address=$WALLET")
---
EOF

./minerd --version
./minerd -a sha256d -o "$POOL" -u "$USER" -p "$PASS" $OPTS "$@"

Configuration for BTC, change BTC address... status

{
  "SSID": "myNerdAP",
  "WifiPW": "mySECRET",
  "PoolUrl": "bowserlab.ddns.net",
  "PoolPort": 3333,
  "PoolPassword": "c=BTC,m=solo,d=1",
  "BtcWallet": "1PKN98VN2z5gwSGZvGKS2bj8aADZBkyhkZ.TEST",
  "Timezone": 0,
  "SaveStats": false
}
BitMaker-hub commented 7 months ago

Hi, I reopened issue and I'll investigate soon. There are some fixes to add and I'll include this in next update. Let me some days & I'll solve it

Cr4zyT1zy commented 4 months ago

I suggest this pool which works with nerdminer and SHA256. https://unmineable.com/coins/BCH?algorithm=sha256 you can midify BCH with any crypto with SHA256 protocol.

PSLLSP commented 4 months ago

I suggest this pool which works with nerdminer and SHA256. https://unmineable.com/coins/BCH?algorithm=sha256 you can midify BCH with any crypto with SHA256 protocol.

I like unmineable pool. Unfortunately, I do not think it is good idea to mine in unmineable with NerdMiner. NerdMiner has really low has rate, it cannot compete with high end ASIC miners. Nerdminer is lottery miner, there is a believe it can find a block in solo mining mode. It is highly rare event but the probability of such event is not zero, so it is possible, at least in theory. It is game with rule "all or nothing".

Unmineable pool doesn't support mining in solo mode, that is the important point why I think it is not good idea to connect NerdMiner to unmineable pool. If you want really to mine in unmineable, set payout to LTC wallet, that coin has very low payout limit, just 0.00075 LTC. LTC is supported by many wallets, it has low payout limit at unmineable, low fees, it is well known coin, good coin to start your crypto experiments... ;-) LTC is good cryptocurrency for your referral fees, advantage is that payout limit is low, that is the key point... Maybe you have powerful PC with Ryzen CPU. Try to mine algo RandomX in unmineable pool, set payout to LTC wallet. Once you verify that your setup works (you will receive LTC to your wallet), you can try to experiment with other coins, just change payout wallet... Be aware that CPU is power hungry and you likely will only lose money in the mining process because you have to pay for electricity (I have to pay for electricity and it is expensive commodity these days...).

I tried calculation, NerdMiner has hashrate about 75 kHps. The lowest unit that Unmineable has in the calculator for sha256 algo is GHps and I assume that 75 kHps is 0.000075 GHps (is this correct?). When I use 0.000075 GHps in the calculator, I see that such miner will earn NOTHING. There is no point to connect NerdMiner to unmineable pool...

Cr4zyT1zy commented 4 months ago

In fact I believe that mining with Nerdminer is just an experiment. The possibility of him mining a BTC block is impossible so he sits on it for 24 hours with no result. On Unmineable currency BCH I received 0.00000085 in these 20 hours.

So we can actually see it in action. For those who want to try I also leave my reference code m0h9-own4 Thank you and good day :) I think I'll try to extract LTC, experiment in progress ...

PSLLSP commented 4 months ago

On Unmineable currency BCH I received 0.00000085 in these 20 hours.

OK. Minimal payout for BCH is set to 0.025 BCH by Unmineable pool. You earned 0.00000085 BCH in 20 hours. You will need 0.025 / 0.00000085 such sessions and that is about 35294 days, only 96 years... ;-) Do you see the point? You can connect 100 NerdMiners, then you will mine 0.025 BCH in a year and you can ask for payout... Try to mine LTC (Litecoin), it is easier to reach payout limit, I believe it is good advice but I do not think it is smart idea to connect NerdMiner to Unmineable pool...

Cr4zyT1zy commented 4 months ago

Yes, in fact I connected it to this pool only because I wanted to see it work and certainly not to earn money from it. As Doc Brown said in Back to the Future: It's a science experiment. Have a nice day. :)

PS. I use Nerdminer 1.6.3 but I can't change the password field so I can't access any pools. I tried Zergpool, bowserlab.ddns.net and others but I can see the miner but from console I get errors. As soon as it is possible to change the password field from the configuration I will do further experiments on other pools more suited to Nerdminer.

PSLLSP commented 4 months ago

I love experiments... ;-) I agree that NerdMiner is an interesting experiment... And I think you still do not understand how unmineable works. The payout limit of the pool is important...

Current price for BCH is about 303.65 USD. Payout limit is 0.025 BCH, it is about 7.59 USD. Current price for LTC is about 74.96 USD. Payout limit is 0.00075 LTC, it is about 0.06 USD, just 6 cents!

You can ask for payout 127x (7.59 / 0.06) sooner when you mine LTC than when you mine BCH.

You earned 0.00000085 BCH in 20 hours, that is about 0.000258 USD and you need to mine for 96 years to reach payout limit. You can earn about 0.0000034 LTC in 20 hours (an estimate), that is about 0.000254864 USD and reach payout limit in "just" 217 days; after 217 days you can ask for payout of 6 cents (based on current LTC price).

Or you can just mine in solo mode and risk that you will earn nothing (you will loose on hardware cost and electricity) or find a block that is worth of several thousand of dollars... NerdMiner is like a lottery ticket; you pay for it and you hope that you will win the main price. In the case you do not win, you loose your bet...

And yes, I would like to know a BCH pool that is friendly to NerdMiner, that allows to mine with such small device in SOLO mode. One such pool is zergpool but that pool requires that an extra parameters are passed in the password field and that is not possible with the current firmware because the password is hardcoded to x. That was the point to open this issue...

Until the issue with the password field is fixed, you can try to run your own pool based on ckpool project, you can create a mining proxy and forward your miners to any compatible pool. Or run your own full node and try solo mining on your own. Hint for a cool experiment! ;-) I am just not sure how well that pool works with other coins, it was designed and tested with BTC and documentation is a weak point of that project...


UPDATE:

NANO (XNO) is another coin that could be mined with low power miner at UnMineable pool. XNO has even lower payout limit than LTC:

0.025 BCH: about 9.875 USD 0.00075 LTC: about 0.06391125 USD 0.001 XNO: about 0.0064065 USD

NANO is an interesting coin, there are no fees and that is why payout limit could be so low. NANO is fast, transactions are executed in just few seconds.

Mining with hashrate 5 GHps (SHA256d algo), miner can earn about 0.0002858 XNO daily, it means it can ask for payout in a week...

XNO could be swapped to BAN (Bannano) at NanSwap. Banano is a fork of NANO and it is another fun project with strong community. BAN could be mined with any PC, Banano miner is a way to be paid for participation in project Folding@Home. Banano miner running at PC could earn much more than NerdMiner connected to UnMineable pool.

IMPORTANT!

There is another issue when mining NANO with NerdMiner at UnMineable. NANO address is long, it is has 65 characters, username for UnMineable miner is XNO:wallet_address.WORKER#REF and that can be longer than 80 characters those are allocated for username buffer by NerdMiner and it means, that username could be trimmed at position 80. Workarround is to not use WORKER, username should be just XNO:wallet_address#REF

sany3001 commented 4 months ago

I like this conversation guys, thanks for that!

PSLLSP commented 4 months ago

I am on a business trip and I do not have any NerdMiner with me. I have a notebook and I tried to configure my notebook to mine sha256d in unmineable pool, I have hashrate about 8000 kHps (it is faster than 100 NerdMiners!), I use pooler CPU miner. I mine for more than 12 hours and I earned nothing (I am not surprised), I have not found any accepted share during this time period. Based on this experiment, I assume that NerdMiner that earned some BCH during 20 hours session was extremely lucky and that is not a repeatable result. Try to run NerdMiner connected to unmineable for a week, check the result, do a math and update this issue with your observation. I guess you will find that you need more time than those 96 years to reach payout limit for BCH...

This is my config for CPU miner (Linux):

$ cat mine-sha256-LTC-UM.sh
#!/bin/sh

WALLET="LTC:FIXME"  # replace FIXME with your LTC wallet
WORKER="TEST1"
REF="wvqn-jf6a"  # replace with your favorite REF code or leave empty, REF code decreases pool fee from 1.00% to 0.75%

POOL="stratum+tcp://sha256.unmineable.com:3333"
USER="$WALLET"
[ -n "$WORKER" ] && USER="$USER.$WORKER"
[ -n "$REF" ] && USER="$USER#$REF"
PASS="x"

OPTS="-t1"

./minerd --version
./minerd -a sha256d -o "$POOL" -u "$USER" -p "$PASS" $OPTS "$@"

Run it:

$ sh mine-sha256-LTC-UM.sh
cpuminer 2.5.1
 built on Jun 25 2020
 features: x86_64 PHE SSE2 AVX AVX2 XOP
libcurl/7.71.0 mbedTLS/2.16.6 zlib/1.2.11
[2024-02-29 11:57:28] 1 miner threads started, using 'sha256d' algorithm.
[2024-02-29 11:57:28] Starting Stratum on stratum+tcp://sha256.unmineable.com:3333
[2024-02-29 11:57:29] Stratum requested work restart
[2024-02-29 11:57:30] thread 0: 2097152 hashes, 10674 khash/s
[2024-02-29 11:58:06] Stratum requested work restart
[2024-02-29 11:58:06] thread 0: 361584688 hashes, 9838 khash/s
[2024-02-29 11:59:08] thread 0: 590303544 hashes, 9512 khash/s
PSLLSP commented 4 months ago

I tried to mine with my NerdMiner in UnMineable pool and I can replicate it, my NerdMiner mines at 5 GHps... ;-) I assume there is a bug in the pool software

UnMineable pool sets difficulty to 16384:

  Received message from pool
  Receiving: {"id": null, "method": "mining.set_difficulty", "params": [16384]}
    Parsing Method [SET DIFFICULTY]
    difficulty: 16384.000000000000

Then pool sends a "job" and just a second later pool updates difficulty, it changes it to 0:

  Received message from pool
  Receiving: {"id": null, "method": "mining.set_difficulty", "params": [0]}
    Parsing Method [SET DIFFICULTY]
    difficulty: 0.000000000000

At this point NerdMiner sends solution...

   - Current diff share: 0.000017076509
   - Current pool diff : 0.000000000000
   - TX SHARE: c731e410d6b0fd4ed791e498d0dee6b9e3c3442102440007fbff0e16bfe40000
>>> Completed 0 share(s), 1974 Khashes, avg. hashrate 73.09 KH/s

And the solution with very low difficulty is accepted by the pool...

Maybe it is not a bug but a design, that some smart fox at UnMineable realized that it is better for them to pay just few cents a year to NerdMiner device. In the case that such NerdMiner device finds a block, the pool will earn a lot of money but miner will receive always only few cents...


Other explanation is that there is a bug at pool stratum code. NerdMiner suggests difficulty 0.0001 and pool replies with "set difficulty to 0", like they do not expect that difficulty could be a floating point number and round 0.0001 to 0; their stratum just works with integers (a bug).

When cpuminer receives request to set difficulty to 0, it ignores it. NerdMiner is happy with value 0 and starts to send frequently results with very low difficulty, this could be a bug in NerdMiner code...

cpuminer ignores difficulty with value 0 (it can be seen in file util.c):

static bool stratum_set_difficulty(struct stratum_ctx *sctx, json_t *params)
{
        double diff; 
        diff = json_number_value(json_array_get(params, 0)); 
        if (diff == 0) 
                return false; 
       // set new difficulty
       ...
Cr4zyT1zy commented 4 months ago

Thanks for your technical explanation.

PSLLSP commented 4 months ago

Issue #352 created, it is about short username, I found that issue when I experiment with NANO at pool unMineable, see comment above for details.

Password field is hardcoded to "x" but other issue is that length of pool password field in code v1.6.3 is limited to 20 characters (19 in real, the last byte should be \0). 20 characters is too short, password field should be at least 100, 128 or even 256 characters...