Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
xmrig committed Feb 9, 2019
2 parents 33c1811 + 463aa30 commit 25b8553
Show file tree
Hide file tree
Showing 17 changed files with 127 additions and 50 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,6 @@
# v2.11.0
- [#928](https://github.com/xmrig/xmrig/issues/928) Added support for new algorithm `cryptonight/gpu`, short alias `cn/gpu` (original name `cryptonight-gpu`), for upcoming [Ryo currency](https://ryo-currency.com) fork on February 14.

# v2.10.0
- [#904](https://github.com/xmrig/xmrig/issues/904) Added new algorithm `cn-pico/trtl` (aliases `cryptonight-turtle`, `cn-trtl`) for upcoming TurtleCoin (TRTL) fork.

Expand Down
1 change: 1 addition & 0 deletions doc/STRATUM_EXT.md
Expand Up @@ -95,6 +95,7 @@ Both miner and pool should support short algorithm name aliases:
| `cryptonight/xao` | `cn/xao` | `"xao"` | Alloy (XAO) |
| `cryptonight/rto` | `cn/rto` | `"rto"` | Arto (RTO) |
| `cryptonight/half` | `cn/half` | `"half"` | CryptoNight variant 2 with half iterations. |
| `cryptonight/gpu` | `cn/gpu` | `"gpu"` | CryptoNight-GPU (RYO). |
| `cryptonight-lite` | `cn-lite` | `-1` | Autodetect works only for Aeon. |
| `cryptonight-lite/0` | `cn-lite/0` | `0` | Original/old CryptoNight-Lite. |
| `cryptonight-lite/1` | `cn-lite/1` | `1` | Also known as `aeon7` |
Expand Down
19 changes: 17 additions & 2 deletions src/common/cpu/BasicCpuInfo.cpp
Expand Up @@ -4,8 +4,9 @@
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -35,6 +36,10 @@
# define bit_AES (1 << 25)
#endif

#ifndef bit_AVX2
# define bit_AVX2 (1 << 5)
#endif


#include "common/cpu/BasicCpuInfo.h"

Expand Down Expand Up @@ -93,9 +98,19 @@ static inline bool has_aes_ni()
}


static inline bool has_avx2()
{
int32_t cpu_info[4] = { 0 };
cpuid(EXTENDED_FEATURES, cpu_info);

return (cpu_info[EBX_Reg] & bit_AVX2) != 0;
}


xmrig::BasicCpuInfo::BasicCpuInfo() :
m_assembly(ASM_NONE),
m_aes(has_aes_ni()),
m_avx2(has_avx2()),
m_brand(),
m_threads(std::thread::hardware_concurrency())
{
Expand Down
7 changes: 5 additions & 2 deletions src/common/cpu/BasicCpuInfo.h
Expand Up @@ -4,8 +4,9 @@
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -41,6 +42,7 @@ class BasicCpuInfo : public ICpuInfo

inline Assembly assembly() const override { return m_assembly; }
inline bool hasAES() const override { return m_aes; }
inline bool hasAVX2() const override { return m_avx2; }
inline bool isSupported() const override { return true; }
inline const char *brand() const override { return m_brand; }
inline int32_t cores() const override { return -1; }
Expand All @@ -59,6 +61,7 @@ class BasicCpuInfo : public ICpuInfo
private:
Assembly m_assembly;
bool m_aes;
bool m_avx2;
char m_brand[64];
int32_t m_threads;
};
Expand Down
19 changes: 15 additions & 4 deletions src/common/cpu/BasicCpuInfo_arm.cpp
Expand Up @@ -4,8 +4,9 @@
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -24,19 +25,29 @@
#include <string.h>
#include <thread>

#if __ARM_FEATURE_CRYPTO
# include <sys/auxv.h>
# include <asm/hwcap.h>
#endif


#include "common/cpu/BasicCpuInfo.h"


xmrig::BasicCpuInfo::BasicCpuInfo() :
m_aes(false),
m_avx2(false),
m_brand(),
m_threads(std::thread::hardware_concurrency())
{
memcpy(m_brand, "Unknown", 7);
# ifdef XMRIG_ARMv8
memcpy(m_brand, "ARMv8", 5);
# else
memcpy(m_brand, "ARMv7", 5);
# endif

# if __ARM_FEATURE_CRYPTO
m_aes = true;
m_aes = getauxval(AT_HWCAP) & HWCAP_AES;
# endif
}

Expand Down
12 changes: 10 additions & 2 deletions src/common/crypto/Algorithm.cpp
Expand Up @@ -86,6 +86,10 @@ static AlgoData const algorithms[] = {
{ "cryptonight-ultralite", "cn-ultralite", xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL },
{ "cryptonight_turtle", "cn_turtle", xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL },
# endif

# ifndef XMRIG_NO_CN_GPU
{ "cryptonight/gpu", "cn/gpu", xmrig::CRYPTONIGHT, xmrig::VARIANT_GPU },
# endif
};


Expand All @@ -102,9 +106,12 @@ static AlgoData const xmrStakAlgorithms[] = {
{ "cryptonight_heavy", nullptr, xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_0 },
{ "cryptonight_haven", nullptr, xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_XHV },
{ "cryptonight_masari", nullptr, xmrig::CRYPTONIGHT, xmrig::VARIANT_MSR },
{ "cryptonight_masari", nullptr, xmrig::CRYPTONIGHT, xmrig::VARIANT_MSR },
{ "cryptonight-bittube2", nullptr, xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_TUBE }, // bittube-miner
{ "cryptonight_bittube2", nullptr, xmrig::CRYPTONIGHT_HEAVY, xmrig::VARIANT_TUBE },
{ "cryptonight_alloy", nullptr, xmrig::CRYPTONIGHT, xmrig::VARIANT_XAO }, // xmr-stak-alloy
{ "cryptonight_turtle", nullptr, xmrig::CRYPTONIGHT_PICO, xmrig::VARIANT_TRTL },
{ "cryptonight_gpu", nullptr, xmrig::CRYPTONIGHT, xmrig::VARIANT_GPU },
{ "cryptonight_v8_half", nullptr, xmrig::CRYPTONIGHT, xmrig::VARIANT_HALF },
};
#endif

Expand All @@ -120,7 +127,8 @@ static const char *variants[] = {
"rto",
"2",
"half",
"trtl"
"trtl",
"gpu"
};


Expand Down
27 changes: 17 additions & 10 deletions src/common/interfaces/IStrategy.h
Expand Up @@ -5,7 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -21,8 +22,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __ISTRATEGY_H__
#define __ISTRATEGY_H__
#ifndef XMRIG_ISTRATEGY_H
#define XMRIG_ISTRATEGY_H


#include <stdint.h>
Expand All @@ -31,18 +32,24 @@
class JobResult;


namespace xmrig {
class Algorithm;
}


class IStrategy
{
public:
virtual ~IStrategy() {}

virtual bool isActive() const = 0;
virtual int64_t submit(const JobResult &result) = 0;
virtual void connect() = 0;
virtual void resume() = 0;
virtual void stop() = 0;
virtual void tick(uint64_t now) = 0;
virtual bool isActive() const = 0;
virtual int64_t submit(const JobResult &result) = 0;
virtual void connect() = 0;
virtual void resume() = 0;
virtual void setAlgo(const xmrig::Algorithm &algo) = 0;
virtual void stop() = 0;
virtual void tick(uint64_t now) = 0;
};


#endif // __ISTRATEGY_H__
#endif // XMRIG_ISTRATEGY_H
1 change: 1 addition & 0 deletions src/common/log/Log.h
Expand Up @@ -77,6 +77,7 @@ class Log
#define CYAN(x) "\x1B[0;36m" x "\x1B[0m"
#define WHITE_BOLD(x) "\x1B[1;37m" x "\x1B[0m"
#define WHITE(x) "\x1B[0;37m" x "\x1B[0m"
#define GRAY(x) "\x1B[1;30m" x "\x1B[0m"


#define LOG_ERR(x, ...) Log::i()->message(ILogBackend::ERR, x, ##__VA_ARGS__)
Expand Down
18 changes: 11 additions & 7 deletions src/common/net/Pool.cpp
Expand Up @@ -4,7 +4,7 @@
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
Expand Down Expand Up @@ -203,10 +203,10 @@ rapidjson::Value Pool::toJSON(rapidjson::Document &doc) const

Value obj(kObjectType);

obj.AddMember("url", StringRef(url()), allocator);
obj.AddMember("user", StringRef(user()), allocator);
obj.AddMember("pass", StringRef(password()), allocator);
obj.AddMember("rig-id", rigId() ? Value(StringRef(rigId())).Move() : Value(kNullType).Move(), allocator);
obj.AddMember("url", m_url.toJSON(), allocator);
obj.AddMember("user", m_user.toJSON(), allocator);
obj.AddMember("pass", m_password.toJSON(), allocator);
obj.AddMember("rig-id", m_rigId.toJSON(), allocator);

# ifndef XMRIG_PROXY_PROJECT
obj.AddMember("nicehash", isNicehash(), allocator);
Expand All @@ -223,17 +223,20 @@ rapidjson::Value Pool::toJSON(rapidjson::Document &doc) const
case xmrig::VARIANT_AUTO:
case xmrig::VARIANT_0:
case xmrig::VARIANT_1:
case xmrig::VARIANT_2:
obj.AddMember("variant", m_algorithm.variant(), allocator);
break;

case xmrig::VARIANT_2:
obj.AddMember("variant", 2, allocator);
break;

default:
obj.AddMember("variant", StringRef(m_algorithm.variantName()), allocator);
break;
}

obj.AddMember("tls", isTLS(), allocator);
obj.AddMember("tls-fingerprint", fingerprint() ? Value(StringRef(fingerprint())).Move() : Value(kNullType).Move(), allocator);
obj.AddMember("tls-fingerprint", m_fingerprint.toJSON(), allocator);

return obj;
}
Expand Down Expand Up @@ -419,6 +422,7 @@ void Pool::rebuild()
addVariant(xmrig::VARIANT_XHV);
addVariant(xmrig::VARIANT_XAO);
addVariant(xmrig::VARIANT_RTO);
addVariant(xmrig::VARIANT_GPU);
addVariant(xmrig::VARIANT_AUTO);
# endif
}
11 changes: 10 additions & 1 deletion src/common/net/strategies/FailoverStrategy.cpp
Expand Up @@ -5,7 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -76,6 +77,14 @@ void FailoverStrategy::resume()
}


void FailoverStrategy::setAlgo(const xmrig::Algorithm &algo)
{
for (Client *client : m_pools) {
client->setAlgo(algo);
}
}


void FailoverStrategy::stop()
{
for (size_t i = 0; i < m_pools.size(); ++i) {
Expand Down
12 changes: 7 additions & 5 deletions src/common/net/strategies/FailoverStrategy.h
Expand Up @@ -5,7 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -21,8 +22,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __FAILOVERSTRATEGY_H__
#define __FAILOVERSTRATEGY_H__
#ifndef XMRIG_FAILOVERSTRATEGY_H
#define XMRIG_FAILOVERSTRATEGY_H


#include <vector>
Expand All @@ -42,14 +43,15 @@ class FailoverStrategy : public IStrategy, public IClientListener
{
public:
FailoverStrategy(const std::vector<Pool> &urls, int retryPause, int retries, IStrategyListener *listener, bool quiet = false);
~FailoverStrategy();
~FailoverStrategy() override;

public:
inline bool isActive() const override { return m_active >= 0; }

int64_t submit(const JobResult &result) override;
void connect() override;
void resume() override;
void setAlgo(const xmrig::Algorithm &algo) override;
void stop() override;
void tick(uint64_t now) override;

Expand All @@ -71,4 +73,4 @@ class FailoverStrategy : public IStrategy, public IClientListener
std::vector<Client*> m_pools;
};

#endif /* __FAILOVERSTRATEGY_H__ */
#endif /* XMRIG_FAILOVERSTRATEGY_H */
9 changes: 8 additions & 1 deletion src/common/net/strategies/SinglePoolStrategy.cpp
Expand Up @@ -5,7 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -68,6 +69,12 @@ void SinglePoolStrategy::resume()
}


void SinglePoolStrategy::setAlgo(const xmrig::Algorithm &algo)
{
m_client->setAlgo(algo);
}


void SinglePoolStrategy::stop()
{
m_client->disconnect();
Expand Down

0 comments on commit 25b8553

Please sign in to comment.