SChernykh / p2pool

Decentralized pool for Monero mining
GNU General Public License v3.0
1.03k stars 123 forks source link

banned for 600 seconds #292

Closed bzhubs closed 4 months ago

bzhubs commented 7 months ago

Hi everyone, does anyone know the cause and how to deal with it?

After a week of observation, I discovered a problem. After a while, p2pool will disable the front-end xmrig-proxy for 10 minutes. What is the reason for this? After being disabled for 10 minutes, it will return to normal.

p2pool log: WARNING 2023-11-17 09:09:25.3223 P2Pool submit_block (external blob): daemon returned error: Block not accepted WARNING 2023-11-17 09:09:56.3888 StratumServer peer MY_XMRIG_PROXY_IP_ADDRESS:50564 banned for 600 seconds

When p2pool disables xmrig-proxy, a large number of the following logs appear in the xmrig-proxy log: [2023-11-17 12:19:53.360] proxy 0323 rejected (34940/7390+56) diff 36583 ip xxxxxxx "Banned" (43 ms) [2023-11-17 12:19:53.503] proxy 0433 rejected (34940/7391+56) diff 422525 ip xxxxxx "Banned" (43 ms) [2023-11-17 12:19:53.514] proxy 0279 rejected (34940/7392+56) diff 90353 ip xxxxxxxx "Banned" (49 ms) [2023-11-17 12:19:53.527] proxy 0038 rejected (34940/7393+56) diff 82049 ip xxxxxxxx "Banned" (43 ms) [2023-11-17 12:19:53.595] proxy 0417 rejected (34940/7394+56) diff 10833 ip xxxxxx "Banned" (44 ms) [2023-11-17 12:19:53.663] proxy 0243 rejected (34940/7395+56) diff 18446 ip xxxxx "Banned" (47 ms) [2023-11-17 12:19:53.801] proxy 0178 rejected (34940/7396+56) diff 44125 ip xxxxx "Banned" (47 ms)

SChernykh commented 7 months ago

Increase log level to 4 in P2Pool to see the reason why it bans your proxy.

bzhubs commented 7 months ago

Ok

SChernykh commented 7 months ago

Any updates on this? Are you running with log level 4, but there have been no bans yet?

bzhubs commented 7 months ago

Sorry, I haven’t replied to you because I have been testing. After two days of testing, the problem pattern was found。

NOTICE 2023-11-19 13:03:27.0470 StratumServer sent new job to 123/123 clients WARNING 2023-11-19 13:03:31.1217 StratumServer client my_xmrig_proxy_ip:37564 invalid JSON request (parse error) WARNING 2023-11-19 13:03:31.1218 StratumServer peer my_xmrig_proxy_ip:37564 banned for 600 seconds

or

NOTICE 2023-11-18 12:03:51.2355 StratumServer sent new job to 123/123 clients WARNING 2023-11-18 12:04:01.6438 StratumServer peer my_xmrig_proxy_ip:52274 banned for 600 seconds

Generally, these two situations occur, with the first situation accounting for the majority.

SChernykh commented 7 months ago
NOTICE 2023-11-18 12:03:51.2355 StratumServer sent new job to 123/123 clients
WARNING 2023-11-18 12:04:01.6438 StratumServer peer my_xmrig_proxy_ip:52274 banned for 600 seconds

Was this one also with log level 4? Because I can't find a place in the code that would ban a connected peer and not write something in the log at least on level 4.

invalid JSON request (parse error)

This means the proxy sent something which is not a valid JSON. Are you using the official xmrig-proxy binary, or is it self-compiled? Is it running in simple or nicehash mode?

bzhubs commented 7 months ago

nohup ./p2pool --host 127.0.0.1 --wallet xxxxxxxxxxxxxxxx --data-api /data/status --loglevel 4 &

This is the command I started with

bzhubs commented 7 months ago

I using the official xmrig-proxy binary, I configured two independent VPS for xmrig-proxy testing, one with nicehash mode and one with simple mode. Same problem. And this problem will occur on both xmrig-proxy at the same time

xrmig-proxy log: [2023-11-19 15:45:45.603] proxy 5108 rejected (2895137/75908+5254) diff 18047 ip xxx "Banned" (52 ms) [2023-11-19 15:45:45.620] proxy 6615 rejected (2895137/75909+5254) diff 85792 ip xxx "Banned" (52 ms) [2023-11-19 15:45:45.676] proxy 7313 rejected (2895137/75910+5254) diff 3507 ip xxx "Banned" (55 ms) ....................

bzhubs commented 7 months ago

No manual intervention is required, both xmrig-proxy will return to normal at the same time. I was suspicious of the firewall, and then I turned off the firewall on all machines, but the problem still exists.

SChernykh commented 7 months ago

Are you able to compile your own p2pool binary? If so, can you change this code https://github.com/SChernykh/p2pool/blob/master/src/stratum_server.cpp#L1133 to this (note the added log line and uncommented size variable):

bool StratumServer::StratumClient::process_request(char* data, uint32_t size)
{
    rapidjson::Document doc;
    if (doc.Parse(data).HasParseError()) {
        LOGWARN(4, "client " << static_cast<char*>(m_addrString) << " invalid JSON request (parse error)");
        LOGWARN(0, log::const_buf(data, std::min<size_t>(size, 900)));
        return false;
    }

It will show what exactly the proxy is trying to send, then I'll know more.

bzhubs commented 7 months ago

Ok, I try

bzhubs commented 7 months ago

I'm afraid this will take some time. I'll get back to you when I have the data. Thank you.

bzhubs commented 7 months ago

I compiled is not a static binary file, but a dynamic binary file.

SChernykh commented 7 months ago

Dynamic binary file will work fine on the same machine. Is it running now?

bzhubs commented 7 months ago

WARNING 2023-11-20 03:20:11.5661 StratumServer client my_xmrig_proxy_ip:34027 invalid JSON request (parse error) WARNING 2023-11-20 03:20:11.5662 StratumServer GET / HTTP/1.1^M WARNING 2023-11-20 03:20:11.5662 StratumServer peer my_xmrig_proxy_ip:34027 banned for 600 seconds

bzhubs commented 7 months ago

There are only such errors in the log, which seem to have no substantial effect.

SChernykh commented 7 months ago

You get an HTTP request instead of a JSON data. And it's not even a valid HTTP request because of an ^M in the end. Either something from that IP address is trying to HTTP probe your P2Pool's Stratum, or it's xmrig-proxy that is misconfigured.

bzhubs commented 7 months ago

{ "access-log-file": "/data/logs/xmrig-proxy.log", "access-password": null, "algo-ext": true, "api": { "id": null, "worker-id": null }, "http": { "enabled": false, "host": "0.0.0.0", "port": 8080, "access-token": "12345678", "restricted": true }, "background": true, "bind": [ { "host": "0.0.0.0", "port": 3333, "tls": true } ], "colors": true, "title": true, "custom-diff": 100000, "custom-diff-stats": false, "donate-level": 0, "log-file": "/data/logs/access.log", "mode": "simple", "pools": [ { "algo": "rx/0", "coin": "Monero", "url": "p2pool_ip:3333", "user": "xxxxxxxxxxxxxxxxxxx.w1", "pass": "x", "rig-id": "w1" "keepalive": true, "enabled": true, "tls": false, "tls-fingerprint": null, "daemon": false } ], "retries": 2, "retry-pause": 1, "reuse-timeout": 0, "tls": { "enabled": true, "protocols": null, "cert": "/data/xmrig-proxy/cert.pem", "cert_key": "/data/xmrig-proxy/cert_key.pem", "ciphers": null, "ciphersuites": null, "dhparam": null }, "user-agent": "XMRig/6.18.2 (Linux x86_64) libuv/1.42.1-dev gcc/7.2.0", "syslog": false, "verbose": false, "watch": true, "workers": true

}

If the configuration is wrong, it should always be wrong or unable to start, but it will automatically recover after a problem occurs.

bzhubs commented 7 months ago

There is no software or tool to configure detection

SChernykh commented 7 months ago

I configured two independent VPS for xmrig-proxy testing

It might be the VPS provider probing your ports. The only way to check if it's an xmrig-proxy problem, is to run it on the same host (proxy and p2pool) and then look for invalid JSON request (parse error) warnings. If they don't appear anymore, it's something external interfering.

SChernykh commented 6 months ago

@bzhubs Did you figure it out?