Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
Dev (#216)
Browse files Browse the repository at this point in the history
* Ignore redundant ZMQ block hash updates for the same block from multiple daemons
* Disable stratum method _suggest_difficulty_ for now
* Job management change
* Runtime info logging
* Fixed GBX, CRC
* Do not return stale miner performance stats via API
* VarDiff maxDelta support
* Validate Monero PaymentID on login
* Do not send work until login is complete. Fixes #204
* Blake2s hash integration
* Support for Legacy Bitcoin daemons. Fixes #77, #119 
* Verge (XVG) integration
* Neoscrypt fix
* Legacy daemon fix
* improved POW/POS check
* Logging of block submissions
* BlockRewardMultiplier
* Increase Pg Command Timeout
* Added payment audit-trail
* Fixes #194
  • Loading branch information
Oliver Weichhold authored Feb 21, 2018
1 parent 8996c0d commit 3988706
Show file tree
Hide file tree
Showing 62 changed files with 1,334 additions and 190 deletions.
4 changes: 2 additions & 2 deletions src/MiningCore.Tests/Blockchain/Bitcoin/BitcoinJobTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void BitcoinJob_Should_Accept_Valid_Share()
var clock = new MockMasterClock { CurrentTime = DateTimeOffset.FromUnixTimeSeconds(1508869874).UtcDateTime };

job.Init(bt, "1", poolConfig, clusterConfig, clock, poolAddressDestination, BitcoinNetworkType.RegTest,
false, 1, sha256d, sha256d, sha256dReverse);
false, 1, 1, sha256d, sha256d, sha256dReverse);

// set clock to submission time
clock.CurrentTime = DateTimeOffset.FromUnixTimeSeconds(1508869907).UtcDateTime;
Expand Down Expand Up @@ -78,7 +78,7 @@ public void BitcoinJob_Should_Not_Accept_Invalid_Share()
var clock = new MockMasterClock { CurrentTime = DateTimeOffset.FromUnixTimeSeconds(1508869874).UtcDateTime };

job.Init(bt, "1", poolConfig, clusterConfig, clock, poolAddressDestination, BitcoinNetworkType.RegTest,
false, 1, sha256d, sha256d, sha256dReverse);
false, 1, 1, sha256d, sha256d, sha256dReverse);

// set clock to submission time
clock.CurrentTime = DateTimeOffset.FromUnixTimeSeconds(1508869907).UtcDateTime;
Expand Down
2 changes: 1 addition & 1 deletion src/MiningCore.Tests/Blockchain/ZCash/ZCashJobTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void ZCashJob_Testnet_Validate_FoundersRewardAddress_At_Height()
var clock = new MockMasterClock { CurrentTime = DateTimeOffset.FromUnixTimeSeconds(1508869874).UtcDateTime };

job.Init(bt, "1", poolConfig, clusterConfig, clock, poolAddressDestination, BitcoinNetworkType.Test,
false, 1, sha256d, sha256d, sha256dReverse);
false, 1, 1, sha256d, sha256d, sha256dReverse);

bt.Height = 1;
Assert.Equal(job.GetFoundersRewardAddress(), "t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi");
Expand Down
16 changes: 16 additions & 0 deletions src/MiningCore.Tests/Crypto/HashingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ public void Blake_Hash_Should_Throw_On_Null_Input()
Assert.Throws<ArgumentNullException>(() => hasher.Digest(null));
}

[Fact]
public void Blake2s_Hash_Should_Match()
{
var hasher = new Blake2s();
var result = hasher.Digest(testValue2).ToHexString();

Assert.Equal("c3ee938582d70ccd9a323b6097357449365d1fdfbbe2ecd7ee44e4bdbbb24392", result);
}

[Fact]
public void Blake2s_Hash_Should_Throw_On_Null_Input()
{
var hasher = new Blake2s();
Assert.Throws<ArgumentNullException>(() => hasher.Digest(null));
}

[Fact]
public void Groestl_Hash_Should_Match()
{
Expand Down
4 changes: 3 additions & 1 deletion src/MiningCore/Api/ApiServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ private async Task GetMinerInfoAsync(HttpContext context, Match m)
return;
}

var perfMode = context.GetQueryParameter<string>("perfMode", "day");

var statsResult = cf.RunTx((con, tx) =>
statsRepo.GetMinerStats(con, tx, pool.Id, address), true, IsolationLevel.Serializable);

Expand All @@ -432,7 +434,7 @@ private async Task GetMinerInfoAsync(HttpContext context, Match m)
stats.LastPaymentLink = string.Format(baseUrl, statsResult.LastPayment.TransactionConfirmationData);
}

stats.Performance24H = GetMinerPerformanceInternal("day", pool, address);
stats.PerformanceSamples = GetMinerPerformanceInternal(perfMode, pool, address);
}

await SendJson(context, stats);
Expand Down
9 changes: 3 additions & 6 deletions src/MiningCore/Api/Extensions/MiningPoolExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,10 @@ public static PoolInfo ToPoolInfo(this PoolConfig pool, IMapper mapper, Persiste

private static string GetPoolAlgorithm(PoolConfig pool)
{
var result = pool.Coin.Algorithm;
string result = null;

if (string.IsNullOrEmpty(result))
{
if (CoinMetaData.CoinAlgorithm.TryGetValue(pool.Coin.Type, out var getter))
result = getter(pool.Coin.Type);
}
if (CoinMetaData.CoinAlgorithm.TryGetValue(pool.Coin.Type, out var getter))
result = getter(pool.Coin.Type, pool.Coin.Algorithm);

// Capitalize
if (!string.IsNullOrEmpty(result) && result.Length > 1)
Expand Down
2 changes: 1 addition & 1 deletion src/MiningCore/Api/Responses/GetMinerStatsResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ public class MinerStats
public DateTime? LastPayment { get; set; }
public string LastPaymentLink { get; set; }
public WorkerPerformanceStatsContainer Performance { get; set; }
public WorkerPerformanceStatsContainer[] Performance24H { get; set; }
public WorkerPerformanceStatsContainer[] PerformanceSamples { get; set; }
}
}
6 changes: 5 additions & 1 deletion src/MiningCore/Blockchain/Bitcoin/BitcoinConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,17 @@ public static class BitcoinCommands
public const string GetMiningInfo = "getmininginfo";
public const string GetPeerInfo = "getpeerinfo";
public const string ValidateAddress = "validateaddress";
public const string GetDifficulty = "getdifficulty";
public const string GetBlockTemplate = "getblocktemplate";
public const string GetBlockSubsidy = "getblocksubsidy";
public const string SubmitBlock = "submitblock";
public const string GetBlockchainInfo = "getblockchaininfo";
public const string GetBlock = "getblock";
public const string GetTransaction = "gettransaction";
public const string SendMany = "sendmany";

// Legacy commands
public const string GetInfo = "getinfo";
public const string GetDifficulty = "getdifficulty";
public const string GetConnectionCount = "getconnectioncount";
}
}
6 changes: 4 additions & 2 deletions src/MiningCore/Blockchain/Bitcoin/BitcoinJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class BitcoinJob<TBlockTemplate>
protected IMasterClock clock;
protected IHashAlgorithm coinbaseHasher;
protected double shareMultiplier;
protected decimal blockRewardMultiplier;
protected int extraNoncePlaceHolderLength;
protected IHashAlgorithm headerHasher;
protected bool isPoS;
Expand Down Expand Up @@ -239,7 +240,7 @@ protected virtual Script GenerateScriptSigInitial()

protected virtual Transaction CreateOutputTransaction()
{
rewardToPool = new Money(BlockTemplate.CoinbaseValue, MoneyUnit.Satoshi);
rewardToPool = new Money(BlockTemplate.CoinbaseValue * blockRewardMultiplier, MoneyUnit.Satoshi);

var tx = new Transaction();

Expand Down Expand Up @@ -411,7 +412,7 @@ protected virtual byte[] BuildRawTransactionBuffer()
public virtual void Init(TBlockTemplate blockTemplate, string jobId,
PoolConfig poolConfig, ClusterConfig clusterConfig, IMasterClock clock,
IDestination poolAddressDestination, BitcoinNetworkType networkType,
bool isPoS, double shareMultiplier,
bool isPoS, double shareMultiplier, decimal blockrewardMultiplier,
IHashAlgorithm coinbaseHasher, IHashAlgorithm headerHasher, IHashAlgorithm blockHasher)
{
Contract.RequiresNonNull(blockTemplate, nameof(blockTemplate));
Expand All @@ -436,6 +437,7 @@ public virtual void Init(TBlockTemplate blockTemplate, string jobId,
extraNoncePlaceHolderLength = BitcoinConstants.ExtranoncePlaceHolderLength;
this.isPoS = isPoS;
this.shareMultiplier = shareMultiplier;
this.blockRewardMultiplier = blockrewardMultiplier;

this.coinbaseHasher = coinbaseHasher;
this.headerHasher = headerHasher;
Expand Down
Loading

0 comments on commit 3988706

Please sign in to comment.