Skip to content

Commit

Permalink
- #64 Jminer for PoC2
Browse files Browse the repository at this point in the history
- added pre-fork support for poc2 plotfiles (detected by no staggersize in filename)
- updated libs and docs
- new version 0.5.0-SNAPSHOT
  • Loading branch information
de-luxe committed May 19, 2018
1 parent 37008fe commit 35a3c23
Show file tree
Hide file tree
Showing 16 changed files with 363 additions and 43 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ GPU assisted Proof of Capacity (PoC) Miner for Burstcoin (BURST)

1. edit 'jminer.properties' with text editor to configure miner
2. ensure java8 (64bit) and openCL driver/sdk is installed (java9 will not work)
3. execute 'java -jar -d64 -XX:+UseG1GC burstcoin-jminer-0.4.x-RELEASE.jar' or run the *.bat/*.sh file
3. execute 'java -jar -d64 -XX:+UseG1GC burstcoin-jminer-0.5.x-RELEASE.jar' or run the *.bat/*.sh file

> '-d64' to ensure 64bit java (remove for 32bit)
> '-XX:+UseG1GC' to free memory after round finished.
Expand All @@ -26,6 +26,16 @@ This file has to be in the miner directory (same folder as '*.jar' file)
poolMining=false
passPhrase=<YOUR PASS PHRASE>

# POC1 and POC2 - NOTICE
jminer supports POC2 since version 0.5.x

only use one type, POC1 or POC2 on one drive ('plotPath'), mixed will be skipped for now.

ensure your POC2 plotfiles do not have staggersize in filename, or they will be treated like POC1.

POC1 filename: 'numericAccountId_startNonce_numberOfNonces_staggersize'
POC2 filename: 'numericAccountId_startNonce_numberOfNonces'


# List of all properties
your 'jminer.properties' hasn't got to contain all properties listed here,
Expand Down Expand Up @@ -274,6 +284,15 @@ For example, if you mine on 4 drives (plotPaths), you can reduce the memory usag
by setting 'readerThreads=2', this will reduce mining speed but save memory.

readerThreads=10



## POC2

### poc2ActivationBlockHeight - (default:500000)
only adjust if the POC2 release fork gets delayed to a later block

poc2ActivationBlockHeight=500000



Expand Down
18 changes: 17 additions & 1 deletion jminer.default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
# -----------------------------------------------------------------------------------
# NOTICE: your 'jminer.properties' hasn't got to contain all properties listed here
# as long there is a default/fallback defined, mentioned in here.
#
# POC1 and POC2
# jminer supports POC2 since version 0.5.x
# only use one type, POC1 or POC2 on one drive ('plotPath'), mixed will be skipped for now.
# ensure your POC2 plotfiles do not have staggersize in filename, or they will be treated like POC1.
# POC1 filename: 'numericAccountId_startNonce_numberOfNonces_staggersize'
# POC2 filename: 'numericAccountId_startNonce_numberOfNonces'
# -----------------------------------------------------------------------------------


Expand Down Expand Up @@ -212,4 +219,13 @@ showSkippedDeadlines=
# by setting 'readerThreads=2', this will reduce mining speed but save memory.
# -----------------------------------------------------------------------------------
chunkPartNonces=
readerThreads=
readerThreads=


# -----------------------------------------------------------------------------------
# - POC2 ----------------------------------------------------------------------------
# -----------------------------------------------------------------------------------
# poc2ActivationBlockHeight - only adjust if the POC2 release fork gets delayed to a later block
# (default:500000)
# -----------------------------------------------------------------------------------
poc2ActivationBlockHeight=
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>burstcoin</groupId>
<artifactId>burstcoin-jminer</artifactId>
<version>0.4.12-RELEASE</version>
<version>0.5.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>burstcoin-jminer</name>
Expand All @@ -14,15 +14,15 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<version>2.0.2.RELEASE</version>
<relativePath/>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>burstcoin.jminer.JMinerApplication</start-class>
<java.version>1.8</java.version>
<jocl-blast.version>1.2.0</jocl-blast.version>
<jocl-blast.version>1.3.0</jocl-blast.version>
<saphir-hash.version>3.0.3</saphir-hash.version>
<bcprov-jdk15on.version>1.59</bcprov-jdk15on.version>

Expand Down
2 changes: 1 addition & 1 deletion run.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
java -jar -d64 -XX:+UseG1GC burstcoin-jminer-0.4.12-RELEASE.jar
java -jar -d64 -XX:+UseG1GC burstcoin-jminer-0.5.0-SNAPSHOT.jar
7 changes: 6 additions & 1 deletion src/main/java/burstcoin/jminer/JMinerCommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,16 @@ public void run(String... args)
LOG.info(" __ __ GPU assisted PoC-Miner");
LOG.info(" |__| _____ |__| ____ ___________ ");
LOG.info(" version | |/ \\| |/ \\_/ __ \\_ __ \\");
LOG.info(" 0.4.12 | | Y Y \\ | | \\ ___/| | \\/");
LOG.info(" 0.5.0 | | Y Y \\ | | \\ ___/| | \\/");
LOG.info(" /\\__| |__|_| /__|___| /\\___ >__| ");
LOG.info(" \\______| \\/ \\/ \\/");
LOG.info(" mining engine: BURST-LUXE-RED2-G6JW-H4HG5");
LOG.info(" openCL checker: BURST-QHCJ-9HB5-PTGC-5Q8J9");
LOG.info("-------------------------------------------------------");
LOG.info("NOTICE:");
LOG.info("1. Only use POC1 or POC2 per drive (plotPaths), mixed is not supported, yet!");
LOG.info("2. POC2 plotfiles are detected by not having 'staggersize' in filename.");
LOG.info(" If you use JohnnyFFM/Poc1to2Converter you need to remove it manually.");

// start mining
Network network = context.getBean(Network.class);
Expand Down
22 changes: 0 additions & 22 deletions src/main/java/burstcoin/jminer/core/CoreConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,18 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

/**
* The type Core config.
*/
@Configuration
@EnableAsync
@ComponentScan(basePackages = {"burstcoin.jminer.core"})
public class CoreConfig
implements AsyncConfigurer
{
@Bean(name = "readerPool")
public ThreadPoolTaskExecutor readerPool()
Expand Down Expand Up @@ -85,18 +77,4 @@ public ObjectMapper objectMapper()
{
return new ObjectMapper();
}

@Override
public Executor getAsyncExecutor()
{
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.initialize();
return executor;
}

@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler()
{
return new SimpleAsyncUncaughtExceptionHandler();
}
}
11 changes: 11 additions & 0 deletions src/main/java/burstcoin/jminer/core/CoreProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class CoreProperties
private static final Properties PROPS = new Properties();

// default values
private static final int DEFAULT_POC2_ACTIVATION_BLOCK_HEIGHT = 500000;
private static final int DEFAULT_CHUNK_PART_NONCES = 960000;
private static final int DEFAULT_PLATFORM_ID = 0;
private static final int DEFAULT_DEVICE_ID = 0;
Expand Down Expand Up @@ -78,6 +79,7 @@ public class CoreProperties
}
}

private static Integer poc2ActivationBlockHeight;
private static Integer readProgressPerRound;
private static Long refreshInterval;
private static Long connectionTimeout;
Expand Down Expand Up @@ -415,6 +417,15 @@ public static long getChunkPartNonces()
return chunkPartNonces;
}

public static int getPoc2ActivationBlockHeight()
{
if(poc2ActivationBlockHeight == null)
{
poc2ActivationBlockHeight = asInteger("poc2ActivationBlockHeight", DEFAULT_POC2_ACTIVATION_BLOCK_HEIGHT);
}
return poc2ActivationBlockHeight;
}

public static boolean isByteUnitDecimal()
{
if(byteUnitDecimal == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class NetworkSubmitPoolNonceTask
implements Runnable
{
private static final Logger LOG = LoggerFactory.getLogger(NetworkSubmitPoolNonceTask.class);
private static final String HEADER_MINER_NAME = "burstcoin-jminer-0.4.12";
private static final String HEADER_MINER_NAME = "burstcoin-jminer-0.5.0";

private final ApplicationEventPublisher publisher;
private final HttpClient httpClient;
Expand Down Expand Up @@ -121,7 +121,7 @@ public void run()
.header("X-Capacity", String.valueOf(gb))

// thanks @systemofapwne
.header("X-PlotsHash", StringUtils.isEmpty(mac)? String.valueOf(gb) : mac) //For CreepMiner: Unique id for system
.header("X-PlotsHash", StringUtils.isEmpty(mac) ? String.valueOf(gb) : mac) //For CreepMiner: Unique id for system
.header("X-Deadline", String.valueOf(calculatedDeadline)) //For CreepMiner proxy: Numerical value of this deadline
.header("X-Plotfile", plotFilePath) //For CreepMiner proxy: Plotfile this deadline origins from

Expand Down
40 changes: 36 additions & 4 deletions src/main/java/burstcoin/jminer/core/reader/Reader.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
import burstcoin.jminer.core.reader.data.PlotDrive;
import burstcoin.jminer.core.reader.data.PlotFile;
import burstcoin.jminer.core.reader.data.Plots;
import burstcoin.jminer.core.reader.data.PocVersion;
import burstcoin.jminer.core.reader.event.ReaderCorruptFileEvent;
import burstcoin.jminer.core.reader.event.ReaderLoadedPartEvent;
import burstcoin.jminer.core.reader.event.ReaderProgressChangedEvent;
import burstcoin.jminer.core.reader.task.ReaderConvertLoadDriveTask;
import burstcoin.jminer.core.reader.task.ReaderLoadDriveTask;
import burstcoin.jminer.core.round.event.RoundStoppedEvent;
import nxt.crypto.Crypto;
Expand Down Expand Up @@ -180,9 +182,39 @@ public void read(long previousBlockNumber, long blockNumber, byte[] generationSi

for(PlotDrive plotDrive : plots.getPlotDrives())
{
ReaderLoadDriveTask readerLoadDriveTask = context.getBean(ReaderLoadDriveTask.class);
readerLoadDriveTask.init(scoopNumber, blockNumber, generationSignature, plotDrive);
readerPool.execute(readerLoadDriveTask);
PocVersion drivePocVersion = plotDrive.getDrivePocVersion();
if(drivePocVersion == null)
{
LOG.warn("Skipped '" + plotDrive.getDirectory()
+ "', different POC versions on one drive is not supported! (Workaround: put them in different directories and add them to 'plotFilePaths')");
}
else
{
if(isCompatibleWithCurrentPoc(blockNumber, drivePocVersion))
{
ReaderLoadDriveTask readerLoadDriveTask = context.getBean(ReaderLoadDriveTask.class);
readerLoadDriveTask.init(scoopNumber, blockNumber, generationSignature, plotDrive);
readerPool.execute(readerLoadDriveTask);
}
else
{
ReaderConvertLoadDriveTask readerConvertLoadDriveTask = context.getBean(ReaderConvertLoadDriveTask.class);
readerConvertLoadDriveTask.init(scoopNumber, blockNumber, generationSignature, plotDrive);
readerPool.execute(readerConvertLoadDriveTask);
}
}
}
}

private Boolean isCompatibleWithCurrentPoc(long blockNumber, PocVersion drivePocVersion)
{
switch(drivePocVersion)
{
case POC_2:
return blockNumber >= CoreProperties.getPoc2ActivationBlockHeight();
case POC_1:
default:
return blockNumber < CoreProperties.getPoc2ActivationBlockHeight();
}
}

Expand Down Expand Up @@ -225,7 +257,7 @@ public void handleMessage(ReaderLoadedPartEvent event)
else
{
LOG.error("Error: ReaderPartLoadedEvent for unknown chunkPartStartNonce: '" + event.getChunkPartStartNonce() + "'!"
+ " Please check for plot-file duplicate or overlapping plots e.g. use https://bchain.info/BURST/tools/overlap");
+ " Please check for plot-file duplicate or overlapping plots.");
}
}
else
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/burstcoin/jminer/core/reader/data/PlotDrive.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,22 @@ public long getSize()
}
return size;
}

/* returns null if drive has mixed poc versions */
public PocVersion getDrivePocVersion()
{
PocVersion drivePocVersion = null;
for(PlotFile plotFile : plotFiles)
{
if(drivePocVersion == null)
{
drivePocVersion = plotFile.getPocVersion();
}
else if(!drivePocVersion.equals(plotFile.getPocVersion()))
{
return null;
}
}
return drivePocVersion;
}
}
26 changes: 23 additions & 3 deletions src/main/java/burstcoin/jminer/core/reader/data/PlotFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public class PlotFile

private long size;

private PocVersion pocVersion;

PlotFile(Path filePath, Long chunkPartNonces)
{
this.filePath = filePath;
Expand All @@ -61,9 +63,22 @@ public class PlotFile
this.address = Convert.parseUnsignedLong(parts[0]);
this.startnonce = new BigInteger(parts[1]);
this.plots = Long.valueOf(parts[2]);
staggeramt = Long.valueOf(parts[3]);
this.numberOfParts = calculateNumberOfParts(staggeramt);
this.numberOfChunks = plots / staggeramt;

// todo this may be weak, requires that poc2 file names do not have staggersize
if(parts.length > 3)
{
pocVersion = PocVersion.POC_1;
staggeramt = Long.valueOf(parts[3]);
this.numberOfParts = calculateNumberOfParts(staggeramt);
this.numberOfChunks = plots / staggeramt;
}
else
{
pocVersion = PocVersion.POC_2;
staggeramt = plots;
this.numberOfParts = calculateNumberOfParts(staggeramt);
this.numberOfChunks = 1;
}

chunkPartStartNonces = new HashMap<>();

Expand Down Expand Up @@ -149,6 +164,11 @@ Map<BigInteger, Long> getChunkPartStartNonces()
return chunkPartStartNonces;
}

PocVersion getPocVersion()
{
return pocVersion;
}

// splitting into parts is not needed, but it seams to improve speed and enables us
// to have steps of nearly same size
private int calculateNumberOfParts(long staggeramt)
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/burstcoin/jminer/core/reader/data/Plots.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public Plots(List<String> plotPaths, String numericAccountId, long chunkPartNonc
chunkPartStartNonces.putAll(plotDrive.collectChunkPartStartNonces());
if(expectedSize != chunkPartStartNonces.size())
{
LOG.error("possible duplicate/overlapping polt-file on drive '" + plotDrive.getDirectory()
+ "' please use 'https://bchain.info/BURST/tools/overlap' to check your plots.");
LOG.error("possible duplicate/overlapping polt-file on drive '" + plotDrive.getDirectory() + "' please check your plots.");
}
}
}
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/burstcoin/jminer/core/reader/data/PocVersion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2018 by luxe - https://github.com/de-luxe - BURST-LUXE-RED2-G6JW-H4HG5
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
* is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies
* or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/

package burstcoin.jminer.core.reader.data;

public enum PocVersion
{
POC_1,
POC_2
}
Loading

0 comments on commit 35a3c23

Please sign in to comment.