Skip to content

Commit f35ee9f

Browse files
author
BLAKE2Share
committed
ZeroNode Update
PreRelease
1 parent 0038a39 commit f35ee9f

File tree

8 files changed

+86
-27
lines changed

8 files changed

+86
-27
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ https://dash.easymine.rocks
1010

1111
### Features
1212

13+
- Zeronode support
1314
- Supports clusters of pools each running individual currencies
1415
- Ultra-low-latency, multi-threaded Stratum implementation using asynchronous I/O
1516
- Adaptive share difficulty ("vardiff")
@@ -30,6 +31,12 @@ https://dash.easymine.rocks
3031
- To increase the share processing throughput it is advisable to increase the maximum number of concurrent equihash solvers through the new configuration property "equihashMaxThreads" of the cluster configuration element. Increasing this value by one increases the peak memory consumption of the pool cluster by 1 GB.
3132
- Miners may use both t-addresses and z-addresses when connecting to the pool
3233

34+
35+
### Zeronode Enforcement
36+
- When zeronodes are enabled a the block subsity for masternodes will be a trickle. Less than one day before the masternode enforcement blockheight a spork will be enabled on the zeronode network changing the Miner Reward to 7.83POW 2.16ZN(MN-POS).
37+
- Due the spork zeronodes will receive reward according to the live zero 3.0x daemon blocktemplate used on the cummunity pool.
38+
- If you are using this privately and don't wish to pay any amount to zeronodes until enforcement is enabled change src/Miningcore/Blockchain/Equihash/Equihashjob.cs @line 128 to "if (coin.HasZeroNodes && BlockTemplate.ZeroNodePaymentsEnabled && BlockTemplate.ZeroNodePaymentsEnforced)"
39+
3340
### Runtime Requirements on Windows
3441

3542
- [.Net Core 2.1 Runtime](https://www.microsoft.com/net/download/core)

src/Miningcore/Blockchain/Equihash/DaemonResponses/GetBlockTemplateResponse.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ public class EquihashBlockTemplate : Bitcoin.DaemonResponses.BlockTemplate
4949

5050
public ZCashBlockSubsidy Subsidy { get; set; }
5151

52+
[JsonProperty("payee")]
53+
public string ZeroNodePayee {get; set; }
54+
[JsonProperty("payee_amount")]
55+
public long ZeroNodePayeeAmount {get; set; }
56+
[JsonProperty("masternode_payments")]
57+
public bool ZeroNodePaymentsEnabled {get; set; }
58+
[JsonProperty("enforce_masternode_payments")]
59+
public bool ZeroNodePaymentsEnforced {get; set; }
60+
5261
[JsonProperty("finalsaplingroothash")]
5362
public string FinalSaplingRootHash { get; set; }
5463
}

src/Miningcore/Blockchain/Equihash/EquihashJob.cs

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public class EquihashJob
7474
// temporary reflection hack to force overwinter
7575
protected static readonly FieldInfo overwinterField = typeof(ZcashTransaction).GetField("fOverwintered", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
7676
protected static readonly FieldInfo versionGroupField = typeof(ZcashTransaction).GetField("nVersionGroupId", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
77-
protected static readonly FieldInfo versionBranchField = typeof(ZcashTransaction).GetField("nVersionBranchId", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
77+
protected static readonly FieldInfo versionBranchField = typeof(ZcashTransaction).GetField("nBranchId", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
7878

7979
// serialization constants
8080
protected byte[] sha256Empty = new byte[32];
@@ -124,14 +124,35 @@ protected virtual Transaction CreateOutputTransaction()
124124

125125
else
126126
{
127-
// pool reward (t-addr)
128-
rewardToPool = new Money(Math.Round(blockReward * (1m - (chainConfig.PercentFoundersReward) / 100m)) + rewardFees, MoneyUnit.Satoshi);
129-
tx.Outputs.Add(rewardToPool, poolAddressDestination);
130-
131-
// founders reward (t-addr)
132-
var destination = FoundersAddressToScriptDestination(GetFoundersRewardAddress());
133-
var amount = new Money(Math.Round(blockReward * (chainConfig.PercentFoundersReward / 100m)), MoneyUnit.Satoshi);
134-
tx.Outputs.Add(amount, destination);
127+
//zeronodes
128+
if (coin.HasZeroNodes && BlockTemplate.ZeroNodePaymentsEnabled)
129+
{
130+
// pool reward (t-addr)
131+
rewardToPool = new Money(Math.Round(blockReward * (1m - (chainConfig.PercentFoundersReward) / 100m)) - BlockTemplate.ZeroNodePayeeAmount + rewardFees, MoneyUnit.Satoshi);
132+
tx.Outputs.Add(rewardToPool, poolAddressDestination);
133+
134+
// founders reward (t-addr)
135+
var destination = FoundersAddressToScriptDestination(GetFoundersRewardAddress());
136+
var amount = new Money(Math.Round(blockReward * (chainConfig.PercentFoundersReward / 100m)), MoneyUnit.Satoshi);
137+
tx.Outputs.Add(amount, destination);
138+
139+
// zeronode reward (t-addr)
140+
var nodedestination = ZeroNodeAddressToScriptDestination(BlockTemplate.ZeroNodePayee);
141+
var nodeamount = new Money(BlockTemplate.ZeroNodePayeeAmount, MoneyUnit.Satoshi);
142+
tx.Outputs.Add(nodeamount, nodedestination);
143+
144+
}
145+
else
146+
{
147+
// pool reward (t-addr)
148+
rewardToPool = new Money(Math.Round(blockReward * (1m - (chainConfig.PercentFoundersReward) / 100m)) + rewardFees, MoneyUnit.Satoshi);
149+
tx.Outputs.Add(rewardToPool, poolAddressDestination);
150+
151+
// founders reward (t-addr)
152+
var destination = FoundersAddressToScriptDestination(GetFoundersRewardAddress());
153+
var amount = new Money(Math.Round(blockReward * (chainConfig.PercentFoundersReward / 100m)), MoneyUnit.Satoshi);
154+
tx.Outputs.Add(amount, destination);
155+
}
135156
}
136157
}
137158

@@ -493,6 +514,13 @@ public static IDestination FoundersAddressToScriptDestination(string address)
493514
return result;
494515
}
495516

517+
public static IDestination ZeroNodeAddressToScriptDestination(string nodeaddress)
518+
{
519+
var zeronodeaddressresult = BitcoinUtils.AddressToDestination(nodeaddress, ZcashNetworks.Instance.Mainnet);
520+
return zeronodeaddressresult;
521+
}
522+
523+
496524
#endregion // API-Surface
497525
}
498526
}

src/Miningcore/Blockchain/Equihash/EquihashJobManager.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ private EquihashJob CreateJob()
155155
else
156156
logger.Info(() => $"Detected new block {blockTemplate.Height}");
157157

158+
// zeronode debugging
159+
if (coin.HasZeroNodes)
160+
{
161+
logger.Debug(() => $"coin HasZeroNodes {coin.HasZeroNodes}");
162+
logger.Debug(() => $"Zeronode Payee {blockTemplate.ZeroNodePayee}");
163+
logger.Debug(() => $"Zeronode Payee Amount {blockTemplate.ZeroNodePayeeAmount}");
164+
}
165+
158166
validJobs.Clear();
159167

160168
// update stats

src/Miningcore/Configuration/ClusterConfig.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ public partial class EquihashNetworkParams
215215

216216
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
217217
public uint? SaplingTxVersionGroupId { get; set; }
218+
218219
}
219220

220221
[JsonProperty(Order = -7, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
@@ -228,6 +229,10 @@ public partial class EquihashNetworkParams
228229
/// <summary>
229230
/// Force use of BitcoinPayoutHandler instead of EquihashPayoutHandler
230231
/// </summary>
232+
233+
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
234+
public bool HasZeroNodes { get; set; }
235+
231236
public bool UseBitcoinPayoutHandler { get; set; }
232237
}
233238

src/Miningcore/Miningcore.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,25 @@
5050
<ItemGroup>
5151
<PackageReference Include="AspNetCoreRateLimit" Version="2.1.0" />
5252
<PackageReference Include="Autofac" Version="4.8.1" />
53-
<PackageReference Include="AutoMapper" Version="7.0.1" />
53+
<PackageReference Include="AutoMapper" Version="8.0.0" />
5454
<PackageReference Include="Dapper" Version="1.50.5" />
55-
<PackageReference Include="FluentValidation" Version="8.0.100" />
55+
<PackageReference Include="FluentValidation" Version="8.0.101" />
5656
<PackageReference Include="FluentValidation.ValidatorAttribute" Version="8.0.100" />
5757
<PackageReference Include="JetBrains.Annotations" Version="2018.2.1" />
58-
<PackageReference Include="MailKit" Version="2.0.7" />
58+
<PackageReference Include="MailKit" Version="2.1.0.2" />
5959
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.2.5" />
60-
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.5" />
60+
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.6" />
6161
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.1.2" />
6262
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
6363
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.1" />
6464
<PackageReference Include="morelinq" Version="3.0.0" />
65-
<PackageReference Include="NBitcoin" Version="4.1.1.71" />
65+
<PackageReference Include="NBitcoin" Version="4.1.1.72" />
6666
<PackageReference Include="NBitcoin.Zcash" Version="3.0.0" />
67-
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
67+
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
6868
<PackageReference Include="NLog" Version="4.5.11" />
6969
<PackageReference Include="NLog.Extensions.Logging" Version="1.3.0" />
7070
<PackageReference Include="Npgsql" Version="4.0.3" />
71-
<PackageReference Include="Polly" Version="6.1.1" />
71+
<PackageReference Include="Polly" Version="6.1.2" />
7272
<PackageReference Include="prometheus-net" Version="2.1.3" />
7373
<PackageReference Include="prometheus-net.AspNetCore" Version="2.1.3" />
7474
<PackageReference Include="protobuf-net" Version="2.4.0" />

src/Miningcore/Persistence/Postgres/Scripts/createdb.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set role miningcore;
1+
SET ROLE miningcore;
22

33
CREATE TABLE shares
44
(
@@ -109,3 +109,4 @@ CREATE INDEX IDX_MINERSTATS_POOL_CREATED on minerstats(poolid, created);
109109
CREATE INDEX IDX_MINERSTATS_POOL_MINER_CREATED on minerstats(poolid, miner, created);
110110
CREATE INDEX IDX_MINERSTATS_POOL_MINER_CREATED_HOUR on minerstats(poolid, miner, date_trunc('hour',created));
111111
CREATE INDEX IDX_MINERSTATS_POOL_MINER_CREATED_DAY on minerstats(poolid, miner, date_trunc('day',created));
112+
CREATE INDEX IDX_MINERSTATS_POOL_MINER_WORKER_CREATED_HASHRATE on minerstats(poolid,miner,worker,created desc,hashrate);

src/Miningcore/coins.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,7 @@
11821182
"name": "Zero",
11831183
"symbol": "ZER",
11841184
"family": "equihash",
1185+
"hasZeroNodes": true,
11851186
"networks": {
11861187
"main": {
11871188
"diff1": "0007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
@@ -1191,7 +1192,7 @@
11911192
"hash": "equihash",
11921193
"args": [ 192, 7, "ZERO_PoW" ]
11931194
},
1194-
"coinbaseTxNetwork": "main",
1195+
"coinbaseTxNetwork": "zcash-main",
11951196
"payFoundersReward": true,
11961197
"percentFoundersReward": 7.5,
11971198
"foundersRewardAddresses": [
@@ -1220,14 +1221,14 @@
12201221
"test": {
12211222
"diff1": "0007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
12221223
"solutionSize": 400,
1223-
"solutionPreambleSize": 1,
1224+
"solutionPreambleSize": 3,
12241225
"solver": {
12251226
"hash": "equihash",
12261227
"args": [ 192, 7, "ZERO_PoW" ]
12271228
},
1228-
"coinbaseTxNetwork": "test",
1229+
"coinbaseTxNetwork": "zcash-test",
12291230
"payFoundersReward": true,
1230-
"percentFoundersReward": 20,
1231+
"percentFoundersReward": 7.5,
12311232
"foundersRewardAddresses": [
12321233
"t2BEnZwurNtPyhyWdZ82zTdS93rKyoUpgMJ",
12331234
"t2AwNRubry4rQrEvHwAdpYve4Gz5cSmjGXA",
@@ -1241,7 +1242,7 @@
12411242
"t28azskSALVTtgbW63CqDwzXgtWQ56GVVXa"
12421243
],
12431244
"foundersRewardSubsidySlowStartInterval": 0,
1244-
"foundersRewardSubsidyHalvingInterval": 30000,
1245+
"foundersRewardSubsidyHalvingInterval": 800000,
12451246
"overwinterTxBranchId": 1870033530,
12461247
"overwinterActivationHeight": 50,
12471248
"overwinterTxVersion": 3,
@@ -1259,7 +1260,7 @@
12591260
"hash": "equihash",
12601261
"args": [ 48, 5, "ZERO_PoW" ]
12611262
},
1262-
"coinbaseTxNetwork": "regtest",
1263+
"coinbaseTxNetwork": "zcash-reg",
12631264
"payFoundersReward": true,
12641265
"percentFoundersReward": 7.5,
12651266
"foundersRewardAddresses": [ "t2FwcEhFdNXuFMv1tcYwaBJtYVtMj8b1uTg" ],
@@ -1269,9 +1270,9 @@
12691270
},
12701271
"usesZCashAddressFormat": true,
12711272
"useBitcoinPayoutHandler": false,
1272-
"explorerBlockLink": "https://zero.cryptonode.cloud/insight/block/$hash$",
1273-
"explorerTxLink": "https://zero.cryptonode.cloud/insight/tx/{0}",
1274-
"explorerAccountLink": "https://zero.cryptonode.cloud/insight/address/{0}"
1273+
"explorerBlockLink": "https://insight.zerocurrency.io/insight/block/$hash$",
1274+
"explorerTxLink": "https://insight.zerocurrency.io/insight/tx/{0}",
1275+
"explorerAccountLink": "https://insight.zerocurrency.io/insight/address/{0}"
12751276
},
12761277
"bitcoin-private": {
12771278
"name": "Bitcoin Private",
@@ -1383,4 +1384,4 @@
13831384
"explorerTxLink": "https://gastracker.io/tx/{0}",
13841385
"explorerAccountLink": "https://gastracker.io/addr/{0}"
13851386
}
1386-
}
1387+
}

0 commit comments

Comments
 (0)