Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update #8

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[Rr]elease/
x64/
build/
build.backup/
[Bb]in/
[Oo]bj/
*.VC.db
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0-jammy as BUILDER
WORKDIR /app
RUN apt-get update && \
apt-get -y install cmake ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5 libzmq3-dev golang-go libgmp-dev
apt-get -y install cmake clang ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5 libzmq3-dev golang-go libgmp-dev libc++-dev
COPY . .
WORKDIR /app/src/Miningcore
RUN dotnet publish -c Release --framework net6.0 -o ../../build
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,5 @@ To support this project you can become a [sponsor]( https://github.com/sponsors/
* CCX: `ccx7S4B3gBeH1SGWCfqZp3NM7Vavg7H3S8ovJn8fU4bwC4vU7ChWfHtbNzifhrpbJ74bMDxj4KZFTcznTfsucCEg1Kgv7zbNgs`
* FIRO: `a5AsoTSkfPHQ3SUmR6binG1XW7oQQoFNU1`
* ERGO: `9gYyuZzaSw3TiCtUkSRuS3XVDUv41EFs3dtNCFGqiEwHqpb7gkF`
* WART: `7795fc0fe93e7e4e232a212f00bdc8885c580a5666d39a0d`
* XMR: `483zaHtMRfM7rw1dXgebhWaRR8QLgAF6w4BomAV319FVVHfdbYTLVuBRc4pQgRAnRpfy6CXvvwngK4Lo3mRKE29RRx3Jb5c`
4 changes: 2 additions & 2 deletions build-debian-11.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ sudo apt-get update; \
sudo apt-get -y install wget

# add dotnet repo
sudo wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb

# install dev-dependencies
sudo apt-get update; \
sudo apt-get -y install dotnet-sdk-6.0 git cmake ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5-dev libgmp-dev
sudo apt-get -y install dotnet-sdk-6.0 git cmake clang ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5-dev libgmp-dev libc++-dev

(cd src/Miningcore && \
BUILDIR=${1:-../../build} && \
Expand Down
4 changes: 2 additions & 2 deletions build-debian-12.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ sudo apt-get update; \
sudo apt-get -y install wget

# add dotnet repo
sudo wget https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
wget https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb

# install dev-dependencies
sudo apt-get update; \
sudo apt-get -y install dotnet-sdk-6.0 git cmake ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5-dev libgmp-dev
sudo apt-get -y install dotnet-sdk-6.0 git cmake clang ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5-dev libgmp-dev libc++-dev

(cd src/Miningcore && \
BUILDIR=${1:-../../build} && \
Expand Down
2 changes: 1 addition & 1 deletion build-ubuntu-20.04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rm packages-microsoft-prod.deb

# install dev-dependencies
sudo apt-get update; \
sudo apt-get -y install dotnet-sdk-6.0 git cmake ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5 libgmp-dev
sudo apt-get -y install dotnet-sdk-6.0 git cmake clang ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5 libgmp-dev libc++-dev

(cd src/Miningcore && \
BUILDIR=${1:-../../build} && \
Expand Down
2 changes: 1 addition & 1 deletion build-ubuntu-21.04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rm packages-microsoft-prod.deb

# install dev-dependencies
sudo apt-get update; \
sudo apt-get -y install dotnet-sdk-6.0 git cmake ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5 libgmp-dev
sudo apt-get -y install dotnet-sdk-6.0 git cmake clang ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5 libgmp-dev libc++-dev

(cd src/Miningcore && \
BUILDIR=${1:-../../build} && \
Expand Down
2 changes: 1 addition & 1 deletion build-ubuntu-22.04.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# install dev-dependencies
sudo apt-get update; \
sudo apt-get -y install dotnet-sdk-6.0 git cmake ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5 libgmp-dev
sudo apt-get -y install dotnet-sdk-6.0 git cmake clang ninja-build build-essential libssl-dev pkg-config libboost-all-dev libsodium-dev libzmq5 libgmp-dev libc++-dev

(cd src/Miningcore && \
BUILDIR=${1:-../../build} && \
Expand Down
6 changes: 5 additions & 1 deletion examples/kaspa_pool.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@
"enabled": true,
"time": 600,
"invalidPercent": 50,
"checkThreshold": 50
"checkThreshold": 50,
"minerEffortPercent": 0.00000000465661287,
"minerEffortTime": 259200
},
"ports": {
"3094": {
Expand Down Expand Up @@ -130,6 +132,8 @@
"enabled": true,
"walletPassword": "<The Kaspa's wallet password which owns the pool address>",
"minimumPayment": 1,
"versionEnablingMaxFee": "v0.12.18-rc5",
"maxFee": 200000,
"payoutScheme": "PPLNS",
"payoutSchemeConfig": {
"factor": 0.5
Expand Down
12 changes: 6 additions & 6 deletions examples/veruscoin_pool.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@
"ports": {
"3092": {
"listenAddress": "0.0.0.0",
"difficulty": 256,
"difficulty": 25600000,
"varDiff": {
"minDiff": 256,
"maxDiff": 1048576000,
"minDiff": 25600000,
"maxDiff": null,
"targetTime": 15,
"retargetTime": 90,
"variancePercent": 30,
Expand All @@ -108,13 +108,13 @@
},
"3093": {
"listenAddress": "0.0.0.0",
"difficulty": 256,
"difficulty": 25600000,
"tls": true,
"tlsPfxFile": "<Your directory for the pfx file>",
"tlsPfxPassword": "password",
"varDiff": {
"minDiff": 256,
"maxDiff": 1048576000,
"minDiff": 25600000,
"maxDiff": null,
"targetTime": 15,
"retargetTime": 90,
"variancePercent": 30,
Expand Down
119 changes: 119 additions & 0 deletions examples/warthog_pool.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
"logging": {
"level": "info",
"enableConsoleLog": true,
"enableConsoleColors": true,
"logFile": "",
"apiLogFile": "",
"logBaseDirectory": "",
"perPoolLogFile": false
},
"banning": {
"manager": "Integrated",
"banOnJunkReceive": false,
"banOnInvalidShares": false
},
"notifications": {
"enabled": false,
"email": {
"host": "smtp.example.com",
"port": 587,
"user": "user",
"password": "password",
"fromAddress": "[email protected]",
"fromName": "support"
},
"admin": {
"enabled": false,
"emailAddress": "[email protected]",
"notifyBlockFound": true
}
},
"persistence": {
"postgres": {
"host": "127.0.0.1",
"port": 5432,
"user": "miningcore",
"password": "password",
"database": "miningcore"
}
},
"paymentProcessing": {
"enabled": true,
"interval": 600,
"shareRecoveryFile": "recovered-shares.txt"
},
"api": {
"enabled": true,
"listenAddress": "*",
"port": 4000,
"metricsIpWhitelist": [],
"rateLimiting": {
"disabled": true,
"rules": [
{
"Endpoint": "*",
"Period": "1s",
"Limit": 5
}
],
"ipWhitelist": [
""
]
}
},
"pools": [{
"id": "wart1",
"enabled": true,
"coin": "warthog",
"address": "5d896758ee0ade5f09fa93d012783beddd82a6ff322f2073",
"rewardRecipients": [
{
"type": "op",
"address": "5d896758ee0ade5f09fa93d012783beddd82a6ff322f2073",
"percentage": 1.0
}
],
"blockRefreshInterval": 250,
"jobRebroadcastTimeout": 0,
"clientConnectionTimeout": 600,
"banning": {
"enabled": true,
"time": 600,
"invalidPercent": 50,
"checkThreshold": 50
},
"ports": {
"4073": {
"name": "GPU-SMALL",
"listenAddress": "*",
"difficulty": 512000000,
"varDiff": {
"minDiff": 256000000,
"maxDiff": null,
"targetTime": 15,
"retargetTime": 90,
"variancePercent": 100,
"maxDelta": 512
}
}
},
"daemons": [
{
"host": "127.0.0.1",
"port": 3000,
"user": "",
"password": ""
}
],
"paymentProcessing": {
"walletPrivateKey": "<DANGER: The Warthog Node's wallet private key which owns the pool address>",
"enabled": true,
"minimumPayment": 1,
"payoutScheme": "PPLNS",
"payoutSchemeConfig": {
"factor": 0.5
}
}
}]
}
2 changes: 1 addition & 1 deletion src/Miningcore.Tests/Miningcore.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Microsoft.Reactive.Testing" Version="5.0.0" />
<PackageReference Include="NLog" Version="5.2.8" />
<PackageReference Include="Npgsql" Version="7.0.1" />
<PackageReference Include="Npgsql" Version="8.0.3" />
<PackageReference Include="NSubstitute" Version="4.4.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
Expand Down
31 changes: 27 additions & 4 deletions src/Miningcore/Api/Controllers/PoolApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@ public async Task<GetPoolsResponse> Get(CancellationToken ct, [FromQuery] uint t
// enrich
result.TotalPaid = await cf.Run(con => statsRepo.GetTotalPoolPaymentsAsync(con, config.Id, ct));
result.TotalBlocks = await cf.Run(con => blocksRepo.GetPoolBlockCountAsync(con, config.Id, ct));
var lastBlockTime = await cf.Run(con => blocksRepo.GetLastPoolBlockTimeAsync(con, config.Id));
result.TotalConfirmedBlocks = await cf.Run(con => blocksRepo.GetTotalConfirmedBlocksAsync(con, config.Id, ct));
result.TotalPendingBlocks = await cf.Run(con => blocksRepo.GetTotalPendingBlocksAsync(con, config.Id, ct));
// get reward of the last confirmed block and set BlockReward
result.BlockReward = await cf.Run(con => blocksRepo.GetLastConfirmedBlockRewardAsync(con, config.Id, ct));
var lastBlockTime = await cf.Run(con => blocksRepo.GetLastPoolBlockTimeAsync(con, config.Id, ct));
result.LastPoolBlockTime = lastBlockTime;

if(lastBlockTime.HasValue)
{
var startTime = lastBlockTime.Value;
var poolEffort = await cf.Run(con => shareRepo.GetEffortBetweenCreatedAsync(con, config.Id, pool.ShareMultiplier, startTime, clock.Now));
var poolEffort = await cf.Run(con => shareRepo.GetEffortBetweenCreatedAsync(con, config.Id, pool.ShareMultiplier, startTime, clock.Now, ct));
if(poolEffort.HasValue)
result.PoolEffort = poolEffort.Value;
}
Expand Down Expand Up @@ -137,13 +141,17 @@ public async Task<GetPoolResponse> GetPoolInfoAsync(string poolId, CancellationT
// enrich
response.Pool.TotalPaid = await cf.Run(con => statsRepo.GetTotalPoolPaymentsAsync(con, pool.Id, ct));
response.Pool.TotalBlocks = await cf.Run(con => blocksRepo.GetPoolBlockCountAsync(con, pool.Id, ct));
var lastBlockTime = await cf.Run(con => blocksRepo.GetLastPoolBlockTimeAsync(con, pool.Id));
response.Pool.TotalConfirmedBlocks = await cf.Run(con => blocksRepo.GetTotalConfirmedBlocksAsync(con, pool.Id, ct));
response.Pool.TotalPendingBlocks = await cf.Run(con => blocksRepo.GetTotalPendingBlocksAsync(con, pool.Id, ct));
// get reward of the last confirmed block and set BlockReward
response.Pool.BlockReward = await cf.Run(con => blocksRepo.GetLastConfirmedBlockRewardAsync(con, pool.Id, ct));
var lastBlockTime = await cf.Run(con => blocksRepo.GetLastPoolBlockTimeAsync(con, pool.Id, ct));
response.Pool.LastPoolBlockTime = lastBlockTime;

if(lastBlockTime.HasValue)
{
var startTime = lastBlockTime.Value;
var poolEffort = await cf.Run(con => shareRepo.GetEffortBetweenCreatedAsync(con, pool.Id, poolInstance.ShareMultiplier, startTime, clock.Now));
var poolEffort = await cf.Run(con => shareRepo.GetEffortBetweenCreatedAsync(con, pool.Id, poolInstance.ShareMultiplier, startTime, clock.Now, ct));
if(poolEffort.HasValue)
response.Pool.PoolEffort = poolEffort.Value;
}
Expand Down Expand Up @@ -393,7 +401,22 @@ public async Task<MinerPerformanceStats[]> PagePoolMinersAsync(
stats.LastPaymentLink = string.Format(baseUrl, statsResult.LastPayment.TransactionConfirmationData);
}

var lastBlockTime = await cf.Run(con => blocksRepo.GetLastPoolBlockTimeAsync(con, pool.Id, ct));
if(lastBlockTime.HasValue)
{
var startTime = lastBlockTime.Value;
var minerEffort = await cf.Run(con => shareRepo.GetMinerEffortBetweenCreatedAsync(con, pool.Id, address, startTime, clock.Now, ct));
if(minerEffort.HasValue)
stats.MinerEffort = minerEffort.Value;
}

stats.PerformanceSamples = await GetMinerPerformanceInternal(perfMode, pool, address, ct);

// add total confirmed and pending blocks
var totalConfirmedBlocks = await cf.Run(con => statsRepo.GetMinerTotalConfirmedBlocksAsync(con, pool.Id, address, ct));
var totalPendingBlocks = await cf.Run(con => statsRepo.GetMinerTotalPendingBlocksAsync(con, pool.Id, address, ct));
stats.TotalConfirmedBlocks = totalConfirmedBlocks;
stats.TotalPendingBlocks = totalPendingBlocks;
}

return stats;
Expand Down
4 changes: 4 additions & 0 deletions src/Miningcore/Api/Extensions/MiningPoolExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Miningcore.Blockchain.Ergo.Configuration;
using Miningcore.Blockchain.Handshake.Configuration;
using Miningcore.Blockchain.Kaspa.Configuration;
using Miningcore.Blockchain.Warthog.Configuration;
using Miningcore.Configuration;
using Miningcore.Extensions;
using Miningcore.Mining;
Expand Down Expand Up @@ -51,6 +52,9 @@ public static PoolInfo ToPoolInfo(this PoolConfig poolConfig, IMapper mapper, Pe
case "kaspa":
extra.StripValue(nameof(KaspaPaymentProcessingConfigExtra.WalletPassword));
break;
case "warthog":
extra.StripValue(nameof(WarthogPaymentProcessingConfigExtra.WalletPrivateKey));
break;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/Miningcore/Api/Responses/GetBlocksResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class Block
public string Type { get; set; }
public double ConfirmationProgress { get; set; }
public double? Effort { get; set; }
public double? MinerEffort { get; set; }
public string TransactionConfirmationData { get; set; }
public decimal Reward { get; set; }
public string InfoLink { get; set; }
Expand Down
3 changes: 3 additions & 0 deletions src/Miningcore/Api/Responses/GetMinerStatsResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ public class MinerStats
public decimal PendingBalance { get; set; }
public decimal TotalPaid { get; set; }
public decimal TodayPaid { get; set; }
public double MinerEffort { get; set; }
public DateTime? LastPayment { get; set; }
public string LastPaymentLink { get; set; }
public WorkerPerformanceStatsContainer Performance { get; set; }
public WorkerPerformanceStatsContainer[] PerformanceSamples { get; set; }
public long TotalConfirmedBlocks { get; set; }
public long TotalPendingBlocks { get; set; }
}
3 changes: 3 additions & 0 deletions src/Miningcore/Api/Responses/GetPoolsResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public partial class PoolInfo
public MinerPerformanceStats[] TopMiners { get; set; }
public decimal TotalPaid { get; set; }
public uint TotalBlocks { get; set; }
public uint TotalConfirmedBlocks { get; set; }
public uint TotalPendingBlocks { get; set; }
public decimal BlockReward { get; set; }
public DateTime? LastPoolBlockTime { get; set; }
public double PoolEffort { get; set; }
}
Expand Down
4 changes: 3 additions & 1 deletion src/Miningcore/AutoMapperProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public AutoMapperProfile()

CreateMap<MinerStats, Api.Responses.MinerStats>()
.ForMember(dest => dest.LastPayment, opt => opt.Ignore())
.ForMember(dest => dest.LastPaymentLink, opt => opt.Ignore());
.ForMember(dest => dest.LastPaymentLink, opt => opt.Ignore())
.ForMember(dest => dest.TotalConfirmedBlocks, opt => opt.MapFrom(src => src.TotalConfirmedBlocks))
.ForMember(dest => dest.TotalPendingBlocks, opt => opt.MapFrom(src => src.TotalPendingBlocks));

CreateMap<WorkerPerformanceStats, Api.Responses.WorkerPerformanceStats>();
CreateMap<WorkerPerformanceStatsContainer, Api.Responses.WorkerPerformanceStatsContainer>();
Expand Down
Loading